From 06d7742e04c496edd7b65dc4cfc81e25e0ef071e Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Wed, 20 Dec 2017 15:12:11 +0100 Subject: [PATCH] Analyzer: Cosmetics for plots --- MABS_run_analyzer/ChargeSpektrum.c | 23 ++++++++++-- MABS_run_analyzer/ChargeSpektrumFunctions.c | 9 +++-- MABS_run_analyzer/HistogramType.cpp | 40 ++++++++++++-------- MABS_run_analyzer/HistogramType.h | 2 +- MABS_run_analyzer/Run.cpp | 41 +++++++++++++++++++-- 5 files changed, 86 insertions(+), 29 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index e764fe7..96fb21d 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -93,6 +93,7 @@ void ChargeSpektrum(TString runnumber = "") // leakage current analysis variables vector compareHistogramLeakageCurrent; + vector compareHistogramLeakageCurrentCalib; for(Int_t runi=0; runihistogramwoRTS->calibrated->LeakageCurrentDistrib); + } + else { + compareHistogramLeakageCurrentCalib.push_back(runs[runi]->histogram->calibrated->LeakageCurrentDistrib); + } + if (runi+1 == numberRuns) { + compareHistogramVectorVector.push_back(compareHistogramLeakageCurrentCalib); + } + } - // Plot leakage current - compareHistogramLeakageCurrent.push_back(HistogramTypeDefaultPt->LeakageCurrentDistrib); - if (runi+1 == numberRuns) { - compareHistogramVectorVector.push_back(compareHistogramLeakageCurrent); + // Plot leakage current + if (numberRuns > 1) { + compareHistogramLeakageCurrent.push_back(HistogramTypeDefaultPt->LeakageCurrentDistrib); + if (runi+1 == numberRuns) { + compareHistogramVectorVector.push_back(compareHistogramLeakageCurrent); + } } if (runs[runi]->labbook.chipGen.EqualTo("Pipper2")) { runs[runi]->plot1DHistogram(runs[runi]->histogramdynamicalthreshold->Veto, "GaussTail", true); diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index 8ce3fd7..4a5e07a 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -315,7 +315,7 @@ plot1DData(std::vector* ntuplepvectorpointer, Bool_t verbose, Bool_t // legend entries Float_t height = ntuplepvectorpointer->size() * 0.03; // TLegend* leg1 = new TLegend(0.3,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); - TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg1 = new TLegend(0.6,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); leg1->SetTextSize(0.025); leg1->SetFillStyle(1001); leg1->SetTextFont(132); @@ -562,8 +562,9 @@ Bool_t CompareHistograms(vector* ptCompareHistogramVector, TString title // legend entries Float_t height = ptCompareHistogramVector->size() * 0.03; // TLegend* leg1 = new TLegend(0.3,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); - TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg1 = new TLegend(0.1,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); leg1->SetTextSize(0.025); + leg1->SetNColumns(3); leg1->SetFillStyle(1001); leg1->SetTextFont(132); leg1->SetFillColor(0); @@ -756,7 +757,7 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector // legend entries Float_t height = ptCompareHistogramClassVector->size() * 0.055; - TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg1 = new TLegend(0.6,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); leg1->SetTextSize(0.035); leg1->SetFillStyle(0); leg1->SetTextFont(132); @@ -926,7 +927,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) // legend entries Float_t height = ptCompareHistogramClassVector->size() * 0.055; - TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg1 = new TLegend(0.6,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); leg1->SetTextSize(0.035); leg1->SetFillStyle(0); leg1->SetTextFont(132); diff --git a/MABS_run_analyzer/HistogramType.cpp b/MABS_run_analyzer/HistogramType.cpp index 9e3e871..3b4a04e 100644 --- a/MABS_run_analyzer/HistogramType.cpp +++ b/MABS_run_analyzer/HistogramType.cpp @@ -56,7 +56,7 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) { initHistogramCustom(pixeltimefiredDistrib, "Fire counter" + histogramdescription, color, style, 0, labbook->frames_foundDB/100, labbook->frames_foundDB/100, "times fired", "Counts"); initHistogramCustom(LeakageCurrentInPixel, "Leakage current per pixel" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS"); initHistogramCustom(LeakageCurrentInPixelSorted, "Leakage current per pixel sorted" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS"); - initHistogramCustom(LeakageCurrentDistrib, "Average Leakage current per pixel" + histogramdescription, color, style, -100, 400, 1000, "Average CDS", "Count"); + initHistogramCustom(LeakageCurrentDistrib, "Average Leakage current per pixel" + histogramdescription, color, style, -100, 400, 1000, "Average CDS [ADU]", "Entries"); // initHistogram(LeakageCurrentInPixelSorted, "Leakage current" + histogramdescription, color, style); initHistogramCustom(pixelHadGoodVeto, "Number of times pixel had good veto" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Counter good veto"); @@ -83,7 +83,8 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) { } void HistogramType::initHistogram(TH1FO* &histogrampointer, TString prefix, Int_t color, Int_t style) { - histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); +// histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); + histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s",prefix.Data()), cursystempar->nbins, 0, cursystempar->maxbin); histogrampointer->SetLineStyle(style); histogrampointer->SetLineColor(color); histogrampointer->SetStats(kTRUE); @@ -98,7 +99,8 @@ void HistogramType::initHistogram(TH1FO* &histogrampointer, TString prefix, Int_ } void HistogramType::initHistogramCustom(TH1FO* &histogrampointer, TString prefix, Int_t color, Int_t style, Double_t xLow, Double_t xUp, Int_t nBins, TString xaxistitle, TString yaxistitle) { - histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), nBins, xLow, xUp); +// histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), nBins, xLow, xUp); + histogrampointer=(TH1FO*)new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s",prefix.Data()), nBins, xLow, xUp); histogrampointer->SetLineStyle(style); histogrampointer->SetLineColor(color); histogrampointer->SetStats(kTRUE); @@ -114,7 +116,8 @@ void HistogramType::initHistogramCustom(TH1FO* &histogrampointer, TString prefix void HistogramType::initHistogramArray(vector* histogramarraypointer, int numberofhisto, TString prefix, Int_t color, Int_t style) { for (int i=0; i < numberofhisto; ++i) { - TH1FO* histogrampointer = (TH1FO*)new TH1F(Form("%d %s %d",labbook->runnumber, prefix.Data(), i+1), Form("%s %d, %s",prefix.Data(), i+1, humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); +// TH1FO* histogrampointer = (TH1FO*)new TH1F(Form("%d %s %d",labbook->runnumber, prefix.Data(), i+1), Form("%s %d, %s",prefix.Data(), i+1, humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); + TH1FO* histogrampointer = (TH1FO*)new TH1F(Form("%d %s %d",labbook->runnumber, prefix.Data(), i+1), Form("%s %d",prefix.Data(), i+1), cursystempar->nbins, 0, cursystempar->maxbin); histogrampointer->SetLineStyle(style); histogrampointer->SetLineColor(color); histogrampointer->SetStats(kTRUE); @@ -154,25 +157,25 @@ Bool_t HistogramType::calibrateHistograms( Float_t gotgain ) { } gain = gotgain; calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, humanreadablestr, labbook, run, color, style); - if (Seed != 0) calibrateHistogram(calibrated->Seed, Seed); - if (Sum9 != 0) calibrateHistogram(calibrated->Sum9, Sum9); - if (Sum25 != 0) calibrateHistogram(calibrated->Sum25, Sum25); + if (Seed != 0) calibrateHistogram(calibrated->Seed, Seed, gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->Seed->GetBinWidth(1))); + if (Sum9 != 0) calibrateHistogram(calibrated->Sum9, Sum9, gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->Sum9->GetBinWidth(1))); + if (Sum25 != 0) calibrateHistogram(calibrated->Sum25, Sum25, gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->Sum25->GetBinWidth(1))); for (unsigned int i=0; i < a_Sum9.size(); ++i) { calibrated->a_Sum9.push_back(a_Sum9[i]); - calibrateHistogram(calibrated->a_Sum9[i], a_Sum9[i]); + calibrateHistogram(calibrated->a_Sum9[i], a_Sum9[i], gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->a_Sum9[i]->GetBinWidth(1))); } for (unsigned int i=0; i < a_Sum25.size(); ++i) { calibrated->a_Sum25.push_back(a_Sum25[i]); - calibrateHistogram(calibrated->a_Sum25[i], a_Sum25[i]); + calibrateHistogram(calibrated->a_Sum25[i], a_Sum25[i], gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->a_Sum25[i]->GetBinWidth(1))); } - if (Veto != 0) calibrateHistogram(calibrated->Veto, Veto); - if (Noise != 0) calibrateHistogram(calibrated->Noise, Noise); + if (Veto != 0) calibrateHistogram(calibrated->Veto, Veto, gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->Veto->GetBinWidth(1))); + if (Noise != 0) calibrateHistogram(calibrated->Noise, Noise, gain, "Collected charge [e]", Form("Entries [1/%.1f e]",calibrated->Noise->GetBinWidth(1))); if (pixeltimefired != 0) calibrated->pixeltimefired = pixeltimefired; if (pixeltimefiredDistrib != 0) calibrated->pixeltimefiredDistrib = pixeltimefiredDistrib; if (SeedPerc != 0) calibrated->SeedPerc = SeedPerc; if (clustermultiplicity != 0) calibrated->clustermultiplicity = clustermultiplicity; if (histAvgCluster != 0) calibrate2DHistogramCounts(calibrated->histAvgCluster, histAvgCluster); - if (LeakageCurrentDistrib != 0) calibrateHistogram(calibrated->LeakageCurrentDistrib,LeakageCurrentDistrib, gain / 3.7 / pow10(-3) * (1.6*pow10(-19)) * pow10(15)); + if (LeakageCurrentDistrib != 0) calibrateHistogram(calibrated->LeakageCurrentDistrib,LeakageCurrentDistrib, gain / 3.7 / pow10(-3) * (1.6*pow10(-19)) * pow10(15), "Average CDS [fA]", Form("Entries [1/%.1f fA]",calibrated->LeakageCurrentDistrib->GetBinWidth(1))); if (LeakageCurrentInPixel != 0) calibrateHistogramYAxis(calibrated->LeakageCurrentInPixel, LeakageCurrentInPixel, gain / 3.7 / pow10(-3) * (1.6*pow10(-19)) * pow10(15)); if (LeakageCurrentInPixelSorted != 0) calibrateHistogramYAxis(calibrated->LeakageCurrentInPixelSorted,LeakageCurrentInPixelSorted, gain / 3.7 / pow10(-3) * (1.6*pow10(-19)) * pow10(15)); @@ -225,11 +228,13 @@ Bool_t HistogramType::calibrateHistograms( Float_t gotgain ) { return 1; } -void HistogramType::calibrateHistogram(TH1FO* &histogrampointernew, TH1FO* &histogrampointerold, Double_t scalefactor) { +void HistogramType::calibrateHistogram(TH1FO* &histogrampointernew, TH1FO* &histogrampointerold, Double_t scalefactor, TString newxAxisLabel, TString newyAxisLabel ) { histogrampointernew = (TH1FO*)histogrampointerold->Clone(); histogrampointernew->SetName(Form("%s Calibr.", histogrampointerold->GetName())); histogrampointernew->SetTitle(Form("%s Calibr.", histogrampointerold->GetTitle())); - histogrampointernew->GetXaxis()->SetTitle("Collected charge [e]"); + if (!newxAxisLabel.EqualTo("")) { + histogrampointernew->GetXaxis()->SetTitle(newxAxisLabel); + } int nbins = histogrampointernew->GetXaxis()->GetNbins(); double new_bins[nbins+1]; if (scalefactor == 0) @@ -238,8 +243,10 @@ void HistogramType::calibrateHistogram(TH1FO* &histogrampointernew, TH1FO* &hist new_bins[i] = histogrampointernew->GetBinLowEdge(i)*scalefactor; // cout << "histogrampointernew->GetBinCenter(i): " << histogrampointernew->GetBinLowEdge(i) << " * gain " << gain << " = " << histogrampointernew->GetBinLowEdge(i)*gain << endl; } - histogrampointernew->SetBins(nbins, new_bins); - histogrampointernew->GetYaxis()->SetTitle(Form("Entries [1/%.1f e]",histogrampointernew->GetBinWidth(1))); + histogrampointernew->SetBins(nbins, new_bins); + if (!newyAxisLabel.EqualTo("")) { + histogrampointernew->GetYaxis()->SetTitle(newyAxisLabel); + } histogrampointernew->itsHistogramType = histogrampointerold->itsHistogramType; } @@ -1284,3 +1291,4 @@ Double_t HistogramType::GaussTail(Double_t *x, Double_t *par) { #endif + diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index ccb8d9e..2048b94 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -75,7 +75,7 @@ private: //***************** /** * @brief rescales one specific histogram from ADU to electrons along the x axis */ - void calibrateHistogram(TH1FO* &histogrampointernew, TH1FO* &histogrampointerold, Double_t scalefactor = 0); + void calibrateHistogram(TH1FO* &histogrampointernew, TH1FO* &histogrampointerold, Double_t scalefactor = 0, TString newxAxisLabel = "", TString newyAxisLabel = ""); /** * @brief rescales one specific histogram from ADU to electrons along the y axis */ diff --git a/MABS_run_analyzer/Run.cpp b/MABS_run_analyzer/Run.cpp index 353d98b..3a4e250 100644 --- a/MABS_run_analyzer/Run.cpp +++ b/MABS_run_analyzer/Run.cpp @@ -465,6 +465,7 @@ Bool_t Run::analyzeRun(Bool_t force) cout << "---------- 1. loop over all classes --------" << endl; for (vector::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) { cout << "Processing histograms in class: <" << colorwhite << (*curHistogramClass)->histogramdescription << colorreset << " >" << endlr; + cout << colorwhite << " BinFiringRates():" << endlr; BinFiringRates(*curHistogramClass); if ((*curHistogramClass)->maskRTSpixel) { // if (labbook.chipGen=="Mi19") { @@ -764,7 +765,10 @@ Bool_t Run::rescaleHistogramClasses(HistogramType* curHistogramClassPt) if (labbook.source.Contains("Fe")) gain = 1640.0/vetopeakposition; else if (labbook.source.Contains("Cd")) - gain = 6140.0/vetopeakposition; + gain = 6140.0/vetopeakposition; + if (gain > 0) { + cout << " Gain for the calibrated class: " << gain << endlr; + } curHistogramClassPt->calibrateHistograms(gain); curHistogramClassPt->normalized->calibrateHistograms(gain); @@ -2397,9 +2401,17 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1FO* onehis // TFitResultPtr* fit_result_ptr; fit_result = new TFitResult(); // fit_result_ptr = new TFitResultPtr(); - TString canvastitle = Form("%s %s", onehistogram->GetName(), runcode.Data()); + TString canvastitle = Form("%s %s", onehistogram->GetTitle(), runcode.Data()); TString canvasname = Form("%s %s %d", onehistogram->GetName(), runcode.Data(), random); - TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700); + TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800); + + TPaveText *owntitle = new TPaveText(0.1,0.9,0.930401,0.995,"nbNDC"); + owntitle->SetFillStyle(0); + owntitle->SetBorderSize(0); + owntitle->SetTextAlign(22); + owntitle->SetTextSize(0.025); + owntitle->SetTextFont(42); + if (titlestr.Length()>0) onehistogram->SetTitle(titlestr); if (logscale) { @@ -2427,7 +2439,8 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1FO* onehis onehistogram->GetYaxis()->SetRangeUser(0.1,endrangeY*5); else onehistogram->GetYaxis()->SetRangeUser(0,endrangeY*1.25); - TLegend* leg = new TLegend(0.2,0.85,0.89,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg = new TLegend(0.2,0.85,0.89,0.89);//(0.6,0.7,0.89,0.89); + leg->SetNColumns(3); leg->SetFillColor(0); leg->SetBorderSize(0); if (legendstr.Length() < 1) @@ -2436,6 +2449,26 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1FO* onehis leg->SetTextSize(0.025); leg->Draw(); + + owntitle->Clear(); + owntitle->AddText(onehistogram->GetName()); + vector headerStringsVector; + TString title1 = Form(" %s, %s, %s, %.0fx%.0f #mum^{2} pitch, %s\nT=%.0f {}^{o}C, %.1f MRad, %.1f*10^{13} n_{eq}/cm^{2}, %.2f Mhz", labbook.source.Data(), + labbook.chipGen.Data(), labbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data(), + labbook.tempSens, labbook.radDoseIon, labbook.radDoseNonIon, labbook.clock); + if (labbook.depletionV >= 0) + title1 += Form(", U_{dep}=%.1f V", labbook.depletionV); + + TString title2 = Form("%s", labbook.comment.Data()); + + headerStringsVector.push_back(title1); + TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n"); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String()); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String()); + headerStringsVector.push_back(title2); + owntitle->AddText(Form("%s", headerStringsVector.at(1).Data())); + owntitle->AddText(headerStringsVector.at(2)); + owntitle->Draw("SAME"); // canvas->Draw(); // canvas->Update(); -- 2.43.0