...
 
Commits (4)
...@@ -125,16 +125,6 @@ void AculCalibCsI::PrintCuts() { ...@@ -125,16 +125,6 @@ void AculCalibCsI::PrintCuts() {
// return; // return;
if (fCuts) printf("Cuts loaded from file \"%s\"\n", fCuts->GetName()); if (fCuts) printf("Cuts loaded from file \"%s\"\n", fCuts->GetName());
/*for (Int_t i = 0; i < NOCALFILES; i++) {
if (cTOF[i]) {
printf("TOF cut No. %d; Name: \"%s\"\n", i, cutsCol[i]->GetName());
cout << "asdjasd" << endl;
}
else {
printf("TOF cut No. %d was not loaded. Maximal number of cuts is %d\n", i, NOCALFILES);
}
}//for */
TCutG *curCut = 0; TCutG *curCut = 0;
//cutsCol //cutsCol
...@@ -147,19 +137,6 @@ void AculCalibCsI::PrintCuts() { ...@@ -147,19 +137,6 @@ void AculCalibCsI::PrintCuts() {
}*/ }*/
} }
/* for (Int_t i = 0; i < NOCALFILES; i++) {
if (cQCD[i]) {
printf("QCD cut No. %d; Name: \"%s\"\n", i, cQCD[i]->GetName());
// cout << "kasjhd" << endl;
} else {
// cout << "bhajskd" << endl;
printf("QCD cut No. %d was not loaded. Maximal number of cuts is %d\n", i, NOCALFILES);
// cout << "vsdfjks" << endl;
}
}
printf("AculCalibCsI::PrintCuts: End of function.\n");
*/
return; return;
} }
...@@ -256,11 +233,11 @@ void AculCalibCsI::DrawBeam(TCanvas *canvas, Int_t files, const char* variable) ...@@ -256,11 +233,11 @@ void AculCalibCsI::DrawBeam(TCanvas *canvas, Int_t files, const char* variable)
con.Form("%s[5]>200", variable); con.Form("%s[5]>200", variable);
curTree->Draw(var.Data(), con.Data(), "cont"); curTree->Draw(var.Data(), con.Data(), "cont");
for (Int_t j = 0; j < energyPoints; j++) { for (Int_t j = 0; j < energyPoints; j++) {
// if ( cutsCol.At(files + j) ) { if ( cutsCol.At(files + j) ) {
// curCutG = (TCutG*)cutsCol.At(files + j); curCutG = (TCutG*)cutsCol.At(files + j);
// curCutG->Draw("same"); curCutG->Draw("same");
// printf("AculCalibCsI::DrawBeam: cQCD cut No. %d cannot be drawn, need to repair this function.\n", j); // printf("AculCalibCsI::DrawBeam: cQCD cut No. %d cannot be drawn, need to repair this function.\n", j);
// } }
} }
canvas->Update(); canvas->Update();
} }
...@@ -365,14 +342,14 @@ void AculCalibCsI::GetPeakMean(const char* variable, Int_t tree, Int_t energy, T ...@@ -365,14 +342,14 @@ void AculCalibCsI::GetPeakMean(const char* variable, Int_t tree, Int_t energy, T
con.Form("%s[%d]>%d && %s", variable, channel, lowRange, cutsCol.FindObject(beamcut)->GetName()); con.Form("%s[%d]>%d && %s", variable, channel, lowRange, cutsCol.FindObject(beamcut)->GetName());
canvas->cd(i+1); canvas->cd(i+1);
hname.Form("hfull[%d][%d]", tree, i); hname.Form("hfull[%d][%d]", tree, i);
hfull[tree][i] = new TH1I(hname.Data(), "title", nbins, 0, 4096); hfull[tree][i] = new TH1I(hname.Data(), "title1", nbins, 0, 4096);
curTree->SetLineColor(1); curTree->SetLineColor(1);
curTree->Draw(var.Data(), con.Data()); curTree->Draw(var.Data(), con.Data());
var.Form("%s[%d]>>hcut[%d][%d]", variable, channel, tree, i); var.Form("%s[%d]>>hcut[%d][%d]", variable, channel, tree, i);
con.Form("%s[%d]>%d && %s[%d]<%d && %s", variable, channel, peakMin[energy][i], variable, channel, peakMax[energy][i], cutsCol.FindObject(beamcut)->GetName()); con.Form("%s[%d]>%d && %s[%d]<%d && %s", variable, channel, peakMin[energy][i], variable, channel, peakMax[energy][i], cutsCol.FindObject(beamcut)->GetName());
hname.Form("hcut[%d][%d]", tree, i); hname.Form("hcut[%d][%d]", tree, i);
hcut[tree][i] = new TH1I(hname.Data(), "title", nbins, 0, 4096); hcut[tree][i] = new TH1I(hname.Data(), "title2", nbins, 0, 4096);
hcut[tree][i]->SetLineColor(3); hcut[tree][i]->SetLineColor(3);
curTree->Draw(var.Data(), con.Data(), "same"); curTree->Draw(var.Data(), con.Data(), "same");
...@@ -395,7 +372,7 @@ void AculCalibCsI::Calibrate(TCanvas *canvas, Bool_t savefile, const char* filen ...@@ -395,7 +372,7 @@ void AculCalibCsI::Calibrate(TCanvas *canvas, Bool_t savefile, const char* filen
canvas->Divide(4,4); canvas->Divide(4,4);
// cout << alphas2.GetSize()+1 << endl; // cout << alphas2.GetSize()+1 << endl;
cout << energyPoints+1 << endl; cout <<" energyPoints+1 "<<energyPoints+1<< endl;
TString gName; TString gName;
TString gTitle; TString gTitle;
...@@ -432,7 +409,7 @@ void AculCalibCsI::FillGraph(TGraphErrors *g, Int_t npoints, Double_t *energies, ...@@ -432,7 +409,7 @@ void AculCalibCsI::FillGraph(TGraphErrors *g, Int_t npoints, Double_t *energies,
TString opt = option; TString opt = option;
//all available energy points and (0,0) //all available energy points and (0,0)
g->SetPoint(0, 0., 0.); g->SetPoint(0, 0., 0.); //(point number, x, y)
for (Int_t i = 0; i < npoints-1; i++) { for (Int_t i = 0; i < npoints-1; i++) {
// g->SetPoint(i+1, energies[i], mean[i][graphNumber]); // g->SetPoint(i+1, energies[i], mean[i][graphNumber]);
// g->SetPointError(i+1, 0, meanRMS[i][graphNumber]); // g->SetPointError(i+1, 0, meanRMS[i][graphNumber]);
......
...@@ -26,8 +26,8 @@ AculCalibration::AculCalibration() : fEnergy(0), fEnergyInput(0), fA(0), fB(0), ...@@ -26,8 +26,8 @@ AculCalibration::AculCalibration() : fEnergy(0), fEnergyInput(0), fA(0), fB(0),
// todo: change size of fA and fB in some other place // todo: change size of fA and fB in some other place
fA.Set(32); fA.Set(32);
fB.Set(32); fB.Set(32);
fEnergy.Set(4); // fEnergy.Set(4);
fEnergyInput.Set(4); // fEnergyInput.Set(4);
kRaNOPEAKS = 0; kRaNOPEAKS = 0;
fLowerPeakRelativeHight = 0.; fLowerPeakRelativeHight = 0.;
...@@ -172,7 +172,6 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s ...@@ -172,7 +172,6 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s
Info("PeaksFitting", "In histogram %s was found %d peaks", hSpectrum->GetName(), peaksNumber); Info("PeaksFitting", "In histogram %s was found %d peaks", hSpectrum->GetName(), peaksNumber);
return 1; return 1;
} }
//should be optional output //should be optional output
Info("PeaksFitting", "Number of peaks in %s: %d", hSpectrum->GetName(), peaksNumber); Info("PeaksFitting", "Number of peaks in %s: %d", hSpectrum->GetName(), peaksNumber);
...@@ -260,6 +259,7 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s ...@@ -260,6 +259,7 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s
fPeak.Set(peaksNumber); fPeak.Set(peaksNumber);
for (Int_t i = 0; i < peaksNumber; i++) { for (Int_t i = 0; i < peaksNumber; i++) {
fPeak[i] = peak[j[i]]; fPeak[i] = peak[j[i]];
//printf("\tPeak peak\t%f\n", fPeak[i]);
} }
if (!opt.Contains("q") || opt.Contains("v")) { if (!opt.Contains("q") || opt.Contains("v")) {
...@@ -275,11 +275,12 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s ...@@ -275,11 +275,12 @@ Int_t AculCalibration::PeaksFitting(TH1* hSpectrum, Option_t* option, Double_t s
// zapis do souboru s chybama, vypis na obrazovku, ... // zapis do souboru s chybama, vypis na obrazovku, ...
for (Int_t i = 0; i < peaksNumber; i++) { for (Int_t i = 0; i < peaksNumber; i++) {
if ( !( (((1-fPeakPositionTolerance)*(fEnergy[0]/fEnergy[i])) < (fPeak[0]/fPeak[i])) && (((1+fPeakPositionTolerance)*(fEnergy[0]/fEnergy[i])) > (fPeak[0]/fPeak[i])) ) ) { if ( !( (((1-fPeakPositionTolerance)*(fEnergy[0]/fEnergy[i])) < (fPeak[0]/fPeak[i])) && (((1+fPeakPositionTolerance)*(fEnergy[0]/fEnergy[i])) > (fPeak[0]/fPeak[i])) ) ) {
if (fCalInformation && opt.Contains("writebad")) { //printf("\tPeaksFitt fEnergy\t%f\n", fEnergy[i]);
if (fCalInformation /* && opt.Contains("writebad")*/) {
fCalInformation->cd(); fCalInformation->cd();
hSpectrum->Write(); hSpectrum->Write();
} }
return 2; //return 2;*/
} }
}//for }//for
...@@ -759,7 +760,7 @@ Bool_t AculCalibration::CalculateCalibParameters(const char* inputfile, const ch ...@@ -759,7 +760,7 @@ Bool_t AculCalibration::CalculateCalibParameters(const char* inputfile, const ch
tr->Draw(fillCommand.Data(), fillCondition.Data(), "goff"); tr->Draw(fillCommand.Data(), fillCondition.Data(), "goff");
//spectrum analysis //spectrum analysis
fitControl = PeaksFitting(hRaw, "Q", fFitMinSigma); fitControl = PeaksFitting(hRaw, "Q V v", fFitMinSigma);
Info("CalculateCalibParameters", "Value of fitControl is: %d", fitControl); //ok Info("CalculateCalibParameters", "Value of fitControl is: %d", fitControl); //ok
//incorrectly treated spectrum output //incorrectly treated spectrum output
...@@ -783,6 +784,7 @@ Bool_t AculCalibration::CalculateCalibParameters(const char* inputfile, const ch ...@@ -783,6 +784,7 @@ Bool_t AculCalibration::CalculateCalibParameters(const char* inputfile, const ch
//calibration parameters calculation //ok //calibration parameters calculation //ok
for (Int_t j = 0; j < kRaNOPEAKS; j++) { //delat podle poctu zkoumanych piku for (Int_t j = 0; j < kRaNOPEAKS; j++) { //delat podle poctu zkoumanych piku
calGraph->SetPoint(j, fPeak[j], fEnergy[j]); //calibration graph filling calGraph->SetPoint(j, fPeak[j], fEnergy[j]); //calibration graph filling
printf("\tPeak\t%f and energy\t%f\n", fPeak[j], fEnergy[j]);
}//for }//for
calGraph->Fit(calFunction, "Q", "goff", 0, 4096); //omezit hlasitost fitovani, udelat volitelne, dodelat volby rozsahu calGraph->Fit(calFunction, "Q", "goff", 0, 4096); //omezit hlasitost fitovani, udelat volitelne, dodelat volby rozsahu
outcalfile outcalfile
...@@ -1101,14 +1103,78 @@ void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char ...@@ -1101,14 +1103,78 @@ void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char
c1->cd(i+1); c1->cd(i+1);
PeaksFitting(hWork); PeaksFitting(hWork);
hWork->Draw(); hWork->Draw();
ofile<<i<<"\t";
for(Int_t j=0; j<kRaNOPEAKS; j++) {
ofile << fPeak[j] <<"\t";
}
ofile<<endl;
}
ofile << i <<"\t"<< fPeak[0] <<"\t"<< fPeak[1] <<"\t"<< fPeak[2] <<"\t"<< fPeak[3] <<endl; 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];
//TString hSumName;
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());
}
//hSumName.Form("hSumE%i",j);
}
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(); 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)
{ {
...@@ -1335,6 +1401,8 @@ void AculCalibration::SetInputParameters() { ...@@ -1335,6 +1401,8 @@ void AculCalibration::SetInputParameters() {
if ( strcmp(identificator, "noPeaks") == 0 ) { if ( strcmp(identificator, "noPeaks") == 0 ) {
kRaNOPEAKS = static_cast<Int_t>(atoi(parameter)); kRaNOPEAKS = static_cast<Int_t>(atoi(parameter));
fEnergyInput.Set(kRaNOPEAKS); fEnergyInput.Set(kRaNOPEAKS);
fEnergy.Set(kRaNOPEAKS);
fPeak.Set(kRaNOPEAKS);
for (Int_t i = 0; i < kRaNOPEAKS; i++) { for (Int_t i = 0; i < kRaNOPEAKS; i++) {
fipr.getline(line, lineLength); fipr.getline(line, lineLength);
sscanf(line, "%s", parameter); sscanf(line, "%s", parameter);
......
...@@ -177,9 +177,16 @@ public: ...@@ -177,9 +177,16 @@ 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:
......
{ {
// gSystem->Load("CsICalib_C.so"); // gSystem->Load("CsICalib_C.so");
gSystem->Load("../../libAculData.so"); gSystem->Load("/home/dariak/AculUtils/libAculData.so");
//CsICalib cal; //CsICalib cal;
AculCalibCsI cal("parameters/SQ13Alpha.par"); AculCalibCsI cal("parameters/SQ13Alpha.par");
...@@ -13,14 +13,17 @@ ...@@ -13,14 +13,17 @@
TCanvas *c2 = new TCanvas("c2", "Plain"); TCanvas *c2 = new TCanvas("c2", "Plain");
TCanvas *c3 = new TCanvas("c3", "Plain"); TCanvas *c3 = new TCanvas("c3", "Plain");
TCanvas *c4 = new TCanvas("c4", "Plain"); TCanvas *c4 = new TCanvas("c4", "Plain");
// TCanvas *myCanv = new TCanvas("myCanv", "Let's see what we see");
cal.PrintTrees(); // cal.PrintTrees();
cal.PrintFiles(); // cal.PrintFiles();
cal.PrintCuts(); // cal.PrintCuts();
// cal.PrintPeakRanges();
// cal.ReadParFile("ranges.dat"); // cal.ReadParFile("ranges.dat");
// cal.PrintParameters(); // cal.PrintParameters("v");
// cal.PrintTrees();
// cal.DrawVariable("SQ13", 0, c1);
// cal.DrawVariable("SQ13", 1, c1); // cal.DrawVariable("SQ13", 1, c1);
...@@ -28,10 +31,10 @@ ...@@ -28,10 +31,10 @@
// cal.DrawVariable("TDC", 2, c2); // cal.DrawVariable("TDC", 2, c2);
// cal.DrawVariable("QDC", 3, c3); // cal.DrawVariable("QDC", 3, c3);
// cal.DrawBeam(c4, 4, "SQ13"); // cal.DrawBeam(myCanv, 4, "SQ13");
//return; //return;
// cal.DrawVariableCut("SQ13", 0, c1, "cutsSQ13Alpha16"); // cal.DrawVariableCut("SQ13", 0, c2, "cutsSQ13Alpha16");
// cal.DrawVariableCut("SQ13", 0, c1, "cutsSQ13Alpha16", "cutSQ13Alpha16Amp"); // cal.DrawVariableCut("SQ13", 0, c2, "cutsSQ13Alpha16", "cutSQ13Alpha16Amp");
//return; //return;
// cal.DrawVariableCut("SQ13", 1, c2, "cutSQ13Alpha21", "cutSQ13Alpha21Amp"); // cal.DrawVariableCut("SQ13", 1, c2, "cutSQ13Alpha21", "cutSQ13Alpha21Amp");
// cal.DrawVariableCut("SQ13", 2, c3, "cutSQ13Alpha26", "cutSQ13Alpha26Amp"); // cal.DrawVariableCut("SQ13", 2, c3, "cutSQ13Alpha26", "cutSQ13Alpha26Amp");
...@@ -50,7 +53,7 @@ ...@@ -50,7 +53,7 @@
// cal.SaveClbGraphs("gSQ13Alpha2points.root", "RECREATE"); // cal.SaveClbGraphs("gSQ13Alpha2points.root", "RECREATE");
// cal.SaveClbGraphs("gSQ13AlphaAlt.root", "RECREATE"); // cal.SaveClbGraphs("gSQ13AlphaAlt.root", "RECREATE");
// cal.WriteClbParameters("calSQ13Alpha.clb"); cal.WriteClbParameters("calSQ13Alpha.clb");
// cal.WriteClbParameters("calSQ13Alpha2points.clb"); // cal.WriteClbParameters("calSQ13Alpha2points.clb");
// cal.WriteClbParameters("calSQ13AlphaAlt.clb"); // cal.WriteClbParameters("calSQ13AlphaAlt.clb");
......
{ {
gSystem->Load("CsICalib_C.so"); gSystem->Load("/home/dariak/AculUtils/libAculData.so");
// CsICalib cal; // CsICalib cal;
CsICalib cal("parameters/SQ23Alpha.par"); AculCalibCsI cal("parameters/SQ23Alpha.par");
// cal.PrintCuts(); // cal.PrintCuts();
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
TCanvas *c2 = new TCanvas("c2", "Plain"); TCanvas *c2 = new TCanvas("c2", "Plain");
TCanvas *c3 = new TCanvas("c3", "Plain"); TCanvas *c3 = new TCanvas("c3", "Plain");
TCanvas *c4 = new TCanvas("c4", "Plain"); TCanvas *c4 = new TCanvas("c4", "Plain");
cal.PrintParameters();
cal.DrawBeam(c4, 4, "SQ23"); // cal.DrawBeam(c4, 4, "SQ23");
return; return;
......