19 f += (par[1]*(xx-par[0]) + par[2]*pow((xx - par[0]),2));
26 double lineWidth = 2.0;
27 double textSize = 0.07;
29 bool fall2016 =
false;
31 TString figsDir =
"./figs/"; figsDir+=
run; figsDir+=
"/";
33 TH2D* hIntegralRatio_UnsaturatedIntegral =
new TH2D(
"IntegralRatio_UnsaturatedIntegral",
"; Unsaturated Integral (fADC); Saturated/Unsaturated Integral", 750, 0, 120000, 100, 0.5, 1.05);
34 TH2D* hIntegralRatio_SaturatedIntegral =
new TH2D(
"IntegralRatio_SaturatedIntegral",
"; Saturated Integral (fADC); Saturated/Unsaturated Integral", 750, 0, 120000, 100, 0.5, 1.05);
36 TH2D* hIntegralResidual_SaturatedIntegral =
new TH2D(
"IntegralResidual_SaturatedIntegral",
"; Saturated Integral (fADC); Integral Residual", 750, 0, 120000, 100, -0.4, 0.4);
38 TF1 *fknown =
new TF1(
"fKnown",
myfunction,0,160000,3);
41 TH2D* hIntegralRatio_UnsaturatedIntegralFull =
new TH2D(
"IntegralRatio_UnsaturatedIntegralFull",
"; Unsaturated Full Integral (fADC); Saturated/Unsaturated Full Integral", 500, 0, 200000, 100, 0.5, 1.05);
43 TString fileName =
"hd_root_";
44 fileName+=
run; fileName+=
"_saturate.root";
45 TFile *
f = TFile::Open(fileName);
47 TH2I* hbcal_waveform_saturate_2D = (TH2I*)f->Get(Form(
"bcal_saturation/bcal%s_waveform_saturate_layer%d", bcalEnd.Data(),
layer));
48 TH2I* hbcal_waveform_2D = (TH2I*)f->Get(Form(
"bcal_saturation/bcal%s_waveform_noSaturate_layer%d", bcalEnd.Data(),
layer));
53 TCanvas* aa =
new TCanvas(
"aa",
"aa", 600, 400);
54 hbcal_waveform_saturate_2D->Draw(
"colz");
55 hbcal_waveform_saturate_2D->SetMaximum(4096);
56 hbcal_waveform_saturate_2D->GetXaxis()->SetRangeUser(0,400);
57 aa->Print(Form(
"%sSaturate_%s_layer%d.pdf",figsDir.Data(),bcalEnd.Data(),
layer));
59 TCanvas* bb =
new TCanvas(
"bb",
"bb", 600, 400);
60 hbcal_waveform_2D->Draw(
"colz");
62 TCanvas* cc =
new TCanvas(
"cc",
"cc", 600, 400);
63 TH1F* hBase =
new TH1F(
"hBase",
";Samples; fADC", 100, 0, 100);
64 hBase->SetMaximum(6000.);
67 int nbins = hbcal_waveform_2D->GetXaxis()->GetNbins();
68 for(
int i=0; i<nbins; i++) {
70 TH1I* hbcal_waveform = (TH1I*)hbcal_waveform_2D->ProjectionY(Form(
"Event_%d",i),i+1,i+1);
71 if(hbcal_waveform->Integral() < 10)
continue;
73 hbcal_waveform->SetLineColor(kBlack);
74 hbcal_waveform->SetLineWidth(2);
76 int threshCrossBin = 0;
77 for(
int j=0; j<hbcal_waveform->GetXaxis()->GetNbins(); j++) {
78 if(hbcal_waveform->GetBinContent(j) > thresh){
84 TH1I* hbcal_waveform_temp = (TH1I*)hbcal_waveform->Clone();
85 hbcal_waveform_temp->Reset();
89 int sampleOffset = 20;
93 for(
int j=0; j<hbcal_waveform->GetXaxis()->GetNbins(); j++) {
94 double fADC = hbcal_waveform->GetBinContent(j+1);
99 hbcal_waveform_temp->SetBinContent(j+1 - threshCrossBin+sampleOffset, fADC);
100 hbcal_waveform_temp->SetBinError(j+1 - threshCrossBin+sampleOffset, 0.);
104 binMax = j+1 - threshCrossBin;
122 hbcal_waveform_temp->Draw(
"h same");
125 int integralNSA = 26;
132 int integralBinMin = sampleOffset - integralNSB;
133 int integralBinMax = sampleOffset + integralNSA;
137 hbcal_waveform_temp->SetTitle(
"");
138 TH1I *hdemo_scale = (TH1I*)hbcal_waveform_temp->Clone();
140 hdemo_scale->Scale(scale);
141 TH1I *hdemo_saturate = (TH1I*)hdemo_scale->Clone();
142 for(
int j=0; j<hdemo_saturate->GetXaxis()->GetNbins(); j++) {
143 if(j+1 < integralBinMin || j+1 >= integralBinMax)
144 hdemo_saturate->SetBinContent(j+1, 0);
145 if(hdemo_saturate->GetBinContent(j+1) > 4095)
146 hdemo_saturate->SetBinContent(j+1, 4096);
148 hdemo_saturate->SetFillColor(kRed);
150 TCanvas *demo =
new TCanvas(
"demo",
"demo", 800, 400);
153 hbcal_waveform_temp->SetMaximum(6000);
154 hbcal_waveform_temp->Draw();
156 hdemo_scale->SetMaximum(6000);
158 hdemo_saturate->Draw(
"same");
160 demo->Print(Form(
"%sexampleSaturate_%0.1f.pdf", figsDir.Data(), scale));
163 double integral_unscaled = 0;
164 double integral_unscaled_full = 0;
165 double integral_unsaturated = 0;
166 double integral_unsaturated_full = 0;
169 for(
int j=0; j<100; j++) {
170 double scale = 1. + j*0.02;
174 double integral_full = 0;
175 for(
int k=integralBinMin; k<hbcal_waveform_temp->GetXaxis()->GetNbins(); k++) {
176 double fADC = scale * (hbcal_waveform_temp->GetBinContent(k) -
pedestal);
177 double fADC_truncated = fADC > (4095 -
pedestal) ? (4095 - pedestal) : fADC;
180 if(k < integralBinMax)
181 integral += fADC_truncated;
184 integral_full += fADC_truncated;
187 integral_unscaled = integral;
188 integral_unscaled_full = integral_full;
191 integral_unsaturated = integral_unscaled*scale;
192 integral_unsaturated_full = integral_unscaled_full*scale;
196 if(integral_unsaturated < 60000 && integral/integral_unsaturated < 0.9)
199 hIntegralRatio_UnsaturatedIntegral->Fill(integral_unsaturated, integral/integral_unsaturated);
200 hIntegralRatio_SaturatedIntegral->Fill(integral, integral/integral_unsaturated);
201 double integral_residual = (integral/fknown->Eval(integral) - integral_unsaturated)/integral_unsaturated;
202 hIntegralResidual_SaturatedIntegral->Fill(integral, integral_residual);
204 hIntegralRatio_UnsaturatedIntegralFull->Fill(integral_unsaturated_full, integral_full/integral_unsaturated_full);
210 double maxXaxis = 1.2e5;
214 TCanvas* dd =
new TCanvas(
"dd",
"dd", 1000, 400);
217 hIntegralRatio_UnsaturatedIntegral->Draw(
"colz");
220 f1->SetParameters(55000,-4
e-6,0);
221 f1->SetLineColor(kRed);
222 f1->SetParNames(
"offset",
"linear",
"quad");
224 hIntegralRatio_UnsaturatedIntegral->Draw(
"colz");
225 hIntegralRatio_UnsaturatedIntegral->GetXaxis()->SetRangeUser(0., maxXaxis);
228 hIntegralRatio_SaturatedIntegral->Draw(
"colz");
229 hIntegralRatio_SaturatedIntegral->GetXaxis()->SetRangeUser(0., maxXaxis);
232 f2->SetParameters(55000,-4
e-6,0);
234 f2->SetParameters(35000,0,-4
e-6);
238 f2->SetLineColor(kRed);
239 f2->SetParNames(
"offset",
"linear",
"quad");
241 hIntegralRatio_SaturatedIntegral->Fit(f2,
"",
"", 30000, 43000);
243 hIntegralRatio_SaturatedIntegral->Fit(f2,
"",
"", 30000, 150000);
246 par0 = f2->GetParameter(0);
par0err = f2->GetParError(0);
247 par1 = f2->GetParameter(1);
par1err = f2->GetParError(1);
248 par2 = f2->GetParameter(2);
par2err = f2->GetParError(2);
250 hIntegralRatio_SaturatedIntegral->Draw(
"colz");
253 hIntegralResidual_SaturatedIntegral->Draw(
"colz");
254 hIntegralResidual_SaturatedIntegral->GetXaxis()->SetRangeUser(0., maxXaxis);
256 dd->Print(Form(
"%s%s_layer%d.pdf",figsDir.Data(),bcalEnd.Data(),
layer));
265 gSystem->Exec(Form(
"mkdir -p figs/%d",
run));
268 string parFileName = Form(
"./figs/%d/parameters.txt",
run);
270 parameters.open(parFileName);
272 TH1F *h0 =
new TH1F(
"par0",
"Integral Offset Parameter", 8, 0, 8);
273 TH1F *
h1 =
new TH1F(
"par1",
"Linear Parameter", 8, 0, 8);
274 TH1F *
h2 =
new TH1F(
"par2",
"Quadratic Parameter", 8, 0, 8);
276 TString bcalEnd[2] = {
"US",
"DS"};
277 for(
int end=0; end<2; end++) {
293 TCanvas *pars =
new TCanvas(
"pars",
"pars", 1200, 500);
300 h1->SetMinimum(-8
e-6); h1->SetMaximum(-3
e-6);
304 h2->SetMinimum(-1.6
e-10); h2->SetMaximum(-1.0
e-11);
306 TString parFigName =
"./figs/";
307 parFigName+=
run; parFigName+=
"/pars.pdf";
308 pars->Print(parFigName);
static TH1I * pedestal[nChan]