Commit 3a55bcf8 authored by Kostyleva D.A's avatar Kostyleva D.A

Fixing bugs for the cases with less than 4 peaks

parent ec951094
...@@ -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,8 +1103,11 @@ void AculCalibration::FindEnergyPeaks(TCanvas *c1, const char* ifile, const char ...@@ -1101,8 +1103,11 @@ 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";
ofile << i <<"\t"<< fPeak[0] <<"\t"<< fPeak[1] <<"\t"<< fPeak[2] <<"\t"<< fPeak[3] <<endl; for(Int_t j=0; j<kRaNOPEAKS; j++) {
ofile << fPeak[j] <<"\t";
}
ofile<<endl;
} }
...@@ -1132,6 +1137,7 @@ void AculCalibration::FindAverageEnergies(const char* ifile, const char* outfile ...@@ -1132,6 +1137,7 @@ void AculCalibration::FindAverageEnergies(const char* ifile, const char* outfile
TH1 *hWork = 0; TH1 *hWork = 0;
Double_t hArray[histList->GetEntries()][kRaNOPEAKS]; Double_t hArray[histList->GetEntries()][kRaNOPEAKS];
//TString hSumName;
Double_t hSumE1 = 0.; Double_t hSumE1 = 0.;
Double_t hAvrE1 = 0.; Double_t hAvrE1 = 0.;
Double_t hSumE2 = 0.; Double_t hSumE2 = 0.;
...@@ -1151,7 +1157,9 @@ void AculCalibration::FindAverageEnergies(const char* ifile, const char* outfile ...@@ -1151,7 +1157,9 @@ void AculCalibration::FindAverageEnergies(const char* ifile, const char* outfile
if(fPeak[j]==0.){ if(fPeak[j]==0.){
Error("FindAverageEnergies", "No peak in channel %i !", histList->GetEntries()); Error("FindAverageEnergies", "No peak in channel %i !", histList->GetEntries());
} }
//hSumName.Form("hSumE%i",j);
} }
hSumE1 += hArray[i][0]; hSumE1 += hArray[i][0];
hSumE2 += hArray[i][1]; hSumE2 += hArray[i][1];
hSumE3 += hArray[i][2]; hSumE3 += hArray[i][2];
...@@ -1393,6 +1401,8 @@ void AculCalibration::SetInputParameters() { ...@@ -1393,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);
......
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