Commit f75d3bfd authored by Kostyleva D.A's avatar Kostyleva D.A

Added new function AculCalibration::FindAverageEnergies

parent 3cda1a29
...@@ -1107,7 +1107,65 @@ void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char ...@@ -1107,7 +1107,65 @@ void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char
} }
ofile.close(); ofile.close();
} }
void AculCalibration::FindAverageEnergies(const char* ifile, const char* outfile) {
TString iFile = ifile;
TFile *fr = new TFile(iFile.Data());
if ( !fr->IsOpen() ) {
Error("FindAverageEnergies", "File %s was not opened and won't be processed.", iFile.Data());
return;
}
TList *histList = fr->GetListOfKeys();
Info("FindAverageEnergies", "%d keys found in file %s.", histList->GetEntries(), fr->GetName());
//creation of output text file with average values of peak energies in MeV
TString workFile = outfile;
ofstream ofile;
ofile.open(workFile.Data());
if (!ofile.is_open()) {
Error("PeaksFitting", "Output file %s was not opened", workFile.Data());
return;
}
TH1 *hWork = 0;
Double_t hArray[histList->GetEntries()][kRaNOPEAKS];
Double_t hSumE1 = 0.;
Double_t hAvrE1 = 0.;
Double_t hSumE2 = 0.;
Double_t hAvrE2 = 0.;
Double_t hSumE3 = 0.;
Double_t hAvrE3 = 0.;
Double_t hSumE4 = 0.;
Double_t hAvrE4 = 0.;
// c1->Clear();
// c1->Divide(6, 6);
for (Int_t i = 0; i < histList->GetEntries(); i++) {
fr->GetObject(histList->At(i)->GetName(), hWork);
PeaksFitting(hWork);
for(Int_t j = 0; j < kRaNOPEAKS; j++) {
hArray[i][j] = fPeak[j];
if(fPeak[j]==0.){
Error("FindAverageEnergies", "No peak in channel %i !", histList->GetEntries());
}
}
hSumE1 += hArray[i][0];
hSumE2 += hArray[i][1];
hSumE3 += hArray[i][2];
hSumE4 += hArray[i][3];
// std::cout<<"i "<<i<<" hSumE1 "<<hSumE1<<std::endl;
}
hAvrE1 = hSumE1/histList->GetEntries();
hAvrE2 = hSumE2/histList->GetEntries();
hAvrE3 = hSumE3/histList->GetEntries();
hAvrE4 = hSumE4/histList->GetEntries();
ofile <<"Average energies are:\t"<<hAvrE1<<"\t"<<hAvrE2<<"\t"<<hAvrE3<<"\t"<<hAvrE4<<std::endl;
ofile.close();
}
void AculCalibration::ShowAnalyzedSpectra(const char *filename, TCanvas* fittedRawCanvas, Int_t xaxismin, Int_t xaxismax, Int_t subaddress) void AculCalibration::ShowAnalyzedSpectra(const char *filename, TCanvas* fittedRawCanvas, Int_t xaxismin, Int_t xaxismax, Int_t subaddress)
{ {
......
...@@ -176,10 +176,17 @@ public: ...@@ -176,10 +176,17 @@ public:
void CalibrateRawSpectra(const char* inputfile, const char* block, const char* treename, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0, Int_t uppersubaddress = ADDRESSNUMBER-1); void CalibrateRawSpectra(const char* inputfile, const char* block, const char* treename, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0, Int_t uppersubaddress = ADDRESSNUMBER-1);
void FindEnergyPeaks(TCanvas *c1, const char* ifile, const char* outfile); void FindEnergyPeaks(TCanvas *c1, const char* ifile, const char* outfile);
// const char* inputfile, const char* block, // Outputs calibrated energies for each channel in txt file
// const Int_t address, const Int_t address, const char* treename, Int_t lowerchannel = 0, //
// Int_t upperchannel = 4095, Int_t lowersubaddress = 0, Int_t uppersubaddress = ADDRESSNUMBER-1); //
//
void FindAverageEnergies(const char* ifile, const char* outfile);
// Outputs average values of calibrated energies for the whole detector in txt file
//
//
//
Int_t PeaksFitting(TH1* hSpectrum, Option_t* option = "", Double_t sigmamin = 2); Int_t PeaksFitting(TH1* hSpectrum, Option_t* option = "", Double_t sigmamin = 2);
//return values: //return values:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment