return 1;
}
-Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t verbose) {
- Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
-
- TH1F* smoothedcurce = (TH1F*)histogrampointer->Clone();
- // smoothedcurce->Smooth(4); // not working method, rescaling is easier and more reliable
- Int_t rebinningfactor = 4;
- smoothedcurce->RebinX(rebinningfactor);
- smoothedcurce->SetAxisRange(0,histogrampointer->GetBinCenter(histogrampointer->GetNbinsX()));
-
- if (verbose) {
- cout << colorwhite << histogrampointer->GetName() << endlr;
- TString canvastitle = Form("%s Noisethreshold border", histogrampointer->GetName());
- TString canvasname = Form("%s Noisethreshold border", histogrampointer->GetName());
- TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
- smoothedcurce->SetLineColor(color+1);
- smoothedcurce->Draw();
- histogrampointer->Draw("SAME");
- canvas->Update();
- }
-
- // Int_t bini =smoothedcurce->GetMaximumBin();
- // thresholdbincurcandidate = bini;
- // if (verbose)
- // cout << "GetMaximumBin: smoothedcurce->GetBinContent(" << bini << "): " << smoothedcurce->GetBinContent(bini) << endl;
- Int_t bini = 0;
- Int_t falling = 0;
- Int_t noisepeakcandidate = 0;
-
- do {
- Float_t curval=smoothedcurce->GetBinContent(bini++);
- if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
- {
- falling = 0;
- noisepeakcandidate = bini;
- }
- else
- {
- falling++;
- if (verbose)
- cout << "falling at " << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t overwrite, Bool_t verbose) {
+ if (overwrite || noisethresholdborder == -1)
+ {
+ Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
+
+ TH1F* smoothedcurce = (TH1F*)histogrampointer->Clone();
+ // smoothedcurce->Smooth(4); // not working method, rescaling is easier and more reliable
+ Int_t rebinningfactor = 2;
+ smoothedcurce->RebinX(rebinningfactor);
+ smoothedcurce->SetAxisRange(0,histogrampointer->GetBinCenter(histogrampointer->GetNbinsX()));
+
+ if (verbose) {
+ cout << colorwhite << histogrampointer->GetName() << endlr;
+ TString canvastitle = Form("%s Noisethreshold border", histogrampointer->GetName());
+ TString canvasname = Form("%s Noisethreshold border", histogrampointer->GetName());
+ TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
+ smoothedcurce->SetLineColor(color+1);
+ smoothedcurce->Draw();
+ histogrampointer->Draw("SAME");
+ canvas->Update();
}
- } while (falling < 2 && bini<smoothedcurce->GetNbinsX());
- if (verbose) {
- cout << "Noise peak at: smoothedcurce->GetBinContent(" << noisepeakcandidate << "): " << smoothedcurce->GetBinContent(noisepeakcandidate) << endl;
- }
- Int_t thresholdbincurcandidate = 0;
- bini = noisepeakcandidate;
-
- Int_t rising = 0;
- do {
- Float_t curval=smoothedcurce->GetBinContent(bini++);
- if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
- {
- rising++;
- if (verbose)
- cout << "rising at bin " << bini << ":" << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+
+ // Int_t bini =smoothedcurce->GetMaximumBin();
+ // thresholdbincurcandidate = bini;
+ // if (verbose)
+ // cout << "GetMaximumBin: smoothedcurce->GetBinContent(" << bini << "): " << smoothedcurce->GetBinContent(bini) << endl;
+ Int_t bini = 0;
+ Int_t falling = 0;
+ Int_t noisepeakcandidate = 0;
+
+ do {
+ Float_t curval=smoothedcurce->GetBinContent(bini++);
+ if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
+ {
+ falling = 0;
+ noisepeakcandidate = bini;
+ }
+ else
+ {
+ falling++;
+ if (verbose)
+ cout << "falling at " << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+ }
+ } while (falling < 2 && bini<smoothedcurce->GetNbinsX());
+ if (verbose) {
+ cout << "Noise peak at: smoothedcurce->GetBinContent(" << noisepeakcandidate << "): " << smoothedcurce->GetBinContent(noisepeakcandidate) << endl;
}
- else
- {
- rising = 0;
- thresholdbincurcandidate = bini;
- if (verbose)
- cout << "falling at bin " << bini << ":" << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+ Int_t thresholdbincurcandidate = 0;
+ bini = noisepeakcandidate;
+
+ Int_t rising = 0;
+ do {
+ Float_t curval=smoothedcurce->GetBinContent(bini++);
+ if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
+ {
+ rising++;
+ if (verbose)
+ cout << "rising at bin " << bini << ":" << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+ }
+ else
+ {
+ rising = 0;
+ thresholdbincurcandidate = bini;
+ if (verbose)
+ cout << "falling at bin " << bini << ":" << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+ }
+ } while (rising < 3 && bini<smoothedcurce->GetNbinsX());
+ thresholdbincurcandidate *= rebinningfactor;
+
+ noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
+ if (verbose) {
+ cout << " Noise threshold at " << noisethresholdborder << endl;
}
- } while (rising < 3 && bini<smoothedcurce->GetNbinsX());
- thresholdbincurcandidate *= rebinningfactor;
-
- noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
- if (verbose) {
- cout << " Noise threshold at " << noisethresholdborder << endl;
+ return 0;
}
- return 0;
+ return 1;
}
Bool_t HistogramType::integrateSr90Spectra(TH1F* histogrampointer, Int_t frames_found, Float_t thresholdborder, Bool_t verbose) {
if (thresholdborder < 0)
{
if (noisethresholdborder < 0) {
- FindNoisethresholdborder(histogrampointer, verbose);
+ FindNoisethresholdborder(histogrampointer, true, verbose);
}
thresholdbincurcandidate = histogrampointer->GetXaxis()->FindBin(noisethresholdborder);
}
}
else
{
- cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
+ cout << endl <<"Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
cout << colorwhite << "initOldRootFile():" << endlr;
}
if (processed->initOldRootFile()) return 1;
cout << "---------- loop over all classes --------" << endl;
for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) {
cout << "Processing histograms in class: <" << colorwhite << (*curHistogramClass)->histogramdescription << colorreset << " >" << endlr;
- binNoise((*curHistogramClass));
+ binNoise((*curHistogramClass));
+ if (noisethresholdborderADU > -1)
+ (*curHistogramClass)->noisethresholdborder = noisethresholdborderADU;
+ if (noisethresholdborderE > -1) {
+ if (labbook.gainDB > 0) {
+ (*curHistogramClass)->noisethresholdborder = noisethresholdborderE / labbook.gainDB;
+ } else {
+ cout << colorred << "Could not set noise threshold border in units of electrons to " << noisethresholdborderE << "e, no calibration done yet. Please rerun after first analysis." <<endlr;
+ }
+ }
if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")) {
cout << colorwhite << " calculateCCE():" << endlr;
(*curHistogramClass)->calculteCCE(true);
}
}
cout << "---------------------------------" << endl;
- cout << colorwhite << "integrateSr90Spectra():" << endlr;
-// histogramthreshold->noisethresholdborder = 35.0; // TODO remove the overwriting of automatic noise threshold setting
- histogramthreshold->integrateSr90Spectra(histogramthreshold->Seed, frames_found, -1, true);
- histogramfixedthreshold->integrateSr90Spectra(histogramfixedthreshold->Seed, frames_found, 0);
+ if (labbook.source.Contains("Sr90")) {
+ cout << colorwhite << "integrateSr90Spectra():" << endlr;
+ histogramthreshold->integrateSr90Spectra(histogramthreshold->Seed, frames_found, -1, true);
+ histogramfixedthreshold->integrateSr90Spectra(histogramfixedthreshold->Seed, frames_found, 0);
+ }
rescaleHistogramClasses();
cout << colorwhite << "updateDatabase():" << endlr;
updateDatabase();
return 1;
}
+Bool_t Run::setNoisethresholdborderADU(Float_t noisethresholdborder)
+{
+ noisethresholdborderADU = noisethresholdborder;
+ cout << " Noise threshold border: " << colorwhite << noisethresholdborder << " ADU"<< endlr;
+ return 0;
+}
+
+Bool_t Run::setNoisethresholdborderE(Float_t noisethresholdborder)
+{
+ noisethresholdborderADU = noisethresholdborder;
+ cout << " Noise threshold border: " << colorwhite << noisethresholdborder << " e"<< colorreset << " <-- only used if GAIN is allready saved in database, rerun after first analysis to make sure" << endl;
+ return 0;
+}
+
Bool_t Run::rescaleHistogramClasses()
{
float_t vetopeakposition = -1;
for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) {
Double_t* parameters = (Double_t *)calloc(3, sizeof(Double_t));
- (*curHistogramClass)->FindNoisethresholdborder((*curHistogramClass)->Seed, false);
+ (*curHistogramClass)->FindNoisethresholdborder((*curHistogramClass)->Seed, false, false);
if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))
parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Veto, "gaus", true);
(*curHistogramClass)->posVeto = parameters[1];