59 std::vector<double>* dedxhit = 0, *doca = 0, *enta = 0;
60 std::vector<int>* layer = 0;
62 ttree->SetBranchAddress(
"dedxhit", &dedxhit);
63 ttree->SetBranchAddress(
"layer", &layer);
64 ttree->SetBranchAddress(
"docaRS", &doca);
65 ttree->SetBranchAddress(
"entaRS", &enta);
71 std::vector<int> globalbinsEnta, globalbinsDoca;
72 for (
int ibin = 0; ibin <
fnEntaBinG; ibin++)globalbinsEnta.push_back(ibin);
73 for (
int ibin = 0; ibin <
fnDocaBinG; ibin++)globalbinsDoca.push_back(ibin);
86 std::vector<std::vector<TH1F*>> hILdEdxhitInEntaDocaBin(
fnEntaBinL, std::vector<TH1F*>(
fnDocaBinL, 0));
87 std::vector<std::vector<TH1F*>> hOLdEdxhitInEntaDocaBin(
fnEntaBinL, std::vector<TH1F*>(
fnDocaBinL, 0));
88 Double_t ifeaLE = 0, ifeaUE = 0, ifdocaLE = 0, ifdocaUE = 0;
96 ifeaUE = ifeaLE +
feaBS;
99 for (
int idoca = 0; idoca <
fnDocaBinL; idoca++) {
104 hILdEdxhitInEntaDocaBin[iea][idoca] =
new TH1F(Form(
"hILdEdxhitInEntaBin%dDocaBin%d", iea, idoca),
"bla-bla", 500, 0., 5.);
105 hILdEdxhitInEntaDocaBin[iea][idoca]->SetTitle(Form(
"IL: EntA = (%0.03f to %0.03f) and Doca = (%0.03f to %0.03f)", ifeaLE,
106 ifeaUE, ifdocaLE, ifdocaUE));
107 hILdEdxhitInEntaDocaBin[iea][idoca]->GetXaxis()->SetTitle(
"dedxhits in Inner Layer");
108 hILdEdxhitInEntaDocaBin[iea][idoca]->GetYaxis()->SetTitle(
"Entries");
110 hOLdEdxhitInEntaDocaBin[iea][idoca] =
new TH1F(Form(
"hOLdEdxhitInEntaBin%dDocaBin%d", iea, idoca),
"bla-bla", 500, 0., 5.);
111 hOLdEdxhitInEntaDocaBin[iea][idoca]->SetTitle(Form(
"OL: EntA = (%0.03f to %0.03f) and Doca = (%0.03f to %0.03f)", ifeaLE,
112 ifeaUE, ifdocaLE, ifdocaUE));
113 hOLdEdxhitInEntaDocaBin[iea][idoca]->GetXaxis()->SetTitle(
"dedxhits in Outer Layer");
114 hOLdEdxhitInEntaDocaBin[iea][idoca]->GetYaxis()->SetTitle(
"Entries");
121 hILDocaEntaG->GetXaxis()->SetTitle(
"Doca");
122 hILDocaEntaG->GetYaxis()->SetTitle(
"Entrance angle (#theta)");
125 hOLDocaEntaG->GetXaxis()->SetTitle(
"Doca");
126 hOLDocaEntaG->GetYaxis()->SetTitle(
"Entrance angle (#theta)");
132 hILDocaEntaL->GetXaxis()->SetTitle(
"Doca");
133 hILDocaEntaL->GetYaxis()->SetTitle(
"Entrance angle (#theta)");
137 hOLDocaEntaL->GetXaxis()->SetTitle(
"Doca");
138 hOLDocaEntaL->GetYaxis()->SetTitle(
"Entrance angle (#theta)");
140 TH1D* hILdEdx_all =
new TH1D(
"hILdEdx_all",
"", 500, 0., 5.);
141 TH1D* hOLdEdx_all =
new TH1D(
"hOLdEdx_all",
"", 500, 0., 5.);
144 Int_t ibinEA = 0, ibinDOCA = 0;
145 for (
int i = 0; i < ttree->GetEntries(); ++i) {
149 for (
unsigned int j = 0; j < dedxhit->size(); ++j) {
151 if (dedxhit->at(j) == 0)
continue;
153 Double_t ieaHit = enta->at(j);
154 if (ieaHit < -TMath::Pi() / 2.0) ieaHit += TMath::Pi() / 2.0;
155 else if (ieaHit > TMath::Pi() / 2.0) ieaHit -= TMath::Pi() / 2.0;
156 if (abs(ieaHit) > TMath::Pi() / 2.0)
continue;
158 Double_t idocaHit = doca->at(j);
159 if (abs(idocaHit) > 1.50)
continue;
170 if (layer->at(j) < 8) {
171 hILDocaEntaG->Fill(idocaHit, ieaHit);
172 if (
IsLocalBin)hILDocaEntaL->Fill(idocaHit, ieaHit);
173 hILdEdx_all->Fill(dedxhit->at(j));
174 hILdEdxhitInEntaDocaBin[ibinEA][ibinDOCA]->Fill(dedxhit->at(j));
176 hOLDocaEntaG->Fill(idocaHit, ieaHit);
177 if (
IsLocalBin)hOLDocaEntaL->Fill(idocaHit, ieaHit);
178 hOLdEdx_all->Fill(dedxhit->at(j));
179 hOLdEdxhitInEntaDocaBin[ibinEA][ibinDOCA]->Fill(dedxhit->at(j));
186 TCanvas* ctmpde =
new TCanvas(
"DocavsEnta",
"Doca vs Enta distributions", 800, 400);
188 ctmpde->SetCanvasSize(800, 800);
189 ctmpde->Divide(2, 2);
190 ctmpde->cd(1); hILDocaEntaG->Draw(
"colz");
191 ctmpde->cd(2); hOLDocaEntaG->Draw(
"colz");
192 ctmpde->cd(3); hILDocaEntaL->Draw(
"colz");
193 ctmpde->cd(4); hOLDocaEntaL->Draw(
"colz");
195 ctmpde->Divide(2, 1);
196 ctmpde->cd(1); hILDocaEntaG->Draw(
"colz");
197 ctmpde->cd(2); hOLDocaEntaG->Draw(
"colz");
199 ctmpde->SaveAs(Form(
"DocavsEnta_%s.pdf",
fSetPrefix.data()));
200 ctmpde->SaveAs(Form(
"DocavsEnta_%s.root",
fSetPrefix.data()));
202 TCanvas* ctem =
new TCanvas(
"Layerhisto",
"Inner and Outer Histo", 600, 600);
203 hOLdEdx_all->Draw(
"histo");
204 hILdEdx_all->SetMarkerColor(kRed);
205 hILdEdx_all->Draw(
"same histo");
206 ctem->SaveAs(Form(
"Layerhistodedxhit_TwoDCorr_%s.pdf",
fSetPrefix.data()));
211 double InsumPer5 = 0.0, InsumPer75 = 0.0;
212 double OutsumPer5 = 0.0, OutsumPer75 = 0.0;
213 double InLayInt = hILdEdx_all->Integral();
214 double OutLayInt = hOLdEdx_all->Integral();
216 Int_t lBinInLayer = 1, hBinInLayer = 1;
217 Int_t lBinOutLayer = 1, hBinOutLayer = 1;
219 for (
int ibin = 1; ibin <= hILdEdx_all->GetNbinsX(); ibin++) {
221 if (InsumPer5 <= 0.05 * InLayInt) {
222 InsumPer5 += hILdEdx_all->GetBinContent(ibin);
226 if (InsumPer75 <= 0.75 * InLayInt) {
227 InsumPer75 += hILdEdx_all->GetBinContent(ibin);
231 if (OutsumPer5 <= 0.05 * OutLayInt) {
232 OutsumPer5 += hOLdEdx_all->GetBinContent(ibin);
236 if (OutsumPer75 <= 0.75 * OutLayInt) {
237 OutsumPer75 += hOLdEdx_all->GetBinContent(ibin);
243 TCanvas* ctmp =
new TCanvas(
"tmp",
"tmp", 1200, 1200);
245 std::stringstream psname; psname << Form(
"dedx_2dcell_%s.pdf[",
fSetPrefix.data());
246 TLine* tl =
new TLine();
247 tl->SetLineColor(kRed);
249 TBox* tb =
new TBox();
252 ctmp->Print(psname.str().c_str());
253 psname.str(
""); psname << Form(
"dedx_2dcell_%s.pdf",
fSetPrefix.data());
256 gStyle->SetOptStat(
"nemriou");
258 std::vector<TH2F> twodcors;
264 std::ofstream file2DILout;
266 for (
int iIOLayer = 0; iIOLayer <= 1; iIOLayer++) {
268 file2DILout.open(Form(
"f2D_Constants_Local_Layer%d_%s.txt", iIOLayer,
fSetPrefix.data()));
270 int startfrom = 1, endat = 1;
272 startfrom = lBinInLayer; endat = hBinInLayer;
274 startfrom = lBinOutLayer; endat = hBinOutLayer;
280 Int_t ieaprime = iea;
283 for (
int idoca = 1; idoca <=
fnDocaBinL; idoca++) {
286 htemp = (TH1D*)hILdEdxhitInEntaDocaBin[ieaprime - 1][idoca - 1]->Clone(Form(
"hL%d_Ea%d_Doca%d", iIOLayer, iea, idoca));
287 else if (iIOLayer == 1)
288 htemp = (TH1D*)hOLdEdxhitInEntaDocaBin[ieaprime - 1][idoca - 1]->Clone(Form(
"hL%d_Ea%d_Doca%d", iIOLayer, iea, idoca));
291 double truncMean = 1.0;
292 if (htemp->GetEntries() < 400) truncMean = 1.0;
294 double binweights = 0.0;
296 for (
int ibin = startfrom; ibin <= endat; ibin++) {
298 if (htemp->GetBinContent(ibin) > 0) {
299 binweights += (htemp->GetBinContent(ibin) * htemp->GetBinCenter(ibin));
300 sumofbc += htemp->GetBinContent(ibin);
303 if (sumofbc > 0)truncMean = (double)(binweights / sumofbc);
304 else truncMean = 1.0;
307 if (truncMean <= 0)truncMean = 1.0;
308 tempTwoD.SetBinContent(idoca, iea, truncMean);
311 ctmp->cd(((idoca - 1) % 16) + 1);
312 htemp->SetTitle(Form(
"%s, mean = %0.4f", htemp->GetTitle(), truncMean));
313 htemp->SetFillColorAlpha(kGreen, 0.30);
314 if (truncMean >= 1.02 || truncMean <= 0.98)htemp->SetFillColor(kYellow);
315 if (truncMean >= 1.05 || truncMean <= 0.95)htemp->SetFillColor(kOrange);
316 if (truncMean >= 1.10 || truncMean <= 0.90)htemp->SetFillColor(kRed);
318 tl->SetLineColor(kRed);
319 tl->SetX1(truncMean); tl->SetX2(truncMean);
320 tl->SetY1(0); tl->SetY2(htemp->GetMaximum());
321 tl->DrawClone(
"same");
323 tb->SetLineColor(kPink);
325 tb->SetFillColorAlpha(kPink, 0.15);
326 tb->SetX1(htemp->GetBinLowEdge(startfrom));
328 tb->SetX2(htemp->GetBinLowEdge(endat));
329 tb->SetY2(htemp->GetMaximum());
330 tb->DrawClone(
"same");
331 if (idoca % 16 == 0)ctmp->Print(psname.str().c_str());
334 file2DILout << iea <<
", \t" << idoca <<
", \t" << truncMean <<
"\n";
343 for (
int idoca = 0; idoca <
fnDocaBinG; idoca++) {
345 twodcor.SetBinContent(idoca + 1, iea + 1, tempTwoD.GetBinContent(ibinDOCA + 1, ibinEA + 1));
349 if (iIOLayer == 0)twodcor.SetTitle(
"InnerLayer: dE/dx in bins of DOCA/Enta");
350 else if (iIOLayer == 1)twodcor.SetTitle(
"OuterLayer: dE/dx in bins of DOCA/Enta");
351 twodcors.push_back(twodcor);
358 psname.str(
""); psname << Form(
"dedx_2dcell_%s.pdf]",
fSetPrefix.data());
359 ctmp->Print(psname.str().c_str());
362 TCanvas* cconst =
new TCanvas(
"FinalConstantHistoMap",
"Inner and Outer Histo", 800, 400);
363 cconst->Divide(2, 1);
364 cconst->cd(1); twodcors.at(0).Draw(
"colz");
365 cconst->cd(2); twodcors.at(1).Draw(
"colz");
366 cconst->SaveAs(Form(
"Final2DConstantMap_wGlobalBin_%s.pdf",
fSetPrefix.data()));
367 cconst->SaveAs(Form(
"Final2DConstantMap_wGlobalBin_%s.root",
fSetPrefix.data()));
371 B2INFO(
"dE/dx calibration done for 2D correction");