From 02adf90ed4c8af393dc5d0ded80fd5607bb99481 Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Wed, 13 Dec 2017 19:23:34 +0100 Subject: [PATCH] Analyzer: calibration is done for each cut type seperately, better fitting of sum and veto peak: tested with Mi19 --- MABS_run_analyzer/ChargeSpektrum.c | 2 +- MABS_run_analyzer/ChargeSpektrumFunctions.c | 107 ++++++++++---------- MABS_run_analyzer/HistogramType.c | 32 ++++-- 3 files changed, 75 insertions(+), 66 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index 497ff54..bbcdeb3 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -467,7 +467,7 @@ void ChargeSpektrum(TString runnumber = "") // DEBUGGING // runs[runi]->histogramwoRTS->FindNoisethresholdborder(runs[runi]->histogramwoRTS->Veto, false, true); - // runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->Veto, "GaussTail", true, false, false, runs[runi]->histogramwoRTS->noisethresholdborder); + runs[runi]->plot1DHistogram( runs[runi]->histogram->Veto, "GaussTail", true, false, false, runs[runi]->histogram->noisethresholdborder); // runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->a_Sum25[22], "gaus", true, false, false, runs[runi]->histogramwoRTS->noisethresholdborder); //cout << runs[runi]->histogram diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index f9aa303..de32326 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -1245,70 +1245,69 @@ Bool_t FindGoodTitle(vector* ptCompareHistogramClassVector, vect // if (!same_RunNumber) { if (legendstr.Length()) legendstr.Append(", "); // legendstr.Append(Form("%d", curhistogramclassp->labbook->runnumber)); } - if (!same_HistType && mayBeSameRun) { if (legendstr.Length()) legendstr.Append(", "); + if (!same_HistType && mayBeSameRun) { if (legendstr.Length()) { legendstr.Append(", "); } legendstr.Append(Form("%s", trimRunnumberAtBegin(curhistogramp->GetName()).Data())); } - if (!same_Source) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%s", curlabbook.source.Data())); } - if (!same_ChipGen) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%s", curlabbook.chipGen.Data())); } - if (!same_ChipNum) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("Chip# %s", curlabbook.chip.Data())); } - if (!same_Matrix) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%s, %.0fx%.0f #mum^{2} pitch, %s", curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data())); } - if (!same_Temp) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("T=%.0f {}^{o}C", curlabbook.tempSens)); } - if (!same_IonRad && curlabbook.radDoseIon != 0) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%.1f MRad", firstlabbook.radDoseIon)); } - if (!same_NonIonRad && curlabbook.radDoseNonIon != 0) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%.1f*10^{13} n_{eq}/cm^{2}", curlabbook.radDoseNonIon)); } - if (!same_Clock) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("%.2f Mhz", curlabbook.clock)); } - if (!same_Depletion && curlabbook.depletionV >= 0) { if (legendstr.Length()) legendstr.Append(", "); - legendstr.Append(Form("U_{dep}=%.1f V", curlabbook.depletionV)); } - legendStringsVector.push_back(legendstr); - + if (!same_Source) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%s", curlabbook.source.Data())); } + if (!same_ChipGen) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%s", curlabbook.chipGen.Data())); } + if (!same_ChipNum) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("Chip# %s", curlabbook.chip.Data())); } + if (!same_Matrix) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%s, %.0fx%.0f #mum^{2} pitch, %s", curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data())); } + if (!same_Temp) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("T=%.0f {}^{o}C", curlabbook.tempSens)); } + if (!same_IonRad && curlabbook.radDoseIon != 0) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%.1f MRad", firstlabbook.radDoseIon)); } + if (!same_NonIonRad && curlabbook.radDoseNonIon != 0) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%.1f*10^{13} n_{eq}/cm^{2}", curlabbook.radDoseNonIon)); } + if (!same_Clock) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("%.2f Mhz", curlabbook.clock)); } + if (!same_Depletion && curlabbook.depletionV >= 0) { if (legendstr.Length()) { legendstr.Append(", "); } + legendstr.Append(Form("U_{dep}=%.1f V", curlabbook.depletionV)); } + + legendStringsVector.push_back(legendstr); // cout << colorred << legendstr << endlr; } } // end else ptCompareHistogramClassVector->size() == 1 // Folder name suffix folderadd = ""; - if (same_RunNumber) - folderadd.Append(Form(" %d", firstlabbook.runnumber)); - if (same_HistType && mayBeSameRun && firsthistogramp != 0) - folderadd.Append(Form(" %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data())); - if (same_Source) - folderadd.Append(Form(" %s", firstlabbook.source.Data())); - if (same_ChipGen) - folderadd.Append(Form(" %s", firstlabbook.chipGen.Data())); - if (same_Matrix) - folderadd.Append(Form("-%s", firstlabbook.matrix.Data())); - if (!same_Matrix) + if (same_RunNumber) { + folderadd.Append(Form(" %d", firstlabbook.runnumber)); } + if (same_HistType && mayBeSameRun && firsthistogramp != 0) { + folderadd.Append(Form(" %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data())); } + if (same_Source) { + folderadd.Append(Form(" %s", firstlabbook.source.Data())); } + if (same_ChipGen) { + folderadd.Append(Form(" %s", firstlabbook.chipGen.Data())); } + if (same_Matrix) { + folderadd.Append(Form("-%s", firstlabbook.matrix.Data())); } + if (!same_Matrix) { for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) folderadd.Append(Form(" -%s", ptCompareHistogramClassVector->at(histogrami)->labbook->matrix.Data())); - if (same_Depletion && firstlabbook.depletionV >= 0) - folderadd.Append(Form(" %.1fV", firstlabbook.depletionV)); - if (!same_Depletion && firstlabbook.depletionV >= 0) - for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) - folderadd.Append(Form(" %.1fV", ptCompareHistogramClassVector->at(histogrami)->labbook->depletionV)); - if (same_Temp) - folderadd.Append(Form(" %.0fC", firstlabbook.tempSens)); - if (same_IonRad && firstlabbook.radDoseIon != 0) - folderadd.Append(Form("%.1fMRad", firstlabbook.radDoseIon)); - if (same_NonIonRad && firstlabbook.radDoseNonIon != 0) - folderadd.Append(Form(" %.1fe13neq", firstlabbook.radDoseNonIon)); - if (same_Clock) - folderadd.Append(Form(" %.2fMhz", firstlabbook.clock)); - if (!same_Clock) - for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) - folderadd.Append(Form(" %.2fMhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); - - removeForbiddenChar(&folderadd); - - system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); - // cout << colorred << savepathresults << folderadd << endlr; + } + if (same_Depletion && firstlabbook.depletionV >= 0) { + folderadd.Append(Form(" %.1fV", firstlabbook.depletionV)); } + if (!same_Depletion && firstlabbook.depletionV >= 0) { + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { + folderadd.Append(Form(" %.1fV", ptCompareHistogramClassVector->at(histogrami)->labbook->depletionV)); } } + if (same_Temp) { + folderadd.Append(Form(" %.0fC", firstlabbook.tempSens)); } + if (same_IonRad && firstlabbook.radDoseIon != 0) { + folderadd.Append(Form("%.1fMRad", firstlabbook.radDoseIon)); } + if (same_NonIonRad && firstlabbook.radDoseNonIon != 0) { + folderadd.Append(Form(" %.1fe13neq", firstlabbook.radDoseNonIon)); } + if (same_Clock) { + folderadd.Append(Form(" %.2fMhz", firstlabbook.clock)); } + if (!same_Clock) { + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { + folderadd.Append(Form(" %.2fMhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); } } - return false; + removeForbiddenChar(&folderadd); + system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); + // cout << colorred << savepathresults << folderadd << endlr; + return false; } diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 7fba882..c10d2ad 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -456,15 +456,15 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType // set start values for some parameters fitFunc->SetParName(0,"amplitude of peak"); fitFunc->SetParameter(0,def_amplitude); - fitFunc->SetParError(0, def_amplitude*0.01); + fitFunc->SetParError(0, def_amplitude*0.05); fitFunc->SetParName(1,"peak centroid"); fitFunc->SetParameter(1,def_peakcenter); fitFunc->SetParLimits(1,def_peakcenter*0.8,def_peakcenter*1.2); - fitFunc->SetParError(1, def_peakcenter*0.01); + fitFunc->SetParError(1, def_peakcenter*0.05); fitFunc->SetParName(2,"Gaussian sigma"); fitFunc->SetParameter(2,def_gausssig); fitFunc->SetParLimits(2,0.0,100.0); - fitFunc->SetParError(2, def_gausssig*0.01); + fitFunc->SetParError(2, def_gausssig*0.05); int fittries = 0; Bool_t failed = false; @@ -722,18 +722,28 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType // } histogrampointer->GetXaxis()->UnZoom(); // resets range Int_t binPosMaxHist = histogrampointer->FindLastBinAbove(1,1); - Int_t binPosMaxPeak = 0; - TString histogramname = histogrampointer->GetName(); posMaxValHist = (histogrampointer->GetBinCenter(binPosMaxHist)); + histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(noiseborder),histogrampointer->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise + Int_t binPosMaxPeak = histogrampointer->GetMaximumBin(); + Double_t valueMaxPeak = histogrampointer->GetBinCenter(binPosMaxPeak); + + TString histogramname = histogrampointer->GetName(); Bool_t do_loop = kTRUE; Int_t loopi = 0; do { + binPosMaxHist = histogrampointer->FindLastBinAbove(valueMaxPeak/10,1); + posMaxValHist = (histogrampointer->GetBinCenter(binPosMaxHist)); + histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(noiseborder*++loopi),histogrampointer->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise binPosMaxPeak = histogrampointer->GetMaximumBin(); + // if Sum peak, than the peak must be in the right region of the whole histogram, so search for it +// cout << colorcyan << "binPosMaxPeak: " << binPosMaxPeak << endlr; +// cout << colorcyan << "binPosMaxHist/2: " << binPosMaxHist/2 << endlr; if (( binPosMaxPeak > binPosMaxHist/2) || (loopi > 3) ) { do_loop = kFALSE; noiseborder = noiseborder*loopi; +// cout << colorcyan << "loopi: " << posMaxValHist << endlr; } } while ( do_loop ); if (verbose) { @@ -759,27 +769,27 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType // set start values for some parameters fitFunc->SetParName(0,"amplitude of peak"); fitFunc->SetParameter(0,def_amplitude); - fitFunc->SetParError(0, def_amplitude*0.01); + fitFunc->SetParError(0, def_amplitude*0.05); fitFunc->SetParName(1,"peak centroid"); fitFunc->SetParameter(1,def_peakcenter); - fitFunc->SetParError(1, def_peakcenter*0.01); + fitFunc->SetParError(1, def_peakcenter*0.05); // fitFunc->SetParLimits(1,def_peakcenter*0.8,def_peakcenter*1.2); fitFunc->SetParName(2,"Gaussian sigma"); fitFunc->SetParameter(2,def_gausssig); fitFunc->SetParLimits(2,0,150); - fitFunc->SetParError(2, def_gausssig*0.01); + fitFunc->SetParError(2, def_gausssig*0.05); fitFunc->SetParName(3,"Distance from Gauss"); fitFunc->SetParameter(3,def_distgauss); fitFunc->SetParLimits(3,0,def_distgauss*4); - fitFunc->SetParError(3, def_distgauss*0.01); + fitFunc->SetParError(3, def_distgauss*0.05); fitFunc->SetParName(4,"background slope"); fitFunc->SetParameter(4,def_bgslope); - fitFunc->SetParError(4, def_bgslope*0.01); + fitFunc->SetParError(4, def_bgslope*0.05); // fitFunc->SetParLimits(4,def_bgslope-0.1,def_bgslope+0.1); fitFunc->SetParName(5,"background offset"); fitFunc->SetParameter(5,def_bgoffs); fitFunc->SetParLimits(5,0,def_bgoffs*4); - fitFunc->SetParError(5, def_bgoffs*0.01); + fitFunc->SetParError(5, def_bgoffs*0.05); // TODO: This fix disables the background // fitFunc->FixParameter(4,0); -- 2.43.0