From: Benjamin Linnik Date: Mon, 10 Oct 2016 10:29:04 +0000 (+0200) Subject: Analyzer: Corrected Veto spectrum analysis, added lastrun.png creation for server... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=34f6b9b63c7c64b5da0a54c7610f238d74f69da7;p=radhard.git Analyzer: Corrected Veto spectrum analysis, added lastrun.png creation for server upload --- diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index 003964c..07459df 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -94,6 +94,7 @@ void ChargeSpektrum(TString runnumber = "") runs[runi]->setLabel(runListCustomTitle[runi]); } } + compareHistogramClassVectorMABSBot.push_back(runs[runi]->histogram); // gROOT->SetBatch(kTRUE); if (!isBatch) @@ -101,8 +102,8 @@ void ChargeSpektrum(TString runnumber = "") // Uncomment below to do classical analysis withour RTS // compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized->calibrated); - compareHistogramClassVector.push_back(runs[runi]->histogram); - compareHistogramClassVector2.push_back(runs[runi]->histogramthreshold); +// compareHistogramClassVector.push_back(runs[runi]->histogram); +// compareHistogramClassVector2.push_back(runs[runi]->histogramthreshold); // compareHistogramVector2.push_back(runs[runi]->histogramwoRTS->normalized->calibrated->Seed); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->normalized->calibrated, runs[runi]->histogramwoRTS->normalized->calibrated->Seed, "landau", true); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->normalized->calibrated, runs[runi]->histogramwoRTS->normalized->calibrated->Sum, "gaus", true); @@ -170,7 +171,7 @@ void ChargeSpektrum(TString runnumber = "") // compareHistogramVector3.push_back(runs[runi]->histogramwoRTS->pixeltimefiredsorted); // compareHistogramVector.push_back(runs[runi]->histogramwoRTS->normalized->Seed); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0); - runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefiredsorted, "", 0, true, true); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0, true, true); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrentInPixel, "", 0); @@ -183,7 +184,7 @@ void ChargeSpektrum(TString runnumber = "") //compareHistogramClassVector.push_back(runs[runi]->histogram); // runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->Veto, "gaus"); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Sum, "gaus", 1); -// runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->Veto, "GaussTail", 1); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Veto, "GaussTail", 1); // compareHistogramVector.push_back(runs[runi]->histogramthreshold->calibrated->normalized->Veto); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1); runs[runi]->writeAllHistogramsToFile(); @@ -229,6 +230,10 @@ CompareLeageCurrent(&compareHistogramClassVector4); CompareLeageCurrent(&compareHistogramClassVector5); writeObservableToFile(); writeOneHistogramTypeToFile(&compareHistogramClassVector); + +// Don't change this +gROOT->SetBatch(kTRUE); +plotAllRuns(&compareHistogramClassVectorMABSBot); // plotAllRuns("seed threshold calibrated"); // setCustomPath("Excel/"); // writeObservableToFile("seed threshold calibrated"); diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index 0861768..2756ab4 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -58,7 +58,7 @@ Bool_t printSummaryTable(vector*); Bool_t testifMixingCalibration(vector*); /** @brief Turns a value into a string with fixed precision */ string to_str_w_prec(const Float_t a_value, int precision = 1); -vector compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8; +vector compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8, compareHistogramClassVectorMABSBot; vector compareHistogramVector, compareHistogramVector2, compareHistogramVector3, compareHistogramVector4, compareHistogramVector5, compareHistogramVector6, compareHistogramVector7, compareHistogramVector8; TString ownpath = ""; @@ -611,19 +611,25 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) { HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami); TH1F* curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone(); + curhistogramclone->GetXaxis()->UnZoom(); heighestval1 = (curhistogramclone->GetMaximum()>heighestval1?curhistogramclone->GetMaximum():heighestval1); lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin1; // cout << "Last bin: " << colorcyan << lastbin1 << endlr; curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone(); + curhistogramclone->GetXaxis()->UnZoom(); heighestval2 = (curhistogramclone->GetMaximum()>heighestval2?curhistogramclone->GetMaximum():heighestval2); lastbin2 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin2)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin2; curhistogramclone = (TH1F*) curhistogramclassp->Veto->Clone(); + curhistogramclone->GetXaxis()->UnZoom(); heighestval3 = (curhistogramclone->GetMaximum()>heighestval3?curhistogramclone->GetMaximum():heighestval3); lastbin3 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin3)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin3; +// cout << "heighestval3: " << colorcyan << heighestval3 << endlr; +// cout << "curhistogramclone->GetMaximum(): " << colorcyan << curhistogramclone->GetMaximum() << endlr; curhistogramclone = (TH1F*) curhistogramclassp->Noise->Clone(); + curhistogramclone->GetXaxis()->UnZoom(); heighestval4 = (curhistogramclone->GetMaximum()>heighestval4?curhistogramclone->GetMaximum():heighestval4); } for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) @@ -705,6 +711,8 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) canvas->Paint(); img->Close(); + MSaveBigPNG(canvas,"lastrun.png"); + TFile *f = new TFile(savepathresults + "/" + canvastitle + ".root","RECREATE"); f->cd(); f->Append(canvas); @@ -717,6 +725,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) return 1; } + /** * @brief This functions prints a summary table of runs pushed into the ptCompareHistogramClassVector * diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index d93731d..09563ce 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -515,23 +515,26 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, // } } else if (fitFuncType=="GaussTail") { -// cout << colorcyan << "maxvalhist: " << posMaxValHist << endlr; -// cout << colorcyan << "noiseborder: " << noiseborder << endlr; + histogrampointer->GetXaxis()->UnZoom(); + posMaxValHist = (histogrampointer->GetBinCenter(histogrampointer->FindLastBinAbove(1,1))); +// cout << colorcyan << "maxvalhist: " << posMaxValHist << endlr; +// cout << colorcyan << "noiseborder: " << noiseborder << endlr; // histogrampointer->GetXaxis()->SetRange(noiseborder,histogrampointer->FindLastBinAbove(0)); // look only for maxima with x greater than noiseborder, cut away noise - histogrampointer->GetXaxis()->SetRange(noiseborder,posMaxValHist); // look only for maxima with x greater than noiseborder, cut away noise + histogrampointer->GetXaxis()->SetRange(histogrampointer->FindBin(noiseborder),histogrampointer->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise + // histogrampointer->GetXaxis()->SetRangeUser(noiseborder,posMaxValHist); TF1* fitFunc = new TF1("fitFunc",GaussTail,noiseborder,posMaxValHist,6); parameters = (Double_t *)calloc(8, sizeof(Double_t)); const Double_t def_amplitude=459.951; const Double_t def_peakcenter=histogrampointer->GetBinCenter(histogrampointer->GetMaximumBin()); - // cout << colorcyan << "def_peakcenter: " << def_peakcenter << endlr; +// cout << colorcyan << "def_peakcenter: " << def_peakcenter << endlr; +// cout << colorcyan << "histogrampointer->GetMaximumBin(): " << histogrampointer->GetMaximumBin() << endlr; const Double_t def_gausssig=-8.68052; const Double_t def_distgauss=20.4; const Double_t def_bgslope=0; const Double_t def_bgoffs=histogrampointer->GetBinContent(histogrampointer->FindBin((noiseborder+def_peakcenter)/2)); -// cout << colorcyan << "histogrampointer->FindBin((noiseborder+def_peakcenter)/2): " << histogrampointer->FindBin((noiseborder+def_peakcenter)/2) << endlr; - - +// cout << colorcyan << "histogrampointer->FindBin((noiseborder+def_peakcenter)/2): " << histogrampointer->FindBin((noiseborder+def_peakcenter)/2) << endlr; + fitFunc->SetLineWidth(4); fitFunc->SetLineColor(kGreen); // set start values for some parameters @@ -554,22 +557,22 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, parameters = (Double_t *)calloc(8, sizeof(Double_t)); int fittries = 0; + Bool_t failed = false; do { + failed = false; // cout << fittries << ": New range: " << histogrampointer->GetXaxis()->GetBinCenter(min+fittries*min/20) << " to " << posMaxValHist << endl; histogrampointer->Fit(fitFunc, "N,M,W,Q", "", noiseborder, posMaxValHist); // cout << colorcyan << " AFTER fit " << endlr; if (gMinuit == nullptr) { - cout << colorred << " Could not find " << histogrampointer->GetName() << " peak" << endlr; - parameters = (Double_t *)calloc(8, sizeof(Double_t)); - return parameters; - } - if (gMinuit->fCstatu == "NOT POSDEF") { - cout << colorred << " Could not find " << histogrampointer->GetName() << " peak" << endlr; - parameters = (Double_t *)calloc(8, sizeof(Double_t)); - return parameters; + failed = true; + } else + { + if (gMinuit->fCstatu == "NOT POSDEF" || gMinuit->fCstatu.Contains("FAILED")) { + failed = true; + } } - - if (gMinuit->fCstatu.Contains("FAILED")) { + if (failed) + { fitFunc->SetParameter(0,def_amplitude*(1.0-0.1*++fittries)); fitFunc->SetParameter(3,def_distgauss*(exp(-fittries/2.0))); fitFunc->SetParameter(1,def_peakcenter); @@ -577,20 +580,42 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, fitFunc->SetParameter(4,def_bgslope); fitFunc->SetParameter(5,def_bgoffs); } -// cout << colorcyan << gMinuit->fCstatu.Data() << " fit tries: " << fittries << endlr; - } while (gMinuit->fCstatu.Contains("FAILED") && fittries < 10 && gMinuit->fCstatu == "NOT POSDEF"); + else + fittries = 100; +// cout << colorcyan << gMinuit->fCstatu.Data() << " fit tries: " << fittries << endlr; + } while (fittries < 10); + if (failed) + { + failed = false; + histogrampointer->GetXaxis()->SetRange(0,posMaxValHist); // look only for maxima with x greater than noiseborder, cut away noise + fitFunc->SetParameter(0,def_amplitude); + fitFunc->SetParameter(3,def_distgauss); + fitFunc->SetParameter(1,def_peakcenter); + fitFunc->SetParameter(2,def_gausssig); + fitFunc->SetParameter(4,def_bgslope); + fitFunc->SetParameter(5,def_bgoffs); + histogrampointer->Fit(fitFunc, "N,M,W,Q", "", noiseborder, posMaxValHist); + if (gMinuit == nullptr) { + failed = true; + } else + { + if (gMinuit->fCstatu == "NOT POSDEF" || gMinuit->fCstatu.Contains("FAILED")) { + failed = true; + } + } + } - for (Int_t pari=0; pari<6; pari++) + if (failed) { - parameters[pari]=fitFunc->GetParameter(pari); -// fitFunc->SetParameter(pari,parameters[pari]); + cout << colorred << " Could not find " << histogrampointer->GetName() << " peak" << endlr; + parameters = (Double_t *)calloc(8, sizeof(Double_t)); + return parameters; } // fitFunc->FixParameter(1,parameters[1]+histogrampointer->GetBinWidth(0)); // histogrampointer->Fit(fitFunc, "N,M,W,Q", "", noiseborder, posMaxValHist); -// for (Int_t pari=0; pari<6; pari++) -// parameters[pari]=fitFunc->GetParameter(pari); + for (Int_t pari=0; pari<6; pari++) + parameters[pari]=fitFunc->GetParameter(pari); parameters[1] = parameters[1] - histogrampointer->GetBinWidth(0)*2; - parameters[7] = FindBorderToPeak(histogrampointer, noiseborder,def_peakcenter, verbose); // starting point of histogram integration parameters[6] = histogrampointer->Integral(histogrampointer->FindBin(parameters[7]), histogrampointer->GetXaxis()->FindBin(posMaxValHist)); // integral value of histogram (NOT fit) diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index c337c71..699ad5f 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -434,7 +434,6 @@ Bool_t Run::analyzeRun(Bool_t force) cout << colorwhite << "initOldRootFile():" << endlr; } if (processed->initOldRootFile()) return 1; - cout << colorcyan << "9TEST" << endlr; frames_found = processed->GetNumberFrames(); // cout << colorwhite << "plotPixSignal():"<< flush << endlr; // processed->plotPixSignal(0,10000000,351); @@ -1081,7 +1080,7 @@ Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass) } oneHistogramClass->avgLeakageCurrentInChip /= numberofconsideredpixel; - cout << "avgLeakageCurrentInChip: " << oneHistogramClass->avgLeakageCurrentInChip << endl; +// cout << "avgLeakageCurrentInChip: " << oneHistogramClass->avgLeakageCurrentInChip << endl; // oneHistogramClass->LeakageCurrentInPixelSorted->GetQuantiles( 3, leakagequantiles, probabilities); Int_t lastbinabovezero = oneHistogramClass->LeakageCurrentInPixelSorted->FindLastBinAbove(0); @@ -1091,9 +1090,9 @@ Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass) oneHistogramClass->medianLeakageCurrentPlus = oneHistogramClass->medianLeakageCurrentPlus - oneHistogramClass->medianLeakageCurrent; oneHistogramClass->medianLeakageCurrentMinus = oneHistogramClass->LeakageCurrentInPixelSorted->GetBinContent(lastbinabovezero*probabilities[0]); oneHistogramClass->medianLeakageCurrentMinus = oneHistogramClass->medianLeakageCurrentMinus - oneHistogramClass->medianLeakageCurrent; - cout << "medianLeakageCurrent: " << oneHistogramClass->medianLeakageCurrent << endl; - cout << "medianLeakageCurrentPlus: " << oneHistogramClass->medianLeakageCurrentPlus << endl; - cout << "medianLeakageCurrentMinus: " << oneHistogramClass->medianLeakageCurrentMinus << endl; +// cout << "medianLeakageCurrent: " << oneHistogramClass->medianLeakageCurrent << endl; +// cout << "medianLeakageCurrentPlus: " << oneHistogramClass->medianLeakageCurrentPlus << endl; +// cout << "medianLeakageCurrentMinus: " << oneHistogramClass->medianLeakageCurrentMinus << endl; // // // oneHistogramClass->medianLeakageCurrent = leakagequantiles[1];