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;
24 his =
ChargeSpectrum(i, windowlow, windowhi, start, end, rangestart, rangeend, nbins);
25 if (windowlow + windowhi > 0.) his->GetXaxis()->SetTitle(
"integral in mV#timesns");
26 else his->GetXaxis()->SetTitle(
"amplitude in mV");
27 chargec->cd(current_canvas);
29 his->GetYaxis()->SetTitle(
"#Entries");
30 his->GetXaxis()->SetTitle(
"integral in mV#timesns");
32 stringstream allname; allname << his->GetEntries() <<
" entries";
33 his->SetTitle(allname.str().c_str());
35 TString name(Form(
"ChargeSpectrumPMT channel_%02d",
active_channels[i]));
36 root_out->WriteObject(his, name.Data());
40 auto gauss =
new TF1(
"gauss",
"gaus", rangestart, rangeend);
41 TFitResultPtr fres_est = his->Fit(gauss,
"QRSL");
43 auto two_gauss =
new TF1(
"two gaussians",
"gaus(0)+gaus(3)", rangestart, rangeend); two_gauss->SetTitle(
"Sum of two gauss");
44 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);
45 two_gauss->SetParName(0,
"A_{pedestal}");
46 two_gauss->SetParName(1,
"#mu_{pedestal}");
47 two_gauss->SetParName(2,
"#sigma_{pedestal}"); two_gauss->SetParLimits(2, 1e-9, 1e3);
48 two_gauss->SetParName(3,
"A_{SPE}");
49 two_gauss->SetParName(4,
"#mu_{SPE}");
50 two_gauss->SetParName(5,
"#sigma_{SPE}"); two_gauss->SetParLimits(5, 1e-9, 1e3);
57 TFitResultPtr fresults = his->Fit(two_gauss,
"RSL");
60 two_gauss->Draw(
"same");
62 auto pedestal =
new TF1(
"pedestal",
"gaus", rangestart, rangeend); pedestal->SetTitle(
"pedestal");
63 pedestal->SetParameters(fresults->Parameter(0), fresults->Parameter(1), fresults->Parameter(2));
64 pedestal->SetLineColor(3);
65 pedestal->Draw(
"same");
67 auto pepeak =
new TF1(
"pepeak",
"gaus", rangestart, rangeend); pepeak->SetTitle(
"pepeak");
68 pepeak->SetParameters(fresults->Parameter(3), fresults->Parameter(4), fresults->Parameter(5));
69 pepeak->SetLineColor(4);
77 root_out->WriteObject(chargec,
"ChargeSpectraPMT");
89 PrintChargeSpectrumPMTthreshold_cnt++;
91 gStyle->SetOptStat(0);
96 bool use_fit_result_for_threshold =
false;
97 if (threshold == 999) {
98 calculate_SiPM_DCR =
true;
99 use_fit_result_for_threshold =
true;
103 string title(
"amplitude in mV");
104 if (windowlow + windowhi > 0.) {
105 unit =
" mV#timesns";
106 title =
"integral in mV#timesns";
108 string ctitle(
"charge spectra PMT threshold" + to_string(PrintChargeSpectrumPMTthreshold_cnt));
109 TCanvas* chargec =
new TCanvas(ctitle.c_str(), ctitle.c_str(), 600, 400);
112 int current_canvas = 0;
113 double threshold_bin_center = 0;
118 if (use_fit_result_for_threshold) threshold =
fit_results[current_canvas]->Parameter(6) +
fit_results[current_canvas]->Parameter(5) / 2.;
120 chargec->cd(++current_canvas);
123 his =
ChargeSpectrum(i, windowlow, windowhi, rangestart, rangeend, rangestart, rangeend, nbins);
124 his->GetXaxis()->SetTitle(title.c_str());
125 his->GetYaxis()->SetTitle(
"#Entries");
127 stringstream allname; allname << his->GetEntries() <<
" entries";
128 his->SetTitle(allname.str().c_str());
130 auto his_lo = (TH1F*)his->Clone();
131 his_lo->GetXaxis()->SetRange(his_lo->GetXaxis()->FindBin(rangestart), his_lo->GetXaxis()->FindBin(threshold));
132 his_lo->SetLineColor(2);
133 his_lo->SetFillColor(2);
134 his_lo->Draw(
"LF2 same");
136 stringstream lonamefrac;
137 stringstream lonamerate;
138 lonamefrac << 100. * his->Integral(his->GetXaxis()->FindBin(rangestart), his->GetXaxis()->FindBin(threshold)) / his->GetEntries() <<
"% <= " << threshold << unit;
139 lonamerate <<
"<0.5 pe=" << threshold << unit <<
" -> " << his->Integral(his->GetXaxis()->FindBin(rangestart), his->GetXaxis()->FindBin(threshold)) / his->GetEntries() / (1.e-3 * (rangeend - rangestart)) <<
" MHz";
140 cout <<
"\n" << lonamerate.str().c_str() << endl;
141 cout <<
"\n" << lonamefrac.str().c_str() << endl;
142 his_lo->SetTitle(lonamerate.str().c_str());
143 if (!calculate_SiPM_DCR) his_lo->SetTitle(lonamefrac.str().c_str());
145 auto his_hi = (TH1F*)his->Clone();
146 his_hi->GetXaxis()->SetRange(his_hi->GetXaxis()->FindBin(threshold), his_lo->GetXaxis()->FindBin(rangeend));
147 his_hi->SetLineColor(1);
148 his_hi->SetFillColor(1);
149 his_hi->Draw(
"LF2 same");
151 stringstream hinamefrac;
152 stringstream hinamerate;
153 hinamefrac << 100. * his->Integral(his->GetXaxis()->FindBin(threshold) + 1, his->GetXaxis()->FindBin(rangeend)) / his->GetEntries() <<
"% > " << threshold << unit;
154 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";
155 cout <<
"\n" << hinamerate.str().c_str() << endl;
156 cout <<
"\n" << hinamefrac.str().c_str() << endl;
157 his_hi->SetTitle(hinamerate.str().c_str());
158 if (!calculate_SiPM_DCR) his_hi->SetTitle(hinamefrac.str().c_str());
162 threshold_bin_center = his->GetXaxis()->GetBinCenter(his->GetXaxis()->FindBin(threshold) + 1);
163 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";
168 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.