46 B2INFO(
"Preparing dE/dx calibration for CDC dE/dx electron saturation");
52 double dedx, costh;
int charge;
53 ttree->SetBranchAddress(
"dedx", &dedx);
54 ttree->SetBranchAddress(
"costh", &costh);
55 ttree->SetBranchAddress(
"charge", &charge);
67 for (
unsigned int i = 0; i <
fCosbins; ++i) {
69 double coslow = i * binW +
fCosMin, coshigh = coslow + binW;
72 hdEdx_elCosbin[i]->SetTitle(Form(
"dE/dx dist (e-) in costh (%0.02f, %0.02f), run start: %d", coslow, coshigh,
fStartRun));
73 hdEdx_elCosbin[i]->GetXaxis()->SetTitle(
"dE/dx (no had sat, for e-)");
74 hdEdx_elCosbin[i]->GetYaxis()->SetTitle(
"Entries");
77 hdEdx_poCosbin[i]->SetTitle(Form(
"dE/dx dist (e+) in costh (%0.02f, %0.02f), run start: %d", coslow, coshigh,
fStartRun));
78 hdEdx_poCosbin[i]->GetXaxis()->SetTitle(
"dE/dx (no had sat, for e+)");
79 hdEdx_poCosbin[i]->GetYaxis()->SetTitle(
"Entries");
82 hdEdx_epCosbin[i]->SetTitle(Form(
"dE/dx dist (e-,e+) in costh (%0.02f, %0.02f), run start: %d", coslow, coshigh,
fStartRun));
83 hdEdx_epCosbin[i]->GetXaxis()->SetTitle(
"dE/dx (no had sat, for e-,e+)");
84 hdEdx_epCosbin[i]->GetYaxis()->SetTitle(
"Entries");
88 TH1D* hCosth_el =
new TH1D(Form(
"hCosth_el_fRun%d",
fStartRun),
90 TH1D* hCosth_po =
new TH1D(Form(
"hCosth_po_fRun%d",
fStartRun), Form(
"cos(#theta) dist (e+), start run: %d; cos(#theta); Entries",
92 TH1D* hCosth_ep =
new TH1D(Form(
"hCosth_ep_fRun%d",
fStartRun),
95 for (
int i = 0; i < ttree->GetEntries(); ++i) {
100 if (dedx <= 0 || charge == 0)
continue;
103 if (costh < TMath::Cos(150 * TMath::DegToRad()) || costh > TMath::Cos(17 * TMath::DegToRad()))
continue;
105 int bin = int((costh -
fCosMin) / binW);
106 if (bin < 0 || bin >=
int(
fCosbins))
continue;
110 hCosth_el->Fill(costh);
111 hdEdx_elCosbin[bin]->Fill(dedx);
112 }
else if (charge > 0) {
113 hCosth_po->Fill(costh);
114 hdEdx_poCosbin[bin]->Fill(dedx);
117 hCosth_ep->Fill(costh);
118 hdEdx_epCosbin[bin]->Fill(dedx);
123 TH1D* hdEdxMeanvsCos_po =
new TH1D(Form(
"hdEdxMeanvsCos_po_fRun%d",
fStartRun),
125 TH1D* hdEdxSigmavsCos_po =
new TH1D(Form(
"hdEdxSigmavsCos_po_fRun%d",
fStartRun),
128 TH1D* hdEdxMeanvsCos_el =
new TH1D(Form(
"hdEdxMeanvsCos_el_fRun%d",
fStartRun),
130 TH1D* hdEdxSigmavsCos_el =
new TH1D(Form(
"hdEdxSigmavsCos_el_fRun%d",
fStartRun),
133 TH1D* hdEdxMeanvsCos_ep =
new TH1D(Form(
"hdEdxMeanvsCos_ep_fRun%d",
fStartRun),
135 TH1D* hdEdxSigmavsCos_ep =
new TH1D(Form(
"hdEdxSigmavsCos_ep_fRun%d",
fStartRun),
139 TCanvas* ctmp_ep =
new TCanvas(
"ctmp_ep",
"ctmp_ep", 800, 400);
142 ctmp_ep->Divide(2, 2);
143 ctmp_ep->SetCanvasSize(800, 800);
145 std::stringstream psname_ep;
149 psname_ep << Form(
"cdcdedx_coscal_fits_frun%d.pdf[",
fStartRun);
150 ctmp_ep->Print(psname_ep.str().c_str());
152 psname_ep << Form(
"cdcdedx_coscal_fits_frun%d.pdf",
fStartRun);
156 std::vector<double> cosine;
157 for (
unsigned int i = 0; i <
fCosbins; ++i) {
160 TLine* tl =
new TLine();
161 tl->SetLineColor(kBlack);
163 double fdEdxMean = 1.0;
164 double fdEdxMeanErr = 0.0;
170 double fdEdxSigma = 0.0, fdEdxSigmaErr = 0.0;
173 if (status !=
"FitOK") {
175 hdEdx_epCosbin[i]->SetTitle(Form(
"%s, Fit(%s)", hdEdx_epCosbin[i]->GetTitle(), status.Data()));
177 fdEdxMean = hdEdx_epCosbin[i]->GetFunction(
"gaus")->GetParameter(1);
178 fdEdxMeanErr = hdEdx_epCosbin[i]->GetFunction(
"gaus")->GetParError(1);
179 fdEdxSigma = hdEdx_epCosbin[i]->GetFunction(
"gaus")->GetParameter(2);
180 fdEdxSigmaErr = hdEdx_epCosbin[i]->GetFunction(
"gaus")->GetParError(2);
181 hdEdx_epCosbin[i]->SetTitle(Form(
"%s, Fit (%s), #mu_{fit}: %0.04f#pm%0.04f,, #sigma_{fit}: %0.04f", hdEdx_epCosbin[i]->GetTitle(),
182 status.Data(), fdEdxMean, fdEdxMeanErr, fdEdxSigma));
185 hdEdxMeanvsCos_ep->SetBinContent(i + 1, fdEdxMean);
186 hdEdxMeanvsCos_ep->SetBinError(i + 1, fdEdxMeanErr);
187 hdEdxSigmavsCos_ep->SetBinContent(i + 1, fdEdxSigma);
188 hdEdxSigmavsCos_ep->SetBinError(i + 1, fdEdxSigmaErr);
191 ctmp_ep->cd(i % 4 + 1);
192 hdEdx_epCosbin[i]->SetFillColorAlpha(kYellow, 0.25);
193 hdEdx_epCosbin[i]->DrawCopy(
"hist");
195 tl->SetX1(fdEdxMean); tl->SetX2(fdEdxMean);
196 tl->SetY1(0); tl->SetY2(hdEdx_epCosbin[i]->GetMaximum());
197 tl->DrawClone(
"same");
198 if ((i + 1) % 4 == 0 || (i + 1 ==
fCosbins))ctmp_ep->Print(psname_ep.str().c_str());
202 double fdEdxMean_el = 1.0, fdEdxMean_elErr = 0.0;
203 double fdEdxSigma_el = 0.0, fdEdxSigma_elErr = 0.0;
204 double fdEdxMean_po = 1.0, fdEdxMean_poErr = 0.0;
205 double fdEdxSigma_po = 0.0, fdEdxSigma_poErr = 0.0;
206 TString status_el =
"", status_po =
"";
210 if (status_el !=
"FitOK") {
212 hdEdx_elCosbin[i]->SetTitle(Form(
"%s, Fit(%s)", hdEdx_elCosbin[i]->GetTitle(), status_el.Data()));
214 fdEdxMean_el = hdEdx_elCosbin[i]->GetFunction(
"gaus")->GetParameter(1);
215 fdEdxMean_elErr = hdEdx_elCosbin[i]->GetFunction(
"gaus")->GetParError(1);
216 fdEdxSigma_el = hdEdx_elCosbin[i]->GetFunction(
"gaus")->GetParameter(2);
217 fdEdxSigma_elErr = hdEdx_elCosbin[i]->GetFunction(
"gaus")->GetParError(2);
218 hdEdx_elCosbin[i]->SetTitle(Form(
"%s, Fit (%s), #mu_{fit}: %0.04f#pm%0.04f,, #sigma_{fit}: %0.04f", hdEdx_elCosbin[i]->GetTitle(),
219 status_el.Data(), fdEdxMean_el, fdEdxMean_elErr, fdEdxSigma_el));
222 hdEdxMeanvsCos_el->SetBinContent(i + 1, fdEdxMean_el);
223 hdEdxMeanvsCos_el->SetBinError(i + 1, fdEdxMean_elErr);
224 hdEdxSigmavsCos_el->SetBinContent(i + 1, fdEdxSigma_el);
225 hdEdxSigmavsCos_el->SetBinError(i + 1, fdEdxSigma_elErr);
229 if (status_po !=
"FitOK") {
231 hdEdx_poCosbin[i]->SetTitle(Form(
"%s, Fit(%s)", hdEdx_poCosbin[i]->GetTitle(), status_po.Data()));
233 fdEdxMean_po = hdEdx_poCosbin[i]->GetFunction(
"gaus")->GetParameter(1);
234 fdEdxMean_poErr = hdEdx_poCosbin[i]->GetFunction(
"gaus")->GetParError(1);
235 fdEdxSigma_po = hdEdx_poCosbin[i]->GetFunction(
"gaus")->GetParameter(2);
236 fdEdxSigma_poErr = hdEdx_poCosbin[i]->GetFunction(
"gaus")->GetParError(2);
237 hdEdx_poCosbin[i]->SetTitle(Form(
"%s, Fit (%s), #mu_{fit}: %0.04f#pm%0.04f,, #sigma_{fit}: %0.04f", hdEdx_poCosbin[i]->GetTitle(),
238 status_po.Data(), fdEdxMean_po, fdEdxMean_poErr, fdEdxSigma_po));
241 if (status_po !=
"FitOK" && status_el ==
"FitOK") {
242 fdEdxMean_po = fdEdxMean_el;
243 hdEdx_poCosbin[i]->SetTitle(Form(
"%s, mean (manual) = elec left", hdEdx_poCosbin[i]->GetTitle()));
244 }
else if (status_el !=
"FitOK" && status_po ==
"FitOK") {
245 fdEdxMean_el = fdEdxMean_po;
246 hdEdx_elCosbin[i]->SetTitle(Form(
"%s, mean (manual) = posi right", hdEdx_elCosbin[i]->GetTitle()));
247 }
else if (status_el !=
"FitOK" && status_po !=
"FitOK") {
248 fdEdxMean_po = 1.0; fdEdxMean_el = 1.0;
251 hdEdxMeanvsCos_po->SetBinContent(i + 1, fdEdxMean_po);
252 hdEdxMeanvsCos_po->SetBinError(i + 1, fdEdxMean_poErr);
253 hdEdxSigmavsCos_po->SetBinContent(i + 1, fdEdxSigma_po);
254 hdEdxSigmavsCos_po->SetBinError(i + 1, fdEdxSigma_poErr);
260 hdEdx_elCosbin[i]->SetFillColorAlpha(kYellow, 0.25);
261 hdEdx_elCosbin[i]->DrawCopy(
"");
262 tl->SetX1(fdEdxMean_el); tl->SetX2(fdEdxMean_el);
263 tl->SetY1(0); tl->SetY2(hdEdx_elCosbin[i]->GetMaximum());
264 tl->DrawClone(
"same");
267 hdEdx_poCosbin[i]->SetFillColorAlpha(kBlue, 0.25);
268 hdEdx_poCosbin[i]->DrawCopy(
"");
269 tl->SetX1(fdEdxMean_po); tl->SetX2(fdEdxMean_po);
270 tl->SetY1(0); tl->SetY2(hdEdx_poCosbin[i]->GetMaximum());
271 tl->DrawClone(
"same");
272 ctmp_ep->Print(psname_ep.str().c_str());
276 fdEdxMean = 0.5 * (fdEdxMean_po + fdEdxMean_el);
277 if (fdEdxMean <= 0)fdEdxMean = 1.0;
278 fdEdxMeanErr = 0.5 * TMath::Sqrt(fdEdxMean_elErr * fdEdxMean_elErr + fdEdxMean_poErr * fdEdxMean_poErr);
279 hdEdxMeanvsCos_ep->SetBinContent(i + 1, fdEdxMean);
280 hdEdxMeanvsCos_ep->SetBinError(i + 1, fdEdxMeanErr);
283 cosine.push_back(fdEdxMean);
291 psname_ep << Form(
"cdcdedx_coscal_fits_frun%d.pdf]",
fStartRun);
292 ctmp_ep->Print(psname_ep.str().c_str());
295 TCanvas* cstats =
new TCanvas(
"cstats",
"cstats", 1000, 500);
296 cstats->SetBatch(kTRUE);
297 cstats->Divide(2, 1);
301 hestats->SetName(Form(
"hestats_fRun%d",
fStartRun));
302 hestats->SetStats(0);
303 hestats->DrawCopy(
"");
308 hestats->SetName(Form(
"htstats_fRun%d",
fStartRun));
309 htstats->DrawCopy(
"");
310 hestats->SetStats(0);
312 cstats->Print(Form(
"cdcdedx_coscal_stats_frun%d.pdf",
fStartRun));
315 TCanvas* ctmp_epConst =
new TCanvas(
"ctmp_epConst",
"ctmp_epConst", 800, 400);
316 ctmp_epConst->Divide(2, 1);
318 TCanvas* ctmp_epCosth =
new TCanvas(
"ctmp_epCosth",
"ctmp_epCosth", 600, 500);
324 hdEdxMeanvsCos_el->SetMarkerStyle(20);
325 hdEdxMeanvsCos_el->SetMarkerSize(0.60);
326 hdEdxMeanvsCos_el->SetMarkerColor(kRed);
327 hdEdxMeanvsCos_el->SetStats(0);
328 hdEdxMeanvsCos_el->SetTitle(
"comparison of dedx #mu_{fit}^{rel}: (e-=red, e+=blue, avg=black)");
329 hdEdxMeanvsCos_el->GetYaxis()->SetRangeUser(0.96, 1.04);
330 hdEdxMeanvsCos_el->DrawCopy(
"");
332 hdEdxMeanvsCos_po->SetMarkerStyle(20);
333 hdEdxMeanvsCos_po->SetMarkerSize(0.60);
334 hdEdxMeanvsCos_po->SetMarkerColor(kBlue);
335 hdEdxMeanvsCos_po->SetStats(0);
336 hdEdxMeanvsCos_po->DrawCopy(
"same");
338 hdEdxMeanvsCos_ep->SetMarkerStyle(20);
339 hdEdxMeanvsCos_ep->SetMarkerSize(0.60);
340 hdEdxMeanvsCos_ep->SetMarkerColor(kBlack);
341 hdEdxMeanvsCos_ep->SetStats(0);
342 hdEdxMeanvsCos_ep->DrawCopy(
"same");
346 hdEdxSigmavsCos_el->SetMarkerStyle(4);
347 hdEdxSigmavsCos_el->SetMarkerColor(kRed);
348 hdEdxSigmavsCos_el->SetMarkerSize(0.90);
349 hdEdxSigmavsCos_el->SetTitle(
"comparison of dedx #mu_{fit}^{rel}: (e-=open, e+=closed)");
350 hdEdxSigmavsCos_el->GetYaxis()->SetRangeUser(0.4, 0.12);
351 hdEdxSigmavsCos_el->SetStats(0);
352 hdEdxSigmavsCos_el->DrawCopy(
"");
354 hdEdxSigmavsCos_po->SetMarkerStyle(8);
355 hdEdxSigmavsCos_po->SetMarkerSize(0.80);
356 hdEdxSigmavsCos_po->SetMarkerColor(kBlue);
357 hdEdxSigmavsCos_po->SetStats(0);
358 hdEdxSigmavsCos_po->DrawCopy(
"same");
361 hCosth_el->SetStats(0);
362 hCosth_el->SetLineColor(kRed);
363 hCosth_el->SetFillColorAlpha(kYellow, 0.55);
364 hCosth_el->DrawCopy(
"");
365 hCosth_po->SetStats(0);
366 hCosth_po->SetLineColor(kBlue);
367 hCosth_po->SetFillColorAlpha(kGray, 0.35);
368 hCosth_po->DrawCopy(
"same");
374 hdEdxMeanvsCos_ep->SetMarkerStyle(20);
375 hdEdxMeanvsCos_ep->SetMarkerSize(0.60);
376 hdEdxMeanvsCos_ep->SetMarkerColor(kBlack);
377 hdEdxMeanvsCos_ep->SetStats(0);
378 hdEdxMeanvsCos_ep->SetTitle(
"dedx rel(#mu_{fit}) for e- and e+ combined");
379 hdEdxMeanvsCos_ep->GetYaxis()->SetRangeUser(0.97, 1.04);
380 hdEdxMeanvsCos_ep->DrawCopy(
"");
384 hdEdxSigmavsCos_ep->SetMarkerStyle(20);
385 hdEdxSigmavsCos_ep->SetMarkerColor(kRed);
386 hdEdxSigmavsCos_ep->SetMarkerSize(1.1);
387 hdEdxSigmavsCos_ep->SetTitle(
"dedx rel(#sigma_{fit}) for e- and e+ combined");
388 hdEdxSigmavsCos_ep->GetYaxis()->SetRangeUser(0.4, 0.12);
389 hdEdxSigmavsCos_ep->SetStats(0);
390 hdEdxSigmavsCos_ep->DrawCopy(
"");
393 hCosth_ep->SetStats(0);
394 hCosth_ep->SetLineColor(kGray);
395 hCosth_ep->SetFillColorAlpha(kGray, 0.25);
396 hCosth_ep->DrawCopy(
"same");
399 ctmp_epCosth->SaveAs(Form(
"cdcdedx_coscal_costhdist_frun%d.pdf",
fStartRun));
402 ctmp_epConst->SaveAs(Form(
"cdcdedx_coscal_relmeans_frun%d.pdf",
fStartRun));
403 ctmp_epConst->SaveAs(Form(
"cdcdedx_coscal_relmeans_frun%d.root",
fStartRun));