From 7be6accfd3343fd281774a75434737482dcb4c2c Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Thu, 6 Oct 2016 13:28:35 +0300 Subject: [PATCH] Function AculCalibration::FindEnergyPeaks(...) added. --- AculData/AculCalibration.cpp | 66 ++++++++++++++++++++++++------------ AculData/AculCalibration.h | 15 +++++--- calibration1.cxx | 6 ++-- calibration2.cxx | 4 ++- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/AculData/AculCalibration.cpp b/AculData/AculCalibration.cpp index a3cab7c..24d86d2 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 ba7e382..4287bf8 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; -- 2.18.1