diff --git a/AculData/AculCalibration.cpp b/AculData/AculCalibration.cpp index a3cab7ca6b8515eb640ee1c6416a1641a72f3278..24d86d266e534c67474084ec559a3d6b9d43dca4 100755 --- a/AculData/AculCalibration.cpp +++ b/AculData/AculCalibration.cpp @@ -147,18 +147,6 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s return 1; } -//creation of output text file with positions of peaks in MeV - TString workFile; - workFile.Form("energies.txt"); - - ofstream outenergfile; - outenergfile.open(workFile.Data()); - if (!outenergfile.is_open()) { - Error("PeaksFitting", "Output file %s was not opened", workFile.Data()); - return 0; - } - - //should be optional output Info("PeaksFitting", "Number of peaks in %s: %d", hSpectrum->GetName(), peaksNumber); @@ -268,8 +256,6 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s } }//for - outenergfile << hSpectrum->GetName()<<"\t"<< fPeak[0] <<"\t"<< fPeak[1] <<"\t"<< fPeak[2] <<"\t"<< fPeak[3] <cd(); hEnergy->Write(); - }//for + }//for; detector channels fw->Close(); fr->Close(); @@ -1100,6 +1087,43 @@ void AculCalibration::CalibrateRawSpectra(const char* inputfile, const char* blo } +void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char* outfile) { + + TString iFile = ifile; + TFile *fr = new TFile(iFile.Data()); + if ( !fr->IsOpen() ) { + Error("FindEnergyPeaks", "File %s was not opened and won't be processed.", iFile.Data()); + return; + } + + TList *histList = fr->GetListOfKeys(); + Info("FindEnergyPeaks", "%d keys found in file %s.", histList->GetEntries(), fr->GetName()); + + //creation of output text file with positions of peaks 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; + c1->Clear(); + c1->Divide(6, 6); + + for (Int_t i = 0; i < histList->GetEntries(); i++) { + fr->GetObject(histList->At(i)->GetName(), hWork); + c1->cd(i+1); + PeaksFitting(hWork); + hWork->Draw(); + + ofile << hWork->GetName()<<"\t"<< fPeak[0] <<"\t"<< fPeak[1] <<"\t"<< fPeak[2] <<"\t"<< fPeak[3] <Load("/home/dariak/AculUtils/libAculData.so"); +// gSystem->Load("/home/dariak/AculUtils/libAculData.so"); + gSystem->Load("/home/vratik/workspace/AculUtils/libAculData.so"); AculCalibration cal; cal.SetInputParameters(); //from .par - cal.CalculateCalibParameters("clb08_0001.root", "SQ22", "AnalysisxTree", 100, 4095); +// cal.CalculateCalibParameters("clb08_0001.root", "SQ22", "AnalysisxTree", 100, 4095); + cal.CalculateCalibParameters("macros/myMacros/clb01_0001.root", "SQ22", "AnalysisxTree", 100, 4095); // CalculateCalibParameters(const char* inputfile, const char* block, const Int_t address, const char* treename, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0, Int_t uppersubaddress = ADDRESSNUMBER-1); diff --git a/calibration2.cxx b/calibration2.cxx index ba7e382173450c4f6dc40afe75ff7eb653c3e7f2..4287bf8c5be8717bcfa9a2cd3d8c908b2041710c 100644 --- a/calibration2.cxx +++ b/calibration2.cxx @@ -1,3 +1,4 @@ +void calibration2() { gSystem->Load("/home/dariak/AculUtils/libAculData.so"); @@ -9,7 +10,8 @@ TCanvas *c1 = new TCanvas(); cal->CalibrateRawSpectra("clb09_0001.root", "SQ22", "AnalysisxTree", 100, 800, 500); //takes data from raw file and calibrates it with obtained calibration parameters - + cal->CalibrateRawSpectra("clb09_0001.root", "SQ22", "AnalysisxTree", 100, 800, 500); //takes data from raw file and calibrates it with obtained calibration parameters +//return; TFile fr("SQ22[]E.root"); cout << fr.GetListOfKeys()->GetEntries() << " histograms" << endl;