initRootParameters();
cout << colorwhite << "initHistograms():" << endlr;
initHistograms(&histogram);
- initHistograms(&histogramthreshold, " threshold");
+ initHistograms(&histogramthreshold, "threshold");
+ initHistograms(&histogramfixedthreshold, "fixed threshold");
debugDBreadout();
}
else
int start = 0;
int nframes = processed->GetNumberFrames();
// for(int i=0; i<1000;i++) // TODO remove 100000 run 342272
- for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
+ for(int i=0; i<nframes/10;i++) // TODO remove 100000 run 342272
{
// cout << "getframe " << i << endl;
processed->getFrame(i);
cout << colorwhite << "rescaleHistograms():" << endlr;
histogramCalibrated.calibrated = rescaleHistograms();
histogramthresholdCalibrated.calibrated = histogramCalibrated.calibrated;
+ histogramfixedthresholdCalibrated.calibrated = histogramCalibrated.calibrated;
cout << colorwhite << "calculateCCE():" << endlr;
calculteCCE();
if (labbook.source.Contains("Sr90")) {
histogramthresholdCalibrated.avgNoisePlus = histogramthreshold.avgNoisePlus * gain;
histogramthresholdCalibrated.avgNoiseMinus = histogramthreshold.avgNoiseMinus * gain;
+ rescaleHistogram(histogramfixedthresholdCalibrated.Seed, histogramfixedthreshold.Seed);
+ rescaleHistogram(histogramfixedthresholdCalibrated.Sum, histogramfixedthreshold.Sum);
+ rescaleHistogram(histogramfixedthresholdCalibrated.Veto, histogramfixedthreshold.Veto);
+ rescaleHistogram(histogramfixedthresholdCalibrated.Noise, histogramfixedthreshold.Noise);
+
+ histogramfixedthresholdCalibrated.posSeed = histogramfixedthreshold.posSeed * gain;
+ histogramfixedthresholdCalibrated.posSum = histogramfixedthreshold.posSum * gain;
+ histogramfixedthresholdCalibrated.posVeto = histogramfixedthreshold.posVeto * gain;
+ histogramfixedthresholdCalibrated.avgNoise = histogramfixedthreshold.avgNoise * gain;
+ histogramfixedthresholdCalibrated.avgNoisePlus = histogramfixedthreshold.avgNoisePlus * gain;
+ histogramfixedthresholdCalibrated.avgNoiseMinus = histogramfixedthreshold.avgNoiseMinus * gain;
+
if (histogramthreshold.histAvgCluster != nullptr)
{
rescale2DHistogramCounts(histogramthresholdCalibrated.histAvgCluster, histogramthreshold.histAvgCluster);
histogramthreshold.avgNoise = histogram.avgNoise;
histogramthreshold.avgNoisePlus = histogram.avgNoisePlus;
histogramthreshold.avgNoiseMinus = histogram.avgNoiseMinus;
+ histogramfixedthreshold.avgNoise = histogram.avgNoise;
+ histogramfixedthreshold.avgNoisePlus = histogram.avgNoisePlus;
+ histogramfixedthreshold.avgNoiseMinus = histogram.avgNoiseMinus;
// if (labbook.system == "PXI")
// for (int j=0; j<3; j++)
// noisequantiles[j] /= 16.0; // TODO analyze PXI scales
if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
histogramthreshold.Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
}
+
+ if (processed->fFrameInfo.pixelfixedthreshold[hiti]>0)
+ {
+ histogramfixedthreshold.numberofhits++;
+
+ histogramfixedthreshold.Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+ histogramfixedthreshold.Sum->Fill(pixelSum);
+ if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
+ histogramfixedthreshold.Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
+ }
}
}
}
histogramthreshold.posVeto=FitPerform(histogram.Veto, "gaus", false);
histogramthreshold.posSeed=FitPerform(histogram.Seed, "landau", false);
histogramthreshold.posSum=FitPerform(histogram.Sum, "gaus", false);
+ if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))
+ histogramfixedthreshold.posVeto=FitPerform(histogramfixedthreshold.Veto, "gaus", false);
+ histogramfixedthreshold.posSeed=FitPerform(histogramfixedthreshold.Seed, "landau", false);
+ histogramfixedthreshold.posSum=FitPerform(histogramfixedthreshold.Sum, "gaus", false);
// gROOT->SetBatch(kFALSE);
return 0;
}
histogram.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
if (processed->fFrameInfo.pixelthreshold[hiti]>0)
histogramthreshold.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
+ if (processed->fFrameInfo.pixelfixedthreshold[hiti]>0)
+ histogramfixedthreshold.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
}
}
else // Diode sitzt unten im SeedPixel, da nach PitchY angeordnet
histogram.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
if (processed->fFrameInfo.pixelthreshold[hiti]>0)
histogramthreshold.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
+ if (processed->fFrameInfo.pixelfixedthreshold[hiti]>0)
+ histogramfixedthreshold.histAvgCluster->Fill(xcoord,ycoord,processed->fFrameInfo.p[clusteri][hiti]);
}
}
}
for (Int_t clustery = 1; clustery <=histogram.histAvgCluster->GetYaxis()->GetNbins();clustery++) {
histogram.histAvgCluster->SetBinContent(clusterx,clustery,histogram.histAvgCluster->GetBinContent(clusterx,clustery)/histogram.numberofhits);
histogramthreshold.histAvgCluster->SetBinContent(clusterx,clustery,histogramthreshold.histAvgCluster->GetBinContent(clusterx,clustery)/histogramthreshold.numberofhits);
+ histogramfixedthreshold.histAvgCluster->SetBinContent(clusterx,clustery,histogramfixedthreshold.histAvgCluster->GetBinContent(clusterx,clustery)/histogramfixedthreshold.numberofhits);
}
}
//
// }
+
+Bool_t Run::plotCompareHistograms()
+{
+ if (!error)
+ {
+ if ( !plothistogramstructpointerarray.size() ) // XOR operator !=
+ {
+ cout << colorred << "plotCompareHistograms(): No plots to compare, please push them into the vector: Run::plothistogramstructpointerarray." << endlr;
+ return 1;
+ }
+ Bool_t calibrated = true;
+ Bool_t uncalibrated = true;
+ for (UInt_t histogrami=0; histogrami < plothistogramstructpointerarray.size(); histogrami++)
+ {
+ calibrated = calibrated && plothistogramstructpointerarray.at(histogrami)->calibrated;
+ uncalibrated = uncalibrated && !plothistogramstructpointerarray.at(histogrami)->calibrated;
+ cout << colorcyan << plothistogramstructpointerarray.at(histogrami)->histogramdescription << endlr;
+ }
+ cout << "Calibrated " << (calibrated?"Yes":"No") << endl;
+ cout << "Uncalibrated " << (uncalibrated?"Yes":"No") << endl;
+ if ( !(calibrated != uncalibrated)) // XOR operator !=
+ {
+ cout << colorred << "plotCompareHistograms(): Mixing of calibrated and uncalibrated histograms when comparing plots. Aborting." << endlr;
+ return 1;
+ }
+
+ // legend entries
+ Float_t height = plothistogramstructpointerarray.size() * 0.04;
+ TLegend* leg1 = new TLegend(0.4,0.89-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
+ leg1->SetTextSize(0.02);
+ leg1->SetFillColor(0); leg1->SetBorderSize(0);
+ TLegend* leg2 = (TLegend*) leg1->Clone();
+ TString legendEntry;
+
+ Float_t lastbin1=0;
+ Float_t lastbin2=0;
+ Float_t lastbin3=0;
+ Float_t lastbin4=0;
+ Int_t random = random1->Rndm()*1000000;
+ TString canvastitle = Form("%s Comparison", runcode.Data());
+ if (calibrated)
+ canvastitle += "_el";
+ TString canvasname = Form("%s%d",runcode.Data(),random);
+ TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
+ canvas->Divide(2,2);
+ for (UInt_t histogrami=0; histogrami < plothistogramstructpointerarray.size(); histogrami++)
+ {
+ histogramstruct* curhistogramstructp = plothistogramstructpointerarray.at(histogrami);
+ TH1F* curhistogramclone;
+ canvas->cd(1);
+ curhistogramclone = (TH1F*) curhistogramstructp->Seed->Clone();
+ curhistogramclone->SetLineColor(rootcolors[histogrami]);
+ curhistogramclone->Draw("SAME");
+ legendEntry = Form("%s", curhistogramclone->GetTitle());
+ leg1->AddEntry(curhistogramclone, legendEntry, "l");
+ leg1->Draw("SAME");
+ lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin1;
+ curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X");
+ gPad->SetLogy(1);
+ canvas->cd(2);
+ curhistogramclone = (TH1F*) curhistogramstructp->Sum->Clone();
+ curhistogramclone->SetLineColor(rootcolors[histogrami]);
+ curhistogramclone->Draw("SAME");
+ leg1->Draw("SAME");
+ lastbin2 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin2)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin2;
+ curhistogramclone->SetAxisRange(0,lastbin2*1.1,"X");
+ gPad->SetLogy(1);
+ canvas->cd(3);
+ curhistogramclone = (TH1F*) curhistogramstructp->Veto->Clone();
+ curhistogramclone->SetLineColor(rootcolors[histogrami]);
+ curhistogramclone->Draw("SAME");
+ leg1->Draw("SAME");
+ lastbin3 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin3)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin3;
+ curhistogramclone->SetAxisRange(0,lastbin3*1.1,"X");
+ canvas->cd(4);
+ curhistogramclone = (TH1F*) curhistogramstructp->Noise->Clone();
+ curhistogramclone->SetLineColor(rootcolors[histogrami]);
+ curhistogramclone->Draw();
+ legendEntry = Form("Noise: %.2f + %.2f - %.2f",curhistogramstructp->avgNoise, curhistogramstructp->avgNoisePlus, curhistogramstructp->avgNoiseMinus);
+ leg2->AddEntry(curhistogramclone, legendEntry, "l");
+ leg2->Draw();
+ }
+
+ return 0;
+ }
+ return 1;
+}
+
+
Bool_t Run::plotAllHistograms(histogramstruct* histogramstructpointer)
{
if (!error)
{
Float_t lastbin;
- Int_t random = random1->Rndm()*100000;
- TString canvastitle = Form("%s", runcode.Data());
+ Int_t random = random1->Rndm()*1000000;
+ TString canvastitle = Form("%s %s", runcode.Data(), histogramstructpointer->histogramdescription.Data());
if (histogramstructpointer->calibrated)
canvastitle += "_el";
- if (histogramstructpointer->thresholdcluster)
- canvastitle += "_trsh";
TString canvasname = Form("%s%d",runcode.Data(),random);
- TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
+ TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
canvas->Divide(2,2);
canvas->cd(1);
histogramstructpointer->Seed->Draw("");
void Run::initHistograms(histogramstruct* histogramstructpointer, TString suffix)
{
- initHistogram(histogramstructpointer->Seed, "Seed" + suffix);
- initHistogram(histogramstructpointer->Sum, "Sum" + suffix);
- initHistogram(histogramstructpointer->Veto, "Veto" + suffix);
+ histogramstructpointer->histogramdescription = suffix;
+ initHistogram(histogramstructpointer->Seed, "Seed " + suffix);
+ initHistogram(histogramstructpointer->Sum, "Sum " + suffix);
+ initHistogram(histogramstructpointer->Veto, "Veto " + suffix);
- TString prefix = "Noise" + suffix;
+ TString prefix = "Noise " + suffix;
TString humanreadablestr = Form("%s, %s spectrum, %s, chip %s, %s, %sT=%.1f",prefix.Data(), labbook.source.Data(), labbook.chipGen.Data(), labbook.chip.Data(), labbook.matrix.Data(), humanreadablesuffix.Data(), labbook.temp);
if (suffix.Contains("threshold"))
initCluster(&histogram, "", xcoord_min_step, xcoord_abs_min, xcoord_abs_max, ycoord_min_step, ycoord_abs_min, ycoord_abs_max);
initCluster(&histogramthreshold, "_threshold", xcoord_min_step, xcoord_abs_min, xcoord_abs_max, ycoord_min_step, ycoord_abs_min, ycoord_abs_max);
+ initCluster(&histogramfixedthreshold, "_fixed_threshold", xcoord_min_step, xcoord_abs_min, xcoord_abs_max, ycoord_min_step, ycoord_abs_min, ycoord_abs_max);
}
void Run::initCluster(histogramstruct* histogramstructpointer, TString suffix, Float_t xcoord_min_step, Float_t xcoord_abs_min, Float_t xcoord_abs_max, Float_t ycoord_min_step, Float_t ycoord_abs_min, Float_t ycoord_abs_max)
}
void Run::initRootParameters()
-{ rootcolors = new Int_t[13]{1, 2, 4, 6, 8, 13, 46, 28, 32, 33, 12, 20, 40};
+{
+ rootcolors = new Int_t[13]{1, 2, 4, 6, 8, 13, 46, 28, 32, 33, 12, 20, 40};
rootlinestyle = new Int_t[13]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-
}
#endif