From 11ec826378585118079db1a6181c9b2da6743f05 Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Tue, 1 Nov 2016 17:18:58 +0100 Subject: [PATCH] Analyzer: Added better integral caluclation for GaussianTail --- MABS_run_analyzer/ChargeSpektrum.c | 6 +- MABS_run_analyzer/ChargeSpektrumFunctions.c | 129 +++++++++++--------- MABS_run_analyzer/HistogramType.c | 24 ++-- MABS_run_analyzer/Run.c | 15 ++- MABS_run_analyzer/SetStyle.c | 2 +- 5 files changed, 105 insertions(+), 71 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index 07459df..b9852dc 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -101,8 +101,8 @@ void ChargeSpektrum(TString runnumber = "") gROOT->SetBatch(kFALSE); // 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]->histogram->normalized->calibrated); + compareHistogramClassVector.push_back(runs[runi]->histogram->normalized); // 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); @@ -184,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]->histogram, runs[runi]->histogram->Veto, "GaussTail", 1); + runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "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(); diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index 2756ab4..b7928c0 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -223,7 +223,7 @@ Bool_t writeOneHistogramTypeToFile(vector* ptCompareHistogramCla { if (ptCompareHistogramClassVector->at(runi) != nullptr) { - // header += Form("#%s, %s\n", ptCompareHistogramClassVector->at(runi)->humanreadablestr.Data(), ptCompareHistogramClassVector->at(runi)->histogramdescription.Data()); + // header += Form("#%s, %s\n", ptCompareHistogramClassVector->at(runi)->humanreadablestr.Data(), ptCompareHistogramClassVector->at(runi)->histogramdescription.Data()); } } filename+=".dat"; @@ -355,14 +355,14 @@ Bool_t CompareHistograms(vector* ptCompareHistogramVector, TString titles curhistogramclone->SetLineWidth(curhistogramclone->GetLineWidth()+1); curhistogramclone->Draw("SAME"); -// legendEntry = Form("%s %s", getRunnumberAtBegin(curhistogramclone->GetName()).Data(), curhistogramclone->GetTitle()); + // legendEntry = Form("%s %s", getRunnumberAtBegin(curhistogramclone->GetName()).Data(), curhistogramclone->GetTitle()); legendEntry = Form("%s", curhistogramclone->GetTitle()); leg1->AddEntry(curhistogramclone, legendEntry, "l"); leg1->Draw("SAME"); - + curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X"); -// curhistogramclone->GetYaxis()->SetRangeUser(5,heighestval1*4); -// gPad->SetLogy(1); + // curhistogramclone->GetYaxis()->SetRangeUser(5,heighestval1*4); + // gPad->SetLogy(1); owntitle->Clear(); owntitle->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); owntitle->Draw("SAME"); @@ -408,7 +408,7 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector owntitle->SetTextAlign(22); owntitle->SetTextSize(0.05); owntitle->SetTextFont(42); - + TString canvastitle = "SummaryLeakeCurrent"+ptCompareHistogramClassVector->at(0)->histogramdescription; for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { @@ -424,29 +424,29 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector double heighestxvalue = 0; -// std::vector sortedXValues; -// for (vector::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) { -// sortedXValues.push_back((*curHistogramClass)->labbook->radDoseNonIon); -// } -// std::sort(sortedXValues.begin(),sortedXValues.end()); -// double xbins[numberofhistogramclasses+1]; -// for(int i=0; i < numberofhistogramclasses; i++){ -// xbins[i] = sortedXValues.at(i) - 0.5; -// } -// xbins[numberofhistogramclasses]=sortedXValues.at(numberofhistogramclasses-1); + // std::vector sortedXValues; + // for (vector::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) { + // sortedXValues.push_back((*curHistogramClass)->labbook->radDoseNonIon); + // } + // std::sort(sortedXValues.begin(),sortedXValues.end()); + // double xbins[numberofhistogramclasses+1]; + // for(int i=0; i < numberofhistogramclasses; i++){ + // xbins[i] = sortedXValues.at(i) - 0.5; + // } + // xbins[numberofhistogramclasses]=sortedXValues.at(numberofhistogramclasses-1); for (vector::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) { lowestxvalue = lowestxvalue>(*curHistogramClass)->labbook->radDoseNonIon?(*curHistogramClass)->labbook->radDoseNonIon:lowestxvalue; heighestxvalue = heighestxvalue<(*curHistogramClass)->labbook->radDoseNonIon?(*curHistogramClass)->labbook->radDoseNonIon:heighestxvalue; -// cout << heighestxvalue << " " << lowestxvalue << " " << (*curHistogramClass)->labbook->radDoseNonIon << endl; + // cout << heighestxvalue << " " << lowestxvalue << " " << (*curHistogramClass)->labbook->radDoseNonIon << endl; } -// cout << "----" << endl; + // cout << "----" << endl; //double stepsizex = (heighestxvalue-lowestxvalue)/(numberofhistogramclasses); double stepsizex = 1; Int_t numberbins = (heighestxvalue-lowestxvalue)/stepsizex; -// if (stepsizex == 0) -// stepsizex = 1; -// cout << "stepsizex: " << stepsizex << endl; + // if (stepsizex == 0) + // stepsizex = 1; + // cout << "stepsizex: " << stepsizex << endl; double xbins[numberbins+2]; for(int i=0; i <= numberbins+1; i++){ xbins[i] = lowestxvalue+stepsizex*i-stepsizex/2; @@ -457,11 +457,11 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector Int_t lastbinabovezero = (*curHistogramClass)->LeakageCurrentInPixelSorted->FindLastBinAbove(0); double curheightyvalue = (*curHistogramClass)->LeakageCurrentInPixelSorted->GetBinContent(lastbinabovezero); heighestyvalue = heighestyvalue* ptCompareHistogramClassVector Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17}; for (vector::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) { for (Int_t pixeli=0; (*curHistogramClass)->LeakageCurrentInPixelSorted->GetBinContent(pixeli) != 0; pixeli++) { -// cout << pixeli << " " << (*curHistogramClass)->LeakageCurrentInPixelSorted->GetBinContent(pixeli) << " "; + // cout << pixeli << " " << (*curHistogramClass)->LeakageCurrentInPixelSorted->GetBinContent(pixeli) << " "; hcandle->Fill((*curHistogramClass)->labbook->radDoseNonIon,(*curHistogramClass)->LeakageCurrentInPixelSorted->GetBinContent(pixeli)); -// hcandle->Fill((*curHistogramClass)->labbook->radDoseNonIon,1.5); + // hcandle->Fill((*curHistogramClass)->labbook->radDoseNonIon,1.5); } legendEntry = Form("%f", (*curHistogramClass)->labbook->radDoseNonIon); // leg1->AddEntry(curhistogramclone, legendEntry, "l"); } -// hcandle->GetXaxis()->SetTitle("Non ionizing radiation damage [10^{13} n_{eq}/cm^{2}]]"); + // hcandle->GetXaxis()->SetTitle("Non ionizing radiation damage [10^{13} n_{eq}/cm^{2}]]"); hcandle->GetXaxis()->SetTitle("Radiation damage [10^{13} n/cm^{2}]]"); if (ptCompareHistogramClassVector->at(0)->iscalibrated) { hcandle->GetYaxis()->SetTitle("Charge [fA]"); @@ -499,8 +499,8 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector owntitle->AddText("Leakage current comparison"); owntitle->Draw("SAME"); -// leg1->Draw("SAME"); - + // leg1->Draw("SAME"); + canvas->Update(); MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png"); @@ -528,8 +528,8 @@ Bool_t plotAllRuns() { Bool_t testifMixingCalibration(vector* ptCompareHistogramClassVector) { if ( !ptCompareHistogramClassVector->size() ) { -// cout << colorwhite << ptCompareHistogramClassVector->size() << endl; -// cout << colorred << "plotCompareHistograms(): No plots to compare, please push them into the vector: CompareHistogramClassVector" << endlr; + // cout << colorwhite << ptCompareHistogramClassVector->size() << endl; + // cout << colorred << "plotCompareHistograms(): No plots to compare, please push them into the vector: CompareHistogramClassVector" << endlr; return 1; } Bool_t calibrated = true; @@ -614,7 +614,8 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) 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; + // cout << "Last bin: " << colorcyan << lastbin1 << endlr; + // cout << "curhistogramclone->GetMaximum(): " << colorcyan << curhistogramclone->GetMaximum() << endlr; curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone(); curhistogramclone->GetXaxis()->UnZoom(); @@ -625,8 +626,8 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) 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; + // cout << "heighestval3: " << colorcyan << heighestval3 << endlr; + // cout << "curhistogramclone->GetMaximum(): " << colorcyan << curhistogramclone->GetMaximum() << endlr; curhistogramclone = (TH1F*) curhistogramclassp->Noise->Clone(); curhistogramclone->GetXaxis()->UnZoom(); @@ -639,20 +640,23 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) canvas->cd(1); curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone(); -// TLatex Tl; -// Tl.SetNDC(); -// Tl.DrawText(0.3, 0.2, "Titel titel"); + // TLatex Tl; + // Tl.SetNDC(); + // Tl.DrawText(0.3, 0.2, "Titel titel"); //TPaveText *t = new TPaveText(0.0, 0.9, 0.3, 1.0, "brNDC"); // left-up curhistogramclone->SetLineColor(rootcolors[histogrami%13]); //curhistogramclone->GetXaxis()->SetRange(0,curhistogramclone->GetXaxis()->GetNbins()); curhistogramclone->Draw("SAME"); -// legendEntry = Form("%d %s", curhistogramclassp->labbook->runnumber, curhistogramclone->GetTitle()); + // legendEntry = Form("%d %s", curhistogramclassp->labbook->runnumber, curhistogramclone->GetTitle()); legendEntry = Form("%s", curhistogramclone->GetTitle()); leg1->AddEntry(curhistogramclone, legendEntry, "l"); leg1->Draw("SAME"); curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X"); - curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*4); - gPad->SetLogy(1); + curhistogramclone->SetAxisRange(0,heighestval1*1.1,"Y"); + curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*1.0); + //gPad->SetLogy(1); + gPad->SetGrid(1); + gPad->SetGridy(1); owntitle->Clear(); owntitle->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); owntitle->Draw("SAME"); @@ -662,28 +666,37 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) curhistogramclone->SetLineColor(rootcolors[histogrami%13]); curhistogramclone->Draw("SAME"); hs->Add(curhistogramclone); + legendEntry = Form("%s", curhistogramclone->GetTitle()); leg2->AddEntry(curhistogramclone, legendEntry, "l"); leg2->Draw("SAME"); -// hs->Add(leg1); + // hs->Add(leg1); curhistogramclone->SetAxisRange(0,lastbin2*1.1,"X"); -// heighestval2 = (curhistogramclone->GetMaximum()>heighestval2?curhistogramclone->GetMaximum():heighestval2); - curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval2*4); + curhistogramclone->SetAxisRange(0,heighestval2*1.1,"Y"); + // heighestval2 = (curhistogramclone->GetMaximum()>heighestval2?curhistogramclone->GetMaximum():heighestval2); + curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval2*1.2); curhistogramclone->Draw("SAME"); - gPad->SetLogy(1); + // gPad->SetLogy(1); + gPad->SetGrid(1); + gPad->SetGridy(1); owntitle2->Clear(); owntitle2->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); -// hs->Add(owntitle2); + // hs->Add(owntitle2); owntitle2->Draw("SAME"); canvas->cd(3); curhistogramclone = (TH1F*) curhistogramclassp->Veto->Clone(); curhistogramclone->SetLineColor(rootcolors[histogrami%13]); curhistogramclone->Draw("SAME"); + legendEntry = Form("%s", curhistogramclone->GetTitle()); leg3->AddEntry(curhistogramclone, legendEntry, "l"); leg3->Draw("SAME"); - curhistogramclone->SetAxisRange(1,lastbin3*1.1,"X"); -// heighestval3 = (curhistogramclone->GetMaximum()>heighestval3?curhistogramclone->GetMaximum():heighestval3); + curhistogramclone->SetAxisRange(1,lastbin3*1.1,"X"); + curhistogramclone->SetAxisRange(1,heighestval3*1.1,"Y"); + // heighestval3 = (curhistogramclone->GetMaximum()>heighestval3?curhistogramclone->GetMaximum():heighestval3); curhistogramclone->GetYaxis()->SetRangeUser(0,heighestval3*1.2); + curhistogramclone->Draw("SAME"); + gPad->SetGrid(1); + gPad->SetGridy(1); owntitle3->Clear(); owntitle3->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); owntitle3->Draw("SAME"); @@ -695,15 +708,15 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) legendEntry = Form("%d Noise: %.2f + %.2f - %.2f",curhistogramclassp->labbook->runnumber, curhistogramclassp->avgNoise, curhistogramclassp->avgNoisePlus, curhistogramclassp->avgNoiseMinus); leg4->AddEntry(curhistogramclone, legendEntry, "l"); leg4->Draw(); - curhistogramclone->GetYaxis()->SetRangeUser(0,heighestval4*1.4); + curhistogramclone->GetYaxis()->SetRangeUser(0,heighestval4*1.2); owntitle4->Clear(); owntitle4->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); owntitle4->Draw("SAME"); } canvas->cd(0); //TText T; T.SetTextFont(42); T.SetTextAlign(21); -// canvas->cd(2); hs->Draw("nostack same");// T.DrawTextNDC(.5,.95,"Option \"nostack\""); -// canvas->BuildLegend(); + // canvas->cd(2); hs->Draw("nostack same");// T.DrawTextNDC(.5,.95,"Option \"nostack\""); + // canvas->BuildLegend(); canvas->Update(); MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png"); @@ -719,7 +732,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) //f->Append(img); f->Write(); -// gROOT->SetStyle("RadHard_AutoTitle"); + // gROOT->SetStyle("RadHard_AutoTitle"); return 0; } return 1; @@ -733,7 +746,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) * * Prints a summary table and compares some observables * -*/ + */ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) { if (ptCompareHistogramClassVector->size()>0) @@ -794,8 +807,8 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) if (printIntegral > 0.0) { cout << left << setw(width+1) << setfill(' ') << "Integral"; filecontent += Form("Integral\t"); } //cout << left << setw(width) << setfill(' ') << "Seed Peak"; filecontent += Form("Seed Peak\t"); //cout << left << setw(width) << setfill(' ') << "Veto Peak"; filecontent += Form("Veto Peak\t"); -// cout << left << setw(width+2) << setfill(' ') << "Veto Integral"; filecontent += Form("Veto Integral\t"); -// cout << left << setw(width+2) << setfill(' ') << "Sum Integral"; filecontent += Form("Veto Integral\t"); + // cout << left << setw(width+2) << setfill(' ') << "Veto Integral"; filecontent += Form("Veto Integral\t"); + // cout << left << setw(width+2) << setfill(' ') << "Sum Integral"; filecontent += Form("Veto Integral\t"); cout << left << setw(width-2) << setfill(' ') << "RTS pixel"; filecontent += Form("RTS pixel\t"); cout << left << setw(width+2) << setfill(' ') << "Leakage"; filecontent += Form("Leakage cur.\t"); cout << left << setw(width-2) << setfill(' ') << "Noise"; filecontent += Form("Noise\t"); @@ -805,12 +818,12 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) { HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami); cout << left << setw(width-5) << setfill(' ') << curhistogramclassp->labbook->runnumber; filecontent += Form("%d\t", curhistogramclassp->labbook->runnumber); -// cout << "1" << endl; + // cout << "1" << endl; cout << left << setw(width-5) << setfill(' ') << to_str_w_prec(curhistogramclassp->frames_found); filecontent += Form("%s\t", to_str_w_prec(curhistogramclassp->frames_found).c_str()); -// cout << "2" << endl; + // cout << "2" << endl; cout << left << setw(width-10) << setfill(' ') << curhistogramclassp->labbook->chip; filecontent += Form("%s\t", curhistogramclassp->labbook->chip.Data()); if (printtemp) { cout << left << setw(width-8) << setfill(' ') << curhistogramclassp->labbook->temp; filecontent += Form("%.1f\t", curhistogramclassp->labbook->temp); } -// cout << "!" << endl; + // cout << "!" << endl; cout << left << setw(width-10) << setfill(' ') << curhistogramclassp->labbook->matrix; filecontent += Form("%s\t", curhistogramclassp->labbook->matrix.Data()); if (printradion > 0) { cout << left << setw(width-5) << setfill(' ') << curhistogramclassp->labbook->radDoseIon; filecontent += Form("%.1f\t", curhistogramclassp->labbook->radDoseIon); } if (printradnonion > 0) { cout << left << setw(width-8) << setfill(' ') << curhistogramclassp->labbook->radDoseNonIon; filecontent += Form("%.1f\t", curhistogramclassp->labbook->radDoseNonIon); } @@ -820,8 +833,8 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) if (printIntegral > 0.0) { cout << left << setw(width+1) << setfill(' ') << printTableElement(curhistogramclassp->sr90IntegralVal,ptCompareHistogramClassVector->at(0)->sr90IntegralVal); filecontent += Form("%s\t", printTableElement(curhistogramclassp->sr90IntegralVal,ptCompareHistogramClassVector->at(0)->sr90IntegralVal).c_str()); } //cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->posSeed,ptCompareHistogramClassVector->at(0)->posSeed); filecontent += Form("%s\t", printTableElement(curhistogramclassp->posSeed,ptCompareHistogramClassVector->at(0)->posSeed).c_str()); //cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->posVeto,ptCompareHistogramClassVector->at(0)->posVeto); filecontent += Form("%s\t", printTableElement(curhistogramclassp->posVeto,ptCompareHistogramClassVector->at(0)->posVeto).c_str()); -// cout << left << setw(width+2) << setfill(' ') << printTableElement(curhistogramclassp->integralVeto,ptCompareHistogramClassVector->at(0)->integralVeto,2); filecontent += Form("%s\t", printTableElement(curhistogramclassp->integralVeto,ptCompareHistogramClassVector->at(0)->integralVeto,4).c_str()); -// cout << left << setw(width+2) << setfill(' ') << printTableElement(curhistogramclassp->integralSum,ptCompareHistogramClassVector->at(0)->integralSum,2); filecontent += Form("%s\t", printTableElement(curhistogramclassp->integralSum,ptCompareHistogramClassVector->at(0)->integralSum,4).c_str()); + // cout << left << setw(width+2) << setfill(' ') << printTableElement(curhistogramclassp->integralVeto,ptCompareHistogramClassVector->at(0)->integralVeto,2); filecontent += Form("%s\t", printTableElement(curhistogramclassp->integralVeto,ptCompareHistogramClassVector->at(0)->integralVeto,4).c_str()); + // cout << left << setw(width+2) << setfill(' ') << printTableElement(curhistogramclassp->integralSum,ptCompareHistogramClassVector->at(0)->integralSum,2); filecontent += Form("%s\t", printTableElement(curhistogramclassp->integralSum,ptCompareHistogramClassVector->at(0)->integralSum,4).c_str()); cout << left << setw(width-2) << setfill(' ') << printTableElement((float)curhistogramclassp->RTSpixel.size(),(float)ptCompareHistogramClassVector->at(0)->RTSpixel.size(),0); filecontent += Form("%s\t", printTableElement((float)curhistogramclassp->RTSpixel.size(),(float)ptCompareHistogramClassVector->at(0)->RTSpixel.size(),0).c_str()); cout << left << setw(width+2) << setfill(' ') << printTableElement((float)curhistogramclassp->medianLeakageCurrent,(float)ptCompareHistogramClassVector->at(0)->medianLeakageCurrent,1); filecontent += Form("%s\t", printTableElement((float)curhistogramclassp->medianLeakageCurrent,(float)ptCompareHistogramClassVector->at(0)->medianLeakageCurrent,1).c_str()); cout << left << setw(width-2) << setfill(' ') << printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise); filecontent += Form("%s\t", printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise).c_str()); diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 09563ce..c97eab1 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -589,9 +589,9 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, 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(3,def_distgauss); fitFunc->SetParameter(4,def_bgslope); fitFunc->SetParameter(5,def_bgoffs); histogrampointer->Fit(fitFunc, "N,M,W,Q", "", noiseborder, posMaxValHist); @@ -615,13 +615,21 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, // histogrampointer->Fit(fitFunc, "N,M,W,Q", "", noiseborder, posMaxValHist); for (Int_t pari=0; pari<6; pari++) parameters[pari]=fitFunc->GetParameter(pari); - parameters[1] = parameters[1] - histogrampointer->GetBinWidth(0)*2; + //parameters[1] = parameters[1] - histogrampointer->GetBinWidth(0)*2; + + //parameters[7] = FindBorderToPeak(histogrampointer, noiseborder,def_peakcenter, verbose); // starting point of histogram integration + parameters[7] = parameters[1] - 2*parameters[2] ; // starting point of histogram integration + parameters[6] = histogrampointer->Integral(histogrampointer->GetXaxis()->FindBin( parameters[1] - 2*parameters[2] ), histogrampointer->GetXaxis()->FindBin( parameters[1] + 2*parameters[2])); // integral value of histogram (NOT fit) + + TF1 *bgfct = new TF1("f1","[0] +[1]*x",0,posMaxValHist); + bgfct->SetParameters(parameters[5],parameters[4]); + double integralbg = bgfct->Integral(parameters[1] - 2*parameters[2] ,parameters[1] + 2*parameters[2]); // integral value of histogram (NOT fit) + parameters[6] -= integralbg; - 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) -// cout << colorcyan << "Integral from bin : " << histogrampointer->FindBin(parameters[7]) << " to " << histogrampointer->GetXaxis()->FindBin(posMaxValHist) << endlr; -// cout << colorcyan << "Integral from val : " << parameters[7] << " to " << histogrampointer->GetBinCenter(histogrampointer->GetXaxis()->FindBin(posMaxValHist)) << endlr; -// cout << colorcyan << "Integral value: " << parameters[6] << endlr; + cout << colorcyan << "Integral from bin : " << histogrampointer->FindBin(parameters[7]) << " to " << histogrampointer->GetXaxis()->FindBin(parameters[1] + 2*parameters[2]) << endlr; + cout << colorcyan << "Integral from val : " << parameters[7] << " to " << parameters[1] + 2*parameters[2] << endlr; + cout << colorcyan << "Integral value: " << parameters[6] << endlr; + cout << colorcyan << "Integral bg: " << integralbg << endlr; // DEBUG // TCanvas* canvas = new TCanvas(histogrampointer->GetName(), histogrampointer->GetName(), 900, 700); @@ -880,7 +888,7 @@ Double_t HistogramType::GaussTail(Double_t *x, Double_t *par) { offset = par[1] - par[3]; bg = par[4]*x[0] + par[5]; rgauss = par[0]*exp(-pow(x[0] - par[1],2)/(2*pow(par[2],2))); - rtail = par[0]*exp(par[3]*(2*x[0] - 2*par[1] + par[3])/(2*pow(par[2],2))); + rtail = par[0]*exp(par[3]*(2*x[0] - 2*par[1] + par[3])/(2*pow(par[2],2))); rtn = (x[0] < offset)? rtail : rgauss; return (rtn + bg); } diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index 699ad5f..319a345 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -251,7 +251,7 @@ void Run::setSystemSpecificParameters() systemparam systemparamPXI (800*16,800,75,150,150); systemparam systemparamFSBB (2800,2800/4,25,10,100); systemparam systemparamUSBMi19 (400/*maxbin*/,400/1/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/); - systemparam systemparamPipper2 (2800,2800/4,15,10,100); + systemparam systemparamPipper2 (1000,1000,15,10,100); if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") ) cursystemparam = systemparamUSB; else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("FSBB") ) @@ -2135,6 +2135,19 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1F* onehist // cout << colorcyan << ": " << parameters[7] << endlr; plotVerticalLineHeigher(onehistogram, integralstart); plotTextAtVal(onehistogram, maxValue, integrallbl); + if (verbose) { + cout << "fit parameters " << endl; + cout << "amplitude of peak: " << parameters[0] << endl; + cout << "peak centroid : " << parameters[1] << endl; + cout << "Gaussian sigma : " << parameters[2] << endl; + cout << "Distance under : " << parameters[3] << endl; + cout << "background slope : " << parameters[4] << endl; + cout << "background offset: " << parameters[5] << endl; + //TF1 *f1 = new TF1("f1","[0] +[1]*x +gaus(2)",0,5); + TF1 *f1 = new TF1("f1","[0] +[1]*x",100,250); + f1->SetParameters(parameters[5],parameters[4]); + f1->Draw("SAME"); + } } if (fitFuncType=="gaus") { diff --git a/MABS_run_analyzer/SetStyle.c b/MABS_run_analyzer/SetStyle.c index ec92f29..1c10c97 100644 --- a/MABS_run_analyzer/SetStyle.c +++ b/MABS_run_analyzer/SetStyle.c @@ -45,7 +45,7 @@ Nab_collaboration->SetPadTickY(1); // Sets tic marks on both vertical axes Nab_collaboration->SetTickLength(0.018,"xyz"); // Sets tic length Nab_collaboration->SetOptStat(0); // Turns off Statistics display - Nab_collaboration->SetOptTitle(1); // Turns off Title display + Nab_collaboration->SetOptTitle(-1); // Turns off Title display Nab_collaboration->SetHistLineWidth(2); // Changes Histogram Line width Nab_collaboration->SetFrameBorderMode(0); // Removes the Frame Border Nab_collaboration->SetFrameFillStyle(0); -- 2.43.0