11 PrintChargeSpectrumPMT_cnt++;
13 string ctitle(
"charge spectra PMT" + to_string(PrintChargeSpectrumPMT_cnt));
14 TCanvas* chargec =
new TCanvas(ctitle.c_str(), ctitle.c_str(), 600, 400);
17 int current_canvas = 0;
23 auto his =
ChargeSpectrum(i, windowlow, windowhi, start, end, rangestart, rangeend, nbins);
24 if (windowlow + windowhi > 0.) his->GetXaxis()->SetTitle(
"integral in mV#timesns");
25 else his->GetXaxis()->SetTitle(
"amplitude in mV");
26 chargec->cd(current_canvas);
28 his->GetYaxis()->SetTitle(
"#Entries");
29 his->GetXaxis()->SetTitle(
"integral in mV#timesns");
31 stringstream allname; allname << his->GetEntries() <<
" entries";
32 his->SetTitle(allname.str().c_str());
34 TString name(Form(
"ChargeSpectrumPMT channel_%02d",
active_channels[i]));
35 root_out->WriteObject(his, name.Data());
39 auto gauss =
new TF1(
"gauss",
"gaus", rangestart, rangeend);
40 TFitResultPtr fres_est = his->Fit(gauss,
"QRSL");
42 auto two_gauss =
new TF1(
"two gaussians",
"gaus(0)+gaus(3)", rangestart, rangeend); two_gauss->SetTitle(
"Sum of two gauss");
43 two_gauss->SetParameters(fres_est->Parameter(0) * .95, fres_est->Parameter(1) * .95, fres_est->Parameter(2) * .95, fres_est->Parameter(0) * .3, fres_est->Parameter(1) * 1.05, fres_est->Parameter(2) * .85);
44 two_gauss->SetParName(0,
"A_{pedestal}");
45 two_gauss->SetParName(1,
"#mu_{pedestal}");
46 two_gauss->SetParName(2,
"#sigma_{pedestal}"); two_gauss->SetParLimits(2, 1e-9, 1e3);
47 two_gauss->SetParName(3,
"A_{SPE}");
48 two_gauss->SetParName(4,
"#mu_{SPE}");
49 two_gauss->SetParName(5,
"#sigma_{SPE}"); two_gauss->SetParLimits(5, 1e-9, 1e3);
56 TFitResultPtr fresults = his->Fit(two_gauss,
"RSL");
59 two_gauss->Draw(
"same");
61 auto pedestal =
new TF1(
"pedestal",
"gaus", rangestart, rangeend); pedestal->SetTitle(
"pedestal");
62 pedestal->SetParameters(fresults->Parameter(0), fresults->Parameter(1), fresults->Parameter(2));
63 pedestal->SetLineColor(3);
64 pedestal->Draw(
"same");
66 auto pepeak =
new TF1(
"pepeak",
"gaus", rangestart, rangeend); pepeak->SetTitle(
"pepeak");
67 pepeak->SetParameters(fresults->Parameter(3), fresults->Parameter(4), fresults->Parameter(5));
68 pepeak->SetLineColor(4);
76 root_out->WriteObject(chargec,
"ChargeSpectraPMT");
88 PrintChargeSpectrumPMTthreshold_cnt++;
90 gStyle->SetOptStat(0);
95 bool use_fit_result_for_threshold =
false;
96 if (threshold == 999) {
97 calculate_SiPM_DCR =
true;
98 use_fit_result_for_threshold =
true;
102 string title(
"amplitude in mV");
103 if (windowlow + windowhi > 0.) {
104 unit =
" mV#timesns";
105 title =
"integral in mV#timesns";
107 string ctitle(
"charge spectra PMT threshold" + to_string(PrintChargeSpectrumPMTthreshold_cnt));
108 TCanvas* chargec =
new TCanvas(ctitle.c_str(), ctitle.c_str(), 600, 400);
111 int current_canvas = 0;
112 double threshold_bin_center = 0;
117 if (use_fit_result_for_threshold) threshold =
fit_results[current_canvas]->Parameter(6) +
fit_results[current_canvas]->Parameter(5) / 2.;
119 chargec->cd(++current_canvas);
121 auto his =
ChargeSpectrum(i, windowlow, windowhi, rangestart, rangeend, rangestart, rangeend, nbins);
122 his->GetXaxis()->SetTitle(title.c_str());
123 his->GetYaxis()->SetTitle(
"#Entries");
125 stringstream allname; allname << his->GetEntries() <<
" entries";
126 his->SetTitle(allname.str().c_str());
128 auto his_lo = (TH1F*)his->Clone();
129 his_lo->GetXaxis()->SetRange(his_lo->GetXaxis()->FindBin(rangestart), his_lo->GetXaxis()->FindBin(threshold));
130 his_lo->SetLineColor(2);
131 his_lo->SetFillColor(2);
132 his_lo->Draw(
"LF2 same");
134 stringstream lonamefrac;
135 stringstream lonamerate;
136 lonamefrac << 100. * his->Integral(his->GetXaxis()->FindBin(rangestart), his->GetXaxis()->FindBin(threshold)) / his->GetEntries() <<
"% <= " << threshold << unit;
137 lonamerate <<
"<0.5 pe=" << threshold << unit <<
" -> " << his->Integral(his->GetXaxis()->FindBin(rangestart), his->GetXaxis()->FindBin(threshold)) / his->GetEntries() / (1.e-3 * (rangeend - rangestart)) <<
" MHz";
138 cout <<
"\n" << lonamerate.str().c_str() << endl;
139 cout <<
"\n" << lonamefrac.str().c_str() << endl;
140 his_lo->SetTitle(lonamerate.str().c_str());
141 if (!calculate_SiPM_DCR) his_lo->SetTitle(lonamefrac.str().c_str());
143 auto his_hi = (TH1F*)his->Clone();
144 his_hi->GetXaxis()->SetRange(his_hi->GetXaxis()->FindBin(threshold), his_lo->GetXaxis()->FindBin(rangeend));
145 his_hi->SetLineColor(1);
146 his_hi->SetFillColor(1);
147 his_hi->Draw(
"LF2 same");
149 stringstream hinamefrac;
150 stringstream hinamerate;
151 hinamefrac << 100. * his->Integral(his->GetXaxis()->FindBin(threshold) + 1, his->GetXaxis()->FindBin(rangeend)) / his->GetEntries() <<
"% > " << threshold << unit;
152 hinamerate <<
">0.5 pe=" << threshold << unit <<
" -> " << his->Integral(his->GetXaxis()->FindBin(threshold) + 1, his->GetXaxis()->FindBin(rangeend)) / his->GetEntries() / (1.e-3 * (rangeend - rangestart)) <<
" MHz";
153 cout <<
"\n" << hinamerate.str().c_str() << endl;
154 cout <<
"\n" << hinamefrac.str().c_str() << endl;
155 his_hi->SetTitle(hinamerate.str().c_str());
156 if (!calculate_SiPM_DCR) his_hi->SetTitle(hinamefrac.str().c_str());
160 threshold_bin_center = his->GetXaxis()->GetBinCenter(his->GetXaxis()->FindBin(threshold) + 1);
161 cout <<
"\n PMT charge spectrum is counting events above threshold from bin center >= " << threshold_bin_center << unit <<
" for a threshold setting of " << threshold << unit <<
"\n\n";
166 root_out->WriteObject(chargec,
"ChargeSpectraPMTthreshold");
void PrintChargeSpectrumPMTthreshold(float=0, float=0, float=0, float=300, int=750, double=4, bool=false)
Print "charge" spectrum with highlight a threshold.
void PrintChargeSpectrumPMT(float, float, float=0, float=300, float=-50, float=600, int=750)
"Charge" spectrum optimized for PMT signals
TH1F * ChargeSpectrum(int, float, float, float=0, float=300, float=-50, float=600, int=750)
Histogram of the "charge" spectrum for one channel.