CbmRoot
Loading...
Searching...
No Matches
LmvmDraw.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2021 UGiessen, JINR-LIT
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Elena Lebedeva */
4
5#include "LmvmDraw.h"
6
7#include "CbmDrawHist.h"
8#include "CbmHistManager.h"
10#include "utils/CbmUtils.h"
11
12#include "TCanvas.h"
13#include "TClass.h"
14#include "TEllipse.h"
15#include "TF1.h"
16#include "TFile.h"
17#include "TH1.h"
18#include "TH1D.h"
19#include "TH2D.h"
20#include "TKey.h"
21#include "TLine.h"
22#include "TMath.h"
23#include "TPad.h"
24#include "TStyle.h"
25#include "TSystem.h"
26#include "TText.h"
27#include <TLegend.h>
28
29#include <iomanip>
30#include <iostream>
31#include <sstream>
32#include <string>
33
35
36using namespace std;
37using namespace Cbm;
39
40void LmvmDraw::DrawHistFromFile(const string& fileName, const string& outputDir, bool useMvd)
41{
43 fOutputDir = outputDir;
44 fUseMvd = useMvd;
45
47 TFile* oldFile = gFile;
48 TDirectory* oldDir = gDirectory;
49
50 TFile* file = new TFile(fileName.c_str());
51 fH.fHM.ReadFromFile(file);
52 fNofEvents = (int) fH.fHM.H1("hEventNumber")->GetEntries();
53 cout << "File name = " << fileName << endl;
54 cout << "Number of events = " << fNofEvents << endl;
55
56 fH.fHM.ScaleByPattern(".*", 1. / fNofEvents);
58
59 DrawAnaStepMany("pty_pair_signal", [this](ELmvmAnaStep step) { DrawPtY("hPtYPairSignal", step); });
60 for (const auto& cand : fH.fCandNames) {
61 const string& cName = "hPtY_cands/" + cand;
62 const string& hName = "hPtY_cands_" + cand;
63 DrawAnaStepMany(cName, [this, hName](ELmvmAnaStep step) { DrawPtY(hName, step); });
64 }
65 DrawAnaStepMany("pair_rapidity", [this](ELmvmAnaStep step) { DrawRapidity(step); });
66 //DrawAnaStepMany("pair_pty_efficiency", [this](ELmvmAnaStep step) { DrawPtYEfficiency(step); }); // TODO: causes segmentation violation error
67 DrawAnaStepMany("minv_sbg", [this](ELmvmAnaStep step) { DrawMinvSBg(step); });
68 //DrawAnaStepMany("minv_bgPairSrc", [this](ELmvmAnaStep step) { DrawMinvBgPairSrc(step); }); // TODO: causes segmentation violation error
69 //DrawAnaStepMany("minv_matching", [this](ELmvmAnaStep step) { DrawMinvMatching(step); }); // TODO: causes segmentation violation error
70 DrawAnaStepMany("minv_pt", [this](ELmvmAnaStep step) { DrawMinvPt(step); });
71 DrawAnaStepMany("anglePair", [this](ELmvmAnaStep step) { DrawSrcAnaStepH1("hAnglePair", step); });
72
73 // draw momentum histograms
74 for (const string& hName : {"hMom", "hMomPx", "hMomPy", "hMomPz", "hPt", "hRapidity"}) {
75 DrawAnaStepMany(hName, [this, hName](ELmvmAnaStep step) { DrawSrcAnaStepH1(hName, step); });
76 DrawAnaStepMany(hName + "EpEm", [this, hName](ELmvmAnaStep step) { DrawSrcAnaStepEpEmH1(hName, step); });
77 }
79 DrawMisc();
81 DrawCuts();
88 DrawAccRecVsMom(); // TODO: finish this method!
89 DrawPmtXY();
90 DrawMinvBg(); // TODO: do not extra method
94
96 gFile = oldFile;
97 gDirectory = oldDir;
98}
99
101{
102 return (!fUseMvd && (step == ELmvmAnaStep::Mvd1Cut || step == ELmvmAnaStep::Mvd2Cut));
103}
104
106{
107 int nGroup = 20;
108 int nGroupCB = 50; // rebin for CB histos
109 int nGroupMatch = 50;
110 int nGroupBgSrc = 50;
111 fH.Rebin("hMinv", fH.fSrcNames, fH.fAnaStepNames, nGroup);
112 fH.Rebin("hMinvCombPM", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
113 fH.Rebin("hMinvCombPP", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
114 fH.Rebin("hMinvCombMM", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
115 fH.Rebin("hMinvCombPM_pluto", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
116 fH.Rebin("hMinvCombPP_pluto", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
117 fH.Rebin("hMinvCombMM_pluto", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
118 fH.Rebin("hMinvCombPM_urqmd", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
119 fH.Rebin("hMinvCombPP_urqmd", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
120 fH.Rebin("hMinvCombMM_urqmd", {"sameEv", "mixedEv"}, fH.fAnaStepNames, nGroupCB);
121 fH.Rebin("hMinvBgMatch", {"trueMatch", "trueMatchEl", "trueMatchNotEl", "mismatch"}, fH.fAnaStepNames, nGroupMatch);
122 fH.Rebin("hMinvBgSource", fH.fBgPairSrcNames, fH.fAnaStepNames, nGroupBgSrc);
123}
124
126{
127 TH2D* hPos = fH.H2Clone("hBetaMom_cands_plutoEl+");
128 TH2D* hEl = fH.H2Clone("hBetaMom_cands_plutoEl-");
129 TCanvas* c = fH.fHM.CreateCanvas("betaMom/", "betaMom/", 1600, 800);
130 c->Divide(2, 1);
131 c->cd(1);
132 DrawH2(hEl, kLinear, kLinear, kLog, "colz");
133 c->cd(2);
134 DrawH2(hPos, kLinear, kLinear, kLog, "colz");
135}
136
137void LmvmDraw::DrawCutEffH1(const string& hist, const string& option)
138{
139 vector<TH1*> effHist;
140 for (ELmvmSrc src : fH.fSrcs) {
141 TH1D* eff = fH.H1Clone(hist, src);
142 int nBins = eff->GetNbinsX();
143 double integralTotal = fH.H1(hist, src)->Integral(1, nBins, "width");
144
145 if (option == "right") {
146 for (int iB = 1; iB <= nBins; iB++) {
147 eff->SetBinContent(iB, fH.H1(hist, src)->Integral(1, iB, "width") / integralTotal);
148 eff->GetYaxis()->SetTitle("Cut Efficiency");
149 }
150 }
151 else if (option == "left") {
152 for (int iB = nBins; iB >= 1; iB--) {
153 eff->SetBinContent(iB, fH.H1(hist, src)->Integral(iB, nBins, "width") / integralTotal);
154 eff->GetYaxis()->SetTitle("Cut Efficiency");
155 }
156 }
157 effHist.push_back(eff);
158 }
159 DrawH1(effHist, fH.fSrcLatex, kLinear, kLinear, true, 0.8, 0.8, 0.99, 0.99, "hist");
160}
161
162void LmvmDraw::DrawAnaStepMany(const string& cName, function<void(ELmvmAnaStep)> drawFunc)
163{
164 int hi = 1;
165 string newCName = cName + "/" + cName + "_all";
166 TCanvas* c = fH.fHM.CreateCanvas(newCName.c_str(), newCName.c_str(), 1600, 1200);
167 c->Divide(4, 3);
168 for (const auto step : fH.fAnaSteps) {
169 if (SkipMvd(step)) continue;
170 c->cd(hi++);
171 drawFunc(step);
172 }
173
174 for (const auto step : fH.fAnaSteps) {
175 if (SkipMvd(step)) continue;
176 newCName = cName + "/" + cName + "_" + fH.fAnaStepNames[static_cast<int>(step)];
177 fH.fHM.CreateCanvas(newCName.c_str(), newCName.c_str(), 800, 800);
178 drawFunc(step);
179 }
180}
181
182void LmvmDraw::DrawPtY(const string& hist, ELmvmAnaStep step)
183{
184 TH2D* h = fH.H2(hist.c_str(), step);
185 TH2D* hmc = fH.H2(hist.c_str(), ELmvmAnaStep::Mc);
186 DrawH2(h, kLinear, kLinear, kLinear, "COLZ");
187 bool drawAnaStep = true;
188 if (drawAnaStep) fH.DrawEfficiency(h, hmc, 0.2, 1.8);
189 if (drawAnaStep) fH.DrawAnaStepOnPad(step);
190}
191
193{
194 DrawH1(fH.H2("hPtYPairSignal", step)->ProjectionX(), kLinear, kLinear, "hist");
195 fH.DrawAnaStepOnPad(step);
196}
197
199{
200 TH2D* h = fH.H2("hPtYPairSignal", step);
201 TH2D* hmc = fH.H2("hPtYPairSignal", ELmvmAnaStep::Mc);
202 TH2D* eff = Cbm::DivideH2(h, hmc, "", 100., "Efficiency [%]");
203 DrawH2(eff);
204 eff->SetMaximum(10.);
205 bool drawAnaStep = true;
206 if (drawAnaStep) fH.DrawEfficiency(h, hmc, 0.2, 1.8);
207 if (drawAnaStep) fH.DrawAnaStepOnPad(step);
208}
209
211{
212 TH2D* h = fH.H2("hMinvPt", ELmvmSrc::Signal, step);
213 DrawH2(h, kLinear, kLinear, kLinear, "COLZ");
214 fH.DrawAnaStepOnPad(step);
215}
216
217void LmvmDraw::DrawSrcAnaStepH1(const string& hName, ELmvmAnaStep step)
218{
219 DrawSrcH1(hName, step, false);
220 fH.DrawAnaStepOnPad(step);
221}
222
223void LmvmDraw::DrawSrcAnaStepEpEmH1(const string& hName, ELmvmAnaStep step)
224{
225 vector<TH1*> hVec;
226 vector<string> latex;
228 for (const string& pm : {"+", "-"}) {
229 hVec.push_back(fH.H1(hName + pm, src, step));
230 latex.push_back(fH.fSrcLatex[static_cast<int>(src)] + " (e" + pm + ")");
231 }
232 }
233 DrawH1(hVec, latex, kLinear, kLog, true, 0.90, 0.7, 0.99, 0.99, "hist");
234 fH.DrawAnaStepOnPad(step);
235}
236
238{
239 fH.fHM.CreateCanvas("mom_pairSignal", "mom_pairSignal", 800, 800);
240 DrawAnaStepH1("hMomPairSignal", true);
241
242 fH.fHM.CreateCanvas("mother_pdg", "mother_pdg", 800, 800);
243 DrawH1({fH.H1("hMotherPdg_mc"), fH.H1("hMotherPdg_acc")}, {"MC", "acc"}, kLinear, kLog, true, 0.7, 0.7, 0.99, 0.99,
244 "hist");
245
246 fH.fHM.CreateCanvas("momVsAngle_pairSignal", "momVsAngle_pairSignal", 800, 800);
247 DrawH2(fH.H2("hMomVsAnglePairSignalMc"));
248}
249
251{
252 // Draw pair yields // TODO: scale to bin width
253 string cbName = "CombPairsPluto/";
254
255 {
256 TCanvas* c3 =
257 fH.fHM.CreateCanvas((cbName + "pairYields_steps").c_str(), (cbName + "pairYields_steps").c_str(), 1800, 600);
258 c3->Divide(3, 1);
259 c3->cd(1);
260 DrawAnaStepH1("hMinvCombPM_pluto_mixedEv", true);
261 DrawTextOnPad("e^{+}e^{-} pairs ", 0.35, 0.9, 0.65, 0.99);
262 c3->cd(2);
263 DrawAnaStepH1("hMinvCombPP_pluto_mixedEv", true);
264 DrawTextOnPad("e^{+}e^{+} pairs ", 0.35, 0.9, 0.65, 0.99);
265 c3->cd(3);
266 DrawAnaStepH1("hMinvCombMM_pluto_mixedEv", true);
267 DrawTextOnPad("e^{-}e^{-} pairs ", 0.35, 0.9, 0.65, 0.99);
268 }
269
270 {
271 TCanvas* c = fH.fHM.CreateCanvas((cbName + "pairYields").c_str(), (cbName + "pairYields").c_str(), 1800, 1800);
272 c->Divide(3, 3);
273 int i = 1;
274 for (auto step : fH.fAnaSteps) {
275 if (step < ELmvmAnaStep::ElId) continue;
276 c->cd(i++);
277 TH1* pm = fH.H1Clone("hMinvCombPM_pluto_mixedEv", step);
278 TH1* pp = fH.H1Clone("hMinvCombPP_pluto_mixedEv", step);
279 TH1* mm = fH.H1Clone("hMinvCombMM_pluto_mixedEv", step);
280 DrawH1({pm, pp, mm},
281 {"e^{+}e^{-} pairs (mixed ev.)", "e^{+}e^{+} pairs (mixed ev.)", "e^{-}e^{-} pairs (mixed ev.)"}, kLinear,
282 kLog, true, 0.57, 0.79, 0.99, 0.99, "hist");
283 fH.DrawAnaStepOnPad(step);
284 }
285 }
286
287 // Draw ratio of e+e+/e-e- pairs
288 {
289 TCanvas* c = fH.fHM.CreateCanvas((cbName + "ratio_PPMM").c_str(), (cbName + "ratio_PPMM").c_str(), 1800, 1800);
290 c->Divide(3, 3);
291 int i = 1;
292 for (auto step : fH.fAnaSteps) {
293 if (step < ELmvmAnaStep::ElId) continue;
294 c->cd(i++);
295 TH1* rat = fH.H1Clone("hMinvCombPP_pluto_mixedEv", step);
296 rat->Divide(fH.H1("hMinvCombMM_pluto_mixedEv", step));
297 rat->GetYaxis()->SetTitle("Ratio");
298 DrawH1(rat, kLinear, kLinear, "hist");
299 fH.DrawAnaStepOnPad(step);
300 DrawTextOnPad("Ratio e^{+}e^{+} / e^{-}e^{-} ", 0.4, 0.80, 0.89, 0.89);
301 }
302 }
303
304 // Draw geometric mean
305 {
306 TCanvas* c = fH.fHM.CreateCanvas((cbName + "geomMean").c_str(), (cbName + "geomMean").c_str(), 1800, 1800);
307 c->Divide(3, 3);
308 int i = 1;
309 for (auto step : fH.fAnaSteps) {
310 if (step < ELmvmAnaStep::ElId) continue;
311 c->cd(i++);
312 TH1* gm = fH.H1Clone("hMinvCombPP_pluto_mixedEv", step);
313 for (int iB = 1; iB <= gm->GetNbinsX(); iB++) {
314 double pp = fH.H1("hMinvCombPP_pluto_mixedEv", step)->GetBinContent(iB);
315 double mm = fH.H1("hMinvCombMM_pluto_mixedEv", step)->GetBinContent(iB);
316 double con = std::sqrt(pp * mm);
317 gm->SetBinContent(iB, con);
318 }
319 DrawH1(gm, kLinear, kLog, "hist");
320 fH.DrawAnaStepOnPad(step);
321 }
322 }
323
324 // draw k Factor
325 {
326 TCanvas* c = fH.fHM.CreateCanvas((cbName + "kFactor").c_str(), (cbName + "kFactor").c_str(), 1800, 1800);
327 c->Divide(3, 3);
328 int i = 1;
329 for (auto step : fH.fAnaSteps) {
330 if (step < ELmvmAnaStep::ElId) continue;
331 c->cd(i++);
332 TH1* k = fH.H1Clone("hMinvCombPM_pluto_mixedEv", step);
333 TH1* gm = fH.H1Clone("hMinvCombPP_pluto_mixedEv", step);
334 for (int iB = 1; iB <= k->GetNbinsX(); iB++) {
335 double con = std::sqrt(fH.H1("hMinvCombPP_pluto_mixedEv", step)->GetBinContent(iB)
336 * fH.H1("hMinvCombMM_pluto_mixedEv", step)->GetBinContent(iB));
337 gm->SetBinContent(iB, con);
338 }
339 k->Divide(gm);
340 k->Scale(0.5);
341 k->GetYaxis()->SetTitle("k Factor");
342 DrawH1(k, kLinear, kLinear, "p");
343 fH.DrawAnaStepOnPad(step);
344 }
345 }
346}
347
349{
350 TCanvas* c = fH.fHM.CreateCanvas("pmtXY", "pmtXY", 1800, 600);
351 c->Divide(3, 1);
352 vector<ELmvmSrc> src {ELmvmSrc::Signal, ELmvmSrc::Pi0, ELmvmSrc::Gamma};
353 for (size_t i = 0; i < src.size(); i++) {
354 c->cd(i + 1);
355 DrawH2(fH.H2("hPmtXY", src[i]));
356 gPad->SetLogz(true);
357 DrawTextOnPad(fH.fSrcLatex[static_cast<int>(src[i])], 0.40, 0.9, 0.60, 0.99);
358 }
359}
360
361void LmvmDraw::DrawSrcH1(const string& hName, ELmvmAnaStep step, bool doScale)
362{
363 vector<TH1*> hVec;
364 for (const ELmvmSrc src : fH.fSrcs) {
365 TH1D* h = (step == ELmvmAnaStep::Undefined) ? fH.H1(hName, src) : fH.H1(hName, src, step);
366 h->SetLineWidth(2);
367 h->SetLineColor(fH.fSrcColors[static_cast<int>(src)]);
368 if (doScale) h->Scale(1. / h->Integral());
369 hVec.push_back(h);
370 }
371 DrawH1(hVec, fH.fSrcLatex, kLinear, kLog, true, 0.90, 0.7, 0.99, 0.99, "hist");
372}
373
374void LmvmDraw::Draw1DCut(const string& hist, const string& sigOption, double cut)
375{
376 int w = 2400;
377 int h = 800;
378 TCanvas* c = fH.fHM.CreateCanvas(("cuts/" + hist).c_str(), ("cuts/" + hist).c_str(), w, h);
379 c->Divide(3, 1);
380
381 c->cd(1);
382 DrawSrcH1(hist);
383 if (cut != -999999.) {
384 TLine* cutLine = new TLine(cut, 0.0, cut, 1.0);
385 cutLine->SetLineWidth(2);
386 cutLine->Draw();
387 }
388
389 c->cd(2);
390 DrawCutEffH1(hist, sigOption);
391
392 c->cd(3);
393 TH1D* sign = fH.CreateSignificanceH1(fH.H1(hist, ELmvmSrc::Signal), fH.H1(hist, ELmvmSrc::Bg), hist + "_significance",
394 sigOption);
395 DrawH1(sign, kLinear, kLinear, "hist");
396}
397
399{
400 Draw1DCut("hAnnRich", "left", -0.4); // CbmLitGlobalElectronId::GetInstance().GetRichAnnCut()
401 //Draw1DCut("hAnnTrd", "left", 0.1); // CbmLitGlobalElectronId::GetInstance().GetTrdAnnCut() // TODO: uncomment when Trd Ann works again
402 Draw2DCut("hTrdLike_El");
403 Draw2DCut("hTrdLike_Pi");
404 Draw2DCut("hAnnRichVsMom");
405 Draw2DCut("hTofM2");
406
407 Draw1DCut("hChi2PrimVertex", "right", fCuts.fChi2PrimCut);
408 //Draw1DCut("hPt", "left", fCuts.fPtCut);
409 //Draw1DCut("hMom", "left");
410 Draw1DCut("hChi2Sts", "right");
411
412 for (const string& type : {"all", "pion", "truePair"}) {
413 Draw2DCut("hStCut_" + type, fCuts.fStCutPP, fCuts.fStCutAngle);
414 Draw2DCut("hTtCut_" + type, fCuts.fTtCutPP, fCuts.fTtCutAngle);
415 Draw2DCut("hRtCut_" + type, fCuts.fRtCutPP, fCuts.fRtCutAngle);
416 }
417
418 if (fUseMvd) {
419 Draw2DCut("hMvdCut_1", fCuts.fMvd1CutD, fCuts.fMvd1CutP);
420 Draw2DCut("hMvdCut_2", fCuts.fMvd2CutD, fCuts.fMvd2CutP);
421 }
422}
423
424
425void LmvmDraw::DrawBgSourcePairs(ELmvmAnaStep step, bool inPercent, bool drawAnaStep)
426{
427 TH2D* h = fH.H2Clone("hSrcBgPairsEpEm", step);
428 gStyle->SetPaintTextFormat("4.1f");
429 string labels[4] = {"#gamma", "#pi^{0}", "#pi^{#pm}", "oth"};
430 for (int i = 1; i <= 4; i++) {
431 h->GetYaxis()->SetBinLabel(i, labels[i - 1].c_str());
432 h->GetXaxis()->SetBinLabel(i, labels[i - 1].c_str());
433 }
434 h->SetMarkerSize(2.5);
435 if (inPercent) {
436 h->Scale(100. / h->Integral());
437 h->GetZaxis()->SetTitle("[%]");
438 }
439 else {
440 h->Scale(1000.);
441 h->GetZaxis()->SetTitle("Number of pairs/event x10^{3}");
442 }
443 DrawH2(h, kLinear, kLinear, kLinear, "text COLZ");
444 h->GetXaxis()->SetLabelSize(0.1);
445 h->GetYaxis()->SetLabelSize(0.1);
446 if (drawAnaStep) fH.DrawAnaStepOnPad(step);
447}
448
450{
451 int hi = 1;
452 TCanvas* c1 = fH.fHM.CreateCanvas("bg/srcPairs_abs", "bg/srcPairs_abs", 1500, 1500);
453 c1->Divide(3, 3);
454 for (ELmvmAnaStep step : fH.fAnaSteps) {
455 if (step == ELmvmAnaStep::Mc || step == ELmvmAnaStep::Acc || SkipMvd(step)) continue;
456 c1->cd(hi++);
457 DrawBgSourcePairs(step, false);
458 }
459
460 hi = 1;
461 TCanvas* c2 = fH.fHM.CreateCanvas("bg/srcPairs_perc", "bg/srcPairs_perc", 1500, 1500);
462 c2->Divide(3, 3);
463 for (ELmvmAnaStep step : fH.fAnaSteps) {
464 if (step == ELmvmAnaStep::Mc || step == ELmvmAnaStep::Acc || SkipMvd(step)) continue;
465 c2->cd(hi++);
466 DrawBgSourcePairs(step, true);
467 }
468
469 string elidCutName = fH.fAnaStepNames[static_cast<int>(ELmvmAnaStep::ElId)];
470 fH.fHM.CreateCanvas("bg/srcPairs_abs_" + elidCutName, "bg/srcPairs_abs_" + elidCutName, 1100, 800);
472
473 fH.fHM.CreateCanvas("bg/srcPairs_perc_" + elidCutName, "bg/srcPairs_perc_" + elidCutName, 1100, 800);
475
476 DrawSource2D("bg/srcPairs_2d", "hSrcBgPairs", fH.fBgPairSrcLatex, 1000., "Pairs per event x10^{3}");
477}
478
479void LmvmDraw::Draw2DCutTriangle(double xCr, double yCr)
480{
481 if (xCr == -999999. || yCr == -999999.) return;
482 vector<TLine*> lines {new TLine(0., 0., xCr, 0.), new TLine(0., 0., 0., yCr), new TLine(xCr, 0., 0., yCr)};
483 for (size_t i = 0; i < lines.size(); i++) {
484 lines[i]->SetLineWidth(2.);
485 lines[i]->Draw();
486 }
487}
488
490{
491 TH1D* gg = fH.H1Clone("hMinvBgSource2_elid_gg");
492 TH1D* pipi = fH.H1Clone("hMinvBgSource2_elid_pipi");
493 TH1D* pi0pi0 = fH.H1Clone("hMinvBgSource2_elid_pi0pi0");
494 TH1D* oo = fH.H1Clone("hMinvBgSource2_elid_oo");
495 TH1D* gpi = fH.H1Clone("hMinvBgSource2_elid_gpi");
496 TH1D* gpi0 = fH.H1Clone("hMinvBgSource2_elid_gpi0");
497 TH1D* go = fH.H1Clone("hMinvBgSource2_elid_go");
498 TH1D* pipi0 = fH.H1Clone("hMinvBgSource2_elid_pipi0");
499 TH1D* pio = fH.H1Clone("hMinvBgSource2_elid_pio");
500 TH1D* pi0o = fH.H1Clone("hMinvBgSource2_elid_pi0o");
501
502 cout << "Entries gg: " << gg->GetEntries() << endl;
503 cout << "Entries pipi: " << pipi->GetEntries() << endl;
504 cout << "Entries pi0pi0: " << pi0pi0->GetEntries() << endl;
505 cout << "Entries oo: " << oo->GetEntries() << endl;
506 cout << "Entries gpi: " << gpi->GetEntries() << endl;
507 cout << "Entries gpi0: " << gpi0->GetEntries() << endl;
508 cout << "Entries go: " << go->GetEntries() << endl;
509 cout << "Entries pipi0: " << pipi0->GetEntries() << endl;
510 cout << "Entries pio: " << pio->GetEntries() << endl;
511 cout << "Entries pi0o: " << pi0o->GetEntries() << endl;
512
513 int reb = 50;
514
515 gg->Rebin(reb);
516 pi0pi0->Rebin(reb);
517 gpi0->Rebin(reb);
518 go->Rebin(reb);
519 pi0o->Rebin(reb);
520
521 gg->Scale(1. / reb);
522 pi0pi0->Scale(1. / reb);
523 gpi0->Scale(1. / reb);
524 go->Scale(1. / reb);
525 pi0o->Scale(1. / reb);
526
527 string cName = "minvBgSrc/minvBgSrc";
528 //vector<string> names = {"#gamma-#gamma", "#pi^{#pm}-#pi^{#pm}", "#pi^{0}-#pi^{0}", "o.-o.", "#gamma-#pi^{#pm}", "#gamma-#pi^{0}", "#gamma-o.", "#pi^{#pm}-#pi^{0}", "#pi^{#pm}-o.", "#pi^{0}-o.", "misid. #pi^{#pm}"};
529 vector<string> names = {"#gamma-#gamma", "#pi^{0}-#pi^{0}", "#gamma-#pi^{0}", "#gamma-o.", "#pi^{0}-o."};
530 fH.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1000, 1000);
531 //DrawH1({gg, pipi, pi0pi0, oo, gpi, gpi0, go, pipi0, pio, pi0o}, names, kLinear, kLog, true, 0.85, 0.7, 0.99, 0.99, "hist");
532 DrawH1({gg, pi0pi0, gpi0, go, pi0o}, names, kLinear, kLog, true, 0.85, 0.7, 0.99, 0.99, "hist");
533}
534
536{
537 // All occuring PIDs
538 for (ELmvmAnaStep step : fH.fAnaSteps) {
539 if (step == ELmvmAnaStep::Mc || step == ELmvmAnaStep::Acc) continue;
540 TCanvas* c = fH.fHM.CreateCanvas("purity/pid_" + fH.fAnaStepNames[static_cast<int>(step)],
541 "purity/pid_" + fH.fAnaStepNames[static_cast<int>(step)], 1600, 800);
542 c->Divide(2, 1);
543 c->cd(1);
544 DrawH1(fH.H1("hCandPdg_" + fH.fAnaStepNames[static_cast<int>(step)]), kLinear, kLog, "hist text40");
545 c->cd(2);
546 TH1D* pdgZoom = fH.H1Clone("hCandPdg_" + fH.fAnaStepNames[static_cast<int>(step)]);
547 pdgZoom->GetXaxis()->SetRangeUser(-20., 20.);
548 DrawH1(pdgZoom, kLinear, kLog, "hist text40");
549 }
550
551 // PID vs momentum
552 vector<string> yLabel = {"e^{#pm}_{PLUTO}", "e^{#pm}_{UrQMD}", "#pi^{#pm}", "p", "K^{+}", "o."};
553 for (ELmvmAnaStep step : fH.fAnaSteps) {
554 if (step == ELmvmAnaStep::Mc || step == ELmvmAnaStep::Acc) continue;
555 fH.fHM.CreateCanvas("purity/PidVsMom_" + fH.fAnaStepNames[static_cast<int>(step)],
556 "purity/PidVsMom_" + fH.fAnaStepNames[static_cast<int>(step)], 800, 600);
557 TH2D* hPidMom = fH.H2("hCandPdgVsMom_" + fH.fAnaStepNames[static_cast<int>(step)]);
558 hPidMom->SetMinimum(5e-7);
559 DrawH2(hPidMom, kLinear, kLinear, kLog, "COLZ");
560 for (size_t y = 1; y <= yLabel.size(); y++) {
561 hPidMom->GetYaxis()->SetBinLabel(y, yLabel[y - 1].c_str());
562 }
563 double nEl = hPidMom->Integral(1, hPidMom->GetXaxis()->GetNbins(), 2, 2); // do not count PLUTO particles
564 double purity =
565 (nEl / hPidMom->Integral(1, hPidMom->GetXaxis()->GetNbins(), 2, hPidMom->GetYaxis()->GetNbins())) * 100;
566 DrawTextOnPad("Purity: " + Cbm::NumberToString(purity, 1) + " %", 0.1, 0.9, 0.45, 0.99);
567 }
568
569 // Purity vs momentum
570 int nBins = fH.H2("hCandPdgVsMom_elid")->GetXaxis()->GetNbins();
571 double xMin = fH.H2("hCandPdgVsMom_elid")->GetXaxis()->GetXmin();
572 double xMax = fH.H2("hCandPdgVsMom_elid")->GetXaxis()->GetXmax();
573 TH1D* purity = new TH1D("purity_Mom", "purity_Mom; P [GeV/c]; Purity [%]", nBins, xMin, xMax);
574 for (int i = 1; i <= purity->GetNbinsX(); i++) {
575 double nEl = fH.H2("hCandPdgVsMom", ELmvmAnaStep::ElId)->GetBinContent(i, 2);
576 double nAll = fH.H2("hCandPdgVsMom", ELmvmAnaStep::ElId)
577 ->Integral(i, i, 2, fH.H2("hCandPdgVsMom_elid")->GetYaxis()->GetNbins());
578 double val = (nAll != 0) ? 100 * nEl / nAll : 0.;
579 purity->SetBinContent(i, val);
580 }
581 purity->Rebin(5);
582 purity->Scale(1. / 5.);
583 fH.fHM.CreateCanvas("purity/purity_mom_elid", "purity/purity_mom_elid", 800, 800);
584 DrawH1(purity, kLinear, kLinear, "pe");
585
586 // Source of electron (PDG = +-11) candidates
587 DrawSource2D("purity/SrcTracksEl_2d", "hCandElSrc",
588 {"#gamma", "#pi^{0}", "#pi^{#pm}", "p", "K", "e^{#pm}_{sec}", "oth.", "signal"}, 1000.,
589 "Tracks per event x10^{3}");
590
591 // Occurency of Electrons and not-Electrons for various cut categories
592 for (const string& hName : {"hAnnRichVsMomPur", "hTrdElLikePur"}) {
593 string cName = "purity/cuts_" + hName;
594 TCanvas* c = fH.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 2400, 800);
595 c->Divide(3, 1);
596 int hi = 1;
597 for (const string& id : {"El", "Bg"}) {
598 TH2D* hist = fH.H2Clone(hName + "_" + id);
599 c->cd(hi);
600 DrawH2(hist, kLinear, kLinear, kLog, "COLZ");
601 DrawTextOnPad(id.c_str(), 0.6, 0.89, 0.7, 0.99);
602 hi++;
603 }
604 c->cd(hi);
605 TH2D* ratio = fH.H2Clone(hName + "_El");
606 ratio->Divide(fH.H2(hName + "_Bg"));
607 DrawH2(ratio, kLinear, kLinear, kLog, "COLZ");
608 DrawTextOnPad("Ratio El/Bg", 0.4, 0.85, 0.8, 0.99);
609 }
610}
611
612void LmvmDraw::Draw2DCut(const string& hist, double cutCrossX, double cutCrossY)
613{
614 TCanvas* c = fH.fHM.CreateCanvas(("cuts/" + hist).c_str(), ("cuts/" + hist).c_str(), 1000, 1500);
615 c->Divide(2, 3);
616 vector<TH1*> projX, projY;
617 projX.clear(); // TODO: clearing needed?
618 projY.clear();
619 vector<string> latex;
621 int srcInt = static_cast<int>(src);
622 c->cd(srcInt + 1);
623 DrawH2(fH.H2(hist, src));
624 double nofPerEvent = fH.H2(hist, src)->GetEntries() / (double) fNofEvents;
625 DrawTextOnPad((Cbm::NumberToString(nofPerEvent, 2) + "/ev."), 0.1, 0.9, 0.5, 0.99);
626 DrawTextOnPad(fH.fSrcLatex[srcInt], 0.6, 0.89, 0.7, 0.99);
627 Draw2DCutTriangle(cutCrossX, cutCrossY);
628 projX.push_back(fH.H2(hist, src)->ProjectionX((hist + fH.fSrcLatex[static_cast<int>(src)]).c_str(), 1,
629 fH.H2(hist, src)->GetYaxis()->GetNbins(), ""));
630 projY.push_back(fH.H2(hist, src)->ProjectionY());
631 latex.push_back(fH.fSrcLatex[srcInt]);
632 }
633
634 c->cd(5);
635 DrawH1(projX, latex, kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99, "hist");
636
637 c->cd(6);
638 DrawH1(projY, latex, kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99, "hist");
639}
640
642{
643 vector<TH2D*> xyz {fH.H2("hVertexGammaXZ", ELmvmAnaStep::Mc), fH.H2("hVertexGammaYZ", ELmvmAnaStep::Mc),
644 fH.H2("hVertexGammaXY", ELmvmAnaStep::Mc)};
645
646 TCanvas* c = fH.fHM.CreateCanvas("vertexGamma_mc", "vertexGamma_mc", 1800, 600);
647 c->Divide(3, 1);
648 for (size_t i = 0; i < xyz.size(); i++) {
649 c->cd(i + 1);
650 DrawH2(xyz[i]);
651 xyz[i]->SetMinimum(1e-3);
652 gPad->SetLogz(true);
653 }
654
655 TCanvas* cZ = fH.fHM.CreateCanvas("vertexGamma_z", "vertexGamma_z", 1500, 750);
656 cZ->Divide(2, 1);
657 int counter = 1;
659 cZ->cd(counter++);
660 string name = fH.GetName("hVertexGammaXZ", step);
661 TH1D* zProj = (TH1D*) fH.H2(name)->ProjectionX((name + "pz").c_str())->Clone();
662 zProj->GetYaxis()->SetTitle("Counter per event");
663 zProj->GetXaxis()->SetRangeUser(-2., 17.);
664 DrawH1(zProj, kLinear, kLinear, "hist");
665 fH.DrawAnaStepOnPad(step);
666 }
667
668 TCanvas* cZoom = fH.fHM.CreateCanvas("vertexGamma_mc_zoom", "vertexGamma_mc_zoom", 1800, 600);
669 cZoom->Divide(3, 1);
670 for (size_t i = 0; i < xyz.size(); i++) {
671 TH2D* hZoom = (TH2D*) xyz[i]->Clone();
672 cZoom->cd(i + 1);
673 hZoom->GetXaxis()->SetRangeUser(-1., 11.);
674 hZoom->GetYaxis()->SetRangeUser(-10., 10.);
675 DrawH2(hZoom);
676 hZoom->SetMinimum(1e-3);
677 gPad->SetLogz(true);
678 }
679
680 fH.fHM.CreateCanvas("vertexGamma_rz_mc", "vertexGamma_rz_mc", 900, 900);
681 DrawH2(fH.H2("hVertexGammaRZ", ELmvmAnaStep::Mc));
682 fH.H2("hVertexGammaRZ", ELmvmAnaStep::Mc)->SetMinimum(1e-3);
683 gPad->SetLogz(true);
684}
685
686void LmvmDraw::DrawAnaStepH1(const string& name, bool logy)
687{
688 double min = std::numeric_limits<Double_t>::max();
689 double max = std::numeric_limits<Double_t>::min();
690 TH1D* h0 = nullptr;
691 TLegend* leg = new TLegend(0.80, 0.32, 0.99, 0.99);
692 for (const auto step : fH.fAnaSteps) {
693 if (SkipMvd(step)) continue;
694 TH1D* h = fH.H1(name, step);
695 LOG(info) << name << " " << h->GetEntries();
696 if (h == nullptr || h->GetEntries() <= 0) continue;
697 leg->AddEntry(h, fH.fAnaStepLatex[static_cast<int>(step)].c_str(), "l");
698 DrawH1(h, kLinear, kLinear, (h0 == nullptr) ? "hist" : "hist,same", fH.fAnaStepColors[static_cast<int>(step)]);
699 if (h0 == nullptr) h0 = h;
700 min = std::min(h->GetMinimum(), min);
701 max = std::max(h->GetMaximum(), max);
702 LOG(info) << name << " min:" << h->GetMinimum() << " max:" << h->GetMaximum();
703 }
704 if (min == 0.) min = std::min(1e-8, max * 1e-6);
705 if (h0 != nullptr) h0->SetMinimum(min);
706 if (h0 != nullptr) h0->SetMaximum(1.1 * max);
707
708 leg->SetFillColor(kWhite);
709 leg->Draw();
710
711 gPad->SetGridx(true);
712 gPad->SetGridy(true);
713 gPad->SetLogy(logy);
714}
715
717{
718 TCanvas* c1 = fH.fHM.CreateCanvas("minv_sbg_anaStep", "minv_sbg_anaStep", 1200, 600);
719 c1->Divide(2, 1);
720 c1->cd(1);
721 DrawAnaStepH1(fH.GetName("hMinv", ELmvmSrc::Signal), true);
722 c1->cd(2);
723 DrawAnaStepH1(fH.GetName("hMinv", ELmvmSrc::Bg), true);
724
725 TCanvas* c2 = fH.fHM.CreateCanvas("minv_pi0_eta_gamma_anaStep", "minv_pi0_eta_gamma_anaStep", 1800, 600);
726 c2->Divide(3, 1);
727 c2->cd(1);
728 DrawAnaStepH1(fH.GetName("hMinv", ELmvmSrc::Pi0), true);
729 c2->cd(2);
730 DrawAnaStepH1(fH.GetName("hMinv", ELmvmSrc::Eta), true);
731 c2->cd(3);
732 DrawAnaStepH1(fH.GetName("hMinv", ELmvmSrc::Gamma), true);
733}
734
736{
737 TH1D* s = fH.H1Clone("hMinv", ELmvmSrc::Signal, step);
738 TH1D* bg = fH.H1Clone("hMinv", ELmvmSrc::Bg, step);
739 TH1D* sbg = static_cast<TH1D*>(bg->Clone());
740 sbg->Add(s);
741 sbg->SetMinimum(1e-8);
742
743 DrawH1({sbg, bg, s}, {"", "", ""}, kLinear, kLog, false, 0, 0, 0, 0, "Hist L");
744 s->SetFillColor(kRed);
745 s->SetLineColor(kBlack);
746 s->SetLineWidth(1);
747 s->SetLineStyle(CbmDrawingOptions::MarkerStyle(1));
748 bg->SetFillColor(kYellow - 10);
749 bg->SetLineColor(kBlack);
750 bg->SetLineWidth(2);
751 bg->SetLineStyle(CbmDrawingOptions::MarkerStyle(1));
752 sbg->SetFillColor(kBlue);
753 sbg->SetLineColor(kBlack);
754 sbg->SetLineWidth(1);
755 sbg->SetLineStyle(CbmDrawingOptions::MarkerStyle(1));
756 s->SetMarkerStyle(1);
757 bg->SetMarkerStyle(1);
758 sbg->SetMarkerStyle(1);
759
760 fH.DrawAnaStepOnPad(step);
761}
762
764{
765 double nofBg = fH.H1("hMinv", ELmvmSrc::Bg, step)->GetEntries();
766 vector<TH1*> hists;
767 vector<string> latex;
768 for (int i = 0; i < fH.fNofBgPairSrc; i++) {
769 hists.push_back(
770 fH.H1("hMinvBgSource_" + fH.fBgPairSrcNames[i] + "_"
771 + fH.fAnaStepNames[static_cast<int>(
772 step)])); // segmentation violation error is caused by this specific histogram; works with others
773 string perc = Cbm::NumberToString(100. * hists[i]->GetEntries() / nofBg, 1);
774 latex.push_back(fH.fBgPairSrcLatex[i] + "(" + perc + "%)");
775 }
776 DrawH1(hists, latex, kLinear, kLinear, true, 0.7, 0.45, 0.99, 0.9, "hist");
777 bool drawAnaStep = true;
778 if (drawAnaStep) fH.DrawAnaStepOnPad(step);
779}
780
782{
783 double nofBg = fH.H1("hMinv", ELmvmSrc::Bg, step)->GetEntries();
784 vector<TH1*> hists;
785 vector<string> latex {"true match", "true match (e^{#pm})", "true match (not e^{#pm})", "mismatch "};
786 int i = 0;
787 for (const string& subName : {"trueMatch", "trueMatchEl", "trueMatchNotEl", "mismatch"}) {
788 TH1D* h = fH.H1("hMinvBgMatch_" + subName, step);
789 latex[i] = latex[i] + " (" + Cbm::NumberToString(100. * h->GetEntries() / nofBg, 1) + "%)";
790 hists.push_back(h);
791 i++;
792 }
793 DrawH1(hists, latex, kLinear, kLinear, true, 0.4, 0.6, 0.99, 0.9, "hist");
794 fH.DrawAnaStepOnPad(step);
795}
796
798{
799 // Acceptance and reconstruction yields cs. momentum for various detector combinations
800 for (const int& pdg : {11, 211, 2212, 321}) {
801 vector<string> subNames {"mc", "acc", "recSts", "recStsRich", "recStsRichTrd", "recStsRichTrdTof"};
802 vector<string> latex {
803 "MC", "Acc", "Rec in STS", "Rec in STS-RICH", "Rec in STS-RICH-TRD", "Rec in STS-RICH-TRD-TOF"};
804 vector<string> latexAll(latex.size()), latexPrim(latex.size());
805 string ptcl = (pdg == 11) ? "hEl" : (pdg == 211) ? "hPi" : (pdg == 2212) ? "hProton" : "hKaon";
806
807 vector<TH1*> histsAll, histsPrim;
808 int i = 0;
809
810 for (const string& subName : subNames) {
811 TH1D* hAll = fH.H1(ptcl + "Mom_all_" + subName);
812 hAll->SetMinimum(3e-6);
813 hAll->SetMaximum(50);
814 latexAll[i] = latex[i] + " (" + Cbm::NumberToString(hAll->GetEntries() / fNofEvents, 2) + "/ev.)";
815 histsAll.push_back(hAll);
816
817 TH1D* hPrim = fH.H1(ptcl + "Mom_prim_" + subName);
818 hPrim->SetMinimum(3e-6);
819 hPrim->SetMaximum(50);
820 latexPrim[i] = latex[i] + " (" + Cbm::NumberToString(hPrim->GetEntries() / fNofEvents, 2) + "/ev.)";
821 histsPrim.push_back(hPrim);
822 i++;
823 }
824
825 //if (pdg == 321) continue; TODO: with kaons?
826 double y1 = 0.17; //(pdg == 211) ? 0.20 : 0.74;
827 double y2 = 0.42; //(pdg == 211) ? 0.45 : 0.99;
828 string cName = "AccRecMom/" + ptcl + "Mom";
829 fH.fHM.CreateCanvas(cName, cName, 900, 900);
830 DrawH1(histsAll, latexAll, kLinear, kLog, true, 0.4, y1, 0.95, y2, "hist");
831
832 fH.fHM.CreateCanvas(cName + "_prime", cName + "_prime", 900, 900);
833 DrawH1(histsPrim, latexPrim, kLinear, kLog, true, 0.4, y1, 0.95, y2, "hist");
834 }
835
836 // Acceptance in single detectors
837 for (const string& det : {"sts", "rich", "trd", "tof"}) {
838 vector<TH1*> hVec;
839 vector<string> latex;
841 for (const string& pm : {"+", "-"}) {
842 hVec.push_back(fH.H1("hMomAcc" + pm + "_" + det, src));
843 latex.push_back(fH.fSrcLatex[static_cast<int>(src)] + " (e" + pm + ")");
844 }
845 }
846 fH.fHM.CreateCanvas("AccRecMom/momDetAcc_" + det, "AccRecMom/momDetAcc_" + det, 800, 800);
847 DrawH1(hVec, latex, kLinear, kLog, true, 0.90, 0.7, 0.99, 0.99, "hist");
848 DrawTextOnPad(det, 0.4, 0.9, 0.6, 0.999);
849 }
850}
851
852void LmvmDraw::DrawSource2D(const string& cName, const string& hName, const vector<string>& yLabels, double scale,
853 const string& zTitle)
854{
855 fH.fHM.CreateCanvas((cName + "_abs").c_str(), (cName + "_abs").c_str(), 900, 600);
856 TH2D* habs = fH.H2Clone(hName);
857 habs->SetStats(false);
858 habs->Scale(scale);
859 habs->SetMinimum(1e-2);
860 habs->GetZaxis()->SetTitle(zTitle.c_str());
861 habs->SetMarkerSize(1.4);
862 DrawH2(habs, kLinear, kLinear, kLog, "text COLZ");
863
864 fH.fHM.CreateCanvas((cName + "_perc").c_str(), (cName + "_perc").c_str(), 900, 600);
865 TH2D* hperc = fH.H2Clone(hName);
866 hperc->SetStats(false);
867 for (int x = 1; x <= hperc->GetNbinsX(); x++) {
868 // calculate total number of BG tracks (pairs) for a current step
869 double nbg = 0.;
870 for (int y = 1; y <= hperc->GetNbinsY(); y++) {
871 nbg += habs->GetBinContent(x, y);
872 }
873 double sc = 100. / (nbg / scale);
874 for (int y = 1; y <= hperc->GetNbinsY(); y++) {
875 double val = sc * hperc->GetBinContent(x, y);
876 hperc->SetBinContent(x, y, val);
877 }
878 }
879 hperc->GetZaxis()->SetTitle("[%]");
880 hperc->GetYaxis()->SetLabelSize(0.06);
881 hperc->SetMarkerColor(kBlack);
882 hperc->SetMarkerSize(1.4);
883 DrawH2(hperc, kLinear, kLinear, kLinear, "text COLZ");
884
885 for (size_t y = 1; y <= yLabels.size(); y++) {
886 hperc->GetYaxis()->SetBinLabel(y, yLabels[y - 1].c_str());
887 habs->GetYaxis()->SetBinLabel(y, yLabels[y - 1].c_str());
888 }
889
890 SetAnalysisStepAxis(hperc);
892}
893
895{
896 gStyle->SetPaintTextFormat("4.1f");
897
898 fH.fHM.CreateCanvas("bg/nofBgTracks", "bg/nofBgTracks", 900, 900);
899 TH1D* hbg = fH.H1Clone("hNofBgTracks");
900 hbg->Scale(10);
901 hbg->GetYaxis()->SetTitle("Tracks/event x10");
902 DrawH1(hbg, kLinear, kLog, "hist text0");
903 hbg->SetMarkerSize(2.);
904
905 fH.fHM.CreateCanvas("signal/nofSignalTracks", "signal/nofSignalTracks", 900, 900);
906 TH1D* hel = fH.H1("hNofSignalTracks");
907 DrawH1(hel, kLinear, kLog, "hist");
908
909 fH.fHM.CreateCanvas("purity", "purity", 900, 900);
910 TH1D* purity = new TH1D("purity", "Purity;Analysis steps;Purity", fH.fNofAnaSteps, 0., fH.fNofAnaSteps);
911 purity->Divide(fH.H1("hNofBgTracks"), fH.H1("hNofSignalTracks"));
912 DrawH1(purity, kLinear, kLog, "hist text30");
913 purity->SetMarkerSize(1.9);
914
917 SetAnalysisStepAxis(purity);
918
919 DrawSource2D("bg/SrcTracksBg_2d", "hBgSrcTracks",
920 {"#gamma", "#pi^{0}", "#pi^{#pm}", "p", "K", "e^{#pm}_{sec}", "oth.", "signal"}, 1000.,
921 "Tracks per event x10^{3}");
922
923 TCanvas* c = fH.fHM.CreateCanvas("nofTopoPairs", "nofTopoPairs", 1600, 800);
924 c->Divide(2, 1);
925 int i = 1;
926 for (const string& p : {"gamma", "pi0"}) {
927 c->cd(i++);
928 TH1D* hTopo = fH.H1Clone("hNofTopoPairs_" + p);
929 hTopo->Scale(1. / hTopo->Integral());
930 DrawH1(hTopo, kLinear, kLinear, "hist");
931 hTopo->SetMarkerSize(1.);
932 }
933}
934
936{
937 gStyle->SetPaintTextFormat("4.1f");
938 TCanvas* c1 = fH.fHM.CreateCanvas("nofMismatches", "nofMismatches", 1500, 1500);
939 c1->Divide(2, 2);
940 vector<string> dets {"all", "rich", "trd", "tof"};
941 for (size_t i = 0; i < dets.size(); i++) {
942 c1->cd(i + 1);
943 TH1D* h = fH.H1Clone("hNofMismatches_" + dets[i]);
944 h->Scale(10);
945 h->GetYaxis()->SetTitle(("Mismatch tracks (" + dets[i] + ")/event x10").c_str());
946 DrawH1(h, kLinear, kLog, "hist text0");
947 h->SetMarkerSize(2.);
949 }
950
951 fH.fHM.CreateCanvas("nofGhosts", "nofGhosts", 900, 900);
952 DrawH1(fH.H1("hNofGhosts"), kLinear, kLog, "hist");
953 SetAnalysisStepAxis(fH.H1("hNofGhosts"));
954}
955
957{
958 // Shift histogram content by 2 bins if MVD was not used
959 if (!fUseMvd) {
960 for (int step = static_cast<int>(ELmvmAnaStep::Mvd1Cut) + 1; step <= fH.fNofAnaSteps - 2; step++) {
961 if (h->IsA() == TH2D::Class()) {
962 for (int y = 1; y <= h->GetYaxis()->GetNbins(); y++) {
963 h->SetBinContent(step, y, h->GetBinContent(step + 2, y));
964 }
965 }
966 else if (h->IsA() == TH1D::Class()) {
967 h->SetBinContent(step, h->GetBinContent(step + 2));
968 }
969 }
970 }
971
972 int rangeMax = fH.fNofAnaSteps;
973 if (!fUseMvd) { rangeMax = rangeMax - 2; }
974 h->GetXaxis()->SetRange(static_cast<int>(ELmvmAnaStep::Reco) + 1, rangeMax);
975 h->GetXaxis()->SetLabelSize(0.06);
976 int x = 1;
977 for (const auto step : fH.fAnaSteps) {
978 if (SkipMvd(step)) continue;
979 h->GetXaxis()->SetBinLabel(x, fH.fAnaStepLatex[static_cast<int>(step)].c_str());
980 x++;
981 }
982}
983
985{
986 if (!fUseMvd) return;
987 TCanvas* c = fH.fHM.CreateCanvas("cuts/mvdCutQa", "cuts/mvd1cut_qa", 1600, 800);
988 c->Divide(2, 1);
989 int i = 1;
990 for (const string& num : {"1", "2"}) {
991 c->cd(i++);
992 DrawSrcH1("hMvdCutQa_" + num);
993 TH1D* h1 = fH.H1("hMvdCutQa_" + num + "_" + fH.fSrcNames[0]);
994 h1->GetXaxis()->SetLabelSize(0.06);
995 h1->GetXaxis()->SetBinLabel(1, "Correct");
996 h1->GetXaxis()->SetBinLabel(2, "Wrong");
997 gPad->SetLogy(false);
998 DrawTextOnPad("MVD " + num, 0.50, 0.90, 0.70, 0.99);
999 }
1000}
1001
1003{
1004 if (!fUseMvd) return;
1005 TCanvas* c1 = fH.fHM.CreateCanvas("nofHitsMvdSts", "nofHitsMvdSts", 1600, 800);
1006 c1->Divide(2, 1);
1007 c1->cd(1);
1008 DrawSrcH1("hNofMvdHits");
1009 c1->cd(2);
1010 DrawSrcH1("hNofStsHits");
1011
1012 Draw2DCut("hMvdXY_1");
1013 fH.fHM.CreateCanvas("mvd1", "mvd1", 900, 900);
1014 DrawSrcH1("hMvdR_1");
1015
1016 Draw2DCut("hMvdXY_2");
1017 fH.fHM.CreateCanvas("mvd2", "mvd2", 900, 900);
1018 DrawSrcH1("hMvdR_2");
1019}
1020
1022{
1023 fH.fHM.SaveCanvasToImage(fOutputDir, "png"); // fHM->SaveCanvasToImage(fOutputDir, "png;eps");
1024}
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void SetDefaultDrawStyle()
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
@ kLinear
Definition CbmDrawHist.h:69
@ kLog
Definition CbmDrawHist.h:68
Histogram manager.
ELmvmSrc
Definition LmvmDef.h:23
ELmvmAnaStep
Definition LmvmDef.h:34
ClassImp(LmvmDraw)
Generates beam ions for transport simulation.
static Int_t MarkerStyle(Int_t markerIndex)
Definition CbmDrawHist.h:51
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
void ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
double fRtCutPP
Definition LmvmCuts.h:101
double fMvd1CutP
Definition LmvmCuts.h:102
double fMvd1CutD
Definition LmvmCuts.h:103
double fStCutPP
Definition LmvmCuts.h:97
double fTtCutAngle
Definition LmvmCuts.h:98
double fRtCutAngle
Definition LmvmCuts.h:100
double fTtCutPP
Definition LmvmCuts.h:99
double fMvd2CutP
Definition LmvmCuts.h:104
double fChi2PrimCut
Definition LmvmCuts.h:94
double fStCutAngle
Definition LmvmCuts.h:96
double fMvd2CutD
Definition LmvmCuts.h:105
void DrawMinvBgPairSrc(ELmvmAnaStep step)
Definition LmvmDraw.cxx:763
void DrawPtY(const std::string &hist, ELmvmAnaStep step)
Definition LmvmDraw.cxx:182
void DrawMisc()
Definition LmvmDraw.cxx:237
void DrawHistFromFile(const std::string &fileName, const std::string &outputDir="", bool useMvd=true)
Implement functionality of drawing histograms in the macro from the specified file,...
Definition LmvmDraw.cxx:40
void DrawSource2D(const std::string &cName, const std::string &hName, const std::vector< std::string > &yLabels, double scale, const std::string &zTitle)
Definition LmvmDraw.cxx:852
void DrawMvdCutQa()
Definition LmvmDraw.cxx:984
void DrawCutEffH1(const std::string &hist, const std::string &option)
Definition LmvmDraw.cxx:137
void Draw2DCutTriangle(double xCr, double yCr)
Definition LmvmDraw.cxx:479
void DrawAnaStepH1(const std::string &hist, bool logy=false)
Definition LmvmDraw.cxx:686
void DrawMinvAll()
Definition LmvmDraw.cxx:716
void DrawBgSourcePairsAll()
Definition LmvmDraw.cxx:449
void Draw2DCut(const std::string &hist, double cutCrossX=-999999., double cutCrossY=-999999.)
Definition LmvmDraw.cxx:612
bool fUseMvd
Definition LmvmDraw.h:48
void DrawMinvMatching(ELmvmAnaStep step)
Definition LmvmDraw.cxx:781
void SetAnalysisStepAxis(TH1 *h)
Definition LmvmDraw.cxx:956
LmvmHist fH
Definition LmvmDraw.h:52
void DrawMinvSBg(ELmvmAnaStep step)
Definition LmvmDraw.cxx:735
bool SkipMvd(ELmvmAnaStep step)
Definition LmvmDraw.cxx:100
Int_t fNofEvents
Definition LmvmDraw.h:46
void Draw1DCut(const std::string &hist, const std::string &sigOption, double cut=-999999.)
Definition LmvmDraw.cxx:374
void DrawMinvPt(ELmvmAnaStep step)
Definition LmvmDraw.cxx:210
void DrawMvdAndStsHist()
void DrawSrcH1(const std::string &hist, ELmvmAnaStep step=ELmvmAnaStep::Undefined, bool doScale=true)
Definition LmvmDraw.cxx:361
void DrawCombinatorialPairs()
Definition LmvmDraw.cxx:250
void DrawBgSourcePairs(ELmvmAnaStep step, bool inPercent, bool drawAnaStep=true)
Definition LmvmDraw.cxx:425
void DrawMismatchesAndGhosts()
Definition LmvmDraw.cxx:935
void DrawMinvBg()
Definition LmvmDraw.cxx:489
void DrawAccRecVsMom()
Definition LmvmDraw.cxx:797
void DrawGammaVertex()
Definition LmvmDraw.cxx:641
void SaveCanvasToImage()
Save all created canvases to images.
void DrawPmtXY()
Definition LmvmDraw.cxx:348
void DrawElPurity()
Definition LmvmDraw.cxx:535
void DrawBgSourceTracks()
Definition LmvmDraw.cxx:894
void DrawRapidity(ELmvmAnaStep step)
Definition LmvmDraw.cxx:192
void DrawCuts()
Definition LmvmDraw.cxx:398
void DrawAnaStepMany(const std::string &cName, std::function< void(ELmvmAnaStep)> drawFunc)
Definition LmvmDraw.cxx:162
void RebinMinvHist()
Rebin minv histograms for better drawing. Should be called after calculation of S/BG ratios.
Definition LmvmDraw.cxx:105
void DrawBetaMomSpectra()
Definition LmvmDraw.cxx:125
LmvmCuts fCuts
Definition LmvmDraw.h:50
void DrawSrcAnaStepH1(const std::string &hName, ELmvmAnaStep step)
Definition LmvmDraw.cxx:217
std::string fOutputDir
Definition LmvmDraw.h:53
void DrawSrcAnaStepEpEmH1(const std::string &cName, ELmvmAnaStep step)
Definition LmvmDraw.cxx:223
void DrawPtYEfficiency(ELmvmAnaStep step)
Definition LmvmDraw.cxx:198
static const std::vector< int > fAnaStepColors
Definition LmvmHist.h:37
static const std::vector< ELmvmSrc > fSrcs
Definition LmvmHist.h:23
static const std::vector< std::string > fCandNames
Definition LmvmHist.h:57
static const std::vector< std::string > fAnaStepLatex
Definition LmvmHist.h:35
void DrawEfficiency(TH1 *h1, TH1 *h2, double xPos, double yPos)
Definition LmvmHist.cxx:479
TH1D * CreateSignificanceH1(TH1D *s, TH1D *bg, const std::string &name, const std::string &option)
Definition LmvmHist.cxx:325
CbmHistManager fHM
Definition LmvmHist.h:165
TH2D * H2Clone(const std::string &name)
Definition LmvmHist.h:119
TH2D * H2(const std::string &name)
Definition LmvmHist.h:110
static const std::vector< int > fSrcColors
Definition LmvmHist.h:27
static const std::vector< std::string > fBgPairSrcNames
Definition LmvmHist.h:45
static const int fNofBgPairSrc
Definition LmvmHist.h:41
static const std::vector< std::string > fSrcNames
Definition LmvmHist.h:25
std::string GetName(const std::string &name, ELmvmAnaStep step)
static const std::vector< std::string > fSrcLatex
Definition LmvmHist.h:26
void Rebin(const std::string &name, int nGroup)
static const std::vector< ELmvmAnaStep > fAnaSteps
Definition LmvmHist.h:29
static const int fNofAnaSteps
Definition LmvmHist.h:31
TH1D * H1Clone(const std::string &name)
Definition LmvmHist.h:118
TH1D * H1(const std::string &name)
Definition LmvmHist.h:109
static const std::vector< std::string > fBgPairSrcLatex
Definition LmvmHist.h:46
static const std::vector< std::string > fAnaStepNames
Definition LmvmHist.h:33
static void DrawAnaStepOnPad(ELmvmAnaStep step)
Definition LmvmHist.cxx:488
TH2D * DivideH2(TH2 *h1, TH2 *h2, const string &histName, double scale, const string &titleZaxis)
Definition CbmUtils.cxx:103
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34
Hash for CbmL1LinkKey.