From: Benjamin Linnik Date: Wed, 2 Dec 2015 11:55:19 +0000 (+0100) Subject: Run analyzer: added improved summary table X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=eed51632d8865c56d5915d4e5ba1d0badc902ca7;p=radhard.git Run analyzer: added improved summary table --- diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index b9091b1..752677e 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -259,6 +259,7 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) for (vector::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) printIntegral += (*curHistogramClass)->sr90IntegralVal; if (printIntegral != 0) cout << left << setw(width) << setfill(' ') << "Integral"; + cout << left << setw(width) << setfill(' ') << "Seed Peak"; cout << left << setw(width) << setfill(' ') << "Noise"; cout << endl; for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) @@ -272,6 +273,7 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) if (printCCE != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->CCE_in_Perc_25,ptCompareHistogramClassVector->at(0)->CCE_in_Perc_25); if (printStoN != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->StoN,ptCompareHistogramClassVector->at(0)->StoN); if (printIntegral != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->sr90IntegralVal,ptCompareHistogramClassVector->at(0)->sr90IntegralVal); + cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->posSeed,ptCompareHistogramClassVector->at(0)->posSeed); cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise); cout << "" << endl; } diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 2ba9f9e..c5d8520 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -49,12 +49,12 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) { } void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) { - histogrampointer=new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%d %s, %s",labbook->runnumber,prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); + histogrampointer=new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin); histogrampointer->SetLineStyle(style); histogrampointer->SetLineColor(color); histogrampointer->SetStats(kTRUE); histogrampointer->SetStats(111111111); - histogrampointer->SetLineWidth(2); // TODO: set to 3 again + histogrampointer->SetLineWidth(3); // TODO: set to 3 again histogrampointer->GetXaxis()->SetTitle("Q_coll [ADU]"); histogrampointer->GetYaxis()->SetTitle(Form("Entries [1/%.1f ADU]",histogrampointer->GetBinWidth(1))); histogrampointer->GetXaxis()->CenterTitle(); @@ -142,9 +142,7 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax(); // posMaxValHist/10 for USB system, the value is 90 Float_t noiseborder = 90; - if (noisethresholdborder>0) - noiseborder = noisethresholdborder; - else if (noisethresholdborder > 0) + if (noisethresholdborder>=0) noiseborder = noisethresholdborder; if (fitFuncType.Contains("gaus")) @@ -155,10 +153,16 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B if (TString(histogrampointer->GetName()).Contains("Veto")) { +// if (verbose) +// cout << "Range: " << histogrampointer->GetXaxis()->FindBin(noiseborder) << " to " << histogrampointer->GetXaxis()->FindBin(posMaxValHist) << endl; Float_t peak1 = histogrampointer->GetMaximumBin(); Float_t peak2; +// if (verbose) +// cout << "histogrampointer->GetBinCenter(peak1) " << histogrampointer->GetBinCenter(peak1) << endl; if (histogrampointer->GetBinCenter(peak1)<3.3*noiseborder) // vermutlich ist veto peak nicht am höchsten { +// if (verbose) +// cout << "histogrampointer->GetBinCenter(peak1) " << histogrampointer->GetBinCenter(peak1) << " < 3 * noiseborder " << noiseborder << endl; Float_t avg = 0; for(Int_t bin=histogrampointer->GetXaxis()->FindBin(noiseborder);binFindLastBinAbove(0);bin++) avg += histogrampointer->GetBinContent(bin); @@ -174,23 +178,45 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B Float_t min = histogrampointer->GetMinimumBin(); histogrampointer->GetXaxis()->SetRange(min,histogrampointer->FindLastBinAbove(0)); // look only for maxima with x greater than noiseborder, cut away noise // DEBUG - // if (verbose) - // { - // cout << coloryellow << "peak1 " << histogrampointer->GetXaxis()->GetBinCenter(peak1) << endlr; - // cout << coloryellow << "peak1val " << histogrampointer->GetBinContent(peak1) << endlr; - // cout << coloryellow << "peak2 " << histogrampointer->GetXaxis()->GetBinCenter(peak2) << endlr; - // cout << coloryellow << "peak2val " << histogrampointer->GetBinContent(peak2) << endlr; - // cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr; - // } - histogrampointer->Fit(fitFunc, "N,Q,W", "", histogrampointer->GetXaxis()->GetBinCenter(min), posMaxValHist); +// if (verbose) +// { +// cout << coloryellow << "noisethresholdborder " << noisethresholdborder << endlr; +// cout << coloryellow << "peak1 " << histogrampointer->GetXaxis()->GetBinCenter(peak1) << endlr; +// cout << coloryellow << "peak1val " << histogrampointer->GetBinContent(peak1) << endlr; +// cout << coloryellow << "peak2 " << histogrampointer->GetXaxis()->GetBinCenter(peak2) << endlr; +// cout << coloryellow << "peak2val " << histogrampointer->GetBinContent(peak2) << endlr; +// cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr; +// cout << coloryellow << "lastbin " << histogrampointer->FindLastBinAbove(0) << endl; +// cout << coloryellow << "posMaxValHist " << posMaxValHist << endl; +// } +// cout << colorred << gMinuit->fCstatu.Data() << endlr; +// cout << colorred << gMinuit->GetStatus() << endlr; +// cout << colorred << fitFunc->GetChisquare() << endlr; + //histogrampointer->Fit(fitFunc, "N,Q,W", "", 70, 500); + int fittries = 0; + do { +// cout << fittries << ": New range: " << histogrampointer->GetXaxis()->GetBinCenter(min+fittries*min/20) << " to " << posMaxValHist << endl; + histogrampointer->Fit(fitFunc, "N,Q,W", "", histogrampointer->GetXaxis()->GetBinCenter(min+fittries++*min/20), posMaxValHist); +// cout << colorred << gMinuit->fCstatu.Data() << endlr; + } while (gMinuit->fCstatu.Contains("FAILED") && fittries < 8); posMax = histogrampointer->GetXaxis()->GetBinCenter(histogrampointer->GetMaximumBin()); // Methode 1 +// if (verbose) +// { +// cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr; +// cout << coloryellow << "posMax " << posMax << endlr; +// } histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(noiseborder),histogrampointer->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise +// TCanvas* canvas = new TCanvas("2121", "212121212", 900, 700); +// histogrampointer->Draw(); +// fitFunc->DrawCopy("same"); } else { histogrampointer->Fit(fitFunc, "N,Q,W", "", noiseborder, posMaxValHist); posMax = fitFunc->GetMaximumX(); // Methode 2 } Float_t sigma = fitFunc->GetParameter(2); posMax2 = fitFunc->GetMaximumX(); // Methode 2 +// if (verbose) +// cout << coloryellow << "posMax2 " << posMax2 << endlr; Float_t peakposdifperc = abs(posMax-posMax2)/min(posMax,posMax2); if (sigma > 260 || peakposdifperc>0.3) { @@ -225,13 +251,13 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B } } } - // fitFunc->DrawCopy("same"); - TString legendEntry = TString(Form("%s","Gaus fit")); - TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); - // leg->SetHeader();//"Legend Title"); - leg->SetFillStyle(0); - leg->AddEntry((TObject*) 0, legendEntry, ""); - leg->SetTextSize(0.05); + +// TString legendEntry = TString(Form("%s","Gaus fit")); +// TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); +// // leg->SetHeader();//"Legend Title"); +// leg->SetFillStyle(0); +// leg->AddEntry((TObject*) 0, legendEntry, ""); +// leg->SetTextSize(0.05); // leg->Draw(); // } @@ -342,6 +368,7 @@ Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t ve 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); @@ -351,30 +378,56 @@ Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t ve 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 + } + } while (falling < 2 && biniGetNbinsX()); + if (verbose) { + cout << "Noise peak at: smoothedcurce->GetBinContent(" << noisepeakcandidate << "): " << smoothedcurce->GetBinContent(noisepeakcandidate) << endl; + } Int_t thresholdbincurcandidate = 0; - Int_t rising = 0; - Int_t bini =smoothedcurce->GetMaximumBin(); - thresholdbincurcandidate = bini; - // cout << "GetMaximumBin: smoothedcurce->GetXaxis()->GetBinCenter(" << bini << "): " << curval << endl; + bini = noisepeakcandidate; + Int_t rising = 0; do { Float_t curval=smoothedcurce->GetBinContent(bini++); if (curval*0.95 <= smoothedcurce->GetBinContent(bini)) { rising++; - // cout << "rising at " << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug + 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 && biniGetNbinsX()); thresholdbincurcandidate *= rebinningfactor; noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate); if (verbose) { - cout << " Noise threshold at " << noisethresholdborder; + cout << " Noise threshold at " << noisethresholdborder << endl; } return 0; } diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index 1d1ff18..700cc99 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "help.h" diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index 793118a..5969c4a 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -844,6 +844,7 @@ Bool_t Run::binSeedSumVeto() // (*curHistogramClass)->Sum->SetBinContent(bini,(*curHistogramClass)->Sum->GetBinContent(bini)/(frames_found*1.0)); } } + histogramfixedthreshold->noisethresholdborder=0; // gROOT->SetBatch(kFALSE); return 0; } @@ -1406,7 +1407,7 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1F* onehist TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700); onehistogram->SetTitle(titlestr); onehistogram->Draw(); - Float_t maxValue = HistogramTypepointer->FitPerform(onehistogram, fitFuncType); + Float_t maxValue = HistogramTypepointer->FitPerform(onehistogram, fitFuncType, true); plotVerticalLine(onehistogram, maxValue); TLegend* leg = new TLegend(0.4,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89); leg->SetFillColor(0); diff --git a/MABS_run_analyzer/Run.h b/MABS_run_analyzer/Run.h index 6a2d78b..7ff0f13 100644 --- a/MABS_run_analyzer/Run.h +++ b/MABS_run_analyzer/Run.h @@ -427,7 +427,5 @@ public: /// sensor information to use in analysis, is the system read out by USB or PXI? Number of rows differ sensorinfostruct cursensorinfo; - - }; #endif \ No newline at end of file