CbmRoot
Loading...
Searching...
No Matches
LmvmDrawAll.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: Elena Lebedeva, Andrey Lebedev, Semen Lebedev [committer], Cornelius Feier-Riesen */
4
5#include "LmvmDrawAll.h"
6
7#include "CbmDrawHist.h"
8#include "CbmHistManager.h"
9#include "CbmUtils.h"
10#include "LmvmDef.h"
11#include "LmvmTask.h"
12#include "LmvmUtils.h"
13#include "Logger.h"
14#include "TCanvas.h"
15#include "TClass.h"
16#include "TCutG.h"
17#include "TEllipse.h"
18#include "TF1.h"
19#include "TFile.h"
20#include "TGraphErrors.h"
21#include "TH1.h"
22#include "TH1D.h"
23#include "TH2D.h"
24#include "TKey.h"
25#include "TLatex.h"
26#include "TLine.h"
27#include "TLorentzVector.h"
28#include "TMath.h"
29#include "TStopwatch.h"
30#include "TStyle.h"
31#include "TSystem.h"
32#include "TText.h"
33
34#include <TLegend.h>
35
36#include <iomanip>
37#include <iostream>
38#include <string>
39
40using namespace std;
41using namespace Cbm;
42
43LmvmHist* LmvmDrawAll::H(ELmvmSignal signal) { return fH[static_cast<int>(signal)]; }
44
45void LmvmDrawAll::DrawHistFromFile(const string& fileInmed, const string& fileQgp, const string& fileOmega,
46 const string& filePhi, const string& fileOmegaD, const string& dataDir, bool useMvd)
47{
49 fDataDir = dataDir;
50 fOutputDir = dataDir + "results/all/";
51 fFileName = fOutputDir + "draw_all_hist.root";
52 fUseMvd = useMvd;
53 fRebinMinv = fHMean.fRebinMinv;
54
55 // order in vector is important, see ELmvmSignal enum.
56 vector<string> fileNames{fileInmed, fileQgp, fileOmega, filePhi, fileOmegaD};
57
58 TFile* oldFile = gFile;
59 TDirectory* oldDir = gDirectory;
60
61 // Load histograms from LmvmTask
62 fH.resize(fHMean.fNofSignals);
63 fNofSimEvents = 0;
64 for (size_t i = 0; i < fH.size(); i++) {
65 fH[i] = new LmvmHist();
66 TFile* file = new TFile(fileNames[i].c_str());
67 fH[i]->fHM.ReadFromFile(file);
68 double nofEventsSig = (double) fH[i]->H1("hEventNumber")->GetEntries();
69 fNofSimEvents += nofEventsSig;
70 LOG(info) << "Signal:" << fHMean.fSignalNames[i] << " nofEvents:" << nofEventsSig << endl;
71 }
73
74 // Calculate Combinatorial BG, Signal and FastSim yields
75 LoadFastSimHistos(); // load histograms provided by LmvmFastSim
76 CalculateCombBGHistos(); // data provided by LmvmEventMix
77 CalculateSignal(); // from FastSim and CB
79
80 // Draw
84 DrawSignal();
94 //ChargeSymmetry(); // Impact of asymmetry onto agreement between Calc. CB and BRE
97 DrawPurity();
100 DrawPtY();
102 CalcCutEffRange(0.0, 0.2);
103 CalcCutEffRange(0.2, 0.6);
104 CalcCutEffRange(0.6, 1.2);
105 SBgRangeAll();
110 DrawNofHits();
113 DrawStudies();
115 DrawTofM2();
116 //InvestigateMisid();
117 //DrawLikeSignCorrelations();
118 //DrawBetaMomSpectra();
119 //DrawSystematicErrorFsSignal(); // occupies a lot of memory
120 //CheckoutAddFunction();
121 //CheckoutAddFunction2();
122 SaveHist();
124 CheckMemory("CreateMeanHistAll(): After all");
125
127 gFile = oldFile;
128 gDirectory = oldDir;
129}
130
131template<class T>
132void LmvmDrawAll::CreateMeanHist(const string& name, int nofRebins)
133{
134 for (ELmvmSignal sig : fHMean.fSignals) {
135 if (static_cast<int>(sig) == 0)
136 fHMean.fHM.Add(name, static_cast<T*>(H(sig)->GetObject(name)->Clone()));
137 else
138 static_cast<T*>(fHMean.GetObject(name))->Add(static_cast<T*>(H(sig)->GetObject(name)->Clone()));
139 }
140 static_cast<T*>(fHMean.GetObject(name))->Scale(1. / (double) fNofSimEvents);
141 if (nofRebins > 0) {
142 static_cast<T*>(fHMean.GetObject(name))->Rebin(nofRebins);
143 double binWidth = static_cast<T*>(fHMean.GetObject(name))->GetBinWidth(1);
144 static_cast<T*>(fHMean.GetObject(name))->Scale(1. / binWidth);
145 }
146}
147
148template<class T>
149void LmvmDrawAll::CreateMeanHistSparse(const string& name)
150{
151 for (ELmvmSignal sig : fHMean.fSignals) {
152 if (static_cast<int>(sig) == 0)
153 fHMean.fHM.Add(name, static_cast<T*>(H(sig)->GetObject(name)->Clone()));
154 else
155 static_cast<T*>(fHMean.GetObject(name))->Add(static_cast<T*>(H(sig)->GetObject(name)->Clone()));
156 }
157}
158
160{
161 LOG(info) << "Nof simulated Events:" << fNofSimEvents << endl;
162
163 CreateMeanHist<TH1D>("hNofMcTracks");
164 CreateMeanHist<TH1D>("hNofGTracks");
165 CreateMeanHist<TH1D>("hNofBgTracks");
166 CreateMeanHist<TH1D>("hNofRichHits");
167 CreateMeanHist<TH1D>("hNofRichRings");
168 CreateMeanHist<TH2D>("hRecoPrec_Minv");
169 CreateMeanHist<TH2D>("hVertexGTrackRZ");
170
171 for (const string ptcl : {"pion", "proton"}) {
172 for (const string step : {"mc", "reco", "acc", "elid", "ttcut", "ptcut"}) { // TODO: why does "reco" not work??
173 //for (const string step : {"mc", "acc", "elid", "ttcut", "ptcut"}) {
174 CreateMeanHist<TH1D>("hSuppression_" + ptcl + "_" + step);
175 }
176 }
177
178 for (const string det : {"rich", "trd", "tof"}) {
179 CreateMeanHist<TH1D>("hMatch_" + det);
180 }
181
182 for (const string comb : {"PM", "PP", "MM"}) {
183 for (const string ev : {"sameEv", "mixedEv"}) {
184 CreateMeanHist<TH1D>("hMinv" + comb + "_" + ev, fRebinMinv);
185 }
186 for (const string cat : {"", "_mother"}) {
187 CreateMeanHist<TH2D>("hMinvComb" + comb + "_px" + cat);
188 CreateMeanHist<TH2D>("hMinvComb" + comb + "_py" + cat);
189 CreateMeanHist<TH2D>("hMinvComb" + comb + "_R" + cat);
190 }
191 for (int i = 0; i <= 24; i++) {
192 for (const string type : {"pMc", "pRec"}) {
193 string hName = "hBgPairPdg" + comb + "_" + type + "_" + Cbm::NumberToString(i, 0);
195 }
196 }
197 CreateMeanHist<TH1D>("hMinvComb" + comb + "_theta-minv");
198 }
199
200 for (const string suff : {"+", "-"}) {
201 CreateMeanHist<TH2D>("hCandPdgVsMom" + suff);
202 CreateMeanHist<TH1D>("hMom" + suff + "_trueEl_bg_elid");
203 }
204
205 for (const string cat : {"tt", "tm", "mt", "mm"}) {
206 CreateMeanHist<TH1D>("hMinv_" + cat, fRebinMinv);
207 CreateMeanHist<TH1D>("hMinvCombPM_same_" + cat, fRebinMinv);
208 }
209
210 for (const string cat : {"true", "misid"}) {
211 CreateMeanHist<TH2D>("hRecoPrec_Mom_ID_" + cat);
212 for (size_t iP = 4; iP < fHMean.fCandNames.size(); iP++) {
213 CreateMeanHist<TH1D>("hMom_" + fHMean.fCandNames[iP] + "_" + cat);
214 CreateMeanHist<TH1D>("hPtY_" + fHMean.fCandNames[iP] + "_" + cat);
215 CreateMeanHist<TH1D>("hTofM2_" + fHMean.fCandNames[iP] + "_" + cat);
216 }
217 }
218 for (const string det : {"rich", "trd", "tof"}) {
219 for (const string cat : {"rec", "acc", "chi2prim"}) {
220 CreateMeanHist<TH2D>("hPdgVsMom_" + det + "_" + cat);
221 }
222 }
223
224 // Global Track Loop
225 for (const string& ptcl : fHMean.fGTrackNames) {
226 //CreateMeanHist<TH2D>("hMatchId_gTracks_" + ptcl);
227 //CreateMeanHist<TH1D>("hNofMismatches_gTracks_" + ptcl);
228 //CreateMeanHist<TH1D>("hNofMismatchedTrackSegments_" + ptcl);
229
230 for (const string det : {"sts", "rich", "trd", "tof"}) {
231 CreateMeanHist<TH2D>("hNofHitsVsMom_" + det + "_" + ptcl);
232 for (const string match : {"truematch", "mismatch"}) {
233 if (det != "sts") CreateMeanHist<TH1D>("hChi2_" + match + "_" + det + "_" + ptcl);
234 }
235 }
236 } // fGTrackNames
237
238 // Candidate Loop
239 for (const string& ptcl : fHMean.fCandNames) {
240 CreateMeanHist<TH2D>("hTofM2_truematch_" + ptcl);
241 CreateMeanHist<TH2D>("hTofM2_mismatch_" + ptcl);
242 CreateMeanHist<TH2D>("hTofDist_truematch_" + ptcl);
243 CreateMeanHist<TH2D>("hTofDist_mismatch_" + ptcl);
244
245 for (auto step : fHMean.fAnaSteps) {
246 CreateMeanHist<TH1D>(fHMean.GetName("hMom_" + ptcl, step));
247 CreateMeanHist<TH2D>(fHMean.GetName("hELossSts_" + ptcl, step));
248 CreateMeanHist<TH2D>(fHMean.GetName("hRichAnn_" + ptcl, step));
249 CreateMeanHist<TH2D>(fHMean.GetName("hTrdElLike_" + ptcl, step));
250 CreateMeanHist<TH2D>(fHMean.GetName("hTofM2_" + ptcl, step));
251 CreateMeanHist<TH2D>(fHMean.GetName("hTofDist_" + ptcl, step));
252 CreateMeanHist<TH2D>(fHMean.GetName("hMomPt_" + ptcl, step));
253 CreateMeanHist<TH2D>(fHMean.GetName("hPtY_" + ptcl, step));
254 CreateMeanHist<TH2D>(fHMean.GetName("hRecoPrec_Mom_" + ptcl, step));
255 CreateMeanHist<TH1D>(fHMean.GetName("hRichRingTrackDist_" + ptcl, step));
256 CreateMeanHist<TH2D>(fHMean.GetName("hRichRingTrackDistVsMom_" + ptcl, step));
257 for (const string det : {"sts", "rich", "trd", "tof"}) {
258 CreateMeanHist<TH2D>(fHMean.GetName("hChi2Dets_" + det + "_" + ptcl, step));
259 }
260 } // steps
261
262 // Number of indices in TOF
263 for (const string nInd : {"1", "2", "3+"}) {
264 CreateMeanHist<TH2D>("hTofM2_woDoubleIndex_" + nInd + "_" + ptcl);
265 }
266
267 // TOF-m2 in dependance on position
268 for (int pos : {50, 100, 150, 200, 300, 400, 500}) {
269 for (const string step : {"chi2prim", "elid"}) {
270 CreateMeanHist<TH2D>("hTofM2_" + step + "_" + Cbm::NumberToString(pos, 0) + "_" + ptcl);
271 }
272 }
273
274 // STS-E-Loss vs. TOF-m2 in dependance on position and momentum
275 for (const string cat : {"Seg1Mom1", "Seg1Mom2", "Seg2Mom1", "Seg2Mom2"}) {
276 CreateMeanHist<TH2D>("hElossTime_chi2prim_" + cat + "_" + ptcl);
277 CreateMeanHist<TH2D>("hElossTime_elid_" + cat + "_" + ptcl);
278 }
279
280 //CreateMeanHist<TH1D>("hBetaMom_" + ptcl);
281
282 for (const string det : {"StsRich", "StsTrd", "RichTrd"}) {
283 CreateMeanHist<TH2D>("hChi2Comb_" + det + "_" + ptcl);
284 }
285
286 for (int i = 1; i <= 11; i++) {
287 string pRange = Cbm::NumberToString(i, 0);
288 CreateMeanHist<TH2D>("hCandProperties_" + pRange + "_" + ptcl);
289 }
290
291 for (const string step : {"all", "elid"}) {
292 //CreateMeanHist<TH2D>("hTofChi2_"+ step + "_" + ptcl);
293 for (const string neighbour : {"next", "secondnext"}) {
294 CreateMeanHist<TH2D>("RichRingNeighbour_" + step + "_" + neighbour + "_" + ptcl);
295 }
296 }
297
298
299 } // fCandNames
300
301 // Step Loop
302 for (auto step : fHMean.fAnaSteps) {
303 CreateMeanHist<TH1D>(fHMean.GetName("hRichRingBoA", step));
304 CreateMeanHist<TH1D>(fHMean.GetName("hVertexXZ_misidTof", step));
305 CreateMeanHist<TH1D>(fHMean.GetName("hVertexYZ_misidTof", step));
306 CreateMeanHist<TH1D>(fHMean.GetName("hVertexXY_misidTof", step));
307 CreateMeanHist<TH1D>(fHMean.GetName("hVertexRZ_misidTof", step));
308 CreateMeanHist<TH1D>(fHMean.GetName("hLikeSignCorr", step));
309 CreateMeanHist<TH2D>(fHMean.GetName("hCandPdg", step));
310 CreateMeanHist<TH2D>(fHMean.GetName("hCandPdgVsMom", step));
311
313 for (const string cat : {"", "_trueEl", "_urqmdEl", "_urqmdAll"}) {
314 CreateMeanHist<TH1D>(fHMean.GetName("hMinv" + cat, src, step), fRebinMinv);
315 }
316 CreateMeanHist<TH2D>(fHMean.GetName("hMinvPt", src, step));
317 for (const string suff : {"+", "-"}) {
318 CreateMeanHist<TH1D>(fHMean.GetName("hRapidity" + suff, src, step));
319 }
320 }
321 for (const string& src : fHMean.fSrcNames) {
322 for (const string suff : {"", "+", "-"}) {
323 CreateMeanHist<TH1D>(fHMean.GetName("hMom" + suff + "_" + src, step));
324 if (suff == "") continue;
325 for (const string pi : {"Px", "Py", "Pz"}) {
326 CreateMeanHist<TH1D>(fHMean.GetName("hMom" + pi + suff + "_" + src, step));
327 }
328 }
329 }
330
331 string hBgSrc = "hMinvBgSource2_" + fHMean.fAnaStepNames[static_cast<int>(step)] + "_";
332 for (const string pair : {"gg", "pipi", "pi0pi0", "oo", "gpi", "gpi0", "go", "pipi0", "pio", "pi0o"}) {
333 string hFullName = hBgSrc + pair;
335 }
336 } // steps
337}
338
339TH1D* LmvmDrawAll::GetCocktailMinvH1(const string& name, ELmvmAnaStep step, bool scaleAll)
340{
341 return GetCocktailMinv<TH1D>(name, step, scaleAll);
342}
343
344void LmvmDrawAll::CalculateHistErrors(TH1D* h, double nofEvents)
345{
346 for (int iB = 1; iB <= h->GetNbinsX(); iB++) {
347 double bW = h->GetBinWidth(iB);
348 double N = h->GetBinContent(iB) * nofEvents * bW;
349 double err = std::sqrt(N) / (bW * nofEvents);
350 h->SetBinError(iB, err);
351 }
352}
353
354TH1D* LmvmDrawAll::CalculateHistRatioWithErrors(TH1D* h1, TH1D* h2, double nEv1, double nEv2)
355{
356 if (h1->GetNbinsX() != h2->GetNbinsX())
357 LOG(error) << "LmvmDrawAll::CalculateHistRatioWithErrors: Histograms don't have same number of bins.";
358 TH1D* hRatio = (TH1D*) h1->Clone();
359 hRatio->Divide(h2);
360 double a = nEv2 / nEv1;
361 cout << "a = " << a << endl;
362 for (int iB = 1; iB <= h1->GetNbinsX(); iB++) {
363 double bw = h1->GetBinWidth(iB);
364 if (h2->GetBinWidth(iB) != bw)
365 LOG(error) << "LmvmDrawAll::CalculateHistRatioWithErrors: Histograms '" << h1->GetName() << "' and '"
366 << h2->GetName() << "': Bin widths of bin " << iB << " of both histograms are not the same.";
367 double c1 = h1->GetBinContent(iB);
368 double c2 = h2->GetBinContent(iB);
369 double n1 = c1 * bw * nEv1;
370 double n2 = c2 * bw * nEv2;
371 double D1 = std::sqrt(n1 / (bw * nEv1));
372 double D2 = std::sqrt(n2 / (bw * nEv2));
373
374 // f = n1/n2
375 double dfdx1 = 1 / n2;
376 double dfdx2 = -n1 / (n2 * n2);
377 double f1 = dfdx1 * D1;
378 double f2 = dfdx2 * D2;
379 double error = std::sqrt(f1 * f1 + f2 * f2);
380 cout << "iB = " << iB << ", bW = " << bw << endl;
381 cout << " c1 = " << c1 << ", n1 = " << n1 << ", D1 = " << D1 << ", f1 = " << f1 << endl;
382 cout << " c2 = " << c2 << ", n2 = " << n2 << ", D2 = " << D2 << ", f2 = " << f2 << endl;
383 cout << " -> error = " << error << endl;
384 hRatio->SetBinError(iB, error);
385 }
386 return hRatio;
387}
388
390{
391 TH1D* h = new TH1D("hCheckoutAddFunc", "hCheckoutAddFunction", 10., 0., 10.);
392 //fHMean.CreateHByClone(h, "hCheckoutAdd");
393 for (int iB = 1; iB <= h->GetNbinsX(); iB++) {
394 h->SetBinContent(iB, iB);
395 double c = h->GetBinContent(iB);
396 double e = iB / 10.;
397 h->SetBinError(iB, e);
398 LOG(info) << "CheckoutAddFunction: hist: iB = " << iB << ", c = " << c << ", e = " << e;
399 }
400 fHMean.CreateHByClone(h, "hCheckoutAdd");
401}
403{
404 TH1D* h2 = fHMean.H1Clone("hCheckoutAdd");
405 for (int iB = 1; iB <= h2->GetNbinsX(); iB++) {
406 double c = h2->GetBinContent(iB);
407 double e = h2->GetBinError(iB);
408 LOG(info) << "CheckoutAddFunction2: check hist: iB = " << iB << ", c = " << c << ", e = " << e;
409 }
410}
411
413 ELmvmAnaStep step, vector<pair<double, double>> bwvar) // Mind: For now only available for ElId step and cat = ""
414{
415 TH1D* bre = VaryBinWidth("mean", "hfsc_MinvBg", step, bwvar);
416 TH1D* bcb = VaryBinWidth("mean", fHMean.GetName("hCbBg", step), bwvar);
417 TH1D* coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", bwvar);
418 TH1D* sig = (TH1D*) bre->Clone();
419 sig->Add(coc);
420 sig->Add(bcb, -1.);
421
422 // For error contribution from CB
423 TH1D* h_s_pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP_sameEv", step), bwvar);
424 TH1D* h_s_mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM_sameEv", step), bwvar);
425 TH1D* h_m_pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP_mixedEv", step), bwvar);
426 TH1D* h_m_mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM_mixedEv", step), bwvar);
427
428 for (int iB = 1; iB <= bre->GetNbinsX(); iB++) {
429 double bW = bre->GetBinWidth(iB);
430
431 // Number of entries
432 double N_bre = bre->GetBinContent(iB) * bW * fNofFastSimEvents;
433 double N_s_pp = h_s_pp->GetBinContent(iB) * bW * fNofEvMixEvents;
434 double N_s_mm = h_s_mm->GetBinContent(iB) * bW * fNofEvMixEvents;
435 double N_m_pp = h_m_pp->GetBinContent(iB) * bW * fNofEvMixEvents * fEvMixDepth;
436 double N_m_mm = h_m_mm->GetBinContent(iB) * bW * fNofEvMixEvents * fEvMixDepth;
437
438 // Errors
439 double D_bcb1 = std::sqrt(N_s_mm + N_s_pp) / (bW * fNofEvMixEvents);
440 double D_bcb2 = std::sqrt(N_m_pp + N_m_mm)
441 / (bW * fNofEvMixEvents * fEvMixDepth * fCbNormFactor[static_cast<int>(ELmvmAnaStep::ElId)]);
442 double D_bcb = (bre->GetBinCenter(iB) <= fCbChange) ? D_bcb1 : D_bcb2;
443 double D_bre = std::sqrt(N_bre) / (bW * fNofFastSimEvents);
444 double D_dNdM = std::sqrt(D_bre * D_bre + D_bcb * D_bcb);
445
446 sig->SetBinError(iB, D_dNdM);
447 }
448 return sig;
449}
450
452{
453 // Signal = B_{FS} + Cocktail - CB_{calc}
454 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
455 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
456 for (const string cat : {"", "_trueEl"}) {
457 // Standard Signal (FastSim will be used for minv > fCbChange)
458 TH1D* sig =
459 fHMean.CreateHByClone(fHMean.H1Clone("hfsc_MinvBg" + cat, step), fHMean.GetName("hSignal" + cat, step));
460 TH1D* sigred = fHMean.CreateHByClone(fHFastSim.H1Clone("hfsc_MinvBg" + cat, step),
461 fHMean.GetName("hSignalReduced" + cat, step));
462 TH1D* reBg = fHFastSim.H1Clone("hfsc_MinvBg" + cat, step);
463 TH1D* mcBg = fHMean.H1Clone("hMinv", ELmvmSrc::Bg, step);
464 //TH1D* mcBg = fHMean.H1Clone("hMinvPM_sameEv");
465 TH1D* cbc = fHMean.H1Clone("hCbBg" + cat, step);
466 TH1D* coc = GetCocktailMinvH1("hMinv" + cat, step, false);
467 double bW = sig->GetBinWidth(1);
468 int ChangeBin = sig->FindBin(0.4);
469 for (int iB = 1; iB <= sig->GetNbinsX(); iB++) {
470 double vMcBg = mcBg->GetBinContent(iB);
471 double vReBg = reBg->GetBinContent(iB);
472 double vCbBg = cbc->GetBinContent(iB);
473 double vCoc = coc->GetBinContent(iB);
474 double vSig = (iB < ChangeBin) ? vMcBg + vCoc - vCbBg : vReBg + vCoc - vCbBg;
475 sig->SetBinContent(iB, vSig);
476 sigred->SetBinContent(iB, vSig);
477 }
478
479 // Reduced Signal
480 TH1D* inmed = H(ELmvmSignal::Inmed)->H1Clone("hMinv", ELmvmSrc::Signal, step);
481 TH1D* qgp = H(ELmvmSignal::Qgp)->H1Clone("hMinv", ELmvmSrc::Signal, step);
482 TH1D* omega = H(ELmvmSignal::Omega)->H1Clone("hMinv", ELmvmSrc::Signal, step);
483 TH1D* omegadalitz = H(ELmvmSignal::OmegaD)->H1Clone("hMinv", ELmvmSrc::Signal, step);
484 TH1D* phi = H(ELmvmSignal::Phi)->H1Clone("hMinv", ELmvmSrc::Signal, step);
485 TH1D* pi0 = fHMean.H1Clone("hMinv", ELmvmSrc::Pi0, step);
486 TH1D* eta = fHMean.H1Clone("hMinv", ELmvmSrc::Eta, step);
487 inmed->Scale(1. / (H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries() * bW));
488 qgp->Scale(1. / (H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries() * bW));
489 omega->Scale(1. / (H(ELmvmSignal::Omega)->H1("hEventNumber")->GetEntries() * bW));
490 omegadalitz->Scale(1. / (H(ELmvmSignal::OmegaD)->H1("hEventNumber")->GetEntries() * bW));
491 phi->Scale(1. / (H(ELmvmSignal::Phi)->H1("hEventNumber")->GetEntries() * bW));
492 sigred->Add(omega, -1.);
493 sigred->Add(omegadalitz, -1.);
494 sigred->Add(phi, -1.);
495 sigred->Add(pi0, -1.);
496 sigred->Add(eta, -1.);
497
498 // Errors for signal histograms with varied bin widths
499 for (auto bwv : fBwVarAll) {
500 string tag = "";
501 if (bwv == fBwVarOrig)
502 tag = fBwVarAllTags[0];
503 else if (bwv == fBwVarReg)
504 tag = fBwVarAllTags[1];
505 else if (bwv == fBwVarBg)
506 tag = fBwVarAllTags[2];
507 else if (bwv == fBwVarSig)
508 tag = fBwVarAllTags[3];
509 else if (bwv == fBwVarSig2)
510 tag = fBwVarAllTags[4];
511 else if (bwv == fBwVarSig3)
512 tag = fBwVarAllTags[5];
513 else
514 LOG(error) << "LmvmDrawAll::CalculateSignal: Check bwVar-tag assignment!";
515 TH1D* sigV = VaryBinWidth(sig, bwv);
516 TH1D* sigredV = VaryBinWidth(sigred, bwv);
517 TH1D* bre = VaryBinWidth("mean", "hfsc_MinvBg" + cat, step, bwv);
518
519 // Histograms for errors
520 TH1D* errSig = (TH1D*) sigV->Clone();
521 TH1D* errBre = (TH1D*) sigV->Clone();
522 TH1D* errBcb = (TH1D*) sigV->Clone();
523 errSig->Reset();
524 errBre->Reset();
525 errBcb->Reset();
526
527 // For error contribution from CB
528 TH1D* h_s_pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP" + cat + "_sameEv", step), bwv);
529 TH1D* h_s_mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM" + cat + "_sameEv", step), bwv);
530 TH1D* h_m_pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP" + cat + "_mixedEv", step), bwv);
531 TH1D* h_m_mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM" + cat + "_mixedEv", step), bwv);
532
533 for (int iB = 1; iB <= bre->GetNbinsX(); iB++) {
534 double bW2 = bre->GetBinWidth(iB);
535
536 // Number of entries
537 double N_bre = bre->GetBinContent(iB) * bW2 * fNofFastSimEvents;
538 double N_s_pp = h_s_pp->GetBinContent(iB) * bW2 * fNofEvMixEvents;
539 double N_s_mm = h_s_mm->GetBinContent(iB) * bW2 * fNofEvMixEvents;
540 double N_m_pp = h_m_pp->GetBinContent(iB) * bW2 * fNofEvMixEvents * fEvMixDepth;
541 double N_m_mm = h_m_mm->GetBinContent(iB) * bW2 * fNofEvMixEvents * fEvMixDepth;
542
543 // Errors
544 double D_bcb1 = std::sqrt(N_s_mm + N_s_pp) / (bW2 * fNofEvMixEvents);
545 double D_bcb2 =
546 std::sqrt(N_m_pp + N_m_mm) / (bW2 * fNofEvMixEvents * fEvMixDepth * fCbNormFactor[static_cast<int>(step)]);
547 double D_bcb = (bre->GetBinCenter(iB) <= fCbChange) ? D_bcb1 : D_bcb2;
548 double D_bre = std::sqrt(N_bre) / (bW2 * fNofFastSimEvents);
549 double D_dNdM = std::sqrt(D_bre * D_bre + D_bcb * D_bcb);
550
551 sigV->SetBinError(iB, D_dNdM);
552 sigredV->SetBinError(iB, D_dNdM);
553
554 errSig->SetBinContent(iB, D_dNdM);
555 errBre->SetBinContent(iB, D_bre);
556 errBcb->SetBinContent(iB, D_bcb);
557 }
558 fHMean.CreateHByClone(sigV, fHMean.GetName("hSignal" + cat + "_" + tag, step));
559 fHMean.CreateHByClone(sigredV, fHMean.GetName("hSignalReduced" + cat + "_" + tag, step));
560
561 if (cat != "") continue;
562 // Draw Histograms as standards for later checking
563 sigV->GetYaxis()->SetRangeUser(1e-9, 2e-1);
564 string cNameSig = "Signal/Standard/" + tag + "_" + stepname;
565 string cNameErr = "Signal/Standard/Error/" + tag + "_" + stepname;
566 fHMean.fHM.CreateCanvas(cNameSig, cNameSig, 800, 800);
567 DrawH1(sigV, kLinear, kLog, "p");
568 DrawTextOnPad("Signal (elid)", 0.35, 0.9, 0.65, 0.99);
569 fHMean.fHM.CreateCanvas(cNameErr, cNameErr, 800, 800);
570 errSig->GetYaxis()->SetRangeUser(1e-10, 5e-2);
571 DrawH1({errSig, errBre, errBcb}, {"S = B_{FS} - B_{CB}", "B_{FS}", "CB_{calc}"}, kLinear, kLog, true, 0.65, 0.7,
572 0.91, 0.9, "p");
573 DrawTextOnPad("Errors", 0.4, 0.9, 0.6, 0.99);
574 } // ..bWidths
575 } // ..cats
576 } // ..steps
577
578 // Check Errors
579 /*{
580 TH1D* sig = fHMean.H1Clone("hSignal_bwvOrig_elid");
581 TH1D* sig2 = fHMean.H1Clone("hSignal_bwvSig_elid");
582 cout << endl << "Signal Histogram original:" << endl;
583 for (int iB = 1; iB <= sig->GetNbinsX(); iB++) {
584 double bW2 = sig->GetBinWidth(iB);
585 double nSigNorm = sig->GetBinContent(iB);
586 double nSig = sig->GetBinContent(iB) * bW2 * fNofFastSimEvents;
587 double errSig = sig->GetBinError(iB);
588 LOG(info) << "Errors2 (CalcSignal): iB = " << iB << ": bW = " << bW2 << ", nSigN = " << nSigNorm << ", nSig = " << nSig << ", errSig = " << errSig;
589 }
590 cout << endl << "Signal Histogram varied bin width:" << endl;
591 for (int iB = 1; iB <= sig2->GetNbinsX(); iB++) {
592 double bW2 = sig2->GetBinWidth(iB);
593 double nSigNorm = sig2->GetBinContent(iB);
594 double nSig = sig2->GetBinContent(iB) * bW2 * fNofFastSimEvents;
595 double errSig = sig2->GetBinError(iB);
596 LOG(info) << "Errors2 (CalcSignal): iB = " << iB << ": bW = " << bW2 << ", nSigN = " << nSigNorm << ", nSig = " << nSig << ", errSig = " << errSig;
597 }
598 }*/
599}
600
602{
603 DrawSignalCBNormRangeDependent("hfsc_MinvBg", "Signal/", ELmvmAnaStep::ElId);
604 DrawSignalCBNormRangeDependent("hfsp_MinvBg", "Signal/", ELmvmAnaStep::ElId);
605
606 // Draw Signal from particle-based FastSim
607 {
609 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
610 TH1D* bre = fHFastSim.H1Clone("hfsp_MinvBg", step);
611 TH1D* cbc = fHMean.H1Clone("hCbBg", step);
612 TH1D* coc = GetCocktailMinvH1("hMinv", step, false);
613 TH1D* sig = (TH1D*) bre->Clone();
614 sig->Add(coc);
615 sig->Add(cbc, -1.);
616 TH1D* bre2 = VaryBinWidth(bre, fNofFastSimEvents, fBwVarBg);
617 TH1D* cbc2 = VaryBinWidth(cbc, fNofFastSimEvents, fBwVarBg);
618 TH1D* coc2 = VaryBinWidth(coc, fNofFastSimEvents, fBwVarSig);
619 TH1D* sig2 = VaryBinWidth(sig, fNofFastSimEvents, fBwVarSig);
620 sig2->GetYaxis()->SetRangeUser(5e-9, 5e-2);
621 TCanvas* c = fHMean.fHM.CreateCanvas("Signal/Particle-based/Standard", "Signal/Particle-based/Standard", 1600, 800);
622 c->Divide(2, 1);
623 c->cd(1);
624 DrawH1({bre2, cbc2}, {"B_{FS}", "CB_{calc}"}, kLinear, kLog, true, 0.75, 0.78, 0.91, 0.91, "pe");
625 c->cd(2);
626 DrawH1({sig2, coc2}, {"Signal", "Cocktail"}, kLinear, kLog, true, 0.75, 0.78, 0.91, 0.91, "pe");
627
628 // Text to compare Rebin with VaryBinWidth (seems good!)
629 TH1D* sig5 = (TH1D*) sig->Clone();
630 TH1D* sig10 = (TH1D*) sig->Clone();
631 TH1D* sig50 = (TH1D*) sig->Clone();
632 TH1D* coc5 = (TH1D*) coc->Clone();
633 TH1D* coc10 = (TH1D*) coc->Clone();
634 TH1D* coc50 = (TH1D*) coc->Clone();
635 sig5->Rebin(5);
636 sig10->Rebin(10);
637 sig50->Rebin(50);
638 coc5->Rebin(5);
639 coc10->Rebin(10);
640 coc50->Rebin(50);
641 sig5->Scale(1. / 5.);
642 sig10->Scale(1. / 10.);
643 sig50->Scale(1. / 50.);
644 coc5->Scale(1. / 5.);
645 coc10->Scale(1. / 10.);
646 coc50->Scale(1. / 50.);
647 TCanvas* ct =
648 fHMean.fHM.CreateCanvas("Signal/Particle-based/Standard_test", "Signal/Particle-based/Standard_test", 2400, 800);
649 ct->Divide(3, 1);
650 ct->cd(1);
651 DrawH1({sig5, coc5}, {"Signal", "Cocktail"}, kLinear, kLog, true, 0.75, 0.78, 0.91, 0.91, "p");
652 DrawTextOnPad("Rebin 5", 0.26, 0.9, 0.74, 0.99);
653 ct->cd(2);
654 DrawH1({sig10, coc10}, {"Signal", "Cocktail"}, kLinear, kLog, true, 0.75, 0.78, 0.91, 0.91, "p");
655 DrawTextOnPad("Rebin 10", 0.25, 0.9, 0.75, 0.99);
656 ct->cd(3);
657 DrawH1({sig50, coc50}, {"Signal", "Cocktail"}, kLinear, kLog, true, 0.75, 0.78, 0.91, 0.91, "p");
658 DrawTextOnPad("Rebin 50", 0.25, 0.9, 0.75, 0.99);
659 }
660
661 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
662 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
663 // Draw common and reduced signal
664 {
665 for (auto bwv : {fBwVarSig3}) {
666 string tag = "";
667 if (bwv == fBwVarOrig)
668 tag = fBwVarAllTags[0];
669 else if (bwv == fBwVarReg)
670 tag = fBwVarAllTags[1];
671 else if (bwv == fBwVarBg)
672 tag = fBwVarAllTags[2];
673 else if (bwv == fBwVarSig)
674 tag = fBwVarAllTags[3];
675 else if (bwv == fBwVarSig2)
676 tag = fBwVarAllTags[4];
677 else if (bwv == fBwVarSig3)
678 tag = fBwVarAllTags[5];
679 for (const string cat : {""}) { //}, "_trueEl", "_urqmdAll", "_urqmdEl"}) {
680 TH1D* sig = fHMean.H1Clone(fHMean.GetName("hSignal" + cat + "_" + tag, step));
681 TH1D* sigred = fHMean.H1Clone(fHMean.GetName("hSignalReduced" + cat + "_" + tag, step));
682 TH1D* coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", bwv);
683 TH1D* inmed = VaryBinWidth("inmed", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwv);
684 TH1D* qgp = VaryBinWidth("qgp", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwv);
685 inmed->Scale(1. / H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries());
686 qgp->Scale(1. / H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries());
687 TH1D* cocred = (TH1D*) inmed->Clone();
688 cocred->Add(qgp);
689 for (int iB = 1; iB <= cocred->GetNbinsX(); iB++) {
690 cocred->SetBinError(iB, 0.);
691 }
692 sig->GetYaxis()->SetRangeUser(1e-9, 3e-2);
693 sigred->GetYaxis()->SetRangeUser(1e-10, 5e-2);
694 fHMean.fHM.CreateCanvas("Signal/Signal" + cat + "_" + tag + "_" + stepname,
695 "Signal/Signal" + cat + "_" + tag + "_" + stepname, 800, 800);
696 DrawH1({sig, coc}, {"Signal", "MC Cocktail"}, kLinear, kLog, true, 0.65, 0.78, 0.91, 0.91, "p");
697 fHMean.fHM.CreateCanvas("Signal/ReducedSignal" + cat + "_" + tag + "_" + stepname,
698 "Signal/ReducedSignal" + cat + "_" + tag + "_" + stepname, 800, 800);
699 DrawH1({sigred, cocred}, {"Signal - #pi^{0} - #eta - #omega - #omega_{D} - #phi", "#rho_{i.m.} + QGP"},
700 kLinear, kLog, true, 0.4, 0.78, 0.91, 0.91, "p");
701 }
702 }
703 }
704 }
705
706 // Signal with single components
707 {
709 TH1D* bre = fHFastSim.H1Clone("hfsc_MinvBg", step);
710 TH1D* cb = fHMean.H1Clone("hCbBg", step);
711 TH1D* coc = GetCocktailMinvH1("hMinv", step, false);
712 TH1D* sig = (TH1D*) bre->Clone();
713 sig->Add(coc);
714 sig->Add(cb, -1.);
715 TCanvas* c = fHMean.fHM.CreateCanvas("Signal/Components", "Signal/Components", 1600, 800);
716 c->Divide(2, 1);
717 c->cd(1);
718 DrawH1(sig, kLinear, kLog, "hist");
719 fHMean.DrawAnaStepOnPad(step);
720 c->cd(2);
721 bre->GetYaxis()->SetRangeUser(1e-10, 1e-1);
722 DrawH1({bre, cb, coc}, {"B_{FS}", "CB_{calc}", "Cocktail"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.91, "hist");
723 fHMean.DrawAnaStepOnPad(step);
724 }
725}
726
728{
729 vector<double> paramsA = {5e-5, 1e-4, 5e-4, 1e-3, 2e-3, 5e-3, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.};
730 vector<double> paramsB = {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1., 2., 5., 10., 20., 50., 100.};
731
732 string h2descr = "hTempVsInitParams; Parameter #it{a}; Parameter #it{b}; T [MeV]";
733 TH2D* h2 = new TH2D("hTempVsInitParams", h2descr.c_str(), paramsA.size(), paramsA[0], paramsA[paramsA.size() - 1],
734 paramsB.size(), paramsB[0], paramsB[paramsB.size() - 1]);
735 for (size_t iX = 0; iX < paramsA.size(); iX++) {
736 string startstr = Cbm::NumberToString(paramsA[iX], 2);
737 h2->GetXaxis()->SetBinLabel(iX + 1, startstr.c_str());
738 }
739 for (size_t iY = 0; iY < paramsB.size(); iY++) {
740 string endstr = Cbm::NumberToString(paramsB[iY], 2);
741 h2->GetYaxis()->SetBinLabel(iY + 1, endstr.c_str());
742 }
743
744 for (size_t iA = 0; iA < paramsA.size(); iA++) {
745 for (size_t iB = 0; iB < paramsB.size(); iB++) {
746
747 // Get Parameter 'b' (is needed later to calculate appropriate x-Position of large bins for Temperature Fit)
748 TH1D* h = VaryBinWidth("cocktail_elid", "", fBwVarReg);
749 TF1* TFitCoc = new TF1("TFitCoc", "[0]*TMath::Exp(-[1]*x)", 1.1, 2.5);
750 TFitCoc->SetParameters(paramsA[iA], paramsB[iB]);
751 string cNameInit = "Temperature/CheckoutInitParams/Init_" + Cbm::NumberToString(paramsA[iA], 2) + "_"
752 + Cbm::NumberToString(paramsB[iB], 2);
753 fHMean.fHM.CreateCanvas(cNameInit, cNameInit, 1600, 1100);
754 DrawH1(h, kLinear, kLog, "p");
755 h->Fit("TFitCoc", "QR");
756 double b = TFitCoc->GetParameter(1);
757 DrawTextOnPad("Parameter #it{b} = " + Cbm::NumberToString(b, 2), 0.12, 0.12, 0.5, 0.25);
758 DrawTextOnPad("Fit: #it{a#upointe^{-bx}}", 0.6, 0.76, 0.8, 0.81);
759
760 // Calculate Temperature with current Parameter b
761 TF1* funcInit = new TF1("TFuncTestInitParams", "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", 1.1, 2.5);
762 funcInit->SetParameters(0.02, 0.15);
763 string cName = "Temperature/CheckoutInitParams/Temp_" + Cbm::NumberToString(paramsA[iA], 2) + "_"
764 + Cbm::NumberToString(paramsB[iB], 2);
765 fHMean.fHM.CreateCanvas(cName, cName, 800, 800);
766 int nBins = h->GetNbinsX();
767 double x[nBins], y[nBins], ex[nBins], ey[nBins];
768 for (int iBin = 1; iBin <= nBins; iBin++) {
769 double bW = h->GetBinWidth(iBin);
770 double x1 = h->GetBinLowEdge(iBin);
771 x[iBin - 1] = x1 + (TMath::Log(b * bW) - TMath::Log(1 - TMath::Exp(-b * bW))) / b;
772 y[iBin - 1] = h->GetBinContent(iBin);
773 ex[iBin - 1] = 0.;
774 ey[iBin - 1] = h->GetBinError(iBin);
775 }
776 auto graph = new TGraphErrors(nBins, x, y, ex, ey);
777 graph->SetTitle("Temperature; M_{ee} [GeV/c^{2}]; dN/dM [Gev/c^{2}]^{-1}");
778 graph->GetXaxis()->SetRangeUser(0., 2.5);
779 graph->GetYaxis()->SetRangeUser(1e-10, 1e-1);
780 graph->SetMarkerStyle(21);
781 graph->Draw("AP");
782 gPad->SetLogy(true);
783 graph->Fit("TFuncTestInitParams", "QR");
784 double T = 1000. * funcInit->GetParameter(1);
785 double TErr = T * funcInit->GetParError(1) / funcInit->GetParameter(1);
786 DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.35, 0.1,
787 0.75, 0.3);
788 DrawTextOnPad("a = " + Cbm::NumberToString(paramsA[iA], 2) + ", b = " + Cbm::NumberToString(paramsB[iB], 2), 0.12,
789 0.12, 0.5, 0.22);
790 h2->SetBinContent(iA + 1, iB + 1, T);
791 }
792 }
793 h2->GetZaxis()->SetRangeUser(163.5, 164.5);
794 string cNameAll = "Temperature/CheckoutInitParams/All";
795 fHMean.fHM.CreateCanvas(cNameAll, cNameAll, 1200, 800);
796 DrawH2(h2, kLinear, kLinear, kLinear, "colz");
797 DrawTextOnPad("Temperature in Dependance on Choice Start Params of Fit", 0.0, 0.9, 0.85, 0.99);
798}
799
801{
802 TH1D* h = VaryBinWidth("cocktail_elid", "", fBwVarSig);
803 vector<double> params;
804 double param = 4.5;
805 for (int i = 1; i <= 30; i++) {
806 params.push_back(param);
807 param += 0.05;
808 }
809 string hdescr = "hTempVsParamB; Parameter #it{b}; T [MeV]";
810 TH1D* h1 = new TH1D("hTempVsParamB", hdescr.c_str(), params.size(), params[0], params[params.size() - 1]);
811 for (size_t iX = 0; iX < params.size(); iX++) {
812 string startstr = Cbm::NumberToString(params[iX], 2);
813 h1->GetXaxis()->SetBinLabel(iX + 1, startstr.c_str());
814 }
815
816 for (size_t iP = 0; iP < params.size(); iP++) {
817 double b = params[iP];
818 TF1* func = new TF1("TFuncTestParamB", "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", 1.1, 2.5);
819 func->SetParameters(0.005, 0.15);
820 string cName = "Temperature/CheckoutParamB/" + Cbm::NumberToString(b, 2);
821 fHMean.fHM.CreateCanvas(cName, cName, 800, 800);
822 int nBins = h->GetNbinsX();
823 double x[nBins], y[nBins], ex[nBins], ey[nBins];
824 for (int iB = 1; iB <= nBins; iB++) {
825 double bW = h->GetBinWidth(iB);
826 double x1 = h->GetBinLowEdge(iB);
827 x[iB - 1] = x1 + (TMath::Log(b * bW) - TMath::Log(1 - TMath::Exp(-b * bW))) / b;
828 y[iB - 1] = h->GetBinContent(iB);
829 ex[iB - 1] = 0.;
830 ey[iB - 1] = h->GetBinError(iB);
831 }
832 auto graph = new TGraphErrors(nBins, x, y, ex, ey);
833 graph->SetTitle("Temperature; M_{ee} [GeV/c^{2}]; dN/dM [Gev/c^{2}]^{-1}");
834 graph->GetXaxis()->SetRangeUser(0., 2.5);
835 graph->GetYaxis()->SetRangeUser(1e-10, 1e-1);
836 graph->SetMarkerStyle(21);
837 graph->Draw("AP");
838 gPad->SetLogy(true);
839 graph->Fit("TFuncTestParamB", "QR");
840 double T = 1000. * func->GetParameter(1);
841 double TErr = T * func->GetParError(1) / func->GetParameter(1);
842 DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.35, 0.1,
843 0.75, 0.3);
844 DrawTextOnPad("#it{b} = " + Cbm::NumberToString(b, 2), 0.12, 0.12, 0.3, 0.22);
845 h1->SetBinContent(iP + 1, T);
846 }
847 h1->GetYaxis()->SetRangeUser(160., 180.);
848 string cNameAll = "Temperature/CheckoutParamB/All";
849 fHMean.fHM.CreateCanvas(cNameAll, cNameAll, 1800, 800);
850 DrawH1(h1, kLinear, kLinear, "colz");
851 DrawTextOnPad("Temperature in Dependance on Parameter #it{b}", 0.0, 0.9, 0.85, 0.99);
852}
853
855{
856 double b = fParamB[static_cast<int>(ELmvmAnaStep::ElId)];
857 TH1D* h = VaryBinWidth("cocktail_elid", "", fBwVarOrig);
858
859 vector<double> params1 = {0.0001, 0.001, 0.005, 0.01, 0.02, 0.04, 0.1, 0.15, 0.2, 0.4, 1., 2., 5.};
860 vector<double> params2 = {0.001, 0.01, 0.05, 0.1, 0.15, 0.2, 0.25, 0.4, 0.6, 1., 1.5, 2., 5., 10.};
861
862 string h2descr = "hTempVsParams; Parameter 1; Parameter 2; T [MeV]";
863 TH2D* h2 = new TH2D("hTempVsParams", h2descr.c_str(), params1.size(), params1[0], params1[params1.size() - 1],
864 params2.size(), params2[0], params2[params2.size() - 1]);
865 for (size_t iX = 0; iX < params1.size(); iX++) {
866 string startstr = Cbm::NumberToString(params1[iX], 2);
867 h2->GetXaxis()->SetBinLabel(iX + 1, startstr.c_str());
868 }
869 for (size_t iY = 0; iY < params2.size(); iY++) {
870 string endstr = Cbm::NumberToString(params2[iY], 2);
871 h2->GetYaxis()->SetBinLabel(iY + 1, endstr.c_str());
872 }
873
874 for (size_t iP1 = 0; iP1 < params1.size(); iP1++) {
875 for (size_t iP2 = 0; iP2 < params2.size(); iP2++) {
876 TF1* func = new TF1("TFuncTestParams", "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", 1.1, 2.5);
877 func->SetParameters(params1[iP1], params2[iP2]);
878 string cName = "Temperature/CheckoutParams/" + Cbm::NumberToString(params1[iP1], 2) + "_"
879 + Cbm::NumberToString(params2[iP2], 2);
880 fHMean.fHM.CreateCanvas(cName, cName, 800, 800);
881 int nBins = h->GetNbinsX();
882 double x[nBins], y[nBins], ex[nBins], ey[nBins];
883 for (int iB = 1; iB <= nBins; iB++) {
884 double bW = h->GetBinWidth(iB);
885 double x1 = h->GetBinLowEdge(iB);
886 x[iB - 1] = x1 + (TMath::Log(b * bW) - TMath::Log(1 - TMath::Exp(-b * bW))) / b;
887 y[iB - 1] = h->GetBinContent(iB);
888 ex[iB - 1] = 0.;
889 ey[iB - 1] = h->GetBinError(iB);
890 }
891 auto graph = new TGraphErrors(nBins, x, y, ex, ey);
892 graph->SetTitle("Temperature; M_{ee} [GeV/c^{2}]; dN/dM [Gev/c^{2}]^{-1}");
893 graph->GetXaxis()->SetRangeUser(0., 2.5);
894 graph->GetYaxis()->SetRangeUser(1e-10, 1e-1);
895 graph->SetMarkerStyle(21);
896 graph->Draw("AP");
897 gPad->SetLogy(true);
898 graph->Fit("TFuncTestParams", "QR");
899 double T = 1000. * func->GetParameter(1);
900 double TErr = T * func->GetParError(1) / func->GetParameter(1);
901 DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.35, 0.1,
902 0.75, 0.3);
903 DrawTextOnPad("p1 = " + Cbm::NumberToString(params1[iP1], 2) + ", p2 = " + Cbm::NumberToString(params2[iP2], 2),
904 0.12, 0.12, 0.5, 0.22);
905 h2->SetBinContent(iP1 + 1, iP2 + 1, T);
906 }
907 }
908 h2->GetZaxis()->SetRangeUser(163.5, 164.5);
909 string cNameAll = "Temperature/CheckoutParams/All";
910 fHMean.fHM.CreateCanvas(cNameAll, cNameAll, 1200, 800);
911 DrawH2(h2, kLinear, kLinear, kLinear, "colz");
912 DrawTextOnPad("Temperature in Dependance on Start Params of Fit", 0.0, 0.9, 0.85, 0.99);
913}
914
916{
918 TH1D* coc = VaryBinWidth("cocktail_elid", "", fBwVarReg);
919 TH1D* inmed = VaryBinWidth("inmed", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), fBwVarReg);
920 TH1D* qgp = VaryBinWidth("qgp", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), fBwVarReg);
921 inmed->Scale(1. / H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries());
922 qgp->Scale(1. / H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries());
923 TH1D* redcoc = (TH1D*) inmed->Clone();
924 redcoc->Add(qgp);
925 CheckoutTemperatureFitRange(coc, "cocktail");
926 CheckoutTemperatureFitRange(redcoc, "reduced cocktail");
927}
928
930{
931 double b = fParamB[static_cast<int>(ELmvmAnaStep::ElId)];
932 vector<double> vStart = {0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5};
933 vector<double> vEnd = {1.8, 1.9, 2., 2.1, 2.2, 2.3, 2.4, 2.5};
934
935 string hName = "hTempVsFitRange_" + name;
936 string h2descr = hName + "; #it{m}_{start} [GeV]; #it{m}_{end} [GeV]; T [MeV]";
937 TH2D* h2 = new TH2D(hName.c_str(), h2descr.c_str(), vStart.size(), vStart[0], vStart[vStart.size() - 1], vEnd.size(),
938 vEnd[0], vEnd[vEnd.size() - 1]);
939 for (size_t iX = 0; iX < vStart.size(); iX++) {
940 string startstr = Cbm::NumberToString(vStart[iX], 2);
941 h2->GetXaxis()->SetBinLabel(iX + 1, startstr.c_str());
942 }
943 for (size_t iY = 0; iY < vEnd.size(); iY++) {
944 string endstr = Cbm::NumberToString(vEnd[iY], 2);
945 h2->GetYaxis()->SetBinLabel(iY + 1, endstr.c_str());
946 }
947
948 for (size_t iStart = 0; iStart < vStart.size(); iStart++) {
949 for (size_t iEnd = 0; iEnd < vEnd.size(); iEnd++) {
950 TF1* func = new TF1("TFuncCheckoutFitRange", "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", vStart[iStart],
951 vEnd[iEnd]);
952 func->SetParameters(0.005, 0.16);
953 string cName = "Temperature/CheckoutFitRange/" + name + "/" + Cbm::NumberToString(vStart[iStart], 2) + "_"
954 + Cbm::NumberToString(vEnd[iEnd], 2);
955 fHMean.fHM.CreateCanvas(cName, cName, 1100, 800);
956 int nBins = h->GetNbinsX();
957 double x[nBins], y[nBins], ex[nBins], ey[nBins];
958 for (int iB = 1; iB <= nBins; iB++) {
959 double bW = h->GetBinWidth(iB);
960 double x1 = h->GetBinLowEdge(iB);
961 x[iB - 1] = x1 + (TMath::Log(b * bW) - TMath::Log(1 - TMath::Exp(-b * bW))) / b;
962 y[iB - 1] = h->GetBinContent(iB);
963 ex[iB - 1] = 0.;
964 ey[iB - 1] = h->GetBinError(iB);
965 }
966 auto graph = new TGraphErrors(nBins, x, y, ex, ey);
967 graph->SetTitle("Temperature; M_{ee} [GeV/c^{2}]; dN/dM [Gev/c^{2}]^{-1}");
968 graph->GetXaxis()->SetRangeUser(0., 2.5);
969 graph->GetYaxis()->SetRangeUser(1e-10, 1e-1);
970 graph->SetMarkerStyle(21);
971 graph->Draw("AP");
972 gPad->SetLogy(true);
973 graph->Fit("TFuncCheckoutFitRange", "QR");
974 double T = 1000. * func->GetParameter(1);
975 double TErr = T * func->GetParError(1) / func->GetParameter(1);
976 DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.35, 0.1,
977 0.75, 0.3);
978 DrawTextOnPad("FitRange: x_{start} = " + Cbm::NumberToString(vStart[iStart], 2)
979 + ", x_{end} = " + Cbm::NumberToString(vEnd[iEnd], 2),
980 0.02, 0.05, 0.44, 0.25);
981 h2->SetBinContent(iStart + 1, iEnd + 1, T);
982 }
983 }
984 h2->GetZaxis()->SetRangeUser(109., 180.);
985 string cNameAll = "Temperature/CheckoutFitRange/" + name + "/All";
986 fHMean.fHM.CreateCanvas(cNameAll, cNameAll, 1530, 800);
987 DrawH2(h2, kLinear, kLinear, kLinear, "colz");
988 DrawTextOnPad("Temperature in Dependance on Fit Range (" + name + ")", 0.0, 0.9, 0.8, 0.99);
989}
990
992 TH1D* h, ELmvmAnaStep step, double startfit,
993 double endfit) // TODO: merge these two methods if bool 'DoCorrectX' is not needed anymore
994{
995 DrawTemperatureGraph(h, step, startfit, endfit, true);
996}
997
998void LmvmDrawAll::DrawTemperatureGraph(TH1D* h, ELmvmAnaStep step, double startfit, double endfit,
999 bool DoCorrectX) // TODO: delete bool etc.;
1000{
1002 string cstring = Cbm::NumberToString(fTempGraphCounter, 0);
1003 // Functions
1004 TF1* TFunc =
1005 new TF1(("TFunc" + cstring).c_str(), "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", startfit, endfit);
1006 TFunc->SetParameters(0.01, 0.15);
1007
1008 double b = fParamB[static_cast<int>(step)];
1009
1010 int nBins = h->GetNbinsX();
1011 double x[nBins], y[nBins], ex[nBins], ey[nBins];
1012 for (int iB = 1; iB <= nBins; iB++) {
1013 double bW = h->GetBinWidth(iB);
1014 double x1 = h->GetBinLowEdge(iB);
1015 x[iB - 1] =
1016 (DoCorrectX) ? x1 + (TMath::Log(b * bW) - TMath::Log(1 - TMath::Exp(-b * bW))) / b : h->GetBinCenter(iB);
1017 y[iB - 1] = h->GetBinContent(iB);
1018 ex[iB - 1] = 0.;
1019 ey[iB - 1] = h->GetBinError(iB);
1020 }
1021 auto graph = new TGraphErrors(nBins, x, y, ex, ey);
1022 graph->SetTitle("Temperature; M_{ee} [GeV/c^{2}]; dN/dM_{ee} [Gev/c^{2}]^{-1}");
1023 graph->GetXaxis()->SetRangeUser(0., 2.5);
1024 graph->GetYaxis()->SetRangeUser(1e-9, 3e-2);
1025 graph->GetXaxis()->SetNdivisions(505, true);
1026 graph->GetYaxis()->SetNdivisions(510, true);
1027 graph->GetXaxis()->SetLabelSize(0.06);
1028 graph->GetYaxis()->SetLabelSize(0.06);
1029 graph->GetXaxis()->SetTitleSize(0.06);
1030 graph->GetYaxis()->SetTitleSize(0.06);
1031 graph->GetXaxis()->SetTitleOffset(1.0);
1032 graph->GetYaxis()->SetTitleOffset(1.3);
1033 graph->SetMarkerStyle(25);
1034 graph->SetMarkerSize(1.2);
1035 graph->SetMarkerColor(2);
1036 graph->SetLineColor(2);
1037 gPad->SetLeftMargin(0.2); //0.17
1038 gPad->SetBottomMargin(0.15);
1039 gPad->SetGrid(1, 1);
1040 graph->Draw("AP");
1041 //graph->Fit(("TFunc" + cstring).c_str(), "QR");
1042 //double T = 1000. * TFunc->GetParameter(1);
1043 //double TErr = T * TFunc->GetParError(1)/TFunc->GetParameter(1);
1044 //DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.35, 0.1, 0.75, 0.3);
1045 gPad->SetLogy(true);
1046}
1047
1048void LmvmDrawAll::DrawTemperature(TH1D* h, double startfit, double endfit)
1049{
1050 TF1* TFunc = new TF1("TFunc", "[0]*TMath::Power(x*[1], 3./2.)*TMath::Exp(-x/[1])", startfit, endfit);
1051 TFunc->SetParameters(0.02, 0.15);
1052 DrawH1(h, kLinear, kLog, "p");
1053 h->Fit("TFunc", "QR");
1054 double T = 1000. * TFunc->GetParameter(1);
1055 double TErr = T * TFunc->GetParError(1) / TFunc->GetParameter(1);
1056 DrawTextOnPad("T = (" + Cbm::NumberToString(T, 1) + " #pm " + Cbm::NumberToString(TErr, 1) + ") MeV", 0.45, 0.1, 0.85,
1057 0.3);
1058}
1059
1061{
1062 fParamB.resize(fHMean.fNofAnaSteps);
1063 for (auto step : fHMean.fAnaSteps) {
1064 TH1D* coc = GetCocktailMinvH1("hMinv", step, false); // "hMinv" + cat,
1065 TF1* TFitCoc = new TF1("TFitCoc", "[0]*TMath::Exp(-[1]*x)", 1.1, 2.5);
1066 TFitCoc->SetParameters(0.01, 5.);
1067 string cName = "Temperature/ParamB/" + fHMean.fAnaStepNames[static_cast<int>(step)];
1068 fHMean.fHM.CreateCanvas(cName, cName, 1600, 1100);
1069 DrawH1(coc, kLinear, kLog, "p");
1070 coc->Fit("TFitCoc", "QR");
1071 double a = TFitCoc->GetParameter(0);
1072 double b = TFitCoc->GetParameter(1);
1073 fParamB[static_cast<int>(step)] = b;
1074 DrawTextOnPad("Parameters: #it{a} = " + Cbm::NumberToString(a, 2) + ", #it{b} = " + Cbm::NumberToString(b, 2), 0.12,
1075 0.12, 0.65, 0.25);
1076 DrawTextOnPad("Fit: #it{a#upointe^{-bx}}", 0.6, 0.76, 0.8, 0.81);
1077 fHMean.DrawAnaStepOnPad(step);
1078 }
1079 // Check Values
1080 /*LOG(info) << "Check Params B:";
1081 for (size_t i = 0; i < fParamB.size(); i++) {
1082 cout << " Step " << fHMean.fAnaStepNames[i] << ": b = " << fParamB[i] << endl;
1083 }*/
1084}
1085
1087{
1089 string cName = "Temperature/";
1091
1092 // Estimate Systematic Error of Temperature Calculation
1093 //CheckoutTemperatureParamB();
1094 //CheckoutTemperatureInitParams();
1095 //CheckoutTemperatureParams();
1096 //CheckoutTemperatureFitRangeAll();
1097
1098 // Draw Temperature related Functions
1099 {
1100 fHMean.fHM.CreateCanvas(cName + "Functions", cName + "Functions", 950, 800);
1101 TF1* cocfit = new TF1("cocfit", "0.000177 * TMath::Exp(-5.25 * x)", 1.1, 2.5);
1102 TF1* tempfit = new TF1("tempfit", "0.005255 * TMath::Power(0.1641 * x, 3./2.) * TMath::Exp(-x/0.1641)", 1.1, 2.5);
1103 cocfit->SetTitle("TempFuncs;M_{ee} [GeV/c^{2}];dN/dM [GeV/c^{2}]^{-1}");
1104 tempfit->SetLineColor(4);
1105 cocfit->Draw();
1106 tempfit->Draw("same");
1107 gPad->SetLogy(true);
1108 gPad->RangeAxis(0., 1e-10, 2.5, 1e-2);
1109 TLegend* legend = new TLegend(0.55, 0.75, 0.88, 0.88);
1110 legend->AddEntry(cocfit, "a #upoint e^{-bx}", "l");
1111 legend->AddEntry(tempfit, "p_{1} #upoint (T #upoint x)^{3/2} #upoint e^{-x/T}", "l");
1112 legend->Draw();
1113 }
1114
1115 // Temperature of Signal vs. Cocktail
1116 {
1117 vector<pair<double, double>> varbin = fBwVarSig3;
1118 TH1D* sig = GetSignal(step, varbin);
1119 //TH1D* sig = VaryBinWidth("mean", "hSignal", step, varbin);
1120 TH1D* coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, varbin);
1121 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "SignalVsCocktail", cName + "SignalVsCocktail", 2100, 800);
1122 c->Divide(2, 1);
1123 c->cd(1);
1124 DrawTemperatureGraph(coc, step, 1.1, 2.5, true);
1125 DrawTextOnPad("Cocktail", 0.25, 0.9, 0.7, 0.99);
1126 c->cd(2);
1127 DrawTemperatureGraph(sig, step, 1.1, 2.5, true);
1128 DrawTextOnPad("Signal", 0.25, 0.9, 0.65, 0.99);
1129 }
1130
1131 // Temperature of Cocktail with different bin width variations
1132 {
1133 TH1D* cocO =
1134 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarOrig);
1135 TH1D* cocR =
1136 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarReg);
1137 TH1D* cocS =
1138 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarSig);
1139 TH1D* cocO2 =
1140 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarOrig);
1141 TH1D* cocR2 =
1142 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarReg);
1143 TH1D* cocS2 =
1144 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarSig);
1145
1146 TCanvas* c =
1147 fHMean.fHM.CreateCanvas(cName + "Cocktail/CheckCorrections", cName + "Cocktail/CheckCorrections", 3800, 1600);
1148 c->Divide(3, 2);
1149 c->SetGrid();
1150 c->cd(1);
1151 DrawTemperatureGraph(cocO, ELmvmAnaStep::ElId, 1.1, 2.5, false);
1152 DrawTextOnPad("Cocktail (#it{X} uncorrected)", 0.1, 0.9, 0.7, 0.99);
1153 c->cd(2);
1154 DrawTemperatureGraph(cocR, ELmvmAnaStep::ElId, 1.1, 2.5, false);
1155 DrawTextOnPad("Cocktail (#it{X} uncorrected)", 0.1, 0.9, 0.7, 0.99);
1156 c->cd(3);
1157 DrawTemperatureGraph(cocS, ELmvmAnaStep::ElId, 1.1, 2.5, false);
1158 DrawTextOnPad("Cocktail (#it{X} uncorrected)", 0.1, 0.9, 0.7, 0.99);
1159 c->cd(4);
1160 DrawTemperatureGraph(cocO2, ELmvmAnaStep::ElId, 1.1, 2.5, true);
1161 DrawTextOnPad("Cocktail (#it{X} corrected)", 0.11, 0.9, 0.69, 0.99);
1162 c->cd(5);
1163 DrawTemperatureGraph(cocR2, ELmvmAnaStep::ElId, 1.1, 2.5, true);
1164 DrawTextOnPad("Cocktail (#it{X} corrected)", 0.11, 0.9, 0.69, 0.99);
1165 c->cd(6);
1166 DrawTemperatureGraph(cocS2, ELmvmAnaStep::ElId, 1.1, 2.5, true);
1167 DrawTextOnPad("Cocktail (#it{X} corrected)", 0.11, 0.9, 0.69, 0.99);
1168 }
1169
1170 // Variation of Temperature in dep. on different Slopes (Cocktail)
1171 {
1172 TH1D* coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarOrig);
1173 TH1D* coc2 = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarOrig);
1174 TH1D* coc5 = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarOrig);
1175 TH1D* coc20 = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarOrig);
1176 coc->GetXaxis()->SetRangeUser(1e-10, 1e-1);
1177 coc2->GetXaxis()->SetRangeUser(1e-10, 1e-1);
1178 coc5->GetXaxis()->SetRangeUser(1e-10, 1e-1);
1179 coc20->GetXaxis()->SetRangeUser(1e-10, 1e-1);
1180 for (int iB = 1; iB <= coc->GetNbinsX(); iB++) {
1181 double m = coc->GetBinCenter(iB);
1182 double y0 = coc->GetBinContent(iB);
1183 double y2 = y0 * (1 + (2 - 1) * (m - 0.) / (2.5 - 0.));
1184 double y5 = y0 * (1 + (5 - 1) * (m - 0.) / (2.5 - 0.));
1185 double y20 = y0 * (1 + (20 - 1) * (m - 0.) / (2.5 - 0.));
1186 coc2->SetBinContent(iB, y2);
1187 coc5->SetBinContent(iB, y5);
1188 coc20->SetBinContent(iB, y20);
1189 }
1190 string cNameFull = cName + "Cocktail/" + "TempVsSlope";
1191 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 2200, 1600);
1192 c->Divide(2, 2);
1193 c->cd(1);
1194 gPad->SetGrid();
1195 DrawTemperatureGraph(coc, step, 1.3, 2.5);
1196 DrawTextOnPad("orig.", 0.67, 0.4, 0.85, 0.5);
1197 c->cd(2);
1198 gPad->SetGrid();
1199 DrawTemperatureGraph(coc2, step, 1.3, 2.5);
1200 DrawTextOnPad("f = 2", 0.67, 0.4, 0.85, 0.5);
1201 c->cd(3);
1202 gPad->SetGrid();
1203 DrawTemperatureGraph(coc5, step, 1.3, 2.5);
1204 DrawTextOnPad("f = 5", 0.67, 0.4, 0.85, 0.5);
1205 c->cd(4);
1206 gPad->SetGrid();
1207 DrawTemperatureGraph(coc20, step, 1.3, 2.5);
1208 DrawTextOnPad("f = 20", 0.67, 0.4, 0.87, 0.5);
1209 }
1210
1211 // Temperature for full and reduced Signal (with different fit ranges)
1212 {
1213 TH1D* hFull = fHMean.H1Clone("hSignal_bwvSig3_elid");
1214 TH1D* hRed = fHMean.H1Clone("hSignalReduced_bwvSig3_elid");
1215 TH1D* hRed2 = fHMean.H1Clone("hSignalReduced_bwvSig3_elid");
1216 hFull->GetYaxis()->SetRangeUser(1e-10, 5e-2);
1217 hRed->GetYaxis()->SetRangeUser(1e-10, 5e-2);
1218 hRed2->GetYaxis()->SetRangeUser(1e-10, 5e-2);
1219 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Signal/Signal", cName + "Signal/Signal", 3300, 800);
1220 c->Divide(3, 1);
1221 c->cd(1);
1222 DrawTemperatureGraph(hFull, step, 1.15, 2.5);
1223 DrawTextOnPad("Signal", 0.35, 0.9, 0.53, 0.99);
1224 c->cd(2);
1225 DrawTemperatureGraph(hRed, step, 1.15, 2.5);
1226 DrawTextOnPad("Reduced Signal", 0.28, 0.9, 0.6, 0.99);
1227 c->cd(3);
1228 DrawTemperatureGraph(hRed2, step, 1.05, 2.5);
1229 DrawTextOnPad("Reduced Signal", 0.28, 0.9, 0.6, 0.99);
1230 }
1231
1232 // Temperature for Signal histograms with different binnings (compared to Cocktail)
1233 {
1234 vector<pair<double, double>> bwv0 = {make_pair(1.1, 0.1), make_pair(1.5, 0.4), make_pair(2.5, 1.0)};
1235 vector<pair<double, double>> bwv1 = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.5, 1.0)};
1236 vector<pair<double, double>> bwv2 = {make_pair(1.1, 0.1), make_pair(1.5, 0.4), make_pair(2.5, 0.5)};
1237 vector<pair<double, double>> bwv3 = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.5, 0.5)};
1238 vector<pair<double, double>> bwv4 = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.0, 0.25),
1239 make_pair(2.5, 0.5)};
1240 vector<pair<double, double>> bwv5 = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.0, 0.25),
1241 make_pair(2.5, 0.25)};
1242 vector<pair<double, double>> bwv6 = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.0, 0.25),
1243 make_pair(2.5, 0.1)};
1244 TCanvas* c =
1245 fHMean.fHM.CreateCanvas("Temperature/Signal_bwVariations", "Temperature/Signal_bwVariations", 1900, 800);
1246 c->Divide(3, 2);
1247 int iC = 1;
1248 for (vector<pair<double, double>> bwv : {bwv1, bwv2, bwv3, bwv4, bwv5, bwv6}) {
1249 c->cd(iC++);
1250 TH1D* sig = GetSignal(step, bwv);
1251 DrawTemperatureGraph(sig, step, 1.1, 2.0);
1252 DrawTextOnPad("Signal", 0.38, 0.9, 0.62, 0.99);
1253 }
1254 }
1255
1256 // Draw Temperature for Signal with un-/corrected x-values
1257 {
1258 TH1D* h = fHMean.H1Clone("hSignal_bwvSig_elid");
1259 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Signal/BinCorrection", cName + "Signal/BinCorrection", 2100, 800);
1260 c->Divide(2, 1);
1261 c->cd(1);
1262 DrawTemperatureGraph(h, ELmvmAnaStep::ElId, 1.1, 2.5, false);
1263 DrawTextOnPad("Signal (uncorrected in #it{X})", 0.1, 0.9, 0.64, 0.99);
1264 c->cd(2);
1265 DrawTemperatureGraph(h, ELmvmAnaStep::ElId, 1.1, 2.5, true);
1266 DrawTextOnPad("Signal (corrected in #it{X})", 0.11, 0.9, 0.62, 0.99);
1267 }
1268
1269 // Plot phi to choose starting point for fitting range
1270 {
1271 TH1D* phiAcc = H(ELmvmSignal::Phi)->H1Clone("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::Acc);
1272 TH1D* phiElid = H(ELmvmSignal::Phi)->H1Clone("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId);
1273 TH1D* phiElid2 = (TH1D*) phiElid->Clone();
1274 phiElid2->GetXaxis()->SetRangeUser(1.0, 1.2);
1275 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Phi", cName + "Phi", 1600, 800);
1276 c->Divide(2, 1);
1277 c->cd(1);
1278 DrawH1({phiElid, phiAcc}, {"El-ID", "Acc"}, kLinear, kLog, true, 0.75, 0.78, 0.9, 0.9, "hist");
1279 c->cd(2);
1280 DrawH1({phiElid2}, {"El-ID zoom"}, kLinear, kLog, true, 0.67, 0.82, 0.9, 0.9, "hist");
1281 }
1282}
1283
1285{
1286 string cName = "ChargeSymmetry/";
1287
1288 // Master
1289 {
1291 vector<pair<double, double>> varbin = {make_pair(2.5, 0.05)};
1292 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "master", cName + "master", 1600, 2400);
1293 c->Divide(2, 3);
1294 int iC = 1;
1295 for (const string type : {"hmx", "hfsc"}) {
1296 for (const string ev : {"sameEv", "mixedEv"}) {
1297 if (type == "hmx" && ev == "mixedEv")
1298 varbin = fBwVarBg;
1299 else if (type == "hmx" && ev == "sameEv")
1300 varbin = fBwVarBg;
1301 string mode = (type == "hmx") ? "evmix" : "fastsim";
1302 string hName = type + "_" + "Minv";
1303 TH1D* pm = VaryBinWidth(mode, fHMean.GetName(hName + "PM_" + ev, step), varbin);
1304 TH1D* pp = VaryBinWidth(mode, fHMean.GetName(hName + "PP_" + ev, step), varbin);
1305 TH1D* mm = VaryBinWidth(mode, fHMean.GetName(hName + "MM_" + ev, step), varbin);
1306 int nBins = pm->GetNbinsX();
1307 TH1D* hr_ppmm = (TH1D*) pp->Clone();
1308 TH1D* hr_pppm = (TH1D*) pp->Clone();
1309 TH1D* hr_mmpm = (TH1D*) mm->Clone();
1310 hr_ppmm->Divide(mm);
1311 hr_pppm->Divide(pm);
1312 hr_mmpm->Divide(pm);
1313 int startbin = pm->FindBin(0.7);
1314 double Ipm = pm->Integral(startbin, nBins);
1315 double Ipp = pp->Integral(startbin, nBins);
1316 double Imm = mm->Integral(startbin, nBins);
1317 double r_ppmm = Ipp / Imm;
1318 double r_pppm = Ipp / Ipm;
1319 double r_mmpm = Imm / Ipm;
1320 double k = Ipm / (2 * std::sqrt(Ipp * Imm));
1321 string sr_ppmm = Cbm::NumberToString(r_ppmm, 2);
1322 string sr_pppm = Cbm::NumberToString(r_pppm, 2);
1323 string sr_mmpm = Cbm::NumberToString(r_mmpm, 2);
1324 string s_k = Cbm::NumberToString(k, 2);
1325 c->cd(iC++);
1326 hr_ppmm->GetYaxis()->SetTitle("Ratio");
1327 hr_ppmm->GetYaxis()->SetRangeUser(0., 1.5);
1328 string texttype = (type == "hmx") ? "Simulation" : "FastSim";
1329 string textmode = (ev == "sameEv") ? "(same Events)" : "(mixed Events)";
1330 DrawH1({hr_ppmm, hr_pppm, hr_mmpm}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, 0.2, 0.6, 0.38, 0.85,
1331 "hist");
1332 //DrawTextOnPad("N++/N-- = " + sr_ppmm + ", N+-/(2 #sqrt{N++ N--}) = " + s_k, 0.05, 0.12, 0.89, 0.25);
1333 DrawTextOnPad(texttype + " " + textmode, 0.1, 0.9, 0.9, 0.99);
1334 }
1335 }
1336 TH1D* bre = VaryBinWidth("mean", fHMean.GetName("hfsc_MinvBg", step), fBwVarBg);
1337 TH1D* cbc = VaryBinWidth("mean", fHMean.GetName("hCbBg", step), fBwVarBg);
1338 TH1D* cbre = VaryBinWidth("mean", "hReCb", fBwVarBg);
1339 TH1D* hr_cbc_bre = (TH1D*) cbc->Clone();
1340 TH1D* hr_cbre_bre = (TH1D*) cbre->Clone();
1341 hr_cbc_bre->Divide(bre);
1342 hr_cbre_bre->Divide(bre);
1343 int nBins = bre->GetNbinsX();
1344 int startbin = bre->FindBin(0.7);
1345 double I_bre = bre->Integral(startbin, nBins);
1346 double I_cbc = cbc->Integral(startbin, nBins);
1347 double I_cbre = cbre->Integral(startbin, nBins);
1348 double r_cbc_bre = I_cbc / I_bre;
1349 double r_cbre_bre = I_cbre / I_bre;
1350 string sr_cbc_bre = Cbm::NumberToString(r_cbc_bre, 2);
1351 string sr_cbre_bre = Cbm::NumberToString(r_cbre_bre, 2);
1352 c->cd(iC++);
1353 DrawH1({hr_cbc_bre, hr_cbre_bre}, {"CB_{Sim} / B_{FS}", "CB_{FS} / B_{FS}"}, kLinear, kLinear, true, 0.6, 0.7, 0.92,
1354 0.91, "hist");
1355 DrawTextOnPad("CB_{Sim} / B_{FS} = " + sr_cbc_bre + ", CB_{FS} / B_{FS} = " + sr_cbre_bre, 0.08, 0.12, 0.89, 0.25);
1356 }
1357
1358 // Ratios of Backgrounds with Charge Symmetries from Simulation
1359 for (const string cat : {""}) { // , "_trueEl"}) { // TODO: ReCb not yet available for true electrons
1360 TH1D* bre = VaryBinWidth("mean", "hfsc_MinvBg" + cat + "_elid", fBwVarBg);
1361 TH1D* cbc = VaryBinWidth("mean", "hCbBg" + cat + "_elid", fBwVarBg);
1362 TH1D* cbre = VaryBinWidth("mean", "hReCb", fBwVarBg);
1363 TH1D* rat1 = (TH1D*) cbc->Clone();
1364 rat1->Divide(bre);
1365 TH1D* rat2 = (TH1D*) cbre->Clone();
1366 rat2->Divide(bre);
1367 rat1->GetYaxis()->SetTitle("Ratio");
1368 rat2->GetYaxis()->SetTitle("Ratio");
1369 rat1->GetYaxis()->SetRangeUser(0.95, 1.05);
1370 rat2->GetYaxis()->SetRangeUser(0.95, 1.05);
1371 string cNameFull = (cat == "") ? cName + "ReCb_all" : cName + "ReCb_trueEl";
1372 string label = (cat == "") ? "(all)" : "(electrons)";
1373 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1600, 1600);
1374 c->Divide(2, 2);
1375 c->cd(1);
1376 DrawH1({rat1}, {"CB_{calc} / B_{FS}"}, kLinear, kLinear, true, 0.7, 0.8, 0.95, 0.9, "hist");
1377 DrawTextOnPad("Ratio " + label, 0.2, 0.9, 0.8, 0.99);
1378 c->cd(2);
1379 if (cat == "") DrawH1({rat2}, {"CB_{FS} / B_{FS}"}, kLinear, kLinear, true, 0.7, 0.8, 0.95, 0.9, "hist");
1380 DrawTextOnPad("Ratio " + label, 0.2, 0.9, 0.8, 0.99);
1381 int iC = 3;
1382 for (const string ev : {"sameEv", "mixedEv"}) {
1383 vector<pair<double, double>> varbin = fBwVarBg4;
1384 if (ev == "mixedEv") varbin = fBwVarBg3;
1385 TH1D* pm = VaryBinWidth("evmix", "hmx_MinvPM" + cat + "_" + ev + "_elid", varbin);
1386 TH1D* pp = VaryBinWidth("evmix", "hmx_MinvPP" + cat + "_" + ev + "_elid", varbin);
1387 TH1D* mm = VaryBinWidth("evmix", "hmx_MinvMM" + cat + "_" + ev + "_elid", varbin);
1388 TH1D* ppmm = (TH1D*) pp->Clone();
1389 TH1D* pppm = (TH1D*) pp->Clone();
1390 TH1D* mmpm = (TH1D*) mm->Clone();
1391 ppmm->Divide(mm);
1392 pppm->Divide(pm);
1393 mmpm->Divide(pm);
1394 ppmm->GetYaxis()->SetTitle("Ratio");
1395 ppmm->GetYaxis()->SetRangeUser(0., 1.6);
1396 c->cd(iC++);
1397 DrawH1({ppmm, pppm, mmpm}, {"N--/N++", "N++/N+-", "N--/N+-"}, kLinear, kLinear, true, 0.77, 0.77, 0.95, 0.95,
1398 "hist");
1399 string title = (ev == "sameEv") ? "Same Events" : "Mixed Events";
1400 DrawTextOnPad(title, 0.2, 0.9, 0.8, 0.99);
1401 }
1402 }
1403
1404 // B_RE vs. CB_RE Ratios with Pair Yields from Fast Simulations
1405 {
1406 string hName = "hfsc_Minv";
1408 TH1D* pmSame = fHFastSim.H1Clone(hName + "PM_sameEv", step);
1409 TH1D* ppSame = fHFastSim.H1Clone(hName + "PP_sameEv", step);
1410 TH1D* mmSame = fHFastSim.H1Clone(hName + "MM_sameEv", step);
1411 TH1D* pmMixed = fHFastSim.H1Clone(hName + "PM_mixedEv", step);
1412 TH1D* ppMixed = fHFastSim.H1Clone(hName + "PP_mixedEv", step);
1413 TH1D* mmMixed = fHFastSim.H1Clone(hName + "MM_mixedEv", step);
1414 TH1D* bre = fHMean.H1Clone("hfsc_MinvBg", step);
1415 TH1D* cbre = fHMean.H1Clone("hReCb");
1416 TH1D* k = fHMean.H1Clone("hReCbK");
1417 TH1D* rat = (TH1D*) cbre->Clone();
1418 rat->Divide(bre);
1419 rat->GetYaxis()->SetTitle("Ratio");
1420 rat->GetYaxis()->SetRangeUser(0.95, 1.05);
1421 string cNameFull = cName + "FastSim";
1422 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1600, 1600);
1423 c->Divide(2, 2);
1424 c->cd(1);
1425 DrawH1({pmSame, ppSame, mmSame}, {"e+e-", "e+e+", "e-e-"}, kLinear, kLog, true, 0.7, 0.7, 0.91, 0.9, "hist");
1426 DrawTextOnPad("Pair Yields (Same Events)", 0.2, 0.9, 0.8, 0.99);
1427 c->cd(2);
1428 DrawH1({pmMixed, ppMixed, mmMixed}, {"e+e-", "e+e+", "e-e-"}, kLinear, kLog, true, 0.7, 0.7, 0.91, 0.9, "hist");
1429 DrawTextOnPad("Pair Yields (Mixed Events)", 0.19, 0.9, 0.81, 0.99);
1430 c->cd(3);
1431 DrawH1(k, kLinear, kLinear, "hist");
1432 DrawTextOnPad("#it{k} Factor", 0.3, 0.9, 0.7, 0.99);
1433 c->cd(4);
1434 DrawH1({rat}, {"CB_{FS} / B_{FS}"}, kLinear, kLinear, true, 0.7, 0.8, 0.91, 0.9, "hist");
1435 DrawTextOnPad("Ratio", 0.1, 0.9, 0.84, 0.99);
1436 }
1437}
1438
1439void LmvmDrawAll::DrawStudies() // Comment procedures which currently are not necessary
1440{
1441 string cName = "Studies/";
1442
1443 // Restricted vs. full RICH: Pt-Y
1444 {
1446 LmvmHist HMfull, HMrestr;
1447
1448 TFile* fileFull =
1449 new TFile("/lustre/cbm/users/criesen/data/studies/FullVsRestrRich/lmvm_fullRich/inmed/analysis.all.root");
1450 HMfull.fHM.ReadFromFile(fileFull);
1451 double nEvFull = HMfull.H1("hEventNumber")->GetEntries();
1452 TH2D* hFullInmed = HMfull.H2Clone("hPtY_plutoEl+", step);
1453 hFullInmed->Add(HMfull.H2("hPtY_plutoEl-", step));
1454 TH2D* hFullEl = HMfull.H2Clone("hPtY_urqmdEl+", step);
1455 hFullEl->Add(HMfull.H2("hPtY_urqmdEl-", step));
1456 TH2D* hFullPi = HMfull.H2Clone("hPtY_pion+", step);
1457 hFullPi->Add(HMfull.H2("hPtY_pion-", step));
1458 hFullInmed->Scale(1. / nEvFull);
1459 hFullEl->Scale(1. / nEvFull);
1460 hFullPi->Scale(1. / nEvFull);
1461
1462 TFile* fileRest =
1463 new TFile("/lustre/cbm/users/criesen/data/studies/FullVsRestrRich/lmvm_restRich/inmed/analysis.all.root");
1464 HMrestr.fHM.ReadFromFile(fileRest);
1465 double nEvRest = HMrestr.H1("hEventNumber")->GetEntries();
1466 TH2D* hRestInmed = HMrestr.H2Clone("hPtY_plutoEl+", step);
1467 hRestInmed->Add(HMrestr.H2("hPtY_plutoEl-", step));
1468 TH2D* hRestEl = HMrestr.H2Clone("hPtY_urqmdEl+", step);
1469 hRestEl->Add(HMrestr.H2("hPtY_urqmdEl-", step));
1470 TH2D* hRestPi = HMrestr.H2Clone("hPtY_pion+", step);
1471 hRestPi->Add(HMrestr.H2("hPtY_pion-", step));
1472 hRestInmed->Scale(1. / nEvRest);
1473 hRestEl->Scale(1. / nEvRest);
1474 hRestPi->Scale(1. / nEvRest);
1475
1476 DrawPtY(hFullInmed, hRestInmed, cName + "/FullVsRestrRich/inmed", 1e-9, 1e-3);
1477 DrawPtY(hFullEl, hRestEl, cName + "/FullVsRestrRich/electrons", 1e-9, 1e-3);
1478 DrawPtY(hFullPi, hRestPi, cName + "/FullVsRestrRich/pions", 1e-9, 1e-3);
1479 }
1480}
1481
1482void LmvmDrawAll::DrawPtY(TH2D* hMc, TH2D* h, const string cName, double zMin, double zMax)
1483{
1484 TH2D* eff = (TH2D*) h->Clone();
1485 eff->Divide(hMc);
1486 hMc->GetZaxis()->SetRangeUser(zMin, zMax);
1487 h->GetZaxis()->SetRangeUser(zMin, zMax);
1488 eff->GetZaxis()->SetRangeUser(0., 2.);
1489 double e = h->Integral(0, h->GetXaxis()->GetNbins() + 1, 0, h->GetYaxis()->GetNbins() + 1)
1490 / hMc->Integral(0, h->GetXaxis()->GetNbins() + 1, 0, h->GetYaxis()->GetNbins() + 1);
1491 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 2400, 800);
1492 c->Divide(3, 1);
1493 c->cd(1);
1494 DrawH2(hMc, kLinear, kLinear, kLog, "colz");
1495 c->cd(2);
1496 DrawH2(h, kLinear, kLinear, kLog, "colz");
1497 c->cd(3);
1498 DrawH2(eff, kLinear, kLinear, kLinear, "colz");
1499 DrawTextOnPad("Efficiency", 0.25, 0.9, 0.75, 0.99);
1500 DrawTextOnPad("Eff = " + Cbm::NumberToString(e, 2), 0.42, 0.8, 0.75, 0.9);
1501}
1502
1504{
1506 string cName = "PtY/";
1507 // UrQMD
1508 for (const string& ptcl : fHMean.fCandNames) {
1509 if (ptcl == fHMean.fCandNames[0] || ptcl == fHMean.fCandNames[1]) continue;
1510 TH2D* hMc = fHMean.H2Clone("hPtY_" + ptcl, ELmvmAnaStep::Mc);
1511 TH2D* h = fHMean.H2Clone("hPtY_" + ptcl, step);
1512 DrawPtY(hMc, h, cName + ptcl, 1e-10, 1e2);
1513 }
1514
1515 // PLUTO
1516 for (ELmvmSignal signal : fHMean.fSignals) {
1517 TH2D* hMcP = H(signal)->H2Clone("hPtY_plutoEl+", ELmvmAnaStep::Mc);
1518 TH2D* hMcM = H(signal)->H2Clone("hPtY_plutoEl-", ELmvmAnaStep::Mc);
1519 TH2D* hMc = (TH2D*) hMcP->Clone();
1520 hMc->Add(hMcM);
1521
1522 TH2D* hP = H(signal)->H2Clone("hPtY_plutoEl+", step);
1523 TH2D* hM = H(signal)->H2Clone("hPtY_plutoEl-", step);
1524 TH2D* h = (TH2D*) hP->Clone();
1525 h->Add(hM);
1526
1527 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
1528 DrawPtY(hMcP, hP, cName + sigName + "_plutoEl+", 1e-10, 1e2);
1529 DrawPtY(hMcM, hM, cName + sigName + "_plutoEl-", 1e-10, 1e2);
1530 DrawPtY(hMc, h, cName + sigName, 1e-10, 1e2);
1531 }
1532}
1533
1534TH1D* LmvmDrawAll::VaryBinWidth(const string& option, const string& hName, ELmvmAnaStep step,
1535 vector<pair<double, double>> binValues)
1536{
1537 TH1D* h = VaryBinWidth(option, fHMean.GetName(hName, step), -1., binValues);
1538 return h;
1539}
1540
1541TH1D* LmvmDrawAll::VaryBinWidth(const string& option, const string& hName, vector<pair<double, double>> binValues)
1542{
1543 TH1D* h = VaryBinWidth(option, hName, -1., binValues);
1544 return h;
1545}
1546
1547TH1D* LmvmDrawAll::VaryBinWidth(TH1D* h, vector<pair<double, double>> binValues) // pair(edge, bW)
1548{
1549 TH1D* hVar = VaryBinWidth(h, -1., binValues);
1550 return hVar;
1551}
1552
1553TH1D* LmvmDrawAll::VaryBinWidth(const string& option, const string& hName, ELmvmAnaStep step, double nEvents,
1554 vector<pair<double, double>> binValues)
1555{
1556 TH1D* h = VaryBinWidth(option, fHMean.GetName(hName, step), nEvents, binValues);
1557 return h;
1558}
1559
1560TH1D* LmvmDrawAll::VaryBinWidth(const string& option, const string& hName, double nEvents,
1561 vector<pair<double, double>> binValues)
1562{
1563 if (option != "mean" && option.find("cocktail_") == string::npos && option != "fastsim" && option != "evmix"
1564 && option != "inmed" && option != "omegaepem" && option != "omegadalitz" && option != "phi" && option != "qgp") {
1565 LOG(error) << "LmvmDrawAll::VaryBinWidth: No option " << option << " available!";
1566 return nullptr;
1567 }
1568
1569 TH1D* h;
1570
1571 if (option == "mean")
1572 h = fHMean.H1Clone(hName);
1573 else if (option == "fastsim")
1574 h = fHFastSim.H1Clone(hName);
1575 else if (option == "evmix")
1576 h = fHEvMix.H1Clone(hName);
1577 else if (option.find("cocktail_") != string::npos) {
1578 if (hName != "") LOG(info) << "LmvmDrawAll::VaryBinWidth: hName '" << hName << "' will be ignored.";
1579 ELmvmAnaStep step;
1580 vector<string> optsplit = Split(option, '_');
1581 string stepName = optsplit[optsplit.size() - 1];
1582 if (stepName == fHMean.fAnaStepNames[0])
1583 step = ELmvmAnaStep::Mc;
1584 else if (stepName == fHMean.fAnaStepNames[1])
1585 step = ELmvmAnaStep::Reco;
1586 else if (stepName == fHMean.fAnaStepNames[2])
1587 step = ELmvmAnaStep::Acc;
1588 else if (stepName == fHMean.fAnaStepNames[3])
1590 else if (stepName == fHMean.fAnaStepNames[4])
1591 step = ELmvmAnaStep::ElId;
1592 else if (stepName == fHMean.fAnaStepNames[5])
1594 else if (stepName == fHMean.fAnaStepNames[6])
1595 step = ELmvmAnaStep::Mvd1Cut;
1596 else if (stepName == fHMean.fAnaStepNames[7])
1597 step = ELmvmAnaStep::Mvd2Cut;
1598 else if (stepName == fHMean.fAnaStepNames[8])
1599 step = ELmvmAnaStep::StCut;
1600 else if (stepName == fHMean.fAnaStepNames[9])
1601 step = ELmvmAnaStep::RtCut;
1602 else if (stepName == fHMean.fAnaStepNames[10])
1603 step = ELmvmAnaStep::TtCut;
1604 else if (stepName == fHMean.fAnaStepNames[11])
1605 step = ELmvmAnaStep::PtCut;
1606 else {
1607 LOG(error) << "LmvmDrawAll::VaryBinWidth: Step name '" << stepName
1608 << "' not available in LmvmHist::fAnaStepNames!";
1609 return nullptr;
1610 }
1611 string hNameCoc; // corrected this on 8.7.24
1612 if (option.find("_trueEl") != string::npos)
1613 hNameCoc = "hMinv_trueEl";
1614 else if (option.find("_urqmdAll") != string::npos)
1615 hNameCoc = "hMinv_urqmdAll";
1616 else if (option.find("_urqmdEl") != string::npos)
1617 hNameCoc = "hMinv_urqmdEl";
1618 else
1619 hNameCoc = "hMinv";
1620 h = GetCocktailMinvH1(hNameCoc, step, false);
1621 }
1622 else {
1624 if (option == "omegaepem")
1625 signal = ELmvmSignal::Omega;
1626 else if (option == "omegadalitz")
1627 signal = ELmvmSignal::OmegaD;
1628 else if (option == "phi")
1629 signal = ELmvmSignal::Phi;
1630 else if (option == "qgp")
1631 signal = ELmvmSignal::Qgp;
1632 h = H(signal)->H1Clone(hName);
1633 h->Scale(1. / h->GetBinWidth(1));
1634 }
1635 TH1D* hVar = VaryBinWidth(h, nEvents, binValues);
1636 // TODO at this place: Scale Pluto histograms! Otherwise it has to be done by hand every time when called.
1637 h->Delete();
1638 return hVar;
1639}
1640
1641TH1D* LmvmDrawAll::VaryBinWidth(TH1D* h, double nEvents, vector<pair<double, double>> binValues) // pair(edge, bW)
1642{
1643 string hName = h->GetName();
1644
1645 // Check if histogram is one-dimensional
1646 if (h->GetDimension() != 1) {
1647 LOG(error) << "LmvmDrawAll::VaryBinWidth: Histogram '" << hName << "' is not one dimensional!";
1648 return nullptr;
1649 }
1650 double bW0 = h->GetXaxis()->GetBinWidth(1);
1651
1652 // Check if histogram has uniform bin width
1653 for (int iB = 2; iB <= h->GetNbinsX(); iB++) {
1654 if (h->GetBinWidth(iB) != bW0) {
1655 LOG(error) << "LmvmDrawAll::VaryBinWidth: name = " << hName << ": Bin width is not uniform!";
1656 return nullptr;
1657 }
1658 }
1659
1660 // Check if values of 'binValues' are integer multiple of origin histogram
1661 for (size_t iV = 0; iV < binValues.size(); iV++) {
1662 if ((int) (1000 * binValues[iV].first) % (int) (1000 * bW0) != 0
1663 || (int) (1000 * binValues[iV].second) % (int) (1000 * bW0) != 0) {
1664 LOG(error) << "LmvmDrawAll::VaryBinWidth: name = " << hName
1665 << ": At least one value of 'binValues' is not multiple integer of origin bin width!";
1666 return nullptr;
1667 }
1668 if (iV > 0) {
1669 if (((int) (1000 * binValues[iV].first) - (int) (1000 * binValues[iV - 1].first))
1670 % (int) (1000 * binValues[iV].second)
1671 != 0) {
1672 LOG(error) << "LmvmDrawAll::VaryBinWidth: name = " << hName
1673 << ": Between at least two edges of different bin widths the bin width misfits its according range!";
1674 return nullptr;
1675 }
1676 }
1677 }
1678
1679 // Create and fill vector for bin edges from binValues
1680 double xMin = h->GetXaxis()->GetBinLowEdge(1);
1681 double xMax = binValues[binValues.size() - 1].first;
1682 double xVal = xMin;
1683 double xUpLast = xMin; // upper edge of previous section
1684 int iBV = 0;
1685 int n = 1;
1686 vector<double> binEdges;
1687 binEdges.clear();
1688 binEdges.push_back(xVal);
1689 while (xVal <= xMax) {
1690 double bW = binValues[iBV].second;
1691 xVal = xUpLast + n * bW;
1692 n++;
1693 binEdges.push_back(xVal);
1694 if (xVal >= xMax) break;
1695 if (IsCloseTo(xVal, binValues[iBV].first, bW / 1e6)) {
1696 iBV++;
1697 xUpLast = binValues[iBV - 1].first;
1698 n = 1;
1699 }
1700 }
1701
1702 // New histogram with new bin edges
1703 fBwVarCounter++;
1704 string hNameFull = hName + "_var" + Cbm::NumberToString(fBwVarCounter, 0);
1705 TH1D* hVar = new TH1D(hNameFull.c_str(), hNameFull.c_str(), binEdges.size() - 1, binEdges.data());
1706 hVar->GetXaxis()->SetTitle(h->GetXaxis()->GetTitle());
1707 hVar->GetYaxis()->SetTitle(h->GetYaxis()->GetTitle());
1708
1709 iBV = 0;
1710 xVal = xMin;
1711 int iBinH0 = 1;
1712 for (int iBinVar = 1; iBinVar <= hVar->GetNbinsX(); iBinVar++) {
1713 double bWNew = binValues[iBV].second;
1714 int f = bWNew / bW0;
1715 double con = 0.;
1716 double lim = iBinH0 + f - 1;
1717 double N = 0.;
1718
1719 for (int iB0 = iBinH0; iB0 <= lim; iB0++) {
1720 con += h->GetBinContent(iB0) / f;
1721 xVal += bW0;
1722 iBinH0++;
1723 if (nEvents > 0) N += h->GetBinContent(iB0) * bW0 * nEvents;
1724 if (xVal >= binValues[iBV].first) iBV++;
1725 }
1726 double error = std::sqrt(N) / (bWNew * nEvents);
1727 hVar->SetBinContent(iBinVar, con);
1728 if (nEvents > 0) hVar->SetBinError(iBinVar, error);
1729 }
1730
1731 // Insert error for cocktail (necessary for temperature plots)
1732 /*if (hName.find("hMinv_signal_") != string::npos && hName.find("_cocktail") != string::npos) {
1733 for (int iB = 1; iB <= hVar->GetNbinsX(); iB++) {
1734 double bW = hVar->GetBinWidth(iB);
1735 double c = hVar->GetBinContent(iB);
1736 double N = c * (fNofFastSimEvents/5.) * bW; // 5: number of signals
1737 double e = std::sqrt(N)/(fNofFastSimEvents/5.);
1738 hVar->SetBinError(iB, e);
1739 }
1740 }*/
1741 return hVar;
1742}
1743
1744bool LmvmDrawAll::IsCloseTo(double value, double refValue, double tol)
1745{
1746 return (value >= refValue - tol && value <= refValue + tol);
1747}
1748
1750{
1751 string cName = "CheckVaryBinWidth/";
1752 vector<pair<double, double>> binValues = {make_pair(0.8, 0.05), make_pair(1.5, 0.1), make_pair(2.5, 0.5)};
1754
1755 // Single contributions
1756 {
1757 TH1D* bg = fHMean.H1Clone("hCbBg", ELmvmAnaStep::ElId);
1758 TH1D* bg2 = VaryBinWidth("mean", fHMean.GetName("hCbBg", ELmvmAnaStep::ElId), binValues);
1760 TH1D* inmed2 = VaryBinWidth("inmed", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), binValues);
1761
1762 inmed->Scale(1. / H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries());
1763 inmed->Scale(1. / inmed->GetBinWidth(1));
1764 inmed2->Scale(1. / H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries());
1765
1766 bg->GetYaxis()->SetRangeUser(1e-7, 2e-2);
1767 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "single", cName + "single", 1600, 800);
1768 c->Divide(2, 1);
1769 c->cd(1);
1770 DrawH1({bg, bg2}, {"CB_{calc}", "CB_{calc}2"}, kLinear, kLog, true, 0.8, 0.8, 0.95, 0.91, "pe");
1771 c->cd(2);
1772 DrawH1({inmed, inmed2}, {"inmed", "inmed2"}, kLinear, kLog, true, 0.8, 0.8, 0.95, 0.91, "pe");
1773 }
1774
1775 // Minv spectra
1776 {
1777 TCanvas* c1 = fHMean.fHM.CreateCanvas(cName + "minv", cName + "minv", 1600, 800);
1778 c1->Divide(2, 1);
1779 c1->cd(1);
1780 TH1D* bgO = fHMean.H1Clone("hMinv", ELmvmSrc::Bg, step);
1781 TH1D* pi0O = fHMean.H1Clone("hMinv", ELmvmSrc::Pi0, step);
1782 TH1D* etaO = fHMean.H1Clone("hMinv", ELmvmSrc::Eta, step);
1783 TH1D* gammaO = fHMean.H1Clone("hMinv", ELmvmSrc::Gamma, step);
1784 TH1D* cocktailO = GetCocktailMinvH1("hMinv", step, false);
1785 TH1D* sbgO = static_cast<TH1D*>(bgO->Clone());
1786 sbgO->Add(cocktailO);
1787 TH1D* cbO = nullptr;
1788 //TH1D* cbSame = nullptr;
1789 if (step == ELmvmAnaStep::ElId) {
1790 cbO = fHMean.H1Clone("hCbBg", step);
1791 //cbSame = fHMean.H1Clone("hCbBgSame", step);
1792 }
1793
1794 double binWidth = bgO->GetBinWidth(1);
1795 vector<TH1D*> sHists(fHMean.fNofSignals);
1796 for (ELmvmSignal signal : fHMean.fSignals) {
1797 TH1D* sHist = H(signal)->H1Clone("hMinv", ELmvmSrc::Signal, step);
1798 sHist->Scale(1. / H(signal)->H1("hEventNumber")->GetEntries());
1799 sHist->Rebin(fRebinMinv);
1800 sHist->Scale(1. / binWidth);
1801 sHists[static_cast<int>(signal)] = sHist;
1802 }
1803
1804 vector<LmvmDrawMinvData> drawData;
1805 if (step >= ELmvmAnaStep::Reco) {
1806 drawData.emplace_back(sbgO, kBlack, kBlack, 1, -1, "Cocktail+B_{MC}");
1807 drawData.emplace_back(bgO, kGray, kBlack, 1, -1, "B_{MC}");
1808 }
1809
1810 drawData.emplace_back(pi0O, kGreen - 3, kGreen + 3, 2, -1, "#pi^{0} #rightarrow #gammae^{+}e^{-}");
1811 drawData.emplace_back(etaO, kRed - 4, kRed + 2, 2, -1, "#eta #rightarrow #gammae^{+}e^{-}");
1812 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::OmegaD)], kCyan + 2, kCyan + 4, 2, -1,
1813 "#omega #rightarrow #pi^{0}e^{+}e^{-}");
1814 drawData.emplace_back(gammaO, -1, kYellow, 4, -1, "#gamma #rightarrow e^{+}e^{-}");
1815 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Omega)], kOrange + 7, kOrange + 4, 2, -1,
1816 "#omega #rightarrow e^{+}e^{-}");
1817 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Phi)], kAzure + 2, kAzure + 3, 2, -1,
1818 "#phi #rightarrow e^{+}e^{-}");
1819 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Qgp)], kOrange - 2, kOrange - 3, 4, 3112,
1820 "QGP radiation");
1821 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Inmed)], kMagenta - 3, kMagenta - 2, 4, 3018,
1822 "in-medium #rho");
1823 drawData.emplace_back(cocktailO, -1, kRed + 2, 4, -1, "Cocktail");
1824 if (step >= ELmvmAnaStep::ElId) {
1825 drawData.emplace_back(cbO, -1, kCyan + 1, 4, -1, "CB_{calc}");
1826 //drawData.emplace_back(cbSame, -1, kCyan, 4, -1, "B_{calc} (same only)");
1827 }
1828
1829 TH1D* h0 = nullptr;
1830 TLegend* leg = new TLegend(0.72, 0.55, 0.97, 0.99);
1831 for (size_t i = 0; i < drawData.size(); i++) {
1832 const auto& d = drawData[i];
1833 d.fH->GetYaxis()->SetLabelSize(0.04);
1834 if (step >= ELmvmAnaStep::ElId)
1835 d.fH->GetYaxis()->SetRangeUser(5e-10, 5e-2);
1836 else
1837 d.fH->GetYaxis()->SetRangeUser(5e-10, 1e2);
1838 if (d.fFillColor != -1) d.fH->SetFillColor(d.fFillColor);
1839 if (d.fFillStyle != -1) d.fH->SetFillStyle(d.fFillStyle);
1840 leg->AddEntry(d.fH, d.fLegend.c_str(), "f");
1841 DrawH1(d.fH, kLinear, kLog, (h0 == nullptr) ? "hist" : "hist,same", d.fLineColor, d.fLineWidth, 0);
1842 if (h0 == nullptr) h0 = d.fH;
1843 }
1844 fHMean.DrawAnaStepOnPad(step);
1845
1846 leg->SetFillColor(kWhite);
1847 leg->Draw();
1848 gPad->SetLogy(true);
1849
1850 c1->cd(2);
1851 DrawMinv(step);
1852 fHMean.DrawAnaStepOnPad(step);
1853 }
1854
1855 // Signal
1856 {
1857 TH1D* bre = fHFastSim.H1Clone("hfsc_MinvBg_elid");
1858 TH1D* cbc = fHMean.H1Clone("hCbBg_elid");
1859 TH1D* coc = GetCocktailMinvH1("hMinv", step, false);
1860 TH1D* sig = (TH1D*) bre->Clone();
1861 sig->Add(coc);
1862 sig->Add(cbc, -1.);
1863 TH1D* sig2 = (TH1D*) sig->Clone();
1864 TH1D* sig5 = (TH1D*) sig->Clone();
1865 TH1D* sig10 = (TH1D*) sig->Clone();
1866 TH1D* sig25 = (TH1D*) sig->Clone();
1867 sig2->Rebin(2);
1868 sig5->Rebin(5);
1869 sig10->Rebin(10);
1870 sig25->Rebin(25);
1871 sig2->Scale(1. / 2.);
1872 sig5->Scale(1. / 5.);
1873 sig10->Scale(1. / 10.);
1874 sig25->Scale(1. / 25.);
1875 fHMean.fHM.CreateCanvas(cName + "Signal", cName + "Signal", 800, 800);
1876 DrawH1({coc, sig2, sig5, sig10, sig25}, {"Cocktail", "Signal2", "Signal5", "Signal10", "Signal25"}, kLinear, kLog,
1877 true, 0.7, 0.8, 0.95, 0.91, "hist");
1878 }
1879
1880 // Ratios of Background Pair PDGs
1881 {
1882 vector<double> v_pm, v_pp, v_mm, v_pm_el, v_pp_el, v_mm_el; // for charge symmetries
1883 for (const string comb : {"PM", "PP", "MM"}) {
1884 for (int iMinv = 0; iMinv <= 24; iMinv++) {
1885 string hName = "hBgPairPdg" + comb + "_pMc_" + Cbm::NumberToString(iMinv, 0);
1886 TH2D* h = fHMean.H2Clone(hName);
1887 double I = h->Integral(1, h->GetNbinsX(), 1, h->GetNbinsX());
1888 double ITrue = h->Integral(1, 4, 1, 4);
1889 if (comb == "PM") {
1890 v_pm.push_back(I);
1891 v_pm_el.push_back(ITrue);
1892 }
1893 else if (comb == "PP") {
1894 v_pp.push_back(I);
1895 v_pp_el.push_back(ITrue);
1896 }
1897 else if (comb == "MM") {
1898 v_mm.push_back(I);
1899 v_mm_el.push_back(ITrue);
1900 }
1901 }
1902 }
1903 // Histograms for charge symmetries
1904 TH1D* hSymm_ppmm = new TH1D("hSymm_ppmm-vb", "hSymm_ppmm-vb; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
1905 TH1D* hSymm_pppm = new TH1D("hSymm_pppm-vb", "hSymm_pppm-vb; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
1906 TH1D* hSymm_mmpm = new TH1D("hSymm_mmpm-vb", "hSymm_mmpm-vb; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
1907 for (int iB = 1; iB <= hSymm_ppmm->GetNbinsX(); iB++) {
1908 double ppmm = v_pp[iB - 1] / v_mm[iB - 1];
1909 double pppm = v_pp[iB - 1] / v_pm[iB - 1];
1910 double mmpm = v_mm[iB - 1] / v_pm[iB - 1];
1911 hSymm_ppmm->SetBinContent(iB, ppmm);
1912 hSymm_pppm->SetBinContent(iB, pppm);
1913 hSymm_mmpm->SetBinContent(iB, mmpm);
1914 }
1915 TH1D* hSymm_ppmm5 = (TH1D*) hSymm_ppmm->Clone();
1916 TH1D* hSymm_pppm5 = (TH1D*) hSymm_pppm->Clone();
1917 TH1D* hSymm_mmpm5 = (TH1D*) hSymm_mmpm->Clone();
1918 hSymm_ppmm5->Rebin(5);
1919 hSymm_pppm5->Rebin(5);
1920 hSymm_mmpm5->Rebin(5);
1921 hSymm_ppmm5->Scale(1. / 5.);
1922 hSymm_pppm5->Scale(1. / 5.);
1923 hSymm_mmpm5->Scale(1. / 5.);
1924 vector<pair<double, double>> varbin5 = {make_pair(2.5, 0.5)};
1925 TH1D* hSymm_ppmmVReg = VaryBinWidth(hSymm_ppmm, fBwVarReg);
1926 TH1D* hSymm_pppmVReg = VaryBinWidth(hSymm_pppm, fBwVarReg);
1927 TH1D* hSymm_mmpmVReg = VaryBinWidth(hSymm_mmpm, fBwVarReg);
1928 TH1D* hSymm_ppmmVBg3 = VaryBinWidth(hSymm_ppmm, varbin5);
1929 TH1D* hSymm_pppmVBg3 = VaryBinWidth(hSymm_pppm, varbin5);
1930 TH1D* hSymm_mmpmVBg3 = VaryBinWidth(hSymm_mmpm, varbin5);
1931 TH1D* hSymm_ppmmVBg4 = VaryBinWidth(hSymm_ppmm, fBwVarBg4);
1932 TH1D* hSymm_pppmVBg4 = VaryBinWidth(hSymm_pppm, fBwVarBg4);
1933 TH1D* hSymm_mmpmVBg4 = VaryBinWidth(hSymm_mmpm, fBwVarBg4);
1934 TH1D* hSymm_ppmmVBg5 = VaryBinWidth(hSymm_ppmm, fBwVarBg5);
1935 TH1D* hSymm_pppmVBg5 = VaryBinWidth(hSymm_pppm, fBwVarBg5);
1936 TH1D* hSymm_mmpmVBg5 = VaryBinWidth(hSymm_mmpm, fBwVarBg5);
1937
1938 double ymax = 3.;
1939 hSymm_ppmm->GetYaxis()->SetRangeUser(0., ymax);
1940 hSymm_pppm->GetYaxis()->SetRangeUser(0., ymax);
1941 hSymm_mmpm->GetYaxis()->SetRangeUser(0., ymax);
1942 hSymm_ppmm5->GetYaxis()->SetRangeUser(0., ymax);
1943 hSymm_pppm5->GetYaxis()->SetRangeUser(0., ymax);
1944 hSymm_mmpm5->GetYaxis()->SetRangeUser(0., ymax);
1945 hSymm_ppmmVReg->GetYaxis()->SetRangeUser(0., ymax);
1946 hSymm_pppmVReg->GetYaxis()->SetRangeUser(0., ymax);
1947 hSymm_mmpmVReg->GetYaxis()->SetRangeUser(0., ymax);
1948 hSymm_ppmmVBg3->GetYaxis()->SetRangeUser(0., ymax);
1949 hSymm_pppmVBg3->GetYaxis()->SetRangeUser(0., ymax);
1950 hSymm_mmpmVBg3->GetYaxis()->SetRangeUser(0., ymax);
1951 hSymm_ppmmVBg4->GetYaxis()->SetRangeUser(0., ymax);
1952 hSymm_pppmVBg4->GetYaxis()->SetRangeUser(0., ymax);
1953 hSymm_mmpmVBg4->GetYaxis()->SetRangeUser(0., ymax);
1954 hSymm_ppmmVBg5->GetYaxis()->SetRangeUser(0., ymax);
1955 hSymm_pppmVBg5->GetYaxis()->SetRangeUser(0., ymax);
1956 hSymm_mmpmVBg5->GetYaxis()->SetRangeUser(0., ymax);
1957
1958 string cNameSymm = cName + "ChargeSymmetries";
1959 double x1 = 0.2;
1960 double x2 = 0.38;
1961 double y1 = 0.6;
1962 double y2 = 0.85;
1963 TCanvas* c = fHMean.fHM.CreateCanvas(cNameSymm, cNameSymm, 2400, 1600);
1964 c->Divide(3, 2);
1965 c->cd(1);
1966 DrawH1({hSymm_ppmm, hSymm_pppm, hSymm_mmpm}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1, y1, x2, y2,
1967 "hist");
1968 DrawTextOnPad("Original", 0.1, 0.9, 0.8, 0.99);
1969 c->cd(2);
1970 DrawH1({hSymm_ppmm5, hSymm_pppm5, hSymm_mmpm5}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1, y1, x2, y2,
1971 "hist");
1972 DrawTextOnPad("Rebin 5", 0.1, 0.9, 0.8, 0.99);
1973 c->cd(3);
1974 DrawH1({hSymm_ppmmVReg, hSymm_pppmVReg, hSymm_mmpmVReg}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1,
1975 y1, x2, y2, "hist");
1976 DrawTextOnPad("Varbin Regular", 0.1, 0.9, 0.8, 0.99);
1977 c->cd(4);
1978 DrawH1({hSymm_ppmmVBg3, hSymm_pppmVBg3, hSymm_mmpmVBg3}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1,
1979 y1, x2, y2, "hist");
1980 DrawTextOnPad("Varbin5", 0.1, 0.9, 0.8, 0.99);
1981 c->cd(5);
1982 DrawH1({hSymm_ppmmVBg4, hSymm_pppmVBg4, hSymm_mmpmVBg4}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1,
1983 y1, x2, y2, "hist");
1984 DrawTextOnPad("Varbin Bg4", 0.1, 0.9, 0.8, 0.99);
1985 c->cd(6);
1986 DrawH1({hSymm_ppmmVBg5, hSymm_pppmVBg5, hSymm_mmpmVBg5}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, x1,
1987 y1, x2, y2, "hist");
1988 DrawTextOnPad("Varbin Bg5", 0.1, 0.9, 0.8, 0.99);
1989 }
1990}
1991
1993{
1994 TH1D* mcReg = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(ELmvmAnaStep::Mc)], "", fBwVarReg);
1995 TH1D* elidReg = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(ELmvmAnaStep::ElId)], "", fBwVarReg);
1996 TH1D* mcSig = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(ELmvmAnaStep::Mc)], "", fBwVarSig);
1997 TH1D* elidSig = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(ELmvmAnaStep::ElId)], "", fBwVarSig);
1998 TH1D* rat = (TH1D*) elidReg->Clone();
1999 rat->Divide(mcReg);
2000 //TH1D* rat = CalculateHistRatioWithErrors(elidReg, mcReg, fNofFastSimEvents, fNofFastSimEvents);
2001 mcReg->GetYaxis()->SetRangeUser(1e-10, 50);
2002 rat->GetYaxis()->SetTitle("Ratio");
2007 TCanvas* c = fHMean.fHM.CreateCanvas("EfficiencyCorrection/ec", "EfficiencyCorrection/ec", 2100, 2400);
2008 c->Divide(2, 3);
2009 c->cd(1);
2010 DrawH1({mcReg, elidReg}, {"MC", "Elid"}, kLinear, kLog, true, 0.8, 0.8, 0.95, 0.95, "p");
2011 DrawTextOnPad("Cocktail", 0.33, 0.9, 0.67, 0.99);
2012 c->cd(2);
2013 DrawH1(rat, kLinear, kLinear, "pe");
2014 c->cd(3);
2015 DrawTemperatureGraph(mcReg, ELmvmAnaStep::Mc, 1.12, 2.5);
2016 DrawTextOnPad("Temperature for MC", 0.25, 0.9, 0.65, 0.99);
2017 c->cd(4);
2018 DrawTemperatureGraph(elidReg, ELmvmAnaStep::ElId, 1.12, 2.5);
2019 DrawTextOnPad("Temperature for Elid", 0.24, 0.9, 0.66, 0.99);
2020 c->cd(5);
2021 DrawTemperatureGraph(mcSig, ELmvmAnaStep::Mc, 1.12, 2.5);
2022 DrawTextOnPad("Temperature for MC", 0.25, 0.9, 0.65, 0.99);
2023 c->cd(6);
2024 DrawTemperatureGraph(elidSig, ELmvmAnaStep::ElId, 1.12, 2.5);
2025 DrawTextOnPad("Temperature for Elid", 0.24, 0.9, 0.66, 0.99);
2026}
2027
2029{
2030 vector<string> xLabel = {"#pi^{0} #rightarrow #gamma #gamma",
2031 "#pi^{0} #rightarrow #gamma e^{+}e^{-}",
2032 "#eta #rightarrow #gamma e^{+}e^{-}",
2033 "#Chi #rightarrow ee...",
2034 "#Chi #rightarrow xee",
2035 "#Chi #rightarrow xx"};
2036 for (auto step : fHMean.fAnaSteps) {
2037 TH1D* h = fHMean.H1Clone("hLikeSignCorr", step);
2038 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2039 h->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2040 }
2041 string cName = "LikeSignCorrelations/LikeSignCorr_" + fHMean.fAnaStepNames[static_cast<int>(step)];
2042 fHMean.fHM.CreateCanvas(cName, cName, 1100, 800);
2043 DrawH1(h, kLinear, kLog, "hist");
2044 }
2045}
2046
2048{
2049 string hName = h->GetName();
2050 int nBinsX = h->GetNbinsX();
2051 string title = (hName + "_symmetry" + "; " + h->GetXaxis()->GetTitle() + "; " + h->GetYaxis()->GetTitle()).c_str();
2052 TH1D* s;
2053 if (nBinsX % 2 == 0) {
2054 s = new TH1D((hName + "_symmetry").c_str(), title.c_str(), nBinsX / 2, h->GetMinimumBin(), h->GetMaximumBin());
2055 int binPartner = nBinsX - 1;
2056 for (int iB = 1; iB <= nBinsX / 2; iB++) {
2057 double r = (h->GetBinContent(iB) == 0) ? 0 : h->GetBinContent(iB + binPartner) / h->GetBinContent(iB);
2058 s->SetBinContent(nBinsX / 2 - iB + 1, r);
2059 binPartner -= 2;
2060 }
2061 }
2062 else {
2063 double bW = h->GetXaxis()->GetBinWidth(1);
2064 vector<double> binEdges((nBinsX + 1) / 2, 0.);
2065 for (int iB = 1; iB <= ((nBinsX + 1) / 2) + 1; iB++) {
2066 binEdges[iB] = (iB == 1) ? binEdges[iB - 1] + bW / 2. : binEdges[iB - 1] + bW;
2067 }
2068 s = new TH1D((hName + "_symmetry").c_str(), title.c_str(), (nBinsX + 1) / 2, binEdges.data());
2069 int binPartner = nBinsX - 1;
2070 for (int iB = 1; iB <= (nBinsX + 1) / 2; iB++) {
2071 double r = (h->GetBinContent(iB) == 0) ? 0 : h->GetBinContent(iB + binPartner) / h->GetBinContent(iB);
2072 s->SetBinContent((nBinsX + 1) / 2 - iB + 1, r);
2073 binPartner -= 2;
2074 }
2075 }
2076 return s;
2077}
2078
2079TH1D* LmvmDrawAll::GetSymmetry(TH1D* h1, string opt1, TH1D* h2, string opt2, const string& label)
2080{
2081 if ((opt1 != "+" && opt1 != "-") || (opt2 != "+" && opt2 != "-"))
2082 LOG(error) << "LmvmDrawAll::GetSymmetry(): At least one of the chosen options is not valid!";
2083 if (h1->GetNbinsX() != h2->GetNbinsX())
2084 LOG(error) << "LmvmDrawAll::GetSymmetry(): Number of bins of h1 and h2 are not equal!";
2085 if (h1 == h2 && opt1 == opt2) LOG(warning) << "LmvmDrawAll::GetSymmetry(): You chose the selfsame histogram parts!";
2086 TH1D* hH1 = GetHalfHisto(h1, opt1, label);
2087 TH1D* hH2 = GetHalfHisto(h2, opt2, label);
2088 TH1D* s = (TH1D*) hH1->Clone();
2089 s->Divide(hH2);
2090 return s;
2091}
2092
2093TH1D* LmvmDrawAll::GetHalfHisto(TH1D* h, string opt, const string& label)
2094{
2095 string hName = h->GetName();
2096 string hNameFull = hName + "_half" + opt + "_" + label;
2097 int nBinsX = h->GetNbinsX();
2098 double bW = h->GetXaxis()->GetBinWidth(1);
2099 string title =
2100 hName + "_half" + opt + "_" + label + "; " + h->GetXaxis()->GetTitle() + "; " + h->GetYaxis()->GetTitle();
2101 TH1D* h2;
2102 if (nBinsX % 2 == 0) { // Histograms with even number of bins
2103 vector<double> binEdges(nBinsX / 2 + 1, 0.);
2104 for (int iB = 1; iB <= nBinsX / 2; iB++) {
2105 binEdges[iB] = binEdges[iB - 1] + bW;
2106 }
2107 h2 = new TH1D(hNameFull.c_str(), title.c_str(), nBinsX / 2, binEdges.data());
2108 if (opt == "+") { // get right half
2109 for (int iB = 1; iB <= nBinsX / 2; iB++) {
2110 h2->SetBinContent(iB, h->GetBinContent(nBinsX / 2 + iB));
2111 }
2112 }
2113 else { // get left half
2114 for (int iB = 1; iB <= nBinsX / 2; iB++) {
2115 h2->SetBinContent(iB, h->GetBinContent(nBinsX / 2 + 1 - iB));
2116 }
2117 }
2118 }
2119 else { // Histograms with odd number of bins
2120 vector<double> binEdges((nBinsX + 1) / 2 + 1, 0.);
2121 for (int iB = 1; iB <= (nBinsX + 1) / 2; iB++) {
2122 binEdges[iB] = (iB == 1) ? binEdges[iB - 1] + bW / 2. : binEdges[iB - 1] + bW;
2123 }
2124 h2 = new TH1D(hNameFull.c_str(), title.c_str(), (nBinsX + 1) / 2, binEdges.data());
2125 if (opt == "+") {
2126 for (int iB = 1; iB <= (nBinsX + 1) / 2; iB++) {
2127 if (iB == 1)
2128 h2->SetBinContent(iB, h->GetBinContent((nBinsX - 1) / 2 + iB) / 2);
2129 else
2130 h2->SetBinContent(iB, h->GetBinContent((nBinsX - 1) / 2 + iB));
2131 }
2132 }
2133 else {
2134 for (int iB = 1; iB <= (nBinsX + 1) / 2; iB++) {
2135 if (iB == 1)
2136 h2->SetBinContent(iB, h->GetBinContent((nBinsX + 1) / 2 + 1 - iB) / 2);
2137 else
2138 h2->SetBinContent(iB, h->GetBinContent((nBinsX + 1) / 2 + 1 - iB));
2139 }
2140 }
2141 }
2142 return h2;
2143}
2144
2145void LmvmDrawAll::DrawMultiplicities(TH1D* plus, TH1D* minus, TH1D* plusrandom, TH1D* minusrandom, string cName,
2146 string hText)
2147{
2148 int nBinsMult = fHFastSim.H1("hfsp_mult_urqmd_gammaEl_plus_elid")->GetNbinsX();
2149 vector<string> xLabel;
2150 for (int iB = 0; iB < nBinsMult; iB++) {
2151 xLabel.push_back(Cbm::NumberToString(iB, 0));
2152 }
2153 TH1D* hRatP = (TH1D*) plus->Clone();
2154 TH1D* hRatM = (TH1D*) minus->Clone();
2155 hRatP->Divide(plusrandom);
2156 hRatM->Divide(minusrandom);
2157 plus->GetYaxis()->SetRangeUser(1e-8, 1);
2158 plusrandom->GetYaxis()->SetRangeUser(1e-7, 1);
2159 //hRatP->GetYaxis()->SetRangeUser(0.8, 5.5);
2160 hRatP->GetYaxis()->SetTitle("Ratio true/random");
2161 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2162 plus->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2163 hRatP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2164 }
2165 double IP = plus->Integral(1, nBinsMult);
2166 double IM = minus->Integral(1, nBinsMult);
2167 double IPrndm = plusrandom->Integral(1, nBinsMult);
2168 double IMrndm = minusrandom->Integral(1, nBinsMult);
2169 minus->Scale(0.1);
2170 minusrandom->Scale(0.1);
2171 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 1700, 800);
2172 c->Divide(2, 1);
2173 c->cd(1);
2174 DrawH1({plus, plusrandom, minus, minusrandom},
2175 {"e^{+}_{true}", "e^{+}_{random}", "e^{-}_{true} #upoint 0.1", "e^{-}_{random} #upoint 0.1"}, kLinear, kLog,
2176 true, 0.63, 0.62, 0.88, 0.87, "hist");
2177 DrawTextOnPad(hText, 0.2, 0.9, 0.8, 0.99);
2178 DrawTextOnPad("I_{+, true} = " + Cbm::NumberToString(IP, 2), 0.13, 0.31, 0.38, 0.36);
2179 DrawTextOnPad("I_{-, true} = " + Cbm::NumberToString(IM, 2), 0.13, 0.26, 0.38, 0.31);
2180 DrawTextOnPad("I_{+, rndm} = " + Cbm::NumberToString(IPrndm, 2), 0.13, 0.21, 0.38, 0.26);
2181 DrawTextOnPad("I_{-, rndm} = " + Cbm::NumberToString(IMrndm, 2), 0.13, 0.16, 0.38, 0.21);
2182 c->cd(2);
2183 DrawH1({hRatP, hRatM}, {"Ratio e+", "Ratio e-"}, kLinear, kLinear, true, 0.67, 0.74, 0.88, 0.87, "hist");
2184 DrawTextOnPad(hText, 0.2, 0.9, 0.8, 0.99);
2185}
2186
2187void LmvmDrawAll::DrawFastSimHistosParticleBased() // TODO: merge with 'DrawFastSimHistos()'
2188{
2189 // Prepare drawing
2190 string cName = "FastSimParticleBased/";
2191 string nEvStr = fNofFastSimEvents >= 1e9 ? Cbm::NumberToString(fNofFastSimEvents / 1e9, 1)
2193 string nEvText = "NofFastSimEvents = " + nEvStr + (fNofFastSimEvents >= 1e9 ? "#times10^{9}" : "#times10^{6}");
2194
2195 // Background: Charge-based vs. Particle-based
2196 {
2197 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2198 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2199 TH1D* cb = VaryBinWidth("fastsim", "hfsc_MinvBg", step, fBwVarBg3);
2200 TH1D* pb = VaryBinWidth("fastsim", "hfsp_MinvBg", step, fBwVarBg3);
2201 TH1D* r = (TH1D*) pb->Clone();
2202 r->Divide(cb);
2203 r->GetYaxis()->SetTitle("Ratio");
2204 string cNameFull = cName + "Background/ParticleVsChargeBased_" + stepname;
2205 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1600, 800);
2206 c->Divide(2, 1);
2207 c->cd(1);
2208 DrawH1({pb, cb}, {"Particle-based", "Charge-Based"}, kLinear, kLog, true, 0.65, 0.7, 0.91, 0.91, "hist");
2209 DrawTextOnPad("Background", 0.2, 0.9, 0.8, 0.99);
2210 c->cd(2);
2211 DrawH1(r, kLinear, kLinear, "hist");
2212 DrawTextOnPad("Ratio Particle/Charge", 0.2, 0.9, 0.8, 0.99);
2213 }
2214 }
2215
2216 // Multiplicity for UrQMD and Plutos
2217 {
2219 for (size_t iP = 0; iP < fHMean.fFSCandNames.size(); iP++) {
2220 string ptcl = fHMean.fFSCandNames[iP];
2221 TH1D* hP = fHFastSim.H1Clone("hfsp_mult_urqmd_" + ptcl + "_plus", step);
2222 TH1D* hM = fHFastSim.H1Clone("hfsp_mult_urqmd_" + ptcl + "_minus", step);
2223 TH1D* hPrndm = fHFastSim.H1Clone("hfsp_multRndm_urqmd_" + ptcl + "_plus", step);
2224 TH1D* hMrndm = fHFastSim.H1Clone("hfsp_multRndm_urqmd_" + ptcl + "_minus", step);
2225 string text = fHMean.fFSCandLatex[iP] + " (" + fHMean.fAnaStepLatex[static_cast<int>(step)] + ")";
2226 string cNameFull = cName + "Multiplicity/" + ptcl;
2227 DrawMultiplicities(hP, hM, hPrndm, hMrndm, cNameFull, text);
2228 }
2229 for (ELmvmSignal signal : fHMean.fSignals) {
2230 //int nofEventsSig = (int) fH[static_cast<int>(signal)]->H1("hEventNumber")->GetEntries();
2231 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
2232 TH1D* hP = fHFastSim.H1Clone("hfsc_mult_pluto_" + sigName + "_plus", step);
2233 TH1D* hM = fHFastSim.H1Clone("hfsc_mult_pluto_" + sigName + "_minus", step);
2234 TH1D* hPrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_plus", step);
2235 TH1D* hMrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_minus", step);
2236 string text = sigName + " (" + fHMean.fAnaStepLatex[static_cast<int>(step)] + ")";
2237 string cNameFull = cName + "Multiplicity/" + sigName + "_raw";
2238 DrawMultiplicities(hP, hM, hPrndm, hMrndm, cNameFull, text);
2239 }
2240 for (ELmvmSignal signal : fHMean.fSignals) {
2241 //int nofEventsSig = (int) fH[static_cast<int>(signal)]->H1("hEventNumber")->GetEntries();
2242 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
2243 TH1D* hPcorr = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_plus", step);
2244 TH1D* hMcorr = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_minus", step);
2245 TH1D* hPrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_plus", step);
2246 TH1D* hMrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_minus", step);
2247 string text = sigName + " (" + fHMean.fAnaStepLatex[static_cast<int>(step)] + ")";
2248 string cNameFull = cName + "Multiplicity/" + sigName + "_corr";
2249 DrawMultiplicities(hPcorr, hMcorr, hPrndm, hMrndm, cNameFull, text);
2250 }
2251 }
2252}
2253
2255{
2256 /****************************************************************************************************************
2257* To be consistent, all histograms concerning Fast Simulations will be taken from fHFastSim, not from fHMean. *
2258* In LmvmFastSim histograms are not scaled, except the minvBg histograms are scaled to bin width only. *
2259* All histograms that are created and filled in LmvmFastSim are scaled by pattern here to 1/fNofFastSimEvents. *
2260* Mind, that this does not include histograms that are created and filled in LmvmTask! *
2261* Until now, the Pluto histograms are scaled with factor fNofSignals "by hand" after scaling by pattern. This *
2262* should be solved more elegant. *
2263* The histograms that are created and filled in LmvmTask, but are taken from LmvmFastSim (fHFastSim), *
2264* additionally have to be scaled to the number of FastSim jobs, since they are added via 'hadd'. *
2265* *
2266* Edit: Since using THnSparse histograms, these are scaled individually before drawing. Make this more elegant! *
2267*****************************************************************************************************************/
2268
2269 // Prepare drawing
2270 string cName = "FastSim/";
2271 string nEvStr = fNofFastSimEvents >= 1e9 ? Cbm::NumberToString(fNofFastSimEvents / 1e9, 1)
2273 string nEvText = "NofFastSimEvents = " + nEvStr + (fNofFastSimEvents >= 1e9 ? "#times10^{9}" : "#times10^{6}");
2274
2275 int nBinsMult = fHFastSim.H1("hfsc_mult_urqmd_urqmd_plus_elid")->GetNbinsX();
2276 vector<string> xLabel;
2277 for (int iB = 0; iB < nBinsMult; iB++) {
2278 xLabel.push_back(Cbm::NumberToString(iB, 0));
2279 }
2280
2281 // Draw
2282 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2283 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2284 string stepLatex = fHMean.fAnaStepLatex[static_cast<int>(step)];
2285
2286 // Multiplicities true vs. random (UrQMD)
2287 {
2288 TH1D* hP = fHFastSim.H1Clone("hfsc_mult_urqmd_urqmd_plus", step);
2289 TH1D* hM = fHFastSim.H1Clone("hfsc_mult_urqmd_urqmd_minus", step);
2290 TH1D* hPrndm = fHFastSim.H1Clone("hfsc_multRndm_urqmd_urqmd_plus", step);
2291 TH1D* hMrndm = fHFastSim.H1Clone("hfsc_multRndm_urqmd_urqmd_minus", step);
2292 TH1D* hRatP = (TH1D*) hP->Clone();
2293 TH1D* hRatM = (TH1D*) hM->Clone();
2294 hRatP->Divide(hPrndm);
2295 hRatM->Divide(hMrndm);
2296 hP->GetYaxis()->SetRangeUser(1e-8, 1);
2297 hP->GetYaxis()->SetTitle("Yield/Event");
2298 hPrndm->GetYaxis()->SetRangeUser(1e-8, 1);
2299 hRatP->GetYaxis()->SetRangeUser(0.5, 1.3);
2300 hRatP->GetYaxis()->SetTitle("Ratio true/random");
2301 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2302 hP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2303 hPrndm->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2304 hRatP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2305 }
2306 //double IP = hP->Integral(1, nBinsMult);
2307 //double IM = hM->Integral(1, nBinsMult);
2308 double IPrndm = hPrndm->Integral(1, nBinsMult);
2309 double IMrndm = hMrndm->Integral(1, nBinsMult);
2310 double nP = 0.;
2311 double nM = 0.;
2312 for (int iB = 2; iB <= hP->GetNbinsX(); iB++) {
2313 nP += hP->GetBinContent(iB) * (iB - 1) * fNofSimEvents;
2314 nM += hM->GetBinContent(iB) * (iB - 1) * fNofSimEvents;
2315 }
2316 if (step == ELmvmAnaStep::ElId) LOG(info) << "DrawFastSim: nP = " << nP << ", nM = " << nM;
2317 string cNameFull = cName + "Multiplicities/urqmd_" + stepname;
2318 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 3200, 800);
2319 c->Divide(3, 1);
2320 c->cd(1);
2321 DrawH1({hP, hM}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2322 DrawTextOnPad("True Multiplicity", 0.2, 0.9, 0.8, 0.99);
2323 //DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2324 //DrawTextOnPad("I_{+} = " + Cbm::NumberToString(IP, 2), 0.17, 0.21, 0.37, 0.28);
2325 //DrawTextOnPad("I_{-} = " + Cbm::NumberToString(IM, 2), 0.17, 0.14, 0.37, 0.21);
2326 c->cd(2);
2327 DrawH1({hPrndm, hMrndm}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2328 DrawTextOnPad("Random Multiplicity", 0.2, 0.9, 0.8, 0.99);
2329 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2330 DrawTextOnPad("I_{+} = " + Cbm::NumberToString(IPrndm, 2), 0.17, 0.21, 0.37, 0.28);
2331 DrawTextOnPad("I_{-} = " + Cbm::NumberToString(IMrndm, 2), 0.17, 0.14, 0.37, 0.21);
2332 c->cd(3);
2333 DrawH1({hRatP, hRatM}, {"e^{+}", "e^{-}"}, kLinear, kLinear, true, 0.8, 0.68, 0.91, 0.9, "hist");
2334 DrawTextOnPad("True vs. Random Multiplicity", 0.1, 0.9, 0.9, 0.99);
2335 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2336 }
2337
2338 // Multiplicities true vs. random (PLUTO)
2339 {
2340 for (ELmvmSignal signal : fHMean.fSignals) {
2341 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
2342 TH1D* hP = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_plus", step);
2343 TH1D* hM = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_minus", step);
2344 TH1D* hPrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_plus", step);
2345 TH1D* hMrndm = fHFastSim.H1Clone("hfsc_multRndm_pluto_" + sigName + "_minus", step);
2346 hPrndm->Scale(fHMean.fNofSignals / fNofFastSimEvents);
2347 hMrndm->Scale(fHMean.fNofSignals / fNofFastSimEvents);
2348 TH1D* hRatP = (TH1D*) hP->Clone();
2349 TH1D* hRatM = (TH1D*) hM->Clone();
2350 hRatP->Divide(hPrndm);
2351 hRatM->Divide(hMrndm);
2352 hP->GetYaxis()->SetRangeUser(1e-6, 1);
2353 hPrndm->GetYaxis()->SetRangeUser(1e-6, 1);
2354 hRatP->GetYaxis()->SetTitle("Ratio true/random");
2355 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2356 hP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2357 hPrndm->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2358 hRatP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2359 }
2360 string cNameFull = cName + "Multiplicities/" + sigName + "_" + stepname;
2361 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 3500, 800);
2362 c->Divide(3, 1);
2363 c->cd(1);
2364 DrawH1({hP, hM}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2365 DrawTextOnPad("True Multiplicity", 0.2, 0.9, 0.8, 0.99);
2366 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2367 c->cd(2);
2368 DrawH1({hPrndm, hMrndm}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2369 DrawTextOnPad("Random Multiplicity", 0.2, 0.9, 0.8, 0.99);
2370 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2371 c->cd(3);
2372 DrawH1({hRatP, hRatM}, {"e^{+}", "e^{-}"}, kLinear, kLinear, true, 0.8, 0.68, 0.91, 0.9, "hist");
2373 DrawTextOnPad("True vs. Random Multiplicity", 0.1, 0.9, 0.9, 0.99);
2374 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2375 }
2376 }
2377
2378 // True Multiplicities all in one canvas
2379 {
2380 string cNameFull = cName + "Multiplicities/all_" + stepname;
2381 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 3500, 1600);
2382 c->Divide(3, 2);
2383 int iC = 1;
2384 TH1D* hPU = fHFastSim.H1Clone("hfsc_mult_urqmd_urqmd_plus", step);
2385 TH1D* hMU = fHFastSim.H1Clone("hfsc_mult_urqmd_urqmd_minus", step);
2386 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2387 hPU->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2388 }
2389 c->cd(iC++);
2390 DrawH1({hPU, hMU}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2391 DrawTextOnPad("True Multiplicity (UrQMD)", 0.17, 0.9, 0.83, 0.99);
2392 DrawTextOnPad(nEvText, 0.5, 0.15, 0.9, 0.25);
2393
2394 for (ELmvmSignal signal : fHMean.fSignals) {
2395 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
2396 TH1D* hP = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_plus", step);
2397 TH1D* hM = fHFastSim.H1Clone("hfsc_multCorr_pluto_" + sigName + "_minus", step);
2398 //hP->GetYaxis()->SetRangeUser(1e-15, 1);
2399 for (size_t iL = 0; iL < xLabel.size(); iL++) {
2400 hP->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
2401 }
2402 c->cd(iC++);
2403 DrawH1({hP, hM}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.68, 0.91, 0.9, "hist");
2404 DrawTextOnPad("True Multiplicity (" + sigName + ")", 0.17, 0.9, 0.83, 0.99);
2405 }
2406 }
2407
2408 // Momentum (UrQMD)
2409 {
2410 // check size of THnSparse histograms
2411 static ProcInfo_t info;
2412 const float toMB = 1.f / 1024.f;
2413 gSystem->GetProcInfo(&info);
2414 double sizeRes1 = info.fMemResident * toMB;
2415 double sizeVir1 = info.fMemVirtual * toMB;
2416
2417 THnSparseD* hPlusT = (THnSparseD*) fHFastSim.fHM.GetObject("hfsc_mom_urqmd_urqmd_plus_" + stepname)->Clone();
2418 THnSparseD* hMinusT = (THnSparseD*) fHFastSim.fHM.GetObject("hfsc_mom_urqmd_urqmd_minus_" + stepname)->Clone();
2419 hPlusT->Scale(1. / (fNofSimEvents));
2420 hMinusT->Scale(1. / (fNofSimEvents));
2421
2422 THnSparseD* hPlusR = (THnSparseD*) fHFastSim.fHM.GetObject("hfsc_momRndm_urqmd_urqmd_plus_" + stepname)->Clone();
2423 THnSparseD* hMinusR =
2424 (THnSparseD*) fHFastSim.fHM.GetObject("hfsc_momRndm_urqmd_urqmd_minus_" + stepname)->Clone();
2425 hPlusR->Scale(1. / fNofFastSimEvents);
2426 hMinusR->Scale(1. / fNofFastSimEvents);
2427
2428 gSystem->GetProcInfo(&info);
2429 double sizeRes2 = info.fMemResident * toMB;
2430 double sizeVir2 = info.fMemVirtual * toMB;
2431 double sizeRes = (sizeRes2 - sizeRes1) / 4.;
2432 double sizeVir = (sizeVir2 - sizeVir1) / 4.;
2433 LOG(info) << "Size of one THnSparseD histogram: virtual: " << sizeVir << " MB, residential: " << sizeRes
2434 << " MB.";
2435
2436 TH1D* hPlusXt = (TH1D*) hPlusT->Projection(0, "");
2437 TH1D* hPlusYt = (TH1D*) hPlusT->Projection(1, "");
2438 TH1D* hPlusZt = (TH1D*) hPlusT->Projection(2, "");
2439 TH1D* hPlusXr = (TH1D*) hPlusR->Projection(0, "");
2440 TH1D* hPlusYr = (TH1D*) hPlusR->Projection(1, "");
2441 TH1D* hPlusZr = (TH1D*) hPlusR->Projection(2, "");
2442 TH1D* hMinusXt = (TH1D*) hMinusT->Projection(0, "");
2443 TH1D* hMinusYt = (TH1D*) hMinusT->Projection(1, "");
2444 TH1D* hMinusZt = (TH1D*) hMinusT->Projection(2, "");
2445 TH1D* hMinusXr = (TH1D*) hMinusR->Projection(0, "");
2446 TH1D* hMinusYr = (TH1D*) hMinusR->Projection(1, "");
2447 TH1D* hMinusZr = (TH1D*) hMinusR->Projection(2, "");
2448 hPlusXt->Scale(1. / fNofFastSimJobs);
2449 hPlusYt->Scale(1. / fNofFastSimJobs);
2450 hPlusZt->Scale(1. / fNofFastSimJobs);
2451 hMinusXt->Scale(1. / fNofFastSimJobs);
2452 hMinusYt->Scale(1. / fNofFastSimJobs);
2453 hMinusZt->Scale(1. / fNofFastSimJobs);
2454 hPlusXt->GetYaxis()->SetTitle("Yield / Bin");
2455 hPlusYt->GetYaxis()->SetTitle("Yield / Bin");
2456 hPlusZt->GetYaxis()->SetTitle("Yield / Bin");
2457 hMinusXt->GetYaxis()->SetTitle("Yield / Bin");
2458 hMinusYt->GetYaxis()->SetTitle("Yield / Bin");
2459 hMinusZt->GetYaxis()->SetTitle("Yield / Bin");
2460 double min = 1e-7;
2461 double max = 3e-4;
2462 hPlusXt->GetYaxis()->SetRangeUser(min, max);
2463 hPlusYt->GetYaxis()->SetRangeUser(min, max);
2464 hPlusZt->GetYaxis()->SetRangeUser(min, max);
2465 hMinusXt->GetYaxis()->SetRangeUser(min, max);
2466 hMinusYt->GetYaxis()->SetRangeUser(min, max);
2467 hMinusZt->GetYaxis()->SetRangeUser(min, max);
2468
2469 string cNametrP = cName + "Momentum/TrueVsRndm_plus_" + stepname;
2470 TCanvas* cP = fHMean.fHM.CreateCanvas(cNametrP, cNametrP, 2400, 800);
2471 cP->Divide(3, 1);
2472 cP->cd(1);
2473 DrawH1({hPlusXt, hPlusXr}, {"P_{x} true", "P_{x} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2474 DrawTextOnPad("True vs. random Momentum (e^{+})", 0.17, 0.9, 0.83, 0.99);
2475 //DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2476 cP->cd(2);
2477 DrawH1({hPlusYt, hPlusYr}, {"P_{y} true", "P_{y} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2478 DrawTextOnPad("True vs. random Momentum (e^{+})", 0.17, 0.9, 0.83, 0.99);
2479 DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2480 cP->cd(3);
2481 DrawH1({hPlusZt, hPlusZr}, {"P_{z} true", "P_{z} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2482 DrawTextOnPad("True vs. random Momentum (e^{+})", 0.17, 0.9, 0.83, 0.99);
2483 DrawTextOnPad(nEvText, 0.2, 0.8, 0.6, 0.89);
2484
2485 string cNametrM = cName + "Momentum/TrueVsRndm_minus_" + stepname;
2486 TCanvas* cM = fHMean.fHM.CreateCanvas(cNametrM, cNametrM, 2400, 800);
2487 cM->Divide(3, 1);
2488 cM->cd(1);
2489 DrawH1({hMinusXt, hMinusXr}, {"P_{x} true", "P_{x} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2490 DrawTextOnPad("True vs. random Momentum (e^{-})", 0.17, 0.9, 0.83, 0.99);
2491 DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2492 cM->cd(2);
2493 DrawH1({hMinusYt, hMinusYr}, {"P_{y} true", "P_{y} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2494 DrawTextOnPad("True vs. random Momentum (e^{-})", 0.17, 0.9, 0.83, 0.99);
2495 DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2496 cM->cd(3);
2497 DrawH1({hMinusZt, hMinusZr}, {"P_{z} true", "P_{z} random"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.9, "hist");
2498 DrawTextOnPad("True vs. random Momentum (e^{-})", 0.17, 0.9, 0.83, 0.99);
2499 DrawTextOnPad(nEvText, 0.2, 0.8, 0.6, 0.89);
2500
2501 // To avoid same colors for different histograms, copy twice used histograms
2502 TH1D* hPlusXt2 = (TH1D*) hPlusXt->Clone();
2503 TH1D* hPlusYt2 = (TH1D*) hPlusYt->Clone();
2504 TH1D* hPlusZt2 = (TH1D*) hPlusZt->Clone();
2505 TH1D* hMinusXt2 = (TH1D*) hMinusXt->Clone();
2506 TH1D* hMinusYt2 = (TH1D*) hMinusYt->Clone();
2507 TH1D* hMinusZt2 = (TH1D*) hMinusZt->Clone();
2508 hPlusXt2->GetYaxis()->SetRangeUser(min, max);
2509 hPlusYt2->GetYaxis()->SetRangeUser(min, max);
2510 hPlusZt2->GetYaxis()->SetRangeUser(min, max);
2511 string cNamePm = cName + "Momentum/PlusVsMinus_" + stepname;
2512 TCanvas* cPm = fHMean.fHM.CreateCanvas(cNamePm, cNamePm, 2400, 800);
2513 cPm->Divide(3, 1);
2514 cPm->cd(1);
2515 DrawH1({hPlusXt2, hMinusXt2}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2516 DrawTextOnPad("True Momentum", 0.3, 0.9, 0.7, 0.99);
2517 //DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2518 cPm->cd(2);
2519 DrawH1({hPlusYt2, hMinusYt2}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2520 DrawTextOnPad("True Momentum", 0.3, 0.9, 0.7, 0.99);
2521 DrawTextOnPad(nEvText, 0.1, 0.8, 0.5, 0.89);
2522 cPm->cd(3);
2523 DrawH1({hPlusZt2, hMinusZt2}, {"e^{+}", "e^{-}"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2524 DrawTextOnPad("True Momentum", 0.3, 0.9, 0.7, 0.99);
2525 DrawTextOnPad(nEvText, 0.2, 0.8, 0.6, 0.89);
2526 }
2527 } // steps
2528
2529 // Background
2530 {
2531 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Background/Background", cName + "Background/Background", 2400, 800);
2532 c->Divide(3, 1);
2533 int iC = 1;
2534 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2535 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2536 TH1D* bg = VaryBinWidth("fastsim", "hfsc_MinvBg_" + stepname, fBwVarReg);
2537 bg->GetYaxis()->SetRangeUser(1e-9, 1e-2);
2538 c->cd(iC++);
2539 DrawH1(bg, kLinear, kLog, "hist");
2540 fHMean.DrawAnaStepOnPad(step);
2541 }
2542 }
2543
2544 // Background: Vs. MC-BG
2545 for (const string cat : {""}) { //, "_trueEl", "_urqmdAll", "_urqmdEl"}) {
2546 TCanvas* c =
2547 fHMean.fHM.CreateCanvas(cName + "Background/VsMcBg" + cat, cName + "Background/VsMcBg" + cat, 1600, 2400);
2548 c->Divide(2, 3);
2549 int iC = 1;
2550 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2551 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2552 TH1D* bfs = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat + "_" + stepname, fNofFastSimEvents, fBwVarSig);
2553 TH1D* bmc = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat + "_bg", step), fNofSimEvents, fBwVarSig);
2554 bfs->GetYaxis()->SetRangeUser(1e-7, 2e-2);
2555 TH1D* r = (TH1D*) bfs->Clone();
2556 r->Divide(bmc);
2557 r->GetYaxis()->SetRangeUser(0.5, 1.4);
2558 r->GetYaxis()->SetTitle("Ratio");
2559 c->cd(iC++);
2560 DrawH1({bfs, bmc}, {"B_{FS}", "B_{MC}"}, kLinear, kLog, true, 0.65, 0.75, 0.95, 0.9, "p");
2561 fHMean.DrawAnaStepOnPad(step);
2562 c->cd(iC++);
2563 DrawH1({r}, {"B_{FS} / B_{MC}"}, kLinear, kLinear, true, 0.75, 0.87, 0.95, 0.95, "p");
2564 fHMean.DrawAnaStepOnPad(step);
2565 }
2566 }
2567
2568 // Background vs CBcalc from Fast Simulation (CB_{calc, FS})
2569 /*{
2570 TH1D* fs = VaryBinWidth("fastsim", "hfsc_MinvBg_elid", fNofFastSimEvents, fBwVarBg);
2571 TH1D* cb = VaryBinWidth("mean", "hFsCb", fNofFastSimEvents, fBwVarBg);
2572 TH1D* r = (TH1D*) fs->Clone();
2573 r->Divide(cb);
2574 r->GetYaxis()->SetTitle("Ratio");
2575 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Background/FsCb", cName + "Background/FsCb", 1600, 800);
2576 c->Divide(2, 1);
2577 c->cd(1);
2578 DrawH1({fs, cb}, {"B_{FS}", "CB_{calc, FS}"}, kLinear, kLog, true, 0.7, 0.82, 0.92, 0.92, "hist");
2579 c->cd(2);
2580 DrawH1(r, kLinear, kLinear, "hist");
2581 }*/
2582
2583 // Background: Smoothing effect of large number of FastSim procedure
2584 {
2586 TCanvas* c =
2587 fHMean.fHM.CreateCanvas(cName + "Background/SmoothEffect", cName + "Background/SmoothEffect", 2400, 1600);
2588 c->Divide(3, 2);
2589 vector<int> canvas = {1, 4, 2, 5, 3, 6};
2590 int iC = 0;
2591 for (const string cat : {""}) { // , "_urqmdAll", "_urqmdEl"}) {
2592 TH1D* mc = fHMean.H1Clone("hMinv" + cat + "_bg", step);
2593 TH1D* fs = fHFastSim.H1Clone("hfsc_MinvBg" + cat, step);
2594 TH1D* cb = fHMean.H1Clone("hCbBg" + cat, step);
2595 TH1D* rat = (TH1D*) cb->Clone();
2596 rat->Divide(fs);
2597 TH1D* rat2 = VaryBinWidth(rat, fBwVarReg);
2598 rat2->GetYaxis()->SetRangeUser(0.97, 1.1);
2599 rat2->GetYaxis()->SetTitle("CB_{calc} / B_{FS}");
2600 mc->GetXaxis()->SetTitle("M_{ee} [GeV/c^{2}]");
2601 mc->GetYaxis()->SetRangeUser(1e-9, 1e-2);
2602 string label = (cat == "") ? "PLUTO + UrQMD" : (cat == "_urqmdAll") ? "UrQMD" : "UrQMD electrons";
2603 c->cd(canvas[iC]);
2604 iC++;
2605 DrawH1({mc, fs, cb}, {"MC Background", "Fast Sim. Background", "CB_{calc}"}, kLinear, kLog, true, 0.52, 0.7, 0.91,
2606 0.9, "hist");
2607 DrawH1({mc, fs}, {"MC Background", "Fast Sim. Background"}, kLinear, kLog, true, 0.52, 0.77, 0.91, 0.9, "hist");
2608 DrawTextOnPad(label, 0.25, 0.9, 0.8, 0.99);
2609 fHMean.DrawSimDataLabel(0.14, 1.02e-8, 0.033);
2610 c->cd(canvas[iC]);
2611 iC++;
2612 DrawH1(rat2, kLinear, kLinear, "hist");
2613 DrawTextOnPad(label, 0.25, 0.9, 0.8, 0.99);
2614 }
2615 }
2616
2617 // Signal: B_{FS} + Cocktail - CB_{calc} vs. Cocktail
2618 {
2619 for (const string cat : {""}) { //}, "_trueEl", "_urqmdAll", "_urqmdEl"}) {
2620 string cNameFull = cName + "Signal/signal" + cat;
2621 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 2400, 800);
2622 c->Divide(3, 1);
2623 int iC = 1;
2624 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2625 TH1D* sig = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat, step, fNofFastSimEvents, fBwVarSig3);
2626 TH1D* cbc = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
2627 fNofSimEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarSig3);
2628 TH1D* coc = VaryBinWidth("cocktail" + cat + "_" + fHMean.fAnaStepNames[static_cast<int>(step)], "",
2630 sig->Add(coc);
2631 sig->Add(cbc, -1.);
2632 sig->GetYaxis()->SetRangeUser(1e-9, 3e-2);
2633 c->cd(iC++);
2634 DrawH1({sig, coc}, {"Signal = B_{FS} + Cocktail - CB_{calc}", "Cocktail"}, kLinear, kLog, true, 0.47, 0.77,
2635 0.91, 0.9, "pe");
2636 fHMean.DrawAnaStepOnPad(step);
2637 fHMean.DrawSimDataLabel(.08, 3e-9, 0.033);
2638 }
2639 }
2640 }
2641
2642 // Signal from FastSim procedure only: B_{FS} + Cocktail - CB_{calc, FS} vs. Cocktail
2643 /*{
2644 vector<pair<double, double>> bwvar = fBwVarSig3;
2645 ELmvmAnaStep step = ELmvmAnaStep::ElId;
2646 TH1D* sig = VaryBinWidth("fastsim", "hfsc_MinvBg", step, fNofFastSimEvents, bwvar);
2647 TH1D* cbfs = VaryBinWidth("mean", "hFsCb", fNofFastSimEvents, bwvar);
2648 TH1D* coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, bwvar);
2649 sig->Add(coc);
2650 sig->Add(cbfs, -1.);
2651 //sig->GetYaxis()->SetRangeUser(1e-9, 3e-2);
2652 string cNameFull = cName + "Signal/signal_RE";
2653 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 800, 800);
2654 DrawH1({sig, coc}, {"Signal = B_{FS} + Cocktail - CB_{calc, FS}", "Cocktail"}, kLinear, kLinear, true, 0.45, 0.77, 0.91, 0.9, "pe");
2655 fHMean.DrawAnaStepOnPad(step);
2656 }*/
2657
2658 // Reduced Signal (without known sources (pi0, eta, omega, phi)) vs. Cocktail
2659 {
2660 vector<pair<double, double>> bwvar = fBwVarSig3;
2661 for (const string cat : {""}) { //, "_trueEl", "_urqmdAll", "_urqmdEl"}) {
2662 string cNameFull = cName + "Signal/Reduced/signal_reduced" + cat;
2663 string legSig = "B_{FS} + Cocktail - CB_{calc} - #pi^{0} - #eta - #omega - #omega_{D} - #phi ";
2664 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 3200, 800);
2665 c->Divide(4, 1);
2666 int iC = 1;
2667 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
2668 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2669 TH1D* sig = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat, step, bwvar);
2670 TH1D* fs = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat, step, bwvar);
2671 TH1D* cbc = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step), bwvar);
2672 TH1D* pi0 = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat, ELmvmSrc::Pi0, step), bwvar);
2673 TH1D* eta = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat, ELmvmSrc::Eta, step), bwvar);
2674 TH1D* gamma = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat, ELmvmSrc::Gamma, step), bwvar);
2675 TH1D* inmed = VaryBinWidth("inmed", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwvar);
2676 TH1D* omega = VaryBinWidth("omegaepem", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwvar);
2677 TH1D* omegadalitz = VaryBinWidth("omegadalitz", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwvar);
2678 TH1D* phi = VaryBinWidth("phi", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwvar);
2679 TH1D* qgp = VaryBinWidth("qgp", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), bwvar);
2680 TH1D* coc = VaryBinWidth("cocktail" + cat + "_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", bwvar);
2681 inmed->Scale(1. / H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries());
2682 omega->Scale(1. / H(ELmvmSignal::Omega)->H1("hEventNumber")->GetEntries());
2683 omegadalitz->Scale(1. / H(ELmvmSignal::OmegaD)->H1("hEventNumber")->GetEntries());
2684 phi->Scale(1. / H(ELmvmSignal::Phi)->H1("hEventNumber")->GetEntries());
2685 qgp->Scale(1. / H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries());
2686 sig->Add(coc);
2687 sig->Add(cbc, -1.);
2688 sig->Add(pi0, -1.);
2689 sig->Add(eta, -1.);
2690 sig->Add(omega, -1.);
2691 sig->Add(omegadalitz, -1.);
2692 sig->Add(phi, -1.);
2693 TH1D* cocRed = (TH1D*) inmed->Clone();
2694 cocRed->Add(qgp);
2695 //CalculateHistErrors(cocRed, fNofFastSimEvents);
2696 //CalculateHistErrors(sig, fNofFastSimEvents);
2697 sig->GetYaxis()->SetRangeUser(1e-10, 5e-2);
2698 fs->GetYaxis()->SetRangeUser(1e-10, 5e-2);
2699 if (step == ELmvmAnaStep::ElId) {
2700 c->cd(iC++);
2701 DrawH1({fs, cbc, coc, omega, omegadalitz, phi, pi0, eta, gamma},
2702 {"B_{FS}", "CB_{calc}", "Cocktail", "#omega", "#omega_{D}", "#phi", "#pi^{0}", "#eta", "#gamma"},
2703 kLinear, kLog, true, 0.85, 0.55, 0.99, 0.9, "p");
2704 }
2705 c->cd(iC++);
2706 DrawH1({sig, cocRed}, {legSig, "#rho_{i.m.} + QGP"}, kLinear, kLog, true, 0.38, 0.77, 0.91, 0.9, "pe");
2707 DrawTextOnPad("Reduced Cocktail (" + stepname + ")", 0.1, 0.9, 0.9, 0.99);
2708 DrawTextOnPad(nEvText, 0.12, 0.15, 0.5, 0.25);
2709 }
2710 }
2711 }
2712
2713 // Time per generated event
2714 {
2715 TH1D* h = fHFastSim.H1Clone("hfs_time");
2716 fHMean.fHM.CreateCanvas(cName + "Time", cName + "Time", 800, 800);
2717 DrawH1(h, kLinear, kLog, "hist");
2718 DrawTextOnPad("Time", 0.35, 0.9, 0.65, 0.99);
2719 h->Fit("gaus", "Q", "", 0., 35.);
2720 TF1* func = h->GetFunction("gaus");
2721 double mean = (func != nullptr) ? func->GetParameter("Mean") : 0.;
2722 DrawTextOnPad("mean: " + Cbm::NumberToString(mean, 2) + " #mus/Event", 0.2, 0.65, 0.6, 0.89);
2723 }
2724
2725 // Occupied memory
2726 {
2727 TH1D* hRes = fHFastSim.H1Clone("hfs_memory_res");
2728 TH1D* hVir = fHFastSim.H1Clone("hfs_memory_vir");
2729 fHMean.fHM.CreateCanvas(cName + "Memory", cName + "Memory", 800, 800);
2730 DrawH1({hRes, hVir}, {"residential", "virtual"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2731 }
2732}
2733
2734void LmvmDrawAll::DrawSignalCBNormRangeDependent(string hName, string cName, ELmvmAnaStep step)
2735{
2736 if (hName != "hfsp_MinvBg" && hName != "hfsc_MinvBg")
2737 LOG(error) << "DrawSignalCBNormRangeDependent: hName " << hName << " is not valid!";
2738 vector<double> Start = {0.40, 0.45, 0.50, 0.55, 0.60};
2739 vector<double> End = {0.70, 0.80, 0.90, 1.00, 1.10, 1.20};
2740 TH1D* bre = VaryBinWidth("fastsim", hName, step, fNofFastSimEvents, fBwVarSig);
2741 TH1D* coc =
2742 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarSig);
2743 for (size_t iStart = 0; iStart < Start.size(); iStart++) {
2744 for (size_t iEnd = 0; iEnd < End.size(); iEnd++) {
2745 TH1D* cbcRaw = GetCBForNormRange("hmx_Minv", step, Start[iStart], End[iEnd]);
2746 TH1D* cbc = VaryBinWidth(cbcRaw, fNofSimEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarSig);
2747 TH1D* sig = (TH1D*) bre->Clone();
2748 sig->Add(coc);
2749 sig->Add(cbc, -1.);
2750 sig->GetYaxis()->SetRangeUser(1e-9, 5e-2);
2751 string sStart = Cbm::NumberToString(Start[iStart], 2);
2752 string sEnd = Cbm::NumberToString(End[iEnd], 2);
2753 string cNameFull = cName + "CbNormRangeDependent/" + hName + "/" + sStart + "_" + sEnd;
2754 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 800, 800);
2755 DrawH1({sig, coc}, {"Signal = B_{FS} + Cocktail - CB_{calc}", "Cocktail"}, kLinear, kLog, true, 0.47, 0.77, 0.91,
2756 0.9, "pe");
2757 fHMean.DrawAnaStepOnPad(step);
2758 }
2759 }
2760}
2761
2762TH1D* LmvmDrawAll::GetCBForNormRange(const string hName, ELmvmAnaStep step, double rangeStart, double rangeEnd)
2763{
2764 LmvmHist HM = fHEvMix;
2765 TH1D* pmSame = HM.H1Clone(hName + "PM_sameEv", step);
2766 TH1D* ppSame = HM.H1Clone(hName + "PP_sameEv", step);
2767 TH1D* mmSame = HM.H1Clone(hName + "MM_sameEv", step);
2768 TH1D* pmMixed = HM.H1Clone(hName + "PM_mixedEv", step);
2769 TH1D* ppMixed = HM.H1Clone(hName + "PP_mixedEv", step);
2770 TH1D* mmMixed = HM.H1Clone(hName + "MM_mixedEv", step);
2771 TH1D* geomSame = (TH1D*) pmSame->Clone();
2772 TH1D* geomMixed = (TH1D*) pmSame->Clone();
2773 TH1D* k = (TH1D*) pmMixed->Clone();
2774 TH1D* cb = (TH1D*) pmSame->Clone();
2775 geomSame->Reset();
2776 geomMixed->Reset();
2777 cb->Reset();
2778 for (int iB = 1; iB <= geomSame->GetNbinsX(); iB++) {
2779 double cppSame = ppSame->GetBinContent(iB);
2780 double cmmSame = mmSame->GetBinContent(iB);
2781 double cSame = std::sqrt(cppSame * cmmSame);
2782 geomSame->SetBinContent(iB, cSame);
2783 double cppMix = ppMixed->GetBinContent(iB);
2784 double cmmMix = mmMixed->GetBinContent(iB);
2785 double cMix = std::sqrt(cppMix * cmmMix);
2786 geomMixed->SetBinContent(iB, cMix);
2787 }
2788 k->Divide(geomMixed);
2789 k->Scale(1. / 2.);
2790 int ChangeBin = pmSame->FindBin(fCbChange);
2791 int NormRangeMinBin = pmSame->FindBin(rangeStart);
2792 int NormRangeMaxBin = pmSame->FindBin(rangeEnd);
2793 double normPPInt =
2794 ppSame->Integral(NormRangeMinBin, NormRangeMaxBin) / ppMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
2795 double normMMInt =
2796 mmSame->Integral(NormRangeMinBin, NormRangeMaxBin) / mmMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
2797 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
2798 double kval = k->GetBinContent(iB);
2799 double pm = pmMixed->GetBinContent(iB);
2800 double cbval = (iB < ChangeBin) ? 2. * kval * geomSame->GetBinContent(iB) : pm * std::sqrt(normPPInt * normMMInt);
2801 cb->SetBinContent(iB, cbval);
2802 }
2803
2804 // Calculate error for CB
2805 double bW = cb->GetBinWidth(1);
2806 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
2807 //s_ for same, m_ for mixed
2808 double s_pp = ppSame->GetBinContent(iB) * fNofSimEvents * bW;
2809 double s_mm = mmSame->GetBinContent(iB) * fNofSimEvents * bW;
2810 double m_pm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2811 double m_pp = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2812 double m_mm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2813
2814 // derivatives of CB_{calc} w.r. to according value
2815 double d_m_pm = std::sqrt(s_pp * s_mm / (m_pp * m_mm));
2816 double d_m_pp = -0.5 * m_pm * std::pow(m_mm, -1. / 2.) * std::pow(m_pp, -3. / 2.) * std::sqrt(s_pp * s_mm);
2817 double d_m_mm = -0.5 * m_pm * std::pow(m_mm, -3. / 2.) * std::pow(m_pp, -1. / 2.) * std::sqrt(s_pp * s_mm);
2818 double d_s_pp = 0.5 * m_pm * std::sqrt(s_mm) * std::pow(m_pp * m_mm * s_pp, -1. / 2.);
2819 double d_s_mm = 0.5 * m_pm * std::sqrt(s_pp) * std::pow(m_pp * m_mm * s_mm, -1. / 2.);
2820
2821 // contributions to error propagation
2822 double f_m_pm = std::pow(d_m_pm * std::sqrt(m_pm), 2);
2823 double f_m_pp = std::pow(d_m_pp * std::sqrt(m_pp), 2);
2824 double f_m_mm = std::pow(d_m_mm * std::sqrt(m_mm), 2);
2825 double f_s_pp = std::pow(d_s_pp * std::sqrt(s_pp), 2);
2826 double f_s_mm = std::pow(d_s_mm * std::sqrt(s_mm), 2);
2827
2828 // final error propagation values
2829 double errorBc = std::sqrt(f_m_pm + f_m_pp + f_m_mm + f_s_pp + f_s_mm) / (fNofSimEvents * bW);
2830 double errorBc2 = std::sqrt(normPPInt * normMMInt) * std::sqrt(m_pm) / (fNofSimEvents * bW); // for range > 0.4 GeV
2831 if (iB < ChangeBin) cb->SetBinError(iB, errorBc);
2832 if (iB >= ChangeBin) cb->SetBinError(iB, errorBc2);
2833 }
2834 return cb;
2835}
2836
2837void LmvmDrawAll::CalculateCBFromFastSimEvents() // TODO: get CB via 'GetCBForNormRange()'
2838{
2839 string hName = "hfsc_Minv";
2841 TH1D* pmSame = fHFastSim.H1Clone(hName + "Bg", step);
2842 TH1D* ppSame = fHFastSim.H1Clone(hName + "PP_sameEv", step);
2843 TH1D* mmSame = fHFastSim.H1Clone(hName + "MM_sameEv", step);
2844 TH1D* pmMixed = fHFastSim.H1Clone(hName + "PM_mixedEv", step);
2845 TH1D* ppMixed = fHFastSim.H1Clone(hName + "PP_mixedEv", step);
2846 TH1D* mmMixed = fHFastSim.H1Clone(hName + "MM_mixedEv", step);
2847 TH1D* geomSame = (TH1D*) pmSame->Clone();
2848 TH1D* geomMixed = (TH1D*) pmSame->Clone();
2849 TH1D* k = (TH1D*) pmMixed->Clone();
2850 TH1D* cb = (TH1D*) pmSame->Clone();
2851 geomSame->Reset();
2852 geomMixed->Reset();
2853 cb->Reset();
2854 k->GetYaxis()->SetTitle("#it{k} Factor");
2855 for (int iB = 1; iB <= geomSame->GetNbinsX(); iB++) {
2856 double cppSame = ppSame->GetBinContent(iB);
2857 double cmmSame = mmSame->GetBinContent(iB);
2858 double cSame = std::sqrt(cppSame * cmmSame);
2859 geomSame->SetBinContent(iB, cSame);
2860 double cppMix = ppMixed->GetBinContent(iB);
2861 double cmmMix = mmMixed->GetBinContent(iB);
2862 double cMix = std::sqrt(cppMix * cmmMix);
2863 geomMixed->SetBinContent(iB, cMix);
2864 }
2865 k->Divide(geomMixed);
2866 k->Scale(1. / 2.);
2867 int ChangeBin = pmSame->FindBin(fCbChange);
2868 int NormRangeMinBin = pmSame->FindBin(fCbNormRangeMin);
2869 int NormRangeMaxBin = pmSame->FindBin(fCbNormRangeMax);
2870 double normPPInt =
2871 ppSame->Integral(NormRangeMinBin, NormRangeMaxBin) / ppMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
2872 double normMMInt =
2873 mmSame->Integral(NormRangeMinBin, NormRangeMaxBin) / mmMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
2874 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
2875 double kval = k->GetBinContent(iB);
2876 double geomMeanMixNormed = geomMixed->GetBinContent(iB) * std::sqrt(normPPInt * normMMInt);
2877 double cbval = (iB < ChangeBin) ? 2. * kval * geomSame->GetBinContent(iB) : 2. * kval * geomMeanMixNormed;
2878 cb->SetBinContent(iB, cbval);
2879 }
2880
2881 // Calculate error for CB
2882 double bW = cb->GetBinWidth(1);
2883 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
2884 //s_ for same, m_ for mixed
2885 double s_pp = ppSame->GetBinContent(iB) * fNofSimEvents * bW;
2886 double s_mm = mmSame->GetBinContent(iB) * fNofSimEvents * bW;
2887 double m_pm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2888 double m_pp = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2889 double m_mm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
2890
2891 // derivatives of CB_{calc} w.r. to according value
2892 double d_m_pm = std::sqrt(s_pp * s_mm / (m_pp * m_mm));
2893 double d_m_pp = -0.5 * m_pm * std::pow(m_mm, -1. / 2.) * std::pow(m_pp, -3. / 2.) * std::sqrt(s_pp * s_mm);
2894 double d_m_mm = -0.5 * m_pm * std::pow(m_mm, -3. / 2.) * std::pow(m_pp, -1. / 2.) * std::sqrt(s_pp * s_mm);
2895 double d_s_pp = 0.5 * m_pm * std::sqrt(s_mm) * std::pow(m_pp * m_mm * s_pp, -1. / 2.);
2896 double d_s_mm = 0.5 * m_pm * std::sqrt(s_pp) * std::pow(m_pp * m_mm * s_mm, -1. / 2.);
2897
2898 // contributions to error propagation
2899 double f_m_pm = std::pow(d_m_pm * std::sqrt(m_pm), 2);
2900 double f_m_pp = std::pow(d_m_pp * std::sqrt(m_pp), 2);
2901 double f_m_mm = std::pow(d_m_mm * std::sqrt(m_mm), 2);
2902 double f_s_pp = std::pow(d_s_pp * std::sqrt(s_pp), 2);
2903 double f_s_mm = std::pow(d_s_mm * std::sqrt(s_mm), 2);
2904
2905 // final error propagation values
2906 double errorBc = std::sqrt(f_m_pm + f_m_pp + f_m_mm + f_s_pp + f_s_mm) / (fNofSimEvents * bW);
2907 double errorBc2 = std::sqrt(normPPInt * normMMInt) * std::sqrt(m_pm) / (fNofSimEvents * bW); // for range > 0.4 GeV
2908 if (iB < ChangeBin) cb->SetBinError(iB, errorBc);
2909 if (iB >= ChangeBin) cb->SetBinError(iB, errorBc2);
2910 }
2911 fHMean.fHM.Add("hReCbGeom_sameEv", geomSame);
2912 fHMean.fHM.Add("hReCbGeom_mixedEv", geomMixed);
2913 fHMean.fHM.Add("hReCbK", k);
2914 fHMean.fHM.Add("hReCb", cb);
2915 string cName = "FastSim/CombinatorialBackground/BG";
2916 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 3200, 800);
2917 c->Divide(4, 1);
2918 c->cd(1);
2919 DrawH1({pmSame, ppSame, mmSame}, {"e+e-", "e+e+", "e-e-"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2920 DrawTextOnPad("Same Events", 0.3, 0.9, 0.7, 0.99);
2921 c->cd(2);
2922 DrawH1({pmMixed, ppMixed, mmMixed}, {"e+e-", "e+e+", "e-e-"}, kLinear, kLog, true, 0.8, 0.75, 0.91, 0.9, "hist");
2923 DrawTextOnPad("Mixed Events", 0.29, 0.9, 0.71, 0.99);
2924 c->cd(3);
2925 DrawH1(k, kLinear, kLinear, "hist");
2926 DrawTextOnPad("#it{k} Factor", 0.3, 0.9, 0.7, 0.99);
2927 c->cd(4);
2928 DrawH1(cb, kLinear, kLog, "hist");
2929 DrawTextOnPad("Combinatorial Background from Fast Simulations", 0.1, 0.9, 0.84, 0.99);
2930}
2931
2933{
2935 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
2936
2937 vector<TH1*> HistsCB;
2938 vector<TH1*> HistsRE;
2939 vector<TH1*> HistsSig;
2940
2941 for (const string cutset : {"cut_standard_8", "cut_looser_10", "cut_stricter_17"}) {
2942 string dir = "/lustre/cbm/users/criesen/data/studies/RandomEvent/SysErrorSignal/" + cutset + "/";
2943 TH1D* coc = nullptr;
2944 TH1D* cocPluto = nullptr;
2945 TH1D* cocUrqmd = nullptr;
2946 int nEvents = 0;
2947 double bW = 0;
2948
2949 // Get Cocktail
2950 for (const string pf : {"inmed", "qgp", "omegadalitz", "omegaepem", "phi"}) {
2951 LmvmHist HM;
2952 TFile* filePluto = new TFile((dir + pf + "/analysis.all.root").c_str());
2953 HM.fHM.ReadFromFile(filePluto);
2954 int nEventsSig = HM.H1("hEventNumber")->GetEntries();
2955 nEvents += nEventsSig;
2956 string nameFull = fHMean.GetName("hMinv", ELmvmSrc::Signal, step);
2957 TH1D* pluto = (TH1D*) HM.fHM.GetObject("hMinv_signal_" + stepname)->Clone();
2958 TH1D* eta = (TH1D*) HM.fHM.GetObject("hMinv_eta_" + stepname)->Clone();
2959 TH1D* pi0 = (TH1D*) HM.fHM.GetObject("hMinv_pi0_" + stepname)->Clone();
2960 bW = pluto->GetBinWidth(1);
2961 pluto->Scale(1. / (nEventsSig * bW));
2962 eta->Scale(1. / bW);
2963 pi0->Scale(1. / bW);
2964 if (cocPluto == nullptr)
2965 cocPluto = pluto;
2966 else
2967 cocPluto->Add(pluto);
2968 if (cocUrqmd == nullptr)
2969 cocUrqmd = eta;
2970 else
2971 cocUrqmd->Add(eta);
2972 cocUrqmd->Add(pi0);
2973 }
2974
2975 cocUrqmd->Scale(1. / nEvents);
2976 coc = cocUrqmd;
2977 coc->Add(cocPluto);
2978
2979 // Get Background from Fast Simulations
2980 LmvmHist HMFastSim;
2981 TFile* fileRandom = new TFile((dir + "randomevent.all.root").c_str());
2982 HMFastSim.fHM.ReadFromFile(fileRandom);
2983 double nofFastSimEv = HMFastSim.H1("hre_EventNumber")->GetEntries();
2984 HMFastSim.fHM.ScaleByPattern("hre.*_Minv.*", 1. / nofFastSimEv);
2985 TH1D* bre = HMFastSim.H1Clone("hrec_MinvBg"); //("hre_MinvBg_" + stepname);
2986
2987 // Calculate Combinatorial Background
2988 LmvmHist HMCB;
2989 TFile* filecb = new TFile((dir + "evmix.all.root").c_str());
2990 HMCB.fHM.ReadFromFile(filecb);
2991 HMCB.fHM.ScaleByPattern("hmx_Minv.*", 1. / fNofEvMixEvents);
2992 string hName = "hmx_Minv";
2993 TH1D* pmSame = HMCB.H1Clone(hName + "PM_sameEv", step);
2994 TH1D* ppSame = HMCB.H1Clone(hName + "PP_sameEv", step);
2995 TH1D* mmSame = HMCB.H1Clone(hName + "MM_sameEv", step);
2996 TH1D* pmMixed = HMCB.H1Clone(hName + "PM_mixedEv", step);
2997 TH1D* ppMixed = HMCB.H1Clone(hName + "PP_mixedEv", step);
2998 TH1D* mmMixed = HMCB.H1Clone(hName + "MM_mixedEv", step);
2999 TH1D* geomSame = (TH1D*) pmSame->Clone();
3000 TH1D* geomMixed = (TH1D*) pmSame->Clone();
3001 TH1D* k = (TH1D*) pmMixed->Clone();
3002 TH1D* cb = (TH1D*) pmSame->Clone();
3003 geomSame->Reset();
3004 geomMixed->Reset();
3005 cb->Reset();
3006
3007 for (int iB = 1; iB <= geomSame->GetNbinsX(); iB++) {
3008 double cppSame = ppSame->GetBinContent(iB);
3009 double cmmSame = mmSame->GetBinContent(iB);
3010 double cSame = std::sqrt(cppSame * cmmSame);
3011 geomSame->SetBinContent(iB, cSame);
3012 double cppMix = ppMixed->GetBinContent(iB);
3013 double cmmMix = mmMixed->GetBinContent(iB);
3014 double cMix = std::sqrt(cppMix * cmmMix);
3015 geomMixed->SetBinContent(iB, cMix);
3016 }
3017 k->Divide(geomMixed);
3018 k->Scale(1. / 2.);
3019 int ChangeBin = pmSame->FindBin(fCbChange);
3020 int NormRangeMinBin = pmSame->FindBin(fCbNormRangeMin);
3021 int NormRangeMaxBin = pmSame->FindBin(fCbNormRangeMax);
3022 double normPPInt =
3023 ppSame->Integral(NormRangeMinBin, NormRangeMaxBin) / ppMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
3024 double normMMInt =
3025 mmSame->Integral(NormRangeMinBin, NormRangeMaxBin) / mmMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
3026
3027 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
3028 double kval = k->GetBinContent(iB);
3029 double pp = ppMixed->GetBinContent(iB);
3030 double mm = mmMixed->GetBinContent(iB);
3031 double cbval = (iB < ChangeBin) ? 2. * kval * geomSame->GetBinContent(iB)
3032 : 2. * kval * std::sqrt(normPPInt * pp * normMMInt * mm);
3033 cb->SetBinContent(iB, cbval);
3034 }
3035
3036 // Calculate error for CB
3037 for (int iB = 1; iB <= cb->GetNbinsX(); iB++) {
3038 //s_ for same, m_ for mixed
3039 double s_pp = ppSame->GetBinContent(iB) * fNofSimEvents * bW;
3040 double s_mm = mmSame->GetBinContent(iB) * fNofSimEvents * bW;
3041 double m_pm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
3042 double m_pp = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
3043 double m_mm = pmMixed->GetBinContent(iB) * fNofSimEvents * bW;
3044
3045 // derivatives of CB_{calc} w.r. to according value
3046 double d_m_pm = std::sqrt(s_pp * s_mm / (m_pp * m_mm));
3047 double d_m_pp = -0.5 * m_pm * std::pow(m_mm, -1. / 2.) * std::pow(m_pp, -3. / 2.) * std::sqrt(s_pp * s_mm);
3048 double d_m_mm = -0.5 * m_pm * std::pow(m_mm, -3. / 2.) * std::pow(m_pp, -1. / 2.) * std::sqrt(s_pp * s_mm);
3049 double d_s_pp = 0.5 * m_pm * std::sqrt(s_mm) * std::pow(m_pp * m_mm * s_pp, -1. / 2.);
3050 double d_s_mm = 0.5 * m_pm * std::sqrt(s_pp) * std::pow(m_pp * m_mm * s_mm, -1. / 2.);
3051
3052 // contributions to error propagation
3053 double f_m_pm = std::pow(d_m_pm * std::sqrt(m_pm), 2);
3054 double f_m_pp = std::pow(d_m_pp * std::sqrt(m_pp), 2);
3055 double f_m_mm = std::pow(d_m_mm * std::sqrt(m_mm), 2);
3056 double f_s_pp = std::pow(d_s_pp * std::sqrt(s_pp), 2);
3057 double f_s_mm = std::pow(d_s_mm * std::sqrt(s_mm), 2);
3058
3059 // final error propagation values
3060 double errorBc = std::sqrt(f_m_pm + f_m_pp + f_m_mm + f_s_pp + f_s_mm) / (fNofSimEvents * bW);
3061 double errorBc2 =
3062 std::sqrt(normPPInt * normMMInt) * std::sqrt(m_pm) / (fNofSimEvents * bW); // for range > 0.4 GeV
3063 if (iB < ChangeBin) cb->SetBinError(iB, errorBc);
3064 if (iB >= ChangeBin) cb->SetBinError(iB, errorBc2);
3065 }
3066
3067 // Calculate Signal with Errors
3068 TH1D* sig = (TH1D*) bre->Clone();
3069 sig->Add(coc);
3070 sig->Add(cb, -1.);
3071 for (int iB = 1; iB <= sig->GetNbinsX(); iB++) {
3072 double D_bre = bre->GetBinError(iB);
3073 double D_cbc = cb->GetBinError(iB);
3074 double D_dNdM = std::sqrt(D_bre * D_bre + D_cbc * D_cbc);
3075 sig->SetBinError(iB, D_dNdM);
3076 }
3077
3078 TH1D* ratio = (TH1D*) sig->Clone();
3079 ratio->Divide(coc);
3080 VaryBinWidth(ratio, fBwVarSig);
3081 ratio->GetYaxis()->SetRangeUser(-2., 2.);
3082 ratio->GetYaxis()->SetTitle("Ratio Sig_{RE} / MC Cocktail");
3083
3084 HistsSig.push_back(ratio);
3085 HistsCB.push_back(cb);
3086 HistsRE.push_back(bre);
3087 }
3088
3089 fHMean.fHM.CreateCanvas("FastSim/SysErrors/SigToCock", "FastSim/SysErrors/SigToCock", 800, 800);
3090 DrawH1(HistsSig, {"cutset_0", "cutset_looser", "cutset_stricter"}, kLinear, kLinear, true, 0.7, 0.8, 0.95, 0.91,
3091 "pe");
3092
3093 // Ratios of each CBcalc and BRE from different Elid cuts
3094 {
3095 TH1D* ratCbLoose = (TH1D*) HistsCB[1];
3096 TH1D* ratCbStrict = (TH1D*) HistsCB[2];
3097 ratCbLoose->Divide(HistsCB[0]);
3098 ratCbStrict->Divide(HistsCB[0]);
3099
3100 TH1D* ratReLoose = (TH1D*) HistsRE[1];
3101 TH1D* ratReStrict = (TH1D*) HistsRE[2];
3102 ratReLoose->Divide(HistsRE[0]);
3103 ratReStrict->Divide(HistsRE[0]);
3104
3105 VaryBinWidth(ratCbLoose, fBwVarReg);
3106 VaryBinWidth(ratCbStrict, fBwVarReg);
3107 VaryBinWidth(ratReLoose, fBwVarReg);
3108 VaryBinWidth(ratReStrict, fBwVarReg);
3109
3110 ratCbLoose->GetYaxis()->SetRangeUser(0.5, 1.5);
3111 ratReLoose->GetYaxis()->SetRangeUser(0.5, 1.5);
3112 ratCbLoose->GetYaxis()->SetTitle("Ratio");
3113 ratReLoose->GetYaxis()->SetTitle("Ratio");
3114
3115 TCanvas* c = fHMean.fHM.CreateCanvas("FastSim/SysErrors/Backgrounds", "FastSim/SysErrors/Backgrounds", 1600, 800);
3116 c->Divide(2, 1);
3117 c->cd(1);
3118 DrawH1({ratCbLoose, ratCbStrict}, {"loose / standard", "strict / standard"}, kLinear, kLinear, true, 0.7, 0.8, 0.95,
3119 0.91, "p");
3120 DrawTextOnPad("Combinatorial Background", 0.25, 0.9, 0.75, 0.99);
3121 c->cd(2);
3122 DrawH1({ratReLoose, ratReStrict}, {"loose / standard", "strict / standard"}, kLinear, kLinear, true, 0.7, 0.8, 0.95,
3123 0.91, "p");
3124 DrawTextOnPad("Fast Simulation Background", 0.25, 0.9, 0.75, 0.99);
3125 }
3126
3127 // Ratio BRE/CBcalc for different Elid cuts
3128 {
3129 TH1D* r0 = (TH1D*) HistsRE[0];
3130 TH1D* rL = (TH1D*) HistsRE[1];
3131 TH1D* rS = (TH1D*) HistsRE[2];
3132 r0->Divide(HistsCB[0]);
3133 rL->Divide(HistsCB[1]);
3134 rS->Divide(HistsCB[2]);
3135
3139
3140 r0->GetYaxis()->SetRangeUser(0.97, 1.03);
3141 r0->GetYaxis()->SetTitle("Ratio");
3142
3143 fHMean.fHM.CreateCanvas("FastSim/SysErrors/BreOverCbcalc", "FastSim/SysErrors/BreOverCbcalc", 800, 800);
3144 DrawH1({r0, rL, rS}, {"cutset_0", "cutset_looser", "cutset_stricter"}, kLinear, kLinear, true, 0.7, 0.8, 0.95, 0.91,
3145 "pe");
3146 DrawTextOnPad("B_{FS} / CB_{calc}", 0.35, 0.9, 0.65, 0.99);
3147 }
3148}
3149
3151{
3152 // Draw Numbers of Events
3153 {
3154 TH1D* h = new TH1D("hNofEvents", "hNofEvents; PLUTO File; Number", fH.size(), 0., fH.size());
3155 double min = 1e9;
3156 double max = -1e9;
3157 for (size_t iS = 0; iS < fH.size(); iS++) {
3158 double iB = iS + 1;
3159 double c = fH[iS]->H1("hEventNumber")->GetEntries();
3160 if (c < min) min = c;
3161 if (c > max) max = c;
3162 h->SetBinContent(iB, c);
3163 h->GetXaxis()->SetBinLabel(iB, fHMean.fSignalNames[iS].c_str());
3164 }
3165 h->GetYaxis()->SetRangeUser(0.9 * min, 1.1 * max);
3166 fHMean.fHM.CreateCanvas("Numbers/NofEvents", "Numbers/NofEvents", 800, 800);
3167 DrawH1(h, kLinear, kLinear, "hist text30"); // "b", "bar"
3168 h->SetMarkerSize(1.);
3169 DrawTextOnPad("Total: " + Cbm::NumberToString(fNofSimEvents, 0) + " Events", 0.1, 0.8, 0.55, 0.89);
3170 }
3171
3172 // Draw Numbers of MC Tracks seperate
3173 {
3174 vector<string> xLabel = {"e^{#pm}", "#pi^{#pm}", "#pi^{0}", "p", "n", "#gamma_{ch}", "o."};
3175 fHMean.fHM.CreateCanvas("Numbers/MCTracks", "Numbers/MCTracks", 800, 800);
3176 TH1D* h = fHMean.H1Clone("hNofMcTracks");
3177 DrawH1(h, kLinear, kLog, "hist");
3178 for (size_t iL = 0; iL < xLabel.size(); iL++) {
3179 h->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
3180 }
3181 double nAll = h->Integral(1, h->GetNbinsX());
3182 double ratEl = 100 * h->GetBinContent(1) / nAll;
3183 double ratPiC = 100 * h->GetBinContent(2) / nAll;
3184 double ratPi0 = 100 * h->GetBinContent(3) / nAll;
3185 double ratProt = 100 * h->GetBinContent(4) / nAll;
3186 double ratNeut = 100 * h->GetBinContent(5) / nAll;
3187 double ratGCh = 100 * h->GetBinContent(6) / nAll;
3188 double ratioO = 100 * h->GetBinContent(7) / nAll;
3189 DrawTextOnPad(Cbm::NumberToString(ratEl, 1) + " %", 0.17, 0.8, 0.27, 0.89);
3190 DrawTextOnPad(Cbm::NumberToString(ratPiC, 1) + " %", 0.28, 0.8, 0.38, 0.89);
3191 DrawTextOnPad(Cbm::NumberToString(ratPi0, 1) + " %", 0.38, 0.8, 0.48, 0.89);
3192 DrawTextOnPad(Cbm::NumberToString(ratProt, 1) + " %", 0.49, 0.8, 0.59, 0.89);
3193 DrawTextOnPad(Cbm::NumberToString(ratNeut, 1) + " %", 0.59, 0.8, 0.69, 0.89);
3194 DrawTextOnPad(Cbm::NumberToString(ratGCh, 0) + " %", 0.69, 0.8, 0.79, 0.89);
3195 DrawTextOnPad(Cbm::NumberToString(ratioO, 1) + " %", 0.8, 0.8, 0.9, 0.89);
3196 DrawTextOnPad("Total: " + Cbm::NumberToString(nAll, 0) + " MC Tracks / Event", 0.05, 0.65, 0.7, 0.83);
3197 }
3198
3199 // Draw Numbers of Global Tracks seperate
3200 {
3201 vector<string> xLabel = {"e_{Pluto}", "e_{#gamma}", "e_{o.}", "#pi^{#pm}", "p", "o."};
3202 fHMean.fHM.CreateCanvas("Numbers/GlobalTracks", "Numbers/GlobalTracks", 800, 800);
3203 TH1D* h = fHMean.H1Clone("hNofGTracks");
3204 DrawH1(h, kLinear, kLog, "hist");
3205 for (size_t iL = 0; iL < xLabel.size(); iL++) {
3206 h->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
3207 }
3208 double nAll = h->Integral(1, h->GetNbinsX());
3209 double ratPlutoEl = 100 * h->GetBinContent(1) / nAll;
3210 double ratGammaEl = 100 * h->GetBinContent(2) / nAll;
3211 double ratOtherEl = 100 * h->GetBinContent(3) / nAll;
3212 double ratPiC = 100 * h->GetBinContent(4) / nAll;
3213 double ratProton = 100 * h->GetBinContent(5) / nAll;
3214 double ratioO = 100 * h->GetBinContent(6) / nAll;
3215 DrawTextOnPad(Cbm::NumberToString(ratPlutoEl, 1) + " %", 0.16, 0.8, 0.30, 0.89);
3216 DrawTextOnPad(Cbm::NumberToString(ratGammaEl, 1) + " %", 0.31, 0.8, 0.40, 0.89);
3217 DrawTextOnPad(Cbm::NumberToString(ratOtherEl, 1) + " %", 0.42, 0.8, 0.54, 0.89);
3218 DrawTextOnPad(Cbm::NumberToString(ratPiC, 1) + " %", 0.55, 0.8, 0.64, 0.89);
3219 DrawTextOnPad(Cbm::NumberToString(ratProton, 0) + " %", 0.67, 0.8, 0.77, 0.89);
3220 DrawTextOnPad(Cbm::NumberToString(ratioO, 1) + " %", 0.79, 0.8, 0.89, 0.89);
3221 DrawTextOnPad(Cbm::NumberToString(nAll, 0) + " Global Tracks / Event", 0.1, 0.7, 0.55, 0.83);
3222 }
3223
3224 // Draw number of Candidates (w.o. Pluto electrons)
3225 {
3226 gStyle->SetPaintTextFormat("4.2f");
3227 fHMean.fHM.CreateCanvas("Numbers/Candidates", "Numbers/Candidates", 1100, 800);
3228 TH1D* h = fHMean.H1Clone("hNofBgTracks");
3229 DrawH1(h, kLinear, kLog, "hist text30");
3230 h->SetMarkerSize(1.5);
3231 fHMean.SetAnalysisStepAxis(h);
3232 }
3233
3234 // Draw Occurence of PDG
3235 /*{
3236 TH1D* h = fHMean.H1Clone("hCandPdg_mc");
3237 TCanvas* c = fHMean.fHM.CreateCanvas("Numbers/pdg", "Numbers/pdg", 2400, 800);
3238 c->Divide(3, 1);
3239 c->cd(1);
3240 DrawH1(h, kLinear, kLog, "hist");
3241 c->cd(2);
3242 TH1D* h2 = (TH1D*) h->Clone();
3243 h2->GetXaxis()->SetRangeUser(-330., 330.);
3244 DrawH1(h2, kLinear, kLog, "hist");
3245 c->cd(3);
3246 TH1D* h3 = (TH1D*) h->Clone();
3247 h3->GetXaxis()->SetRangeUser(-25., 25.);
3248 DrawH1(h3, kLinear, kLog, "hist");
3249
3250 vector<int> pdg;
3251 for (int iB = 1; iB < h->GetNbinsX(); iB++) {
3252 if (h->GetBinContent(iB) != 0 && h->GetBinCenter(iB) < 0) pdg.push_back(h->GetXaxis()->GetBinCenter(iB) - 0.5);
3253 if (h->GetBinContent(iB) != 0 && h->GetBinCenter(iB) > 0) pdg.push_back(h->GetXaxis()->GetBinCenter(iB) + 0.5);
3254 }
3255 cout << "Occuring PDGs: ";
3256 for (size_t i = 0; i < pdg.size(); i++) {
3257 cout << pdg[i] << ", ";
3258 if (i == pdg.size() - 1) cout << endl;
3259 }
3260 }*/
3261}
3262
3264{
3265 string cName = "Rapidity/";
3266 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Rapidity_mc", cName + "Rapidity_mc", 2400, 1600);
3267 c->Divide(3, 2);
3268 int iC = 1;
3269 for (ELmvmSignal signal : fHMean.fSignals) {
3270 int nEventsSig = (int) fH[static_cast<int>(signal)]->H1("hEventNumber")->GetEntries();
3271 TH1D* plus = H(signal)->H1Clone("hRapidity+_signal_mc");
3272 TH1D* minus = H(signal)->H1Clone("hRapidity-_signal_mc");
3273 plus->Scale(1. / nEventsSig);
3274 minus->Scale(1. / nEventsSig);
3275 plus->GetYaxis()->SetTitle("Entries/Event");
3276 c->cd(iC++);
3277 DrawH1({plus, minus}, {"e+", "e-"}, kLinear, kLog, true, 0.85, 0.7, 0.97, 0.92, "hist");
3278 DrawTextOnPad(fHMean.fSignalNames[static_cast<int>(signal)], 0.35, 0.9, 0.65, 0.99);
3279 }
3280 c->cd(6);
3281 //int nEventsSig = (int) fH[static_cast<int>(ELmvmSignal::Inmed)]->H1("hEventNumber")->GetEntries();
3282 TH1D* plus = fHMean.H1Clone("hRapidity+_eta_mc");
3283 TH1D* minus = fHMean.H1Clone("hRapidity-_eta_mc");
3284 //plus->Scale(1. / nEventsSig);
3285 //minus->Scale(1. / nEventsSig);
3286 plus->GetYaxis()->SetTitle("Entries/Event");
3287 DrawH1({plus, minus}, {"e+", "e-"}, kLinear, kLog, true, 0.85, 0.7, 0.97, 0.92, "hist");
3288 DrawTextOnPad("Eta Dalitz (UrQMD)", 0.32, 0.9, 0.68, 0.99);
3289}
3290
3292{
3293 vector<string> xLabel = {
3294 "P_{x}", "P_{y}", "#Chi^{2}_{prim}", "#Chi^{2}_{STS}", "#Chi^{2}_{RICH}", "#Chi^{2}_{TRD} / 2",
3295 "E-Loss / 10^{4}", "ANN_{RICH} + 2", "Like El", "Like Pi", "m^{2} + 1", "time_{TOF}",
3296 "dist_{TOF} / 5", "nHitsSts", "nHitsRich / 5", "nHitsTrd"};
3297
3298 //TCanvas* c = fHMean.fHM.CreateCanvas("Properties/Ratio/All", "Properties/Ratio/All", 3200, 1800);
3299 //c->Divide(4, 3);
3300
3301 for (int i = 1; i <= 11; i++) {
3302 string hName = "hCandProperties_" + Cbm::NumberToString(i, 0);
3303 fHMean.DrawAllCands(2, "Properties/" + Cbm::NumberToString(i, 0), hName, xLabel, {""}, false, true, 1e-12, 10.);
3304 }
3305
3306 TCanvas* cRat = fHMean.fHM.CreateCanvas("Properties/Ratio/All", "Properties/Ratio/All", 3200, 1800);
3307 cRat->Divide(4, 3);
3308 for (int i = 1; i <= 11; i++) {
3309 string hName = "hCandProperties_" + Cbm::NumberToString(i, 0);
3310
3311 TH2D* ratio = fHMean.H2Clone(hName + "_" + fHMean.fCandNames[0]);
3312 ratio->Add(fHMean.H2(hName + "_" + fHMean.fCandNames[1]));
3313
3314 TH2D* bg = fHMean.H2Clone(hName + "_" + fHMean.fCandNames[2]);
3315 for (size_t iC = 3; iC < fHMean.fCandNames.size(); iC++) {
3316 bg->Add(fHMean.H2(hName + "_" + fHMean.fCandNames[iC]));
3317 }
3318
3319 ratio->Divide(bg);
3320 ratio->GetZaxis()->SetRangeUser(1e-5, 2);
3321 ratio->GetZaxis()->SetTitle("Ratio Signal/BG");
3322
3323 cRat->cd(i);
3324 DrawH2(ratio, kLinear, kLog, kLog, "colz");
3325
3326 for (size_t iL = 0; iL < xLabel.size(); iL++) {
3327 ratio->GetXaxis()->SetBinLabel(iL + 1, xLabel[iL].c_str());
3328 }
3329 if (i < 11)
3330 DrawTextOnPad(Cbm::NumberToString(i - 1, 0) + " GeV < P < " + Cbm::NumberToString(i, 0) + " GeV", 0.15, 0.9, 0.65,
3331 0.99);
3332 else
3333 DrawTextOnPad("P > 10 GeV", 0.15, 0.9, 0.65, 0.99);
3334
3335 fHMean.fHM.CreateCanvas("Properties/Ratio/" + Cbm::NumberToString(i, 0),
3336 "Properties/Ratio/" + Cbm::NumberToString(i, 0), 2800, 800);
3337 DrawH2(ratio, kLinear, kLog, kLog, "colz");
3338 if (i < 11)
3339 DrawTextOnPad(Cbm::NumberToString(i - 1, 0) + " GeV < P < " + Cbm::NumberToString(i, 0) + " GeV", 0.15, 0.9, 0.65,
3340 0.99);
3341 else
3342 DrawTextOnPad("P > 10 GeV", 0.15, 0.9, 0.65, 0.99);
3343 }
3344}
3345
3347{
3348 double min = 1e-7;
3349 double max = 1e-1;
3350 fHMean.DrawAllCands(2, "RICH/RingTrackDist/NextVsSecond/all_next", "RichRingNeighbour_all_next", {""}, {""}, false,
3351 false, min, max);
3352 fHMean.DrawAllCands(2, "RICH/RingTrackDist/NextVsSecond/all_secondnext", "RichRingNeighbour_all_secondnext", {""},
3353 {""}, false, false, min, max);
3354 fHMean.DrawAllCands(2, "RICH/RingTrackDist/NextVsSecond/elid_next", "RichRingNeighbour_elid_next", {""}, {""}, false,
3355 false, min, max);
3356 fHMean.DrawAllCands(2, "RICH/RingTrackDist/NextVsSecond/elid_secondnext", "RichRingNeighbour_elid_secondnext", {""},
3357 {""}, false, false, min, max);
3358
3359 fHMean.DrawAllCandsAndSteps(1, "RICH/RingTrackDist/1D/", "hRichRingTrackDist", {""}, {""}, false, false, 1e-9, 10);
3360 fHMean.DrawAllCandsAndSteps(2, "RICH/RingTrackDist/2D/", "hRichRingTrackDistVsMom", {""}, {""}, false, false, 1e-7,
3361 1e-2);
3362
3363 fHMean.fHM.CreateCanvas("RICH/NofHits", "RICH/NofHits", 800, 800);
3364 TH1D* hHits = fHMean.H1Clone("hNofRichHits");
3365 //hHits->SetStats(1);
3366 DrawH1(hHits, kLinear, kLog, "hist");
3367 hHits->Fit("gaus", "Q");
3368 TF1* fHits = hHits->GetFunction("gaus");
3369 double meanH = (fHits != nullptr) ? fHits->GetParameter("Mean") : 0.;
3370 DrawTextOnPad("mean: " + Cbm::NumberToString(meanH, 0), 0.1, 0.8, 0.4, 0.89);
3371
3372 fHMean.fHM.CreateCanvas("RICH/NofRings", "RICH/NofRings", 800, 800);
3373 TH1D* hRings = fHMean.H1Clone("hNofRichRings");
3374 DrawH1(hRings, kLinear, kLog, "hist");
3375 hRings->Fit("gaus", "Q");
3376 TF1* fRings = hRings->GetFunction("gaus");
3377 double meanR = (fRings != nullptr) ? fRings->GetParameter("Mean") : 0.;
3378 DrawTextOnPad("mean: " + Cbm::NumberToString(meanR, 0), 0.1, 0.8, 0.4, 0.89);
3379
3380 TCanvas* c = fHMean.fHM.CreateCanvas("RICH/BoA", "RICH/BoA", 1600, 1600);
3381 c->Divide(2, 2);
3382 int iC = 1;
3383 for (const string step : {"mc", "acc", "chi2prim", "elid"}) {
3384 string hName = "hRichRingBoA_" + step;
3385 TH1D* h = fHMean.H1Clone(hName);
3386 c->cd(iC++);
3387 DrawH1(h, kLinear, kLog, "hist");
3388 DrawTextOnPad(step, 0.3, 0.9, 0.7, 0.99);
3389 }
3390}
3391
3392template<class T>
3393T* LmvmDrawAll::GetCocktailMinv(const string& name, ELmvmAnaStep step, bool scaleAll)
3394{
3395 T* sEta = dynamic_cast<T*>(fHMean.GetObject(fHMean.GetName(name, ELmvmSrc::Eta, step)));
3396 T* sPi0 = dynamic_cast<T*>(fHMean.GetObject(fHMean.GetName(name, ELmvmSrc::Pi0, step)));
3397 T* cocktail = nullptr;
3398 string nameFull;
3399 for (ELmvmSignal signal : fHMean.fSignals) {
3400 nameFull = fHMean.GetName(name, ELmvmSrc::Signal, step);
3401 T* sHist = dynamic_cast<T*>(H(signal)->GetObject(nameFull)->Clone());
3402 int nofEventsSig = (int) H(signal)->H1("hEventNumber")->GetEntries();
3403 if (scaleAll)
3404 sHist->Scale(1. / (nofEventsSig * fHMean.fNofSignals));
3405 else
3406 sHist->Scale(1. / nofEventsSig);
3407 // Rebinning only for 1D histograms
3408 if (dynamic_cast<T*>(fHMean.GetObject(fHMean.GetName(name, ELmvmSrc::Eta, step)))->GetDimension() == 1) {
3409 sHist->Rebin(fRebinMinv);
3410 double binWidth = sHist->GetBinWidth(1);
3411 sHist->Scale(1. / binWidth);
3412 }
3413 if (cocktail == nullptr)
3414 cocktail = sHist;
3415 else
3416 cocktail->Add(sHist);
3417 }
3418 cocktail->Add(sEta);
3419 cocktail->Add(sPi0);
3420 cocktail->SetName((nameFull + "_cocktail").c_str());
3421 return cocktail;
3422}
3423
3425{
3426 fHMean.DrawAllCandsAndSteps(2, "STS/E-Loss/", "hELossSts", {""}, {""}, false, false, 1e-12, 1e-2);
3427 fHMean.DrawAllCandsAndSteps(2, "RICH/ANN/", "hRichAnn", {""}, {""}, false, false, 1e-13, 1.);
3428 fHMean.DrawAllCandsAndSteps(2, "TRD/El-Like/", "hTrdElLike", {""}, {""}, false, false, 1e-13, 1.);
3429 fHMean.DrawAllCandsAndSteps(2, "TRD/Chi2/", "hChi2Dets_trd", {""}, {""}, false, false, 1e-13, 1e-2);
3430 fHMean.DrawAllCandsAndSteps(2, "TOF/M2/", "hTofM2", {""}, {""}, false, false, 1e-12, 1e-1);
3431 fHMean.DrawAllCandsAndSteps(2, "TOF/Dist/", "hTofDist", {""}, {""}, false, false, 1e-12, 1e-1);
3432 fHMean.DrawAllCands(2, "TOF/Dist/truematch", "hTofDist_truematch", {""}, {""}, false, false, 1e-12, 1e-1);
3433 fHMean.DrawAllCands(2, "TOF/Dist/mismatch", "hTofDist_mismatch", {""}, {""}, false, false, 1e-12, 1e-1);
3434 //fHMean.DrawAllCands(2, "TOF/Chi2/all", "hTofChi2_all", {""}, {""}, false, false, 1e-12, 1e-1);
3435 //fHMean.DrawAllCands(2, "TOF/Chi2/elid", "hTofChi2_elid", {""}, {""}, false, false, 1e-12, 1e-1);
3436 //fHMean.DrawAllCandsAndSteps(2, "Momentum/Pt/", "hMomPt", {""}, {""}, false, false, 1e-12, 1e-1);
3437
3438 // All Elid cuts in one Canvas
3439 {
3441 TH2D* stsELoss = fHMean.GetRatioElectronsOthers("hELossSts", step);
3442 TH2D* richAnn = fHMean.GetRatioElectronsOthers("hRichAnn", step);
3443 TH2D* trdLike = fHMean.GetRatioElectronsOthers("hTrdElLike", step);
3444 TH2D* trdChi2 = fHMean.GetRatioElectronsOthers("hChi2Dets_trd", step);
3445 TH2D* tofM2 = fHMean.GetRatioElectronsOthers("hTofM2", step);
3446 TH2D* tofM2z = fHMean.GetRatioElectronsOthers("hTofM2", step);
3447 TH2D* tofDist = fHMean.GetRatioElectronsOthers("hTofDist", step);
3448 double min = 1e-2;
3449 double max = 1e4;
3450 stsELoss->GetZaxis()->SetRangeUser(min, max);
3451 richAnn->GetZaxis()->SetRangeUser(min, max);
3452 trdLike->GetZaxis()->SetRangeUser(min, max);
3453 trdChi2->GetZaxis()->SetRangeUser(min, max);
3454 tofM2->GetZaxis()->SetRangeUser(min, max);
3455 tofM2z->GetZaxis()->SetRangeUser(min, max);
3456 tofM2z->GetXaxis()->SetRangeUser(0., 4.);
3457 tofM2z->GetYaxis()->SetRangeUser(-0.1, 0.1);
3458 string cName = "ElidCuts/" + fHMean.fAnaStepNames[static_cast<int>(step)];
3459 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 3200, 1600);
3460 c->Divide(4, 2);
3461 c->cd(1);
3462 DrawH2(stsELoss, kLinear, kLinear, kLog, "colz");
3463 DrawTextOnPad("STS E-Loss", 0.2, 0.9, 0.68, 0.99);
3464 c->cd(2);
3465 DrawH2(richAnn, kLinear, kLinear, kLog, "colz");
3466 DrawTextOnPad("RICH ANN", 0.23, 0.9, 0.67, 0.99);
3467 c->cd(3);
3468 DrawH2(trdLike, kLinear, kLinear, kLog, "colz");
3469 DrawTextOnPad("TRD Likelihood", 0.15, 0.9, 0.73, 0.99);
3470 c->cd(4);
3471 DrawH2(trdChi2, kLinear, kLinear, kLog, "colz");
3472 DrawTextOnPad("TRD #chi^{2}", 0.24, 0.9, 0.62, 0.99);
3473 c->cd(5);
3474 DrawH2(tofM2, kLinear, kLinear, kLog, "colz");
3475 DrawTextOnPad("TOF #it{m}^{2}", 0.24, 0.9, 0.64, 0.99);
3476 c->cd(6);
3477 DrawH2(tofM2z, kLinear, kLinear, kLog, "colz");
3478 DrawTextOnPad("TOF #it{m}^{2} (zoom)", 0.12, 0.9, 0.64, 0.99);
3479 c->cd(7);
3480 DrawH2(tofDist, kLinear, kLinear, kLog, "colz");
3481 DrawTextOnPad("TOF Dist (norm.)", 0.12, 0.9, 0.64, 0.99);
3482 }
3483 }
3484
3485 // TRD: Likelihood in 1D (Projection)
3486 {
3488 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
3489 string cName = "TRD/El-Like/Steps/1D_" + stepname;
3490 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 2400, 1800);
3491 c->Divide(4, 3);
3492 int iC = 1;
3493 for (const string& ptcl : fHMean.fCandNames) {
3494 string hName = fHMean.GetName("hTrdElLike_" + ptcl, step);
3495 string projname = hName + "_y";
3496 TH2D* h2 = fHMean.H2Clone(hName);
3497 TH1D* h1 = (TH1D*) h2->ProjectionY(projname.c_str(), 1, h2->GetYaxis()->GetNbins(), "");
3498 c->cd(iC++);
3499 DrawH1(h1, kLinear, kLinear, "p");
3500 DrawTextOnPad(fHMean.fCandLatex[iC - 2], 0.3, 0.9, 0.8, 0.99);
3501 }
3502 }
3503 }
3504
3505 // TOF-M2 zoomed
3507 string cName = "TOF/M2/Steps/" + fHMean.fAnaStepNames[static_cast<int>(step)] + "_zoom";
3508 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 3200, 2400);
3509 c->Divide(4, 3);
3510 int iC = 1;
3511 for (const string& ptcl : fHMean.fCandNames) {
3512 TH2D* h = fHMean.H2Clone("hTofM2_" + ptcl, step);
3513 h->GetXaxis()->SetRangeUser(0., 4.);
3514 h->GetYaxis()->SetRangeUser(-0.1, 0.1);
3515 h->GetZaxis()->SetRangeUser(1e-12, 1e-1);
3516 c->cd(iC++);
3517 DrawH2(h, kLinear, kLinear, kLog, "colz");
3518 DrawTextOnPad(fHMean.fCandLatex[iC - 2], 0.25, 0.9, 0.75, 0.99);
3519 }
3520 }
3521}
3522
3524{
3525 TH1D* inmedRaw = H(ELmvmSignal::Inmed)->H1Clone("hMinv_unscaled");
3526 TH1D* qgpRaw = H(ELmvmSignal::Qgp)->H1Clone("hMinv_unscaled");
3527 TH1D* inmedScaled = H(ELmvmSignal::Inmed)->H1Clone("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::Mc);
3528 TH1D* qgpScaled = H(ELmvmSignal::Qgp)->H1Clone("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::Mc);
3529 double bW = inmedRaw->GetBinWidth(1);
3530 inmedRaw->Scale(1. / (bW * H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries()));
3531 inmedScaled->Scale(1. / (bW * H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries()));
3532 qgpRaw->Scale(1. / (bW * H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries()));
3533 qgpScaled->Scale(1. / (bW * H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries()));
3534 inmedRaw->GetYaxis()->SetRangeUser(1e-9, 6e-1);
3535 qgpRaw->GetYaxis()->SetRangeUser(1e-9, 6e-1);
3536
3537 TCanvas* c = fHMean.fHM.CreateCanvas("MassScaling/signal", "MassScaling/signal", 1600, 800);
3538 c->Divide(2, 1);
3539 c->cd(1);
3540 DrawH1({inmedRaw, inmedScaled},
3541 {"#rho_{i.m.}(raw)", "#rho_{i.m.}(raw) #upoint fW_{#rho} #upoint #it{w}_{#rho}(#it{m}_{inv.})"}, kLinear, kLog,
3542 true, 0.2, 0.16, 0.6, 0.3, "hist");
3543 DrawTextOnPad("inmed", 0.35, 0.9, 0.65, 0.99);
3544 c->cd(2);
3545 DrawH1({qgpRaw, qgpScaled}, {"QGP (raw)", "QGP (raw) #upoint fW_{QGP} #upoint #it{w}_{QGP}(#it{m}_{inv.})"}, kLinear,
3546 kLog, true, 0.2, 0.16, 0.6, 0.3, "hist");
3547 DrawTextOnPad("qgp", 0.36, 0.9, 0.64, 0.99);
3548
3549 TH1D* scaleInmed = new TH1D("inmed", "inmed; M_{ee} [GeV/c^{2}]; Scale Value", 3400., 0., 3.4);
3550 TH1D* scaleQgp = new TH1D("qgp", "qgp; M_{ee} [GeV/c^{2}]; Scale Value", 3400., 0., 3.4);
3551 for (int iB = 1; iB < 3400; iB++) {
3552 double binCenter = scaleInmed->GetBinCenter(iB);
3553 double sInmed = LmvmUtils::GetMassScaleInmed(binCenter);
3554 double sQgp = LmvmUtils::GetMassScaleQgp(binCenter);
3555 scaleInmed->SetBinContent(iB, sInmed);
3556 scaleQgp->SetBinContent(iB, sQgp);
3557 }
3558 scaleInmed->GetXaxis()->SetRangeUser(0., 3.);
3559 fHMean.fHM.CreateCanvas("MassScaling/scaling", "MassScaling/scaling", 1120, 800);
3560 DrawH1({scaleInmed, scaleQgp}, {"inmed", "QGP"}, kLinear, kLog, true, 0.7, 0.73, 0.91, 0.9, "hist");
3561 DrawTextOnPad("Scaling Factors #it{w_{i}}(#it{m}_{inv.})", 0.25, 0.9, 0.75, 0.99);
3562
3563 TH1D* inmed2 = (TH1D*) scaleInmed->Clone();
3564 TH1D* qgp2 = (TH1D*) scaleQgp->Clone();
3565 inmed2->GetXaxis()->SetRangeUser(1., 1.1);
3566 qgp2->GetXaxis()->SetRangeUser(1., 1.1);
3567 inmed2->GetYaxis()->SetRangeUser(3e-3, 5e-1);
3568 qgp2->GetYaxis()->SetRangeUser(3e-3, 5e-1);
3569 fHMean.fHM.CreateCanvas("MassScaling/scaling_zoom", "MassScaling/scaling_zoom", 800, 800);
3570 DrawH1({inmed2, qgp2}, {"inmed", "QGP"}, kLinear, kLog, true, 0.7, 0.7, 0.9, 0.9, "p");
3571 DrawTextOnPad("Scaling Factors #it{w_{i}}(#it{m}_{inv.}) (zoom)", 0.18, 0.9, 0.8, 0.99);
3572}
3573
3575{
3576 for (const string det : {"sts", "rich", "trd", "tof"}) {
3577 string cName = "NofHits/" + det;
3578 string hName = "hNofHitsVsMom_" + det;
3579 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 1600, 1600);
3580 c->Divide(4, 4);
3581 int i = 1;
3582 for (const string& ptcl : fHMean.fGTrackNames) {
3583 int hitsMax = (det == "sts") ? 10 : (det == "rich") ? 50 : (det == "trd") ? 5 : 2;
3584 double limY = (det == "sts") ? 3.5 : (det == "rich") ? 6.5 : (det == "trd") ? 1.5 : 0.5;
3585 TLine* limLine = new TLine(-0.5, limY, 10.5, limY);
3586 limLine->SetLineWidth(4.);
3587 TH2D* h = fHMean.H2Clone(hName + "_" + ptcl);
3588 h->GetYaxis()->SetRangeUser(0., hitsMax);
3589 h->GetZaxis()->SetRangeUser(1e-9, 100);
3590 c->cd(i++);
3591 DrawH2(h, kLinear, kLinear, kLog, "colz");
3592 DrawTextOnPad(fHMean.fGTrackLatex[i - 2], 0.25, 0.9, 0.75, 0.99);
3593 if (hitsMax <= 20) {
3594 for (int iB = 0; iB < hitsMax; iB++) {
3595 TLine* binLine = new TLine(0., iB + 0.5, 10., iB + 0.5);
3596 binLine->SetLineWidth(1.);
3597 binLine->Draw();
3598 }
3599 }
3600 limLine->Draw();
3601 }
3602 }
3603}
3604
3605void LmvmDrawAll::DrawSignificance(TH2D* hEl, TH2D* hBg, const string& name, double minZ, double maxZ,
3606 const string& option)
3607{
3608 string hElProjName = name + "_yProjEl";
3609 string hBgProjName = name + "_yProjBg";
3610 TH1D* el = hEl->ProjectionY(hElProjName.c_str(), 1, hEl->GetXaxis()->GetNbins(), "");
3611 TH1D* bg = hBg->ProjectionY(hBgProjName.c_str(), 1, hBg->GetXaxis()->GetNbins(), "");
3612 TH2D* rat = (TH2D*) hEl->Clone();
3613 rat->Divide(hBg);
3614
3615 const string hName = name + "_sign";
3616 const string cName = "Significance/" + name;
3617
3618 TH1D* sign = fHMean.CreateSignificanceH1(el, bg, hName.c_str(), option);
3619 TCanvas* c = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 2400, 1600);
3620 c->Divide(3, 2);
3621 c->cd(1);
3622 DrawH2(hEl, kLinear, kLinear, kLog, "colz");
3623 hEl->GetZaxis()->SetRangeUser(minZ, maxZ);
3624 DrawTextOnPad("Electrons", 0.25, 0.9, 0.75, 0.99);
3625 c->cd(2);
3626 DrawH2(hBg, kLinear, kLinear, kLog, "colz");
3627 hBg->GetZaxis()->SetRangeUser(minZ, maxZ);
3628 DrawTextOnPad("Other", 0.25, 0.9, 0.75, 0.99);
3629 c->cd(3);
3630 DrawH2(rat, kLinear, kLinear, kLog, "colz");
3631 DrawTextOnPad("Ratio Electrons/Other", 0.2, 0.9, 0.8, 0.99);
3632 c->cd(4);
3633 DrawH1({el, bg}, {"Electrons", "Other"}, kLinear, kLog, true, 0.75, 0.75, 0.91, 0.91);
3634 DrawTextOnPad("Yield / Event", 0.25, 0.9, 0.75, 0.99);
3635 c->cd(5);
3636 DrawH1(sign, kLinear, kLinear, "hist");
3637 double maxX = -999999.;
3638 double maxY = -999999.;
3639 for (int iB = 1; iB <= sign->GetNbinsX(); iB++) {
3640 if (option == "right" && sign->GetBinContent(iB) >= maxY) {
3641 maxX = sign->GetBinCenter(iB);
3642 maxY = sign->GetBinContent(iB);
3643 }
3644 if (option == "left" && sign->GetBinContent(iB) > maxY) {
3645 maxX = sign->GetBinCenter(iB);
3646 maxY = sign->GetBinContent(iB);
3647 }
3648 }
3649 DrawTextOnPad("max. at: " + Cbm::NumberToString(maxX, 1), 0.55, 0.2, 0.85, 0.5);
3650 DrawTextOnPad("Significance", 0.25, 0.9, 0.75, 0.99);
3651}
3652
3654{
3656 // X2 in TRD (filled after ElID step)
3657 {
3658 TH2D* el = fHMean.H2Clone("hChi2Dets_trd_" + fHMean.fCandNames[0], step);
3659 el->Add(fHMean.H2("hChi2Dets_trd_" + fHMean.fCandNames[1], step));
3660
3661 TH2D* bg = fHMean.H2Clone("hChi2Dets_trd_" + fHMean.fCandNames[2], step);
3662 for (size_t iP = 3; iP < fHMean.fCandNames.size(); iP++) { // consider UrQMD-electrons as "BG"
3663 string ptcl = fHMean.fCandNames[iP];
3664 string hName = "hChi2Dets_trd_" + ptcl + "_" + fHMean.fAnaStepNames[static_cast<int>(step)];
3665 bg->Add(fHMean.H2(hName.c_str()));
3666 }
3667
3668 DrawSignificance(el, bg, "hChi2Dets_trd", 1e-9, 1e-3, "right");
3669 }
3670}
3671
3673{
3674 TCanvas* c = fHMean.fHM.CreateCanvas("Vertex/globalTrackRZ", "Vertex/globalTrackRZ", 1600, 800);
3675 c->Divide(2, 1);
3676 c->cd(1);
3677 TH2D* h = fHMean.H2Clone("hVertexGTrackRZ");
3678 h->GetYaxis()->SetRangeUser(0., 50);
3679 h->GetZaxis()->SetRangeUser(1e-7, 10);
3680 DrawH2(h, kLinear, kLinear, kLog, "colz");
3681 c->cd(2);
3682 TH2D* h2 = fHMean.H2Clone("hVertexGTrackRZ");
3683 h2->GetXaxis()->SetRangeUser(-49., -39.);
3684 h2->GetYaxis()->SetRangeUser(0., 10.);
3685 h2->GetZaxis()->SetRangeUser(1e-7, 10);
3686 DrawH2(h2, kLinear, kLinear, kLog, "colz");
3687}
3688
3690{
3691 double min = 1e-5;
3692 double max = 10;
3693 for (size_t i = 0; i < fHMean.fCandNames.size(); i++) {
3694 string cName = "BetaMom/" + fHMean.fCandNames[i];
3695 string hName = "hBetaMom_" + fHMean.fCandNames[i];
3696 fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 800, 800);
3697 TH2D* h = fHMean.H2Clone(hName.c_str());
3698 h->GetZaxis()->SetRangeUser(min, max);
3699 DrawH2(h, kLinear, kLinear, kLog, "colz");
3700 DrawTextOnPad((fHMean.fCandLatex[i]).c_str(), 0.25, 0.9, 0.75, 0.999);
3701 }
3702}
3703
3705{
3706 vector<pair<double, double>> varbinLongMc = {make_pair(6., 0.1), make_pair(10., 0.2)};
3707 vector<pair<double, double>> varbinLongId = {make_pair(6., 0.4), make_pair(10., 1.)};
3708 //vector<pair<double, double>> varbinTrMc = {make_pair(-1., 0.5), make_pair(1., 0.1), make_pair(3., 0.5)};
3709 //vector<pair<double, double>> varbinTrId = {make_pair(-1., 0.5), make_pair(1., 0.1), make_pair(3., 0.5)};
3710 vector<pair<double, double>> varbinTrMc = {make_pair(3., 0.2)};
3711 vector<pair<double, double>> varbinTrId = {make_pair(3., 0.2)};
3712 // Sources
3713 {
3714 vector<string> srcs = {"bg", "pi0", "gamma", "eta"};
3715 vector<TH1*> ratios;
3716 for (const string& src : srcs) {
3717 TCanvas* c = fHMean.fHM.CreateCanvas("Momentum/UrQMD/" + src, "Momentum/UrQMD/" + src, 3200, 800);
3718 c->Divide(4, 1);
3719 int iC = 1;
3720 for (const string pi : {"", "Px", "Py", "Pz"}) {
3721 vector<pair<double, double>> varbinMc = varbinLongMc;
3722 vector<pair<double, double>> varbinId = varbinLongId;
3723 if (pi == "Px" || pi == "Py") {
3724 varbinMc = varbinTrMc;
3725 varbinId = varbinTrId;
3726 }
3727 string xTitle = "P [GeV/c]";
3728 if (pi != "") xTitle = pi + " [GeV/c]";
3729 TH1D* mcP = VaryBinWidth("mean", "hMom" + pi + "+_" + src + "_mc", varbinMc);
3730 TH1D* mcM = VaryBinWidth("mean", "hMom" + pi + "-_" + src + "_mc", varbinMc);
3731 TH1D* elidP = VaryBinWidth("mean", "hMom" + pi + "+_" + src + "_elid", varbinId);
3732 TH1D* elidM = VaryBinWidth("mean", "hMom" + pi + "-_" + src + "_elid", varbinId);
3733 mcP->GetXaxis()->SetTitle(xTitle.c_str());
3734 mcP->GetYaxis()->SetRangeUser(1e-8, 5e2);
3735 if (pi == "") {
3736 TH1D* ratio = (TH1D*) elidP->Clone();
3737 ratio->Divide(elidM);
3738 ratio->GetYaxis()->SetTitle("Ratio e+/e-");
3739 ratios.push_back(ratio);
3740 }
3741 c->cd(iC++);
3742 DrawH1({mcP, mcM, elidP, elidM}, {"e+ (MC)", "e- (MC)", "e+ (ID)", "e- (ID)"}, kLinear, kLog, true, 0.75, 0.7,
3743 0.92, 0.91, "hist");
3744 string tag = (src == "bg") ? "BG" : (src == "pi0") ? "#pi^{0}" : (src == "gamma") ? "#gamma" : "#eta";
3745 DrawTextOnPad(tag, 0.3, 0.9, 0.7, 0.99);
3746 }
3747 }
3748 fHMean.fHM.CreateCanvas("Momentum/UrQMD/ChargeSymmetry", "Momentum/UrQMD/ChargeSymmetry", 800, 800);
3749 DrawH1(ratios, srcs, kLinear, kLinear, true, 0.75, 0.7, 0.91, 0.91, "pe");
3750 fHMean.DrawAnaStepOnPad(ELmvmAnaStep::ElId);
3751 }
3752
3753 // BG with true electrons
3754 {
3755 TH1D* plus = VaryBinWidth("mean", "hMom+_trueEl_bg_elid", varbinLongId);
3756 TH1D* minus = VaryBinWidth("mean", "hMom-_trueEl_bg_elid", varbinLongId);
3757 fHMean.fHM.CreateCanvas("Momentum/UrQMD/bg_trueEl", "Momentum/UrQMD/bg_trueEl", 800, 800);
3758 DrawH1({plus, minus}, {"e+ (ID)", "e- (ID)"}, kLinear, kLog, true, 0.75, 0.8, 0.92, 0.91, "hist");
3759 DrawTextOnPad("BG (true electrons)", 0.15, 0.9, 0.85, 0.99);
3760 }
3761
3762 // Compare Pi0 with Gamma
3763 {
3764 TCanvas* c = fHMean.fHM.CreateCanvas("Momentum/UrQMD/Pi0Gamma", "Momentum/UrQMD/Pi0Gamma", 1600, 800);
3765 c->Divide(2, 1);
3766 int iC = 1;
3767 for (const string suff : {"+", "-"}) {
3768 TH1D* pi0Mc = VaryBinWidth("mean", "hMom" + suff + "_pi0_mc", varbinLongMc);
3769 TH1D* pi0Elid = VaryBinWidth("mean", "hMom" + suff + "_pi0_elid", varbinLongId);
3770 TH1D* gammaMc = VaryBinWidth("mean", "hMom" + suff + "_gamma_mc", varbinLongMc);
3771 TH1D* gammaElid = VaryBinWidth("mean", "hMom" + suff + "_gamma_elid", varbinLongId);
3772 pi0Mc->GetYaxis()->SetRangeUser(1e-8, 1e2);
3773 c->cd(iC++);
3774 DrawH1({pi0Mc, gammaMc, pi0Elid, gammaElid}, {"#pi^{0} (MC)", "#gamma (MC)", "#pi^{0} (ID)", "#gamma (ID)"},
3775 kLinear, kLog, true, 0.8, 0.75, 0.92, 0.91, "hist");
3776 DrawTextOnPad("e" + suff, 0.3, 0.9, 0.7, 0.99);
3777 }
3778 }
3779}
3780
3782{
3783 for (ELmvmSignal signal : fHMean.fSignals) {
3784 string cName = "Momentum/Pluto/" + fHMean.fSignalNames[static_cast<int>(signal)];
3785 TCanvas* c = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 3200, 800);
3786 c->Divide(4, 1);
3787 int i = 1;
3788 for (const string pi : {"", "Px", "Py", "Pz"}) {
3789 c->cd(i++);
3790 string hName = "hMom" + pi;
3791 TH1D* epMc = H(signal)->H1Clone((hName + "+_signal_mc").c_str());
3792 TH1D* emMc = H(signal)->H1Clone((hName + "-_signal_mc").c_str());
3793 TH1D* epElid = H(signal)->H1Clone((hName + "+_signal_elid").c_str());
3794 TH1D* emElid = H(signal)->H1Clone((hName + "-_signal_elid").c_str());
3795 double bW = epMc->GetBinWidth(1);
3796 epMc->Scale(1. / (H(signal)->H1("hEventNumber")->GetEntries() * bW));
3797 emMc->Scale(1. / (H(signal)->H1("hEventNumber")->GetEntries() * bW));
3798 epElid->Scale(1. / (H(signal)->H1("hEventNumber")->GetEntries() * bW));
3799 emElid->Scale(1. / (H(signal)->H1("hEventNumber")->GetEntries() * bW));
3800 string xTitle = (pi == "Px") ? "P_{X}" : (pi == "Py") ? "P_{Y}" : (pi == "Pz") ? "P_{Z}" : "P";
3801 string xTitleFull = xTitle + " [GeV/c]";
3802 epMc->GetXaxis()->SetTitle(xTitleFull.c_str());
3803 epMc->GetYaxis()->SetTitle("dN/dP [GeV/c]^{-1}");
3804 epMc->GetYaxis()->SetTitleOffset(1.6);
3805 DrawH1({epMc, emMc, epElid, emElid}, {"e^{+} (MC)", "e^{-} (MC)", "e^{+} (ID)", "e^{-} (ID)"}, kLinear, kLog,
3806 true, 0.75, 0.7, 0.91, 0.91);
3807 DrawTextOnPad(fHMean.fSignalNames[static_cast<int>(signal)].c_str(), 0.25, 0.9, 0.85, 0.99);
3808 }
3809 }
3810}
3811
3813{
3814 // draw momentum for misidentified and not-misidentified particles (from global tracks)
3815 {
3816 double min = 5e-8;
3817 double max = 10;
3818 TCanvas* c = fHMean.fHM.CreateCanvas("Momentum/misid_vs_True", "Momentum/misid_vs_True", 2400, 1600);
3819 c->Divide(3, 2);
3820 int iC = 1;
3821 for (size_t iP = 4; iP < fHMean.fCandNames.size(); iP++) { // only draw for not-electrons
3822 c->cd(iC++);
3823 string ptcl = fHMean.fCandNames[iP];
3824 TH1D* hMis = fHMean.H1Clone("hMom_" + ptcl + "_misid");
3825 TH1D* hTrue = fHMean.H1Clone("hMom_" + ptcl + "_true");
3826 hMis->GetYaxis()->SetRangeUser(min, max);
3827 hTrue->GetYaxis()->SetRangeUser(min, max);
3828 DrawH1({hTrue, hMis}, {"not misidentified", "misidentified as electron"}, kLinear, kLog, true, 0.55, 0.8, 0.95,
3829 0.91, "hist");
3830 DrawTextOnPad(fHMean.fCandLatex[iP], 0.4, 0.9, 0.54, 0.99);
3831 }
3832 }
3833}
3834
3836{
3837 string cName = "Efficiency/";
3838 string hName = "hMom_";
3839
3841
3842 // hMinv
3843 TCanvas* c1 = fHMean.fHM.CreateCanvas(cName + "hMinv", cName + "hMinv", 2400, 1600);
3844 c1->Divide(3, 2);
3845 int iC = 1;
3846 for (ELmvmSignal signal : fHMean.fSignals) {
3847 TH1D* mc = H(signal)->H1Clone("hMinv_signal_mc");
3848 TH1D* reco = H(signal)->H1Clone("hMinv_signal_reco");
3849 TH1D* elid = H(signal)->H1Clone("hMinv_signal_elid");
3850 mc->Rebin(fRebinMinv);
3851 reco->Rebin(fRebinMinv);
3852 elid->Rebin(fRebinMinv);
3853 TH1D* effMc = (TH1D*) elid->Clone();
3854 TH1D* effReco = (TH1D*) elid->Clone();
3855 effMc->Divide(mc);
3856 effReco->Divide(reco);
3857 effMc->GetYaxis()->SetTitle("Efficiency");
3858 int nBinsXMinv = mc->GetXaxis()->GetNbins();
3859 double eMc = 100 * elid->Integral(1, nBinsXMinv) / mc->Integral(1, nBinsXMinv);
3860 double eReco = 100 * elid->Integral(1, nBinsXMinv) / reco->Integral(1, nBinsXMinv);
3861 string eMcString = Cbm::NumberToString(eMc, 2) + " %";
3862 string eRecoString = Cbm::NumberToString(eReco, 2) + " %";
3863 c1->cd(iC++);
3864 effMc->GetYaxis()->SetRangeUser(0., 0.3);
3865 effReco->GetYaxis()->SetRangeUser(0., 0.3);
3866 DrawH1({effMc, effReco}, {"Eff_{MC}: " + eMcString, "Eff_{Reco}: " + eRecoString}, kLinear, kLinear, true, 0.6, 0.7,
3867 0.97, 0.92, "hist");
3868 DrawTextOnPad(fHMean.fSignalNames[static_cast<int>(signal)], 0.35, 0.9, 0.65, 0.99);
3869 }
3870
3871 // Draw Efficiency for all together for various steps
3872 TH1D* hRef = fHMean.H1Clone(hName + fHMean.fCandNames[0], refstep);
3873 hRef->Add(fHMean.H1(hName + fHMean.fCandNames[1], refstep));
3874
3875 TH1D* elid = fHMean.H1Clone(hName + fHMean.fCandNames[0], ELmvmAnaStep::ElId);
3876 elid->Add(fHMean.H1(hName + fHMean.fCandNames[1], ELmvmAnaStep::ElId));
3877 elid->Divide(hRef);
3878
3879 TH1D* gamma = fHMean.H1Clone(hName + fHMean.fCandNames[0], ELmvmAnaStep::GammaCut);
3880 gamma->Add(fHMean.H1(hName + fHMean.fCandNames[1], ELmvmAnaStep::GammaCut));
3881 gamma->Divide(hRef);
3882
3883 TH1D* tt = fHMean.H1Clone(hName + fHMean.fCandNames[0], ELmvmAnaStep::TtCut);
3884 tt->Add(fHMean.H1(hName + fHMean.fCandNames[1], ELmvmAnaStep::TtCut));
3885 tt->Divide(hRef);
3886
3887 TH1D* pt = fHMean.H1Clone(hName + fHMean.fCandNames[0], ELmvmAnaStep::PtCut);
3888 pt->Add(fHMean.H1(hName + fHMean.fCandNames[1], ELmvmAnaStep::PtCut));
3889 pt->Divide(hRef);
3890
3891 int nBinsX = hRef->GetXaxis()->GetNbins();
3892
3893 double effElid = 100 * elid->Integral(1, nBinsX) / nBinsX;
3894 double effGamma = 100 * gamma->Integral(1, nBinsX) / nBinsX;
3895 double effTt = 100 * tt->Integral(1, nBinsX) / nBinsX;
3896 double effPt = 100 * pt->Integral(1, nBinsX) / nBinsX;
3897
3898 fHMean.fHM.CreateCanvas(cName + "all_steps", cName + "all_steps", 900, 900);
3899 elid->GetYaxis()->SetTitle("Efficiency");
3900 DrawH1({elid, gamma, tt, pt},
3901 {"El-ID (" + Cbm::NumberToString(effElid, 1) + " %)", "Gamma cut (" + Cbm::NumberToString(effGamma, 1) + " %)",
3902 "TT cut (" + Cbm::NumberToString(effTt, 1) + " %)", "P_{t} cut (" + Cbm::NumberToString(effPt, 1) + " %)"},
3903 kLinear, kLinear, true, 0.6, 0.75, 0.95, 0.91, "hist");
3904 DrawTextOnPad("Signal Efficiency", 0.3, 0.9, 0.7, 0.99);
3905
3906 // Draw Efficiency seperate for PLUTO (after El-ID)
3908 string cNameFull = cName + "plutos_" + fHMean.fAnaStepNames[static_cast<int>(step)];
3909 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 900, 900);
3910
3911 vector<TH1D*> sHists(fHMean.fNofSignals);
3912 for (ELmvmSignal signal : fHMean.fSignals) {
3913 TH1D* hRef2 = H(signal)->H1Clone(hName + fHMean.fCandNames[0], refstep);
3914 hRef2->Add(H(signal)->H1Clone(hName + fHMean.fCandNames[1], refstep));
3915 TH1D* hEff = H(signal)->H1Clone(hName + fHMean.fCandNames[0], step);
3916 hEff->Add(H(signal)->H1Clone(hName + fHMean.fCandNames[1], step));
3917 hEff->Divide(hRef2);
3918 hEff->GetYaxis()->SetTitle("Efficiency");
3919 sHists[static_cast<int>(signal)] = hEff;
3920 }
3921
3922 double effInmed = 100 * sHists[0]->Integral(1, nBinsX) / nBinsX;
3923 double effQgp = 100 * sHists[1]->Integral(1, nBinsX) / nBinsX;
3924 double effOmega = 100 * sHists[2]->Integral(1, nBinsX) / nBinsX;
3925 double effPhi = 100 * sHists[3]->Integral(1, nBinsX) / nBinsX;
3926 double effOmegaD = 100 * sHists[4]->Integral(1, nBinsX) / nBinsX;
3927
3928 vector<LmvmDrawMinvData> data;
3929 data.emplace_back(sHists[static_cast<int>(ELmvmSignal::OmegaD)], -1, kCyan + 2, 2, -1,
3930 "#omega #rightarrow #pi^{0}e^{+}e^{-} (" + Cbm::NumberToString(effOmegaD, 1) + " %)");
3931 data.emplace_back(sHists[static_cast<int>(ELmvmSignal::Omega)], -1, kOrange + 7, 2, -1,
3932 "#omega #rightarrow e^{+}e^{-} (" + Cbm::NumberToString(effOmega, 1) + " %)");
3933 data.emplace_back(sHists[static_cast<int>(ELmvmSignal::Phi)], -1, kAzure + 2, 2, -1,
3934 "#phi #rightarrow e^{+}e^{-} (" + Cbm::NumberToString(effPhi, 1) + " %)");
3935 data.emplace_back(sHists[static_cast<int>(ELmvmSignal::Qgp)], -1, kOrange - 2, 2, -1,
3936 "QGP radiation (" + Cbm::NumberToString(effQgp, 1) + " %)");
3937 data.emplace_back(sHists[static_cast<int>(ELmvmSignal::Inmed)], -1, kMagenta - 3, 2, -1,
3938 "in-medium #rho (" + Cbm::NumberToString(effInmed, 1) + " %)");
3939
3940 TLegend* leg = new TLegend(0.75, 0.65, .99, 0.99);
3941 for (size_t i = 0; i < data.size(); i++) {
3942 const auto& d = data[i];
3943 d.fH->GetYaxis()->SetLabelSize(0.05);
3944 if (d.fFillColor != -1) d.fH->SetFillColor(d.fFillColor);
3945 if (d.fFillStyle != -1) d.fH->SetFillStyle(d.fFillStyle);
3946 leg->AddEntry(d.fH, d.fLegend.c_str(), "f");
3947 DrawH1(d.fH, kLinear, kLinear, (i == 0) ? "hist" : "hist,same", d.fLineColor, d.fLineWidth, 0);
3948 }
3949 DrawTextOnPad("Efficiency (average of each both electrons)", 0.01, 0.9, 0.8, 0.99);
3950 leg->SetFillColor(kWhite);
3951 leg->Draw();
3952
3953 // Draw single contributions
3954 vector<TH1D*> sHistsStepP(fHMean.fNofSignals);
3955 vector<TH1D*> sHistsStepE(fHMean.fNofSignals);
3956 vector<TH1D*> sHistsRefP(fHMean.fNofSignals);
3957 vector<TH1D*> sHistsRefE(fHMean.fNofSignals);
3958 for (ELmvmSignal signal : fHMean.fSignals) {
3959 TH1D* hStepP = H(signal)->H1Clone(hName + fHMean.fCandNames[0], step);
3960 TH1D* hStepE = H(signal)->H1Clone(hName + fHMean.fCandNames[1], step);
3961 TH1D* hRefP = H(signal)->H1Clone(hName + fHMean.fCandNames[0], refstep);
3962 TH1D* hRefE = H(signal)->H1Clone(hName + fHMean.fCandNames[1], refstep);
3963 sHistsStepP[static_cast<int>(signal)] = hStepP;
3964 sHistsStepE[static_cast<int>(signal)] = hStepE;
3965 sHistsRefP[static_cast<int>(signal)] = hRefP;
3966 sHistsRefE[static_cast<int>(signal)] = hRefE;
3967 }
3968
3969 for (ELmvmSignal signal : fHMean.fSignals) {
3970 string cNameFull2 = cName + "Components_" + fHMean.fSignalNames[static_cast<int>(signal)];
3971 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull2, cNameFull2, 1600, 800);
3972 c->Divide(2, 1);
3973 c->cd(1);
3974 DrawH1({sHistsStepP[static_cast<int>(signal)], sHistsStepE[static_cast<int>(signal)]}, {"positron", "electron"},
3975 kLinear, kLog, true, 0.85, 0.7, 0.99, 0.99, "hist");
3976 fHMean.DrawAnaStepOnPad(step);
3977 c->cd(2);
3978 DrawH1({sHistsRefP[static_cast<int>(signal)], sHistsRefE[static_cast<int>(signal)]}, {"positron", "electron"},
3979 kLinear, kLog, true, 0.85, 0.7, 0.99, 0.99, "hist");
3980 fHMean.DrawAnaStepOnPad(refstep);
3981 }
3982
3983 // Efficiency electrons
3984 {
3985 vector<pair<double, double>> bwvar = {make_pair(10., 1.)};
3986 TH1D* hElRef = VaryBinWidth("mean", "hMom_plutoEl+_reco", bwvar);
3987 TH1D* hElCounter = VaryBinWidth("mean", "hMom_plutoEl+_elid", bwvar);
3988 for (int iP = 1; iP <= 3; iP++) {
3989 string ptcl = fHMean.fCandNames[iP];
3990 TH1D* href = VaryBinWidth("mean", "hMom_" + ptcl + "_reco", bwvar);
3991 TH1D* hcounter = VaryBinWidth("mean", "hMom_" + ptcl + "_elid", bwvar);
3992 hElRef->Add(href);
3993 hElCounter->Add(hcounter);
3994 }
3995 TH1D* hEff = (TH1D*) hElCounter->Clone();
3996 hEff->Divide(hElRef);
3997 int nX = hElRef->GetNbinsX();
3998 double eff = hEff->Integral(1, nX) / nX;
3999 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "efficiency_electrons", cName + "Efficiency_electrons", 1600, 800);
4000 c->Divide(2, 1);
4001 c->cd(1);
4002 DrawH1({hElRef, hElCounter}, {"Ref", "Counter"}, kLinear, kLog, true, 0.85, 0.85, 0.95, 0.95, "p");
4003 c->cd(2);
4004 DrawH1(hEff, kLinear, kLog, "p");
4005 DrawTextOnPad("Efficiency", 0.3, 0.9, 0.7, 0.99);
4006 DrawTextOnPad("Electron Efficiency = " + Cbm::NumberToString(eff, 1), 0.11, 0.15, 0.6, 0.28);
4007 }
4008}
4009
4011{
4012 vector<pair<double, double>> varbin = {make_pair(8., 0.5), make_pair(10., 2.)};
4013 for (const string ptcl : {"pion", "proton"}) {
4014 TCanvas* c = fHMean.fHM.CreateCanvas("Suppression/" + ptcl + "s", "Suppression/" + ptcl + "s", 3200, 800);
4015 c->Divide(4, 1);
4016 c->cd(1);
4017 TH1D* mc = VaryBinWidth("mean", "hSuppression_" + ptcl + "_mc", varbin);
4018 TH1D* reco = VaryBinWidth("mean", "hSuppression_" + ptcl + "_reco", varbin);
4019 TH1D* acc = VaryBinWidth("mean", "hSuppression_" + ptcl + "_acc", varbin);
4020 TH1D* elid = VaryBinWidth("mean", "hSuppression_" + ptcl + "_elid", varbin);
4021 TH1D* tt = VaryBinWidth("mean", "hSuppression_" + ptcl + "_ttcut", varbin);
4022 TH1D* pt = VaryBinWidth("mean", "hSuppression_" + ptcl + "_ptcut", varbin);
4023
4024 mc->GetYaxis()->SetRangeUser(1e-7, 250);
4025 DrawH1({mc, reco, acc, elid, tt, pt}, {"MC", "Rec", "Acc", "El-ID", "TT", "P_{t}"}, kLinear, kLog, true, 0.8, 0.7,
4026 0.95, 0.91, "hist");
4027 DrawTextOnPad(ptcl, 0.4, 0.9, 0.6, 0.99);
4028
4029 int iC = 2;
4030 for (const string step : {"mc", "reco", "acc"}) {
4031 TH1D* supElid = VaryBinWidth("mean", "hSuppression_" + ptcl + "_" + step, varbin);
4032 TH1D* supTt = VaryBinWidth("mean", "hSuppression_" + ptcl + "_" + step, varbin);
4033 TH1D* supPt = VaryBinWidth("mean", "hSuppression_" + ptcl + "_" + step, varbin);
4034 supElid->Divide(elid);
4035 supTt->Divide(tt);
4036 supPt->Divide(pt);
4037 supElid->GetYaxis()->SetTitle("Suppression");
4038 int nBins = supElid->GetNbinsX();
4039 string sElid = Cbm::NumberToString((double) (supElid->Integral(1, nBins) / nBins), 0);
4040 c->cd(iC++);
4041 supElid->GetYaxis()->SetRangeUser(1e2, 1e7);
4042 DrawH1({supElid, supTt, supPt}, {"El-ID", "TT", "P_{t}"}, kLinear, kLog, true, 0.73, 0.86, 0.95, 0.97, "p");
4043 DrawTextOnPad(ptcl + " suppression (norm. to " + step + ")", 0.04, 0.87, 0.8, 0.99);
4044 DrawTextOnPad(ptcl + " supp. (El-ID): " + sElid, 0.04, 0.12, 0.65, 0.25);
4045 }
4046 }
4047}
4048
4050{
4051 // for candidates
4052 {
4053 double minX = 0.;
4054 double maxX = 2.5;
4055 double minY = -0.05;
4056 double maxY = 0.05;
4057 double minZ = 1e-8;
4058 double maxZ = 10;
4059 vector<TLine*> lines{new TLine(0., 0.01, 1.3, 0.01), new TLine(1.3, 0.01, 2.5, 0.022)}; // set by hand
4060
4061 for (auto step : fHMean.fAnaSteps) {
4062 TH2D* hEl = fHMean.H2Clone(("hTofM2_" + fHMean.fCandNames[0]), step);
4063 for (size_t iP = 1; iP < 4; iP++) {
4064 string hName = "hTofM2_" + fHMean.fCandNames[iP] + "_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4065 hEl->Add(fHMean.H2(hName.c_str()));
4066 }
4067 TH2D* hBg = fHMean.H2Clone(("hTofM2_" + fHMean.fCandNames[4]), step);
4068 for (size_t iP = 5; iP < fHMean.fCandNames.size(); iP++) {
4069 string hName = "hTofM2_" + fHMean.fCandNames[iP] + "_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4070 hBg->Add(fHMean.H2(hName.c_str()));
4071 }
4072 string cName = "TOF/M2/" + fHMean.fAnaStepNames[static_cast<int>(step)];
4073 TCanvas* c = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1600, 800);
4074 c->Divide(2, 1);
4075 c->cd(1);
4076 hEl->GetXaxis()->SetRangeUser(minX, maxX);
4077 hEl->GetYaxis()->SetRangeUser(minY, maxY);
4078 hEl->GetZaxis()->SetRangeUser(minZ, maxZ);
4079 DrawH2(hEl, kLinear, kLinear, kLog, "colz");
4080 DrawTextOnPad("Electrons (" + fHMean.fAnaStepNames[static_cast<int>(step)] + ")", 0.3, 0.89, 0.6, 0.99);
4081 for (size_t i = 0; i < lines.size(); i++) {
4082 lines[i]->SetLineWidth(2.);
4083 lines[i]->Draw();
4084 }
4085 c->cd(2);
4086 hBg->GetXaxis()->SetRangeUser(minX, maxX);
4087 hBg->GetYaxis()->SetRangeUser(minY, maxY);
4088 hBg->GetZaxis()->SetRangeUser(minZ, maxZ);
4089 DrawH2(hBg, kLinear, kLinear, kLog, "colz");
4090 DrawTextOnPad("Other (" + fHMean.fAnaStepNames[static_cast<int>(step)] + ")", 0.3, 0.89, 0.55, 0.99);
4091 for (size_t i = 0; i < lines.size(); i++) {
4092 lines[i]->SetLineWidth(2.);
4093 lines[i]->Draw();
4094 }
4095 }
4096 }
4097 fHMean.DrawAllCands(2, "TOF/M2/MatchTrue", "hTofM2_truematch", {""}, {""}, false, false, 1e-9, 1e-2);
4098 fHMean.DrawAllCands(2, "TOF/M2/MatchMis", "hTofM2_mismatch", {""}, {""}, false, false, 1e-9, 1e-2);
4099}
4100
4102{
4103 int n = 200;
4104 double x[n], y[n];
4105 double m = 511e-6;
4106 double m2 = m * m;
4107 double p = 6;
4108 double p2 = p * p;
4109 for (int i = 0; i < n; i++) {
4110 x[i] = 0.02 * i;
4111 double counter =
4112 std::sqrt(2 * m2 * TMath::Exp(2 * x[i]) - m2 * TMath::Exp(4 * x[i]) + 4 * p2 * TMath::Exp(2 * x[i]) - m2);
4113 double denom = std::sqrt(1 + 2 * TMath::Exp(2 * x[i]) + TMath::Exp(4 * x[i]));
4114 double r = counter / denom;
4115 y[i] = r;
4116 }
4117 auto pLine = new TGraph(n, x, y); // draw momentum line into Pt-Y histogram
4118
4119 for (const string cat : {"hPtY"}) { //, "hTofM2"}) {
4120
4121 // draw misidentified and not-misidentified particles and ratio of both (all from global tracks)
4122 {
4123 double min = (cat == "hPtY") ? 1e-7 : 1e-8;
4124 double max = (cat == "hPtY") ? 10 : 10;
4125 string cName = (cat == "hPtY") ? "PtY/Misids/" : "TOF/M2/Misids/";
4126 for (size_t iP = 4; iP < fHMean.fCandNames.size(); iP++) { // only draw for not-electrons
4127 string ptcl = fHMean.fCandNames[iP];
4128 string cNameFull = cName + ptcl + "_misid";
4129 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull.c_str(), cNameFull.c_str(), 2400, 800);
4130 c->Divide(3, 1);
4131 c->cd(1);
4132 TH2D* hTrue = fHMean.H2Clone(cat + "_" + ptcl + "_true");
4133 if (cat == "hTofM2") {
4134 hTrue->GetXaxis()->SetRangeUser(0., 2.5);
4135 hTrue->GetYaxis()->SetRangeUser(-0.05, 0.05);
4136 }
4137 hTrue->GetZaxis()->SetRangeUser(min, max);
4138 DrawH2(hTrue, kLinear, kLinear, kLog, "colz");
4139 DrawTextOnPad(fHMean.fCandLatex[iP] + " (not misidentified)", 0.2, 0.9, 0.75, 0.99);
4140 if (cat == "hPtY") pLine->Draw("C");
4141
4142 c->cd(2);
4143 TH2D* hMis = fHMean.H2Clone(cat + "_" + ptcl + "_misid");
4144 if (cat == "hTofM2") {
4145 hMis->GetXaxis()->SetRangeUser(0., 2.5);
4146 hMis->GetYaxis()->SetRangeUser(-0.05, 0.05);
4147 }
4148 hMis->GetZaxis()->SetRangeUser(min, max);
4149 DrawH2(hMis, kLinear, kLinear, kLog, "colz");
4150 DrawTextOnPad(fHMean.fCandLatex[iP] + " (misidentified as electron)", 0.15, 0.9, 0.75, 0.99);
4151 if (cat == "hPtY") pLine->Draw("C");
4152
4153 c->cd(3);
4154 TH2D* hRat = fHMean.H2Clone(cat + "_" + ptcl + "_misid");
4155 hRat->Divide(hTrue);
4156 if (cat == "hTofM2") {
4157 hRat->GetXaxis()->SetRangeUser(0., 2.5);
4158 hRat->GetYaxis()->SetRangeUser(-0.05, 0.05);
4159 }
4160 hRat->GetZaxis()->SetRangeUser(1e-5, 1);
4161 hRat->GetZaxis()->SetTitle("Ratio #misid./#not misid.");
4162 DrawH2(hRat, kLinear, kLinear, kLog, "colz");
4163 DrawTextOnPad(fHMean.fCandLatex[iP] + ": Ratio #misid./#not misid.", 0.1, 0.9, 0.6, 0.99);
4164 if (cat == "hPtY") pLine->Draw("C");
4165 }
4166 }
4167
4168 // draw misidentified candidates for each step
4169 {
4170 double min = (cat == "hPtY") ? 2e-8 : 2e-8;
4171 double max = (cat == "hPtY") ? 5e-3 : 5e-3;
4172 string cName = (cat == "hPtY") ? "PtY/Misids/" : "TOF/M2/Misids/";
4173 for (size_t iP = 4; iP < fHMean.fCandNames.size(); iP++) {
4174 string ptcl = fHMean.fCandNames[iP];
4175 string cNameFull = cName + ptcl + "_misid_steps";
4176 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull.c_str(), cNameFull.c_str(), 1800, 1800);
4177 c->Divide(3, 3);
4178 int i = 1;
4179 for (auto step : fHMean.fAnaSteps) {
4180 if (step < ELmvmAnaStep::ElId) continue;
4181 c->cd(i++);
4182 string hName = cat + "_" + ptcl;
4183 TH2D* h = fHMean.H2Clone(hName.c_str(), step);
4184 if (cat == "hTofM2") {
4185 h->GetXaxis()->SetRangeUser(0., 2.5);
4186 h->GetYaxis()->SetRangeUser(-0.05, 0.05);
4187 }
4188 h->GetZaxis()->SetRangeUser(min, max);
4189 DrawH2(h, kLinear, kLinear, kLog, "colz");
4190 fHMean.DrawAnaStepOnPad(step);
4191 if (cat == "hPtY") pLine->Draw("C");
4192 }
4193 }
4194 }
4195 } // cat: "hPtY", "hTofM2"
4196}
4197
4199{
4200 vector<string> pLabel = {"e^{#pm}_{PLUTO}", "e^{#pm}_{UrQMD}", "e_{#gamma}", "#pi^{#pm}", "p", "K^{#pm}", "o."};
4201
4202 // Misidentified Particles vs. Momentum
4203 {
4204 for (const string suff : {"", "+", "-"}) {
4205 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
4206 if (step == ELmvmAnaStep::Mc) continue;
4207 if ((suff == "+" || suff == "-") && step != ELmvmAnaStep::ElId) continue;
4208 string cName = "";
4209 string hName = "";
4210 if (suff == "+" || suff == "-") {
4211 hName = "hCandPdgVsMom" + suff;
4212 cName = "Purity/purity" + suff;
4213 }
4214 else {
4215 hName = "hCandPdgVsMom_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4216 cName = "Purity/purity_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4217 }
4218 fHMean.fHM.CreateCanvas(cName, cName, 800, 600);
4219 TH2D* h = fHMean.H2Clone(hName);
4220 h->GetZaxis()->SetRangeUser(1e-11, 1e-2);
4221 DrawH2(h, kLinear, kLinear, kLog, "colz");
4222 for (size_t y = 1; y <= pLabel.size(); y++) {
4223 h->GetYaxis()->SetBinLabel(y, pLabel[y - 1].c_str());
4224 }
4225 double nSigEl = h->Integral(1, h->GetXaxis()->GetNbins(), 1, 1);
4226 double nUrqmdEl = h->Integral(1, h->GetXaxis()->GetNbins(), 2, 2);
4227 double nGammaEl = h->Integral(1, h->GetXaxis()->GetNbins(), 3, 3);
4228 double nEl = nSigEl + nUrqmdEl + nGammaEl;
4229 double nPions = h->Integral(1, h->GetXaxis()->GetNbins(), 4, 4);
4230 double nProtons = h->Integral(1, h->GetXaxis()->GetNbins(), 5, 5);
4231 double nKaons = h->Integral(1, h->GetXaxis()->GetNbins(), 6, 6);
4232 double nOther = h->Integral(1, h->GetXaxis()->GetNbins(), 7, 7);
4233 double nAll = h->Integral(1, h->GetXaxis()->GetNbins(), 1, h->GetYaxis()->GetNbins());
4234 double purSig = (nSigEl / nAll) * 100;
4235 double purUrqmdEl = (nUrqmdEl / nAll) * 100;
4236 double purGammaEl = (nGammaEl / nAll) * 100;
4237 double purEl = (nEl / nAll) * 100;
4238 double purPions = (nPions / nAll) * 100;
4239 double purProtons = (nProtons / nAll) * 100;
4240 double purKaons = (nKaons / nAll) * 100;
4241 double purOther = (nOther / nAll) * 100;
4242 DrawTextOnPad("Purity: " + Cbm::NumberToString(purEl, 1) + " % or " + Cbm::NumberToString(purSig, 2) + " %",
4243 0.1, 0.9, 0.45, 0.99);
4244 if (suff == "+" || suff == "-") DrawTextOnPad("(" + suff + ")", 0.5, 0.9, 0.6, 0.99);
4245
4246 double xMin = 0.08;
4247 double xMax = 0.63;
4248 DrawTextOnPad(Cbm::NumberToString(nSigEl, 3) + "/Event, Portion: " + Cbm::NumberToString(purSig, 1) + " %",
4249 xMin, 0.15, xMax, 0.25);
4250 DrawTextOnPad(Cbm::NumberToString(nUrqmdEl, 3) + "/Event, Portion: " + Cbm::NumberToString(purUrqmdEl, 1)
4251 + " %",
4252 xMin, 0.27, xMax, 0.35);
4253 DrawTextOnPad(Cbm::NumberToString(nGammaEl, 3) + "/Event, Portion: " + Cbm::NumberToString(purGammaEl, 1)
4254 + " %",
4255 xMin, 0.37, xMax, 0.46);
4256 DrawTextOnPad(Cbm::NumberToString(nPions, 3) + "/Event, Portion: " + Cbm::NumberToString(purPions, 1) + " %",
4257 xMin, 0.47, xMax, 0.56);
4258 DrawTextOnPad(Cbm::NumberToString(nProtons, 3) + "/Event, Portion: " + Cbm::NumberToString(purProtons, 1)
4259 + " %",
4260 xMin, 0.58, xMax, 0.67);
4261 DrawTextOnPad(Cbm::NumberToString(nKaons, 3) + "/Event, Portion: " + Cbm::NumberToString(purKaons, 1) + " %",
4262 xMin, 0.70, xMax, 0.78);
4263 DrawTextOnPad(Cbm::NumberToString(nOther, 3) + "/Event, Portion: " + Cbm::NumberToString(purOther, 1) + " %",
4264 xMin, 0.80, xMax, 0.89);
4265 }
4266 }
4267 }
4268
4269 // Purity vs. Momentum
4270 {
4272 int nBins = fHMean.H2("hCandPdgVsMom", step)->GetXaxis()->GetNbins();
4273 double xMin = fHMean.H2("hCandPdgVsMom", step)->GetXaxis()->GetXmin();
4274 double xMax = fHMean.H2("hCandPdgVsMom", step)->GetXaxis()->GetXmax();
4275 string hNameEl = "purityEl_mom_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4276 string hNameSig = "puritySig_mom_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4277 TH1D* purityEl = new TH1D(hNameEl.c_str(), "purityEl_mom; P [GeV/c]; Purity [%]", nBins, xMin, xMax);
4278 TH1D* puritySig = new TH1D(hNameSig.c_str(), "puritySig_mom; P [GeV/c]; Purity [%]", nBins, xMin, xMax);
4279 for (int i = 1; i <= purityEl->GetNbinsX(); i++) {
4280 double nEl = fHMean.H2("hCandPdgVsMom", step)->GetBinContent(i, 2);
4281 double nSig = fHMean.H2("hCandPdgVsMom", step)->GetBinContent(i, 1);
4282 double nAll =
4283 fHMean.H2("hCandPdgVsMom", step)->Integral(i, i, 1, fHMean.H2("hCandPdgVsMom_elid")->GetYaxis()->GetNbins());
4284 double pEl = (nAll != 0) ? 100 * nEl / nAll : 0.;
4285 double pSig = (nAll != 0) ? 100 * nSig / nAll : 0.;
4286 purityEl->SetBinContent(i, pEl);
4287 puritySig->SetBinContent(i, pSig);
4288 }
4289 purityEl->Rebin(5);
4290 purityEl->Scale(1. / 5.);
4291 puritySig->Rebin(5);
4292 puritySig->Scale(1. / 5.);
4293 puritySig->GetYaxis()->SetRangeUser(0., 100.);
4294 string cName = "Purity/PurityVsMom_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4295 fHMean.fHM.CreateCanvas(cName, cName, 800, 800);
4296 DrawH1({puritySig, purityEl}, {"Signal Electrons", "All Electrons"}, kLinear, kLinear, true, 0.7, 0.8, 0.95, 0.91,
4297 "p");
4298 }
4299 }
4300
4301 // Projections of Y
4302 {
4303 for (auto step : fHMean.fAnaSteps) {
4304 if (step == ELmvmAnaStep::Mc) continue;
4305 string hName = "hCandPdgInt_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4306 TH2D* h2D = fHMean.H2Clone("hCandPdgVsMom_" + fHMean.fAnaStepNames[static_cast<int>(step)]);
4307 TH1D* h1D =
4308 h2D->ProjectionY(hName.c_str(), 0, h2D->GetXaxis()->GetNbins() + 1, ""); // include under- / overflow bins
4309 h1D->GetYaxis()->SetRangeUser(1e-6, 5.);
4310 h1D->GetYaxis()->SetTitle("N / Event");
4311 for (size_t iL = 0; iL < pLabel.size(); iL++) {
4312 h1D->GetXaxis()->SetBinLabel(iL + 1, pLabel[iL].c_str());
4313 }
4314 string cName = "Purity/1D/" + fHMean.fAnaStepNames[static_cast<int>(step)];
4315 fHMean.fHM.CreateCanvas(cName, cName, 800, 800);
4316 DrawH1(h1D, kLinear, kLog, "hist");
4317 fHMean.DrawAnaStepOnPad(step);
4318
4319 double nAll = h1D->Integral(1, h1D->GetNbinsX(), "width");
4320
4321 double pElP = 100 * (h1D->GetBinContent(1) / nAll);
4322 double pElU = 100 * (h1D->GetBinContent(2) / nAll);
4323 double pElG = 100 * (h1D->GetBinContent(3) / nAll);
4324 double pPiC = 100 * (h1D->GetBinContent(4) / nAll);
4325 double pProt = 100 * (h1D->GetBinContent(5) / nAll);
4326 double pK = 100 * (h1D->GetBinContent(6) / nAll);
4327 double pOth = 100 * (h1D->GetBinContent(7) / nAll);
4328
4329 DrawTextOnPad(Cbm::NumberToString(pElP, 1) + " %", 0.17, 0.8, 0.27, 0.89);
4330 DrawTextOnPad(Cbm::NumberToString(pElU, 1) + " %", 0.28, 0.8, 0.38, 0.89);
4331 DrawTextOnPad(Cbm::NumberToString(pElG, 1) + " %", 0.38, 0.8, 0.48, 0.89);
4332 DrawTextOnPad(Cbm::NumberToString(pPiC, 1) + " %", 0.49, 0.8, 0.59, 0.89);
4333 DrawTextOnPad(Cbm::NumberToString(pProt, 1) + " %", 0.59, 0.8, 0.69, 0.89);
4334 DrawTextOnPad(Cbm::NumberToString(pK, 1) + " %", 0.69, 0.8, 0.79, 0.89);
4335 DrawTextOnPad(Cbm::NumberToString(pOth, 1) + " %", 0.80, 0.8, 0.90, 0.89);
4336 }
4337 }
4338
4339 // Purity seperate for ID Detectors
4340 {
4341 vector<string> yLabel = {"#pi^{+}", "#pi^{-}", "p", "K^{+}", "K^{-}", "o."};
4342 double min = 1e-7;
4343 double max = 10;
4344
4345 for (const string cat : {"rec", "acc", "chi2prim"}) {
4346 TH2D* rich = fHMean.H2Clone("hPdgVsMom_rich_" + cat);
4347 TH2D* trd = fHMean.H2Clone("hPdgVsMom_trd_" + cat);
4348 TH2D* tof = fHMean.H2Clone("hPdgVsMom_tof_" + cat);
4349
4350 rich->GetZaxis()->SetRangeUser(min, max);
4351 trd->GetZaxis()->SetRangeUser(min, max);
4352 tof->GetZaxis()->SetRangeUser(min, max);
4353
4354 for (size_t y = 1; y <= yLabel.size(); y++) {
4355 rich->GetYaxis()->SetBinLabel(y, yLabel[y - 1].c_str());
4356 trd->GetYaxis()->SetBinLabel(y, yLabel[y - 1].c_str());
4357 tof->GetYaxis()->SetBinLabel(y, yLabel[y - 1].c_str());
4358 }
4359
4360 TCanvas* c = fHMean.fHM.CreateCanvas("Purity/misid_gTracks_" + cat, "Purity/misid_gTracks_" + cat, 2400, 800);
4361 c->Divide(3, 1);
4362 c->cd(1);
4363 DrawH2(rich, kLinear, kLinear, kLog, "colz");
4364 DrawTextOnPad("RICH", 0.25, 0.9, 0.75, 0.999);
4365 DrawPurityHistText(rich);
4366 c->cd(2);
4367 DrawH2(trd, kLinear, kLinear, kLog, "colz");
4368 DrawTextOnPad("TRD", 0.25, 0.9, 0.75, 0.999);
4369 DrawPurityHistText(trd);
4370 c->cd(3);
4371 DrawH2(tof, kLinear, kLinear, kLog, "colz");
4372 DrawTextOnPad("ToF", 0.25, 0.9, 0.75, 0.999);
4373 DrawPurityHistText(tof);
4374 }
4375 }
4376}
4377
4379{
4380 int nX = h->GetXaxis()->GetNbins();
4381
4382 double xMin = 0.4;
4383 double xMax = 0.75;
4384 double piP = h->Integral(1, nX, 1, 1);
4385 double piM = h->Integral(1, nX, 2, 2);
4386 double p = h->Integral(1, nX, 3, 3);
4387 double KP = h->Integral(1, nX, 4, 4);
4388 double KM = h->Integral(1, nX, 5, 5);
4389 double o = h->Integral(1, nX, 6, 6);
4390
4391 DrawTextOnPad("#pi^{+}: " + Cbm::NumberToString(piP, 1) + " /Ev", xMin, 0.12, xMax, 0.3);
4392 DrawTextOnPad("#pi^{-}: " + Cbm::NumberToString(piM, 1) + " /Ev", xMin, 0.28, xMax, 0.37);
4393 DrawTextOnPad("p: " + Cbm::NumberToString(p, 1) + " /Ev", xMin, 0.43, xMax, 0.48);
4394 DrawTextOnPad("K^{+}: " + Cbm::NumberToString(KP, 1) + " /Ev", xMin, 0.53, xMax, 0.65);
4395 DrawTextOnPad("K^{-}: " + Cbm::NumberToString(KM, 1) + " /Ev", xMin, 0.66, xMax, 0.76);
4396 DrawTextOnPad("o.: " + Cbm::NumberToString(o, 1) + " /Ev", xMin, 0.77, xMax, 0.9);
4397}
4398
4405
4407{
4409 DrawChi2();
4410
4411 // Connection between Misidentification and Mismatches
4412 {
4413 vector<string> xLabel = {"0", "1", "2", "3"};
4414 vector<string> yLabel = {"true-ID", "mis-ID"};
4415 fHMean.DrawAllGTracks(2, "hMatchId_gTracks", "hMatchId_gTracks", {xLabel}, {yLabel}, false, false, 1e-7, 1e3);
4416 }
4417
4418 // Number of Matches/Mismatches
4419 {
4420 TCanvas* c = fHMean.fHM.CreateCanvas("Mismatches/Det_Yields", "Mismatches/Det_Yields", 2400, 800);
4421 c->Divide(3, 1);
4422 int iC = 1;
4423 for (const string det : {"rich", "trd", "tof"}) {
4424 TH1D* h = fHMean.H1Clone("hMatch_" + det);
4425 h->GetXaxis()->SetBinLabel(1, "True Match");
4426 h->GetXaxis()->SetBinLabel(2, "Mismatch");
4427 c->cd(iC++);
4428 DrawH1(h, kLinear, kLinear, "hist");
4429 DrawTextOnPad(det, 0.42, 0.9, 0.58, 0.99);
4430 double mism = 100 * h->GetBinContent(2) / (h->GetBinContent(1) + h->GetBinContent(2));
4431 DrawTextOnPad("Mismatches: " + Cbm::NumberToString(mism, 1) + " %", 0.12, 0.14, 0.42, 0.24);
4432 }
4433 }
4434
4435 // STS-E-Loss vs. TOF-M2
4436 {
4437 for (const string cat : {"Seg1Mom1", "Seg1Mom2", "Seg2Mom1", "Seg2Mom2"}) {
4438 fHMean.DrawAllCands(2, "ELossM2/chi2prim" + cat, "hElossTime_chi2prim_" + cat, {""}, {""}, false, false, 1e-17,
4439 1e-2);
4440 fHMean.DrawAllCands(2, "ELossM2/elid" + cat, "hElossTime_elid_" + cat, {""}, {""}, false, false, 1e-17, 1e-2);
4441 }
4442 }
4443
4444 // TOF-m2 in dependance on position
4445 for (int pos : {50, 100, 150, 200, 300, 400, 500}) {
4446 for (const string step : {"chi2prim", "elid"}) {
4447 string cName = "TOF/M2/Position/" + step + "_" + Cbm::NumberToString(pos, 0);
4448 string hName = "hTofM2_" + step + "_" + Cbm::NumberToString(pos, 0);
4449 fHMean.DrawAllCands(2, cName, hName, {""}, {""}, false, false, 1e-15, 1e-2);
4450 }
4451 }
4452
4453 // TOF: Multiplicity of TofHitIndex at TofTracks
4454 for (const string nInd : {"1", "2", "3+"}) {
4455 string cName = "TOF/M2/NofTofHitIndex/" + nInd;
4456 string hName = "hTofM2_woDoubleIndex_" + nInd;
4457 fHMean.DrawAllCands(2, cName, hName, {""}, {""}, false, false, 1e-15, 1e-2);
4458 }
4459
4460 // Vertex of TOF-misidentifications
4461 {
4462 double min = 1e-7;
4463 for (auto step : fHMean.fAnaSteps) {
4464 string cName = "TOF/Vertex/tofMisid_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4465 vector<TH2D*> xyz{fHMean.H2("hVertexXZ_misidTof", step), fHMean.H2("hVertexYZ_misidTof", step),
4466 fHMean.H2("hVertexXY_misidTof", step)};
4467
4468 TCanvas* c = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1800, 600);
4469 c->Divide(3, 1);
4470 for (size_t i = 0; i < xyz.size(); i++) {
4471 c->cd(i + 1);
4472 DrawH2(xyz[i]);
4473 xyz[i]->SetMinimum(min);
4474 gPad->SetLogz(true);
4475 }
4476
4477 TCanvas* cZoom = fHMean.fHM.CreateCanvas((cName + "_zoom").c_str(), (cName + "_zoom").c_str(), 1800, 600);
4478 cZoom->Divide(3, 1);
4479 for (size_t i = 0; i < xyz.size(); i++) {
4480 TH2D* hZoom = (TH2D*) xyz[i]->Clone();
4481 cZoom->cd(i + 1);
4482 if (i == 2) {
4483 hZoom->GetXaxis()->SetRangeUser(-10., 10.);
4484 hZoom->GetYaxis()->SetRangeUser(-10., 10.);
4485 }
4486 else {
4487 hZoom->GetXaxis()->SetRangeUser(fZ - 1., fZ + 10.);
4488 hZoom->GetYaxis()->SetRangeUser(-10., 10.);
4489 }
4490 DrawH2(hZoom);
4491 hZoom->SetMinimum(min);
4492 gPad->SetLogz(true);
4493 }
4494
4495 fHMean.fHM.CreateCanvas((cName + "_RZ").c_str(), (cName + "_RZ").c_str(), 900, 900);
4496 TH2D* hRZ = fHMean.H2Clone("hVertexRZ_misidTof", step);
4497 hRZ->SetMinimum(min);
4498 DrawH2(hRZ, kLinear, kLinear, kLog);
4499 }
4500 }
4501
4502 // draw chi2 of true-matched vs. mismatched
4503 for (const string match : {"truematch", "mismatch"}) {
4504 for (const string det : {"rich", "trd", "tof"}) {
4505 string cName = "hChi2/" + match + "_" + det;
4506 string hName = "hChi2_" + match + "_" + det;
4507 fHMean.DrawAllGTracks(1, cName, hName, {""}, {""}, false, false, 2e-7, 10);
4508 }
4509 }
4510
4511 double minMism = 1e-4;
4512 double maxMism = 100.;
4513
4514 vector<string> xLabelDet = {"STS_{all}", "RICH_{all}", "RICH_{mis}", "TRD_{all}",
4515 "TRD_{mis}", "ToF_{all}", "ToF_{mis}"};
4516 fHMean.DrawAllGTracks(1, "Mismatches/FullGTracks", "hNofMismatches_gTracks", xLabelDet, {""}, false, false, minMism,
4517 maxMism);
4518
4519 vector<string> xLabelSeg = {"0", "1", "2", "3"};
4520 fHMean.DrawAllGTracks(1, "Mismatches/TrackSegments", "hNofMismatchedTrackSegments", xLabelSeg, {""}, false, false,
4521 minMism, maxMism);
4522}
4523
4525{
4526 string step = fHMean.fAnaStepNames[static_cast<int>(ELmvmAnaStep::ElId)];
4527 double min = 1e-9;
4528 double max = 5e-3;
4529 for (const string det : {"StsRich", "StsTrd", "RichTrd"}) {
4530 fHMean.DrawAllCands(2, "hChi2/Detectors/hChi2Comb" + det, "hChi2Comb_" + det, {""}, {""}, false, false, min, max);
4531 }
4532}
4533
4535{
4536 for (const ELmvmAnaStep step : fHMean.fAnaSteps) {
4537 //if (step < ELmvmAnaStep::ElId) continue;
4538 string cName = "Minv/" + fHMean.fAnaStepNames[static_cast<int>(step)];
4539 fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1000, 1000);
4540 DrawMinv(step);
4541 fHMean.DrawAnaStepOnPad(step);
4542 }
4543}
4544
4546{
4547 TH1D* sbg = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Bg, step), fBwVarBg);
4548 sbg->Add(VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarBg));
4549 TH1D* bg = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Bg, step), fBwVarBg);
4550 TH1D* pi0 = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Pi0, step), fBwVarBg);
4551 TH1D* eta = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Eta, step), fBwVarBg);
4552 TH1D* gamma = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Gamma, step), {make_pair(2.5, 0.02)});
4553 TH1D* cocktail = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarCock);
4554
4555 TH1D* cb = nullptr;
4556 if (step >= ELmvmAnaStep::ElId) cb = VaryBinWidth("mean", fHMean.GetName("hCbBg", step), fBwVarBg);
4557
4558 // Signals
4559 vector<TH1D*> sHists(fHMean.fNofSignals);
4561 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
4562 TH1D* sHist = VaryBinWidth(sigName, fHMean.GetName("hMinv", ELmvmSrc::Signal, step), fBwVarReg);
4563 sHist->Scale(1. / H(signal)->H1("hEventNumber")->GetEntries());
4564 sHists[static_cast<int>(signal)] = sHist;
4565 }
4566
4567 TH1D* phi = VaryBinWidth("phi", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), fBwVarPhi);
4568 phi->Scale(1. / H(ELmvmSignal::Phi)->H1("hEventNumber")->GetEntries());
4569 sHists[static_cast<int>(ELmvmSignal::Phi)] = phi;
4570
4571 TH1D* omega = VaryBinWidth("omegaepem", fHMean.GetName("hMinv", ELmvmSrc::Signal, step), fBwVarOmega);
4572 omega->Scale(1. / H(ELmvmSignal::Omega)->H1("hEventNumber")->GetEntries());
4573 sHists[static_cast<int>(ELmvmSignal::Omega)] = omega;
4574
4575 // Prepare drawing
4576 vector<LmvmDrawMinvData> drawData;
4577 sbg->GetYaxis()->ChangeLabel(0, -1., 10., -1, -1, -1); //, "dN/dM_{ee}/N_{Ev} [GeV/c^{2}]^{-1}");
4578 if (step >= ELmvmAnaStep::Reco) {
4579 drawData.emplace_back(sbg, kBlack, kBlack, 1, -1, "Cocktail+B_{MC}");
4580 drawData.emplace_back(bg, kGray, kBlack, 1, -1, "B_{MC}");
4581 }
4582
4583 drawData.emplace_back(pi0, kGreen - 3, kGreen + 3, 2, -1, "#pi^{0} #rightarrow #gammae^{+}e^{-}");
4584 drawData.emplace_back(eta, kRed - 4, kRed + 2, 2, -1, "#eta #rightarrow #gammae^{+}e^{-}");
4585 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::OmegaD)], kCyan + 2, kCyan + 4, 2, -1,
4586 "#omega #rightarrow #pi^{0}e^{+}e^{-}");
4587 drawData.emplace_back(gamma, -1, kYellow, 4, -1, "#gamma #rightarrow e^{+}e^{-}");
4588 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Omega)], kOrange + 7, kOrange + 4, 2, -1,
4589 "#omega #rightarrow e^{+}e^{-}");
4590 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Phi)], kAzure + 2, kAzure + 3, 2, -1,
4591 "#phi #rightarrow e^{+}e^{-}");
4592 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Qgp)], kOrange - 2, kOrange - 3, 4, 3112, "QGP radiation");
4593 drawData.emplace_back(sHists[static_cast<int>(ELmvmSignal::Inmed)], kMagenta - 3, kMagenta - 2, 4, 3018,
4594 "in-medium #rho");
4595 drawData.emplace_back(cocktail, -1, kRed + 2, 4, -1, "Cocktail");
4596 if (step >= ELmvmAnaStep::ElId) drawData.emplace_back(cb, -1, kCyan + 1, 4, -1, "CB_{calc}");
4597
4598 TH1D* h0 = nullptr;
4599 TLegend* leg = new TLegend(0.72, 0.55, 0.97, 0.99);
4600 for (size_t i = 0; i < drawData.size(); i++) {
4601 const auto& d = drawData[i];
4602 d.fH->GetYaxis()->SetLabelSize(0.04);
4603 if (step >= ELmvmAnaStep::ElId)
4604 d.fH->GetYaxis()->SetRangeUser(5e-10, 5e-2);
4605 else
4606 d.fH->GetYaxis()->SetRangeUser(5e-10, 1e2);
4607 if (d.fFillColor != -1) d.fH->SetFillColor(d.fFillColor);
4608 if (d.fFillStyle != -1) d.fH->SetFillStyle(d.fFillStyle);
4609 leg->AddEntry(d.fH, d.fLegend.c_str(), "f");
4610 DrawH1(d.fH, kLinear, kLinear, (h0 == nullptr) ? "hist" : "hist,same", d.fLineColor, d.fLineWidth, 0);
4611 if (h0 == nullptr) h0 = d.fH;
4612 }
4613
4614 leg->SetFillColor(kWhite);
4615 leg->Draw();
4616 gPad->SetLogy(true);
4617}
4618
4620{
4621 string cName = "PrecisionReco/";
4622
4623 // Minv
4624 fHMean.fHM.CreateCanvas(cName + "Minv", cName + "Minv", 800, 800);
4625 TH2D* minv = fHMean.H2Clone("hRecoPrec_Minv");
4626 minv->GetZaxis()->SetRangeUser(1e-15, 1e-3);
4627 DrawH2(minv, kLinear, kLinear, kLog, "colz");
4628
4629
4630 //TODO: do next histograms as projections from 2D histograms
4631 // Draw ratio P_rec/P_MC
4632 /*{
4633 for (const string cat : {"", "_zoom"}) {
4634 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Mom_steps" + cat, cName + "Mom_steps" + cat, 1800, 1800);
4635 c->Divide(3, 3);
4636 int i = 1;
4637 for (auto step : fHMean.fAnaSteps) {
4638 if (step < ELmvmAnaStep::ElId) continue;
4639 vector<TH1*> hists;
4640 vector<string> legend;
4641 c->cd(i++);
4642 for (size_t iP = 0; iP < fHMean.fCandNames.size(); iP++) {
4643 TH1D* h = fHMean.H1Clone("hMomRatio_" + fHMean.fCandNames[iP], step);
4644 if (cat == "_zoom") h->GetXaxis()->SetRangeUser(0.9, 1.1);
4645 hists.push_back(h);
4646 legend.push_back((fHMean.fCandLatex[iP]).c_str());
4647 }
4648 DrawH1(hists, legend, kLinear, kLog, true, 0.8, 0.65, 0.99, 0.99, "hist");
4649 fHMean.DrawAnaStepOnPad(step);
4650 }
4651 }
4652 }*/
4653
4654 // draw ratio P_rec/P_MC vs P
4655 {
4657 double min = 0.5;
4658 double max = 1.5;
4659
4660 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Mom_cands", cName + "Mom_cands", 2700, 1800);
4661 c->Divide(4, 3);
4662 int i = 1;
4663 for (auto ptcl : fHMean.fCandNames) {
4664 int iL = i - 1;
4665 c->cd(i++);
4666 string hName = "hRecoPrec_Mom_" + ptcl;
4667 TH2D* h = fHMean.H2Clone(hName.c_str(), step);
4668 h->GetYaxis()->SetRangeUser(min, max);
4669 h->GetZaxis()->SetRangeUser(1e-10, 1e-2);
4670 DrawH2(h, kLinear, kLinear, kLog, "colz");
4671 string text = fHMean.fCandLatex[iL] + ", " + fHMean.fAnaStepLatex[static_cast<int>(step)];
4672 DrawTextOnPad(text.c_str(), 0.25, 0.9, 0.75, 0.999);
4673 }
4674
4675 TCanvas* c2 = fHMean.fHM.CreateCanvas(cName + "Mom_ID", cName + "Mom_ID", 1800, 900);
4676 c2->Divide(2, 1);
4677 c2->cd(1);
4678 TH2D* hT = fHMean.H2Clone("hRecoPrec_Mom_ID_true");
4679 hT->GetYaxis()->SetRangeUser(0.7, 1.2);
4680 hT->GetZaxis()->SetRangeUser(1e-10, 1e-2);
4681 DrawH2(hT, kLinear, kLinear, kLog, "colz");
4682 DrawTextOnPad("True ID", 0.25, 0.9, 0.75, 0.999);
4683 c2->cd(2);
4684 TH2D* hM = fHMean.H2Clone("hRecoPrec_Mom_ID_misid");
4685 hM->GetYaxis()->SetRangeUser(0.7, 1.2);
4686 hM->GetZaxis()->SetRangeUser(1e-10, 1e-2);
4687 DrawH2(hM, kLinear, kLinear, kLog, "colz");
4688 DrawTextOnPad("Mis-ID", 0.25, 0.9, 0.75, 0.999);
4689 }
4690}
4691
4693{
4694 int nofInmed = H(ELmvmSignal::Inmed)->H1("hEventNumber")->GetEntries();
4695 int nofQgp = H(ELmvmSignal::Qgp)->H1("hEventNumber")->GetEntries();
4696 int nofOmega = H(ELmvmSignal::Omega)->H1("hEventNumber")->GetEntries();
4697 int nofOmegaD = H(ELmvmSignal::OmegaD)->H1("hEventNumber")->GetEntries();
4698 int nofPhi = H(ELmvmSignal::Phi)->H1("hEventNumber")->GetEntries();
4699
4700 for (auto step : fHMean.fAnaSteps) {
4701 if (step < ELmvmAnaStep::ElId) continue;
4702 TH1D* h_npm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPM_sameEv", step), fNofSimEvents, fBwVarBg2);
4703 TH1D* h_cb = VaryBinWidth("mean", fHMean.GetName("hCbBg", step),
4704 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg2);
4705 TH1D* h_coc = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fBwVarCock);
4706 TH1D* h_eta = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Eta, step), fBwVarReg);
4707 TH1D* h_pi0 = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Pi0, step), fBwVarReg);
4708 TH1D* h_inmed = VaryBinWidth("inmed", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarReg);
4709 TH1D* h_qgp = VaryBinWidth("qgp", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarReg);
4710 TH1D* h_omega = VaryBinWidth("omegaepem", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarReg);
4711 TH1D* h_omegadalitz =
4712 VaryBinWidth("omegadalitz", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarReg);
4713 TH1D* h_phi = VaryBinWidth("phi", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarReg);
4714 TH1D* h_omega2 =
4715 VaryBinWidth("omegaepem", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarOmega);
4716 TH1D* h_phi2 = VaryBinWidth("phi", fHMean.GetName("hMinv", ELmvmSrc::Signal, ELmvmAnaStep::ElId), fBwVarPhi);
4717 h_inmed->Scale(1. / nofInmed);
4718 h_qgp->Scale(1. / nofQgp);
4719 h_omega->Scale(1. / nofOmega);
4720 h_omegadalitz->Scale(1. / nofOmegaD);
4721 h_phi->Scale(1. / nofPhi);
4722 h_omega2->Scale(1. / nofOmega);
4723 h_phi2->Scale(1. / nofPhi);
4724
4725 TH1D* h_sum = (TH1D*) h_eta->Clone();
4726 h_sum->Add(h_pi0);
4727 h_sum->Add(h_inmed);
4728 h_sum->Add(h_qgp);
4729 h_sum->Add(h_omega);
4730 h_sum->Add(h_omegadalitz);
4731 h_sum->Add(h_phi);
4732
4733 TH1D* h_sum2 = (TH1D*) h_sum->Clone();
4734
4735 /*for (int iB = 1; iB <= h_npm->GetXaxis()->GetNbins(); iB++) { // same result as automatically calculated by ROOT
4736 double bW = h_npm->GetBinWidth(iB);
4737 double c = h_npm->GetBinContent(iB);
4738 double n = c * bW * fNofSimEvents; // total entries in bin
4739 double err = std::sqrt(n)/(fNofSimEvents * bW);
4740 h_npm->SetBinError(iB, err);
4741 }*/
4742
4743 fHMean.SetOptH1(h_npm, "#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]",
4744 "1/N_{ev} dN/d#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]^{-1}", 510, 21, 1.3, kPink, "marker");
4745 fHMean.SetOptH1(h_cb, "#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]",
4746 "1/N_{ev} dN/d#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]^{-1}", 510, 22, 1.3, kBlue - 2, "marker");
4747 fHMean.SetOptH1(h_coc, "#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]",
4748 "1/N_{ev} dN/d#font[52]{M}_{ee} [GeV/#font[52]{c}^{2}]^{-1}", 510, 20, 1.1, kBlack, "marker");
4749
4750 fHMean.SetOptH1(h_sum2, "", "", 510, 1, 1, kBlack, "line");
4751 fHMean.SetOptH1(h_eta, "", "", 510, 1, 1, kBlue + 2, "line");
4752 fHMean.SetOptH1(h_pi0, "", "", 510, 1, 1, kAzure - 4, "line");
4753 fHMean.SetOptH1(h_inmed, "", "", 510, 1, 1, kPink, "line");
4754 fHMean.SetOptH1(h_qgp, "", "", 510, 1, 1, kOrange, "line");
4755 fHMean.SetOptH1(h_omega2, "", "", 510, 1, 1, kGreen + 1, "line");
4756 fHMean.SetOptH1(h_omegadalitz, "", "", 510, 1, 1, kGreen + 3, "line");
4757 fHMean.SetOptH1(h_phi2, "", "", 510, 1, 1, kMagenta + 2, "line");
4758
4759 h_npm->GetYaxis()->SetRangeUser(1e-9, 10);
4760
4761 string cName = "MinvOfficialStyle/minv_" + fHMean.fAnaStepNames[static_cast<int>(step)];
4762 TCanvas* can = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 900, 918);
4763 fHMean.SetOptCanvas(can);
4764 can->SetLogy();
4765 can->cd();
4766
4767 h_npm->Draw("peist");
4768 h_cb->Draw("peistsame");
4769 h_coc->Draw("phistsame");
4770
4771 h_sum2->Draw("histsame");
4772 h_eta->Draw("histsame");
4773 h_pi0->Draw("histsame");
4774 h_inmed->Draw("histsame");
4775 h_qgp->Draw("histsame");
4776 h_omega2->Draw("histsame");
4777 h_omegadalitz->Draw("histsame");
4778 h_phi2->Draw("histsame");
4779
4780 vector<LmvmLegend> legend3;
4781 legend3.emplace_back(h_npm, "N^{#pm}_{same}", "p");
4782 legend3.emplace_back(h_cb, "CB_{calc}", "p");
4783 legend3.emplace_back(h_coc, "MC Cocktail", "p");
4784
4785 vector<LmvmLegend> legend8;
4786 legend8.emplace_back(h_sum2, "MC Cocktail", "l");
4787 legend8.emplace_back(h_eta, "#eta#rightarrow#gammae^{+}e^{-}", "l");
4788 legend8.emplace_back(h_pi0, "#pi^{0}#rightarrow#gammae^{+}e^{-}", "l");
4789 legend8.emplace_back(h_omegadalitz, "#omega#rightarrow#pi^{0}e^{+}e^{-}", "l");
4790 legend8.emplace_back(h_omega2, "#omega#rightarrowe^{+}e^{-}", "l");
4791 legend8.emplace_back(h_phi2, "#phi#rightarrowe^{+}e^{-}", "l");
4792 legend8.emplace_back(h_inmed, "Rapp in-medium SF", "l");
4793 legend8.emplace_back(h_qgp, "Rapp QGP", "l");
4794
4795 fHMean.SetLegend(legend3, 0.035, 0.37, 0.64, 0.57, 0.77);
4796 fHMean.SetLegend(legend8, 0.025, 0.66, 0.57, 0.82, 0.87);
4797 fHMean.DrawSimDataLabel(0.15, 1.8);
4798 } // steps
4799}
4800
4802{
4803 string cName = "Background/";
4804
4805 // Compare "hMinv_bg" with "hMinvPM_sameEv"
4806 {
4807 TH1D* pm1 = VaryBinWidth("mean", "hMinv_bg_elid", fBwVarBg);
4808 TH1D* pm2 = VaryBinWidth("mean", "hMinvPM_sameEv", fBwVarBg);
4809 TH1D* gamma = VaryBinWidth("mean", "hMinv_gamma_elid", fBwVarBg);
4810 pm1->Add(VaryBinWidth("cocktail_elid", "", fBwVarBg));
4811 pm1->Add(gamma);
4812 TH1D* rat = (TH1D*) pm2->Clone();
4813 rat->Divide(pm1);
4814 string cNameFull = cName + "McBg_vs_McPM";
4815 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1600, 800);
4816 c->Divide(2, 1);
4817 c->cd(1);
4818 DrawH1({pm1, pm2}, {"hMinv_bg + Coc + #gamma", "hMinvPM"}, kLinear, kLog, true, 0.6, 0.8, 0.91, 0.91, "hist");
4819 c->cd(2);
4820 DrawH1(rat, kLinear, kLinear, "hist");
4821 }
4822
4823 // Background Types (BRE, CBcalc, MC) for different categories
4824 for (const string cat : {"", "_trueEl"}) { //, "_urqmdAll", "_urqmdEl"}) {
4825 string cNameFull = cName + "Types/Backgrounds" + cat;
4826 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 2400, 800);
4827 c->Divide(3, 1);
4828 int iC = 1;
4829 for (auto step : fHMean.fAnaStepsFS) {
4830 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
4831 TH1D* mc = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat + "_bg", step), fNofSimEvents, fBwVarSig);
4832 TH1D* cb = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
4833 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarSig);
4834 TH1D* re = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat + "_" + stepname, fNofFastSimEvents, fBwVarSig);
4835 mc->GetYaxis()->SetRangeUser(1e-7, 1e-2);
4836 c->cd(iC++);
4837 DrawH1({mc, cb, re}, {"B_{MC}", "CB_{calc}", "B_{FS}"}, kLinear, kLog, true, 0.8, 0.76, 0.91, 0.93, "pe");
4838 fHMean.DrawAnaStepOnPad(step);
4839 }
4840 }
4841
4842 // Ratios of Background Types
4843 vector<pair<double, double>> varbinZoom = {make_pair(2.5, 0.02)};
4844 for (const string cat : {""}) { //"_trueEl", "_urqmdAll", "_urqmdEl"}) {
4845 string cNameFull = cName + "Types/Ratios" + cat;
4846 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 3200, 2400);
4847 c->Divide(4, 3);
4848 int iC = 1;
4849 for (auto step : fHMean.fAnaStepsFS) {
4850 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
4851 if (step != ELmvmAnaStep::ElId) continue;
4852 TH1D* mc = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat + "_bg", step), fNofSimEvents, fBwVarBg);
4853 TH1D* cb = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
4854 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
4855 TH1D* re = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat, step, fNofFastSimEvents, fBwVarBg);
4856 TH1D* mcZoom = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat + "_bg", step), fNofSimEvents, varbinZoom);
4857 TH1D* cbZoom = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
4858 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), varbinZoom);
4859 TH1D* reZoom = VaryBinWidth("fastsim", "hfsc_MinvBg" + cat, step, fNofFastSimEvents, varbinZoom);
4860 mcZoom->GetXaxis()->SetRangeUser(0., 0.5);
4861 cbZoom->GetXaxis()->SetRangeUser(0., 0.5);
4862 reZoom->GetXaxis()->SetRangeUser(0., 0.5);
4863 TH1D* remc = (TH1D*) re->Clone();
4864 TH1D* cbmc = (TH1D*) cb->Clone();
4865 TH1D* cbre = (TH1D*) cb->Clone();
4866 remc->Divide(mc);
4867 cbmc->Divide(mc);
4868 cbre->Divide(re);
4869 /*for (int iB = 1; iB <= mc->GetNbinsX(); iB++) {
4870 double bW = mc->GetBinWidth(iB);
4871 double contmc = mc->GetBinContent(iB) * bW * fNofSimEvents;
4872 double contre = re->GetBinContent(iB) * bW * fNofFastSimEvents;
4873 double contcb = cb->GetBinContent(iB) * bW * fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]);
4874 double errMc = std::sqrt(contmc);
4875 double errRe = std::sqrt(contre);
4876 double errCb = std::sqrt(contcb);
4877 double errReMc = std::sqrt(std::pow(errRe/contmc, 2)/(bW*fNofFastSimEvents) + std::pow(contre * errMc / (contmc * contmc), 2)/(bW*fNofSimEvents));
4878 double errCbMc = std::sqrt(std::pow(errCb/contmc, 2)/(bW * fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)])) + std::pow(contcb * errMc / (contmc * contmc), 2)/(bW*fNofSimEvents));
4879 double errReCb = std::sqrt(std::pow(errRe/contcb, 2)/(bW*fNofFastSimEvents) + std::pow(contre * errCb / (contcb * contcb), 2))/(bW * fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]));
4880 remc->SetBinError(iB, errReMc);
4881 cbmc->SetBinError(iB, errCbMc);
4882 cbre->SetBinError(iB, errReCb);
4883 }*/
4884 //TH1D* remc = CalculateHistRatioWithErrors(re, mc, fNofFastSimEvents, fNofSimEvents);
4885 //TH1D* cbmc = CalculateHistRatioWithErrors(cb, mc, fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fNofSimEvents);
4886 //TH1D* cbre = CalculateHistRatioWithErrors(cb, re, fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fNofFastSimEvents);
4887 remc->GetYaxis()->SetTitle("Ratio");
4888 cbre->GetYaxis()->SetTitle("Ratio");
4889 remc->GetYaxis()->SetRangeUser(0.5, 2.);
4890 cbmc->GetYaxis()->SetRangeUser(0.5, 2.);
4891 cbre->GetYaxis()->SetRangeUser(0.8, 1.2);
4892 mc->GetYaxis()->SetRangeUser(1e-7, 1e-2);
4893
4894 c->cd(iC++);
4895 DrawH1({mc, re, cb}, {"B_{MC}", "B_{FS}", "CB_{calc}"}, kLinear, kLog, true, 0.78, 0.76, 0.95, 0.93, "pe");
4896 fHMean.DrawAnaStepOnPad(step);
4897 c->cd(iC++);
4898 //DrawH1({mcZoom, reZoom, cbZoom}, {"B_{MC}", "B_{FS}", "CB_{calc}"}, kLinear, kLog, true, 0.78, 0.76, 0.95, 0.93, "pe");
4899 DrawH1({reZoom, cbZoom}, {"B_{FS}", "CB_{calc}"}, kLinear, kLog, true, 0.78, 0.82, 0.95, 0.93, "pe");
4900 fHMean.DrawAnaStepOnPad(step);
4901 c->cd(iC++);
4902 DrawH1({cbmc, remc}, {"CB_{calc} / B_{MC}", "B_{FS} / B_{MC}"}, kLinear, kLinear, true, 0.7, 0.75, 0.95, 0.9,
4903 "pe");
4904 fHMean.DrawAnaStepOnPad(step);
4905 c->cd(iC++);
4906 DrawH1({cbre}, {"CB_{calc} / B_{FS}"}, kLinear, kLinear, true, 0.65, 0.82, 0.95, 0.9, "pe");
4907 fHMean.DrawAnaStepOnPad(step);
4908 }
4909 }
4910
4911 // Combinatorial Backgrounds from Simulation and Fast Simulations
4912 {
4913 TH1D* cbsim = VaryBinWidth(
4914 "mean", "hCbBg_elid", fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(ELmvmAnaStep::ElId)]), fBwVarBg);
4915 TH1D* ksim = VaryBinWidth(
4916 "mean", "hCbK_elid", fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(ELmvmAnaStep::ElId)]), fBwVarBg);
4917 TH1D* cbre = VaryBinWidth("mean", "hReCb", fNofFastSimEvents, fBwVarBg);
4918 TH1D* kre = VaryBinWidth("mean", "hReCbK", fNofFastSimEvents, fBwVarBg);
4919 TH1D* rat = (TH1D*) cbre->Clone();
4920 rat->Divide(cbsim);
4921 ksim->GetYaxis()->SetTitle("#it{k} Factor");
4922 rat->GetYaxis()->SetTitle("Ratio");
4923 string cNameFull = cName + "Types/CombinatorialBackground";
4924 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 2400, 800);
4925 c->Divide(3, 1);
4926 c->cd(1);
4927 DrawH1({cbsim, cbre}, {"Simulation", "Fast Simulations"}, kLinear, kLog, true, 0.65, 0.8, 0.92, 0.92, "hist");
4928 DrawTextOnPad("Combinatorial Background", 0.2, 0.9, 0.8, 0.99);
4929 c->cd(2);
4930 DrawH1({ksim, kre}, {"Simulation", "Fast Simulations"}, kLinear, kLinear, true, 0.65, 0.8, 0.92, 0.92, "hist");
4931 DrawTextOnPad("#it{k} Factor", 0.3, 0.9, 0.7, 0.99);
4932 c->cd(3);
4933 DrawH1({rat}, {"CB_{calc, RE} / CB_{calc, Sim}"}, kLinear, kLinear, true, 0.65, 0.82, 0.92, 0.92, "hist");
4934 DrawTextOnPad("Ratio Combinatorial Backgrounds", 0.2, 0.9, 0.85, 0.99);
4935 }
4936
4937 // Compare Pair Yields (from MC, CBcalc, BRE)
4938 {
4940 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
4941 vector<pair<double, double>> varbin = {make_pair(1.6, 0.2), make_pair(2.0, 0.4), make_pair(2.5, 0.5)};
4942 for (const string ev : {"sameEv", "mixedEv"}) {
4943 string cNameFull = cName + "Types/PairYields_" + ev;
4944 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 2400, 2400);
4945 int iC = 1;
4946 c->Divide(3, 3);
4947 for (const string comb : {"PM", "PP", "MM"}) {
4948 TH1D* mc = VaryBinWidth("mean", "hMinv" + comb + "_" + ev, fNofSimEvents, varbin);
4949 TH1D* re = VaryBinWidth("fastsim", "hfsc_Minv" + comb + "_" + ev + "_" + stepname, fNofFastSimEvents, varbin);
4950 TH1D* cb = VaryBinWidth("evmix", "hmx_Minv" + comb + "_" + ev + "_" + stepname, fNofEvMixEvents, varbin);
4951 TH1D* remc = (TH1D*) re->Clone();
4952 TH1D* cbmc = (TH1D*) cb->Clone();
4953 TH1D* cbre = (TH1D*) cb->Clone();
4954 remc->Divide(mc);
4955 cbmc->Divide(mc);
4956 cbre->Divide(re);
4957 remc->GetYaxis()->SetTitle("Ratio");
4958 cbre->GetYaxis()->SetTitle("Ratio");
4959 mc->GetYaxis()->SetRangeUser(1e-7, 1e-2);
4960 remc->GetYaxis()->SetRangeUser(0.0, 2.);
4961 string combMode = (comb == "PP") ? "e^{+}e^{+}" : (comb == "MM") ? "e^{-}e^{-}" : "e^{+}e^{-}";
4962 string label = combMode + " (" + ev + ")";
4963 c->cd(iC++);
4964 DrawH1({mc, re, cb}, {"MC Simulation", "Fast Simulations", "Comb. BG Procedure"}, kLinear, kLog, true, 0.6, 0.7,
4965 0.91, 0.91, "pe");
4966 DrawTextOnPad(label, 0.25, 0.9, 0.72, 0.99);
4967 c->cd(iC++);
4968 DrawH1({remc, cbmc}, {"Fast Simulations / MC Simulation", "Comb. BG Procedure / MC Simulation"}, kLinear,
4969 kLinear, true, 0.55, 0.75, 0.92, 0.92, "hist");
4970 DrawTextOnPad(label, 0.25, 0.9, 0.72, 0.99);
4971 c->cd(iC++);
4972 DrawH1({cbre}, {"Comb. BG Procedure / Fast Sim."}, kLinear, kLinear, true, 0.5, 0.82, 0.95, 0.9, "hist");
4973 DrawTextOnPad(label, 0.25, 0.9, 0.72, 0.99);
4974 }
4975 // Geometric Mean
4976 TH1D* gmre = VaryBinWidth("mean", "hReCbGeom_" + ev, fNofFastSimEvents, varbin);
4977 TH1D* gmcb = VaryBinWidth("mean", fHMean.GetName("hCbGeom_" + ev, step), fNofFastSimEvents, varbin);
4978 TH1D* rat = (TH1D*) gmre->Clone();
4979 rat->Divide(gmcb);
4980 rat->GetYaxis()->SetTitle("Ratio");
4981 string cNameFull2 = cName + "Types/GeomMean_" + ev;
4982 TCanvas* c2 = fHMean.fHM.CreateCanvas(cNameFull2, cNameFull2, 1600, 800);
4983 c2->Divide(2, 1);
4984 c2->cd(1);
4985 DrawH1({gmre, gmcb}, {"Fast Simulations", "Comb. BG Procedure"}, kLinear, kLog, true, 0.65, 0.75, 0.95, 0.9,
4986 "hist");
4987 DrawTextOnPad("Geometric Mean (" + ev + ")", 0.25, 0.9, 0.75, 0.99);
4988 c2->cd(2);
4989 DrawH1({rat}, {"Fast Simulations / Comb. BG Procedure"}, kLinear, kLinear, true, 0.65, 0.82, 0.95, 0.9, "hist");
4990 DrawTextOnPad("Ratio", 0.35, 0.9, 0.65, 0.99);
4991 }
4992 }
4993
4994 // Compare unlike-sign yield (PM) of Fast Sim. with MC, with / without Cocktail
4995 {
4997 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
4998 vector<pair<double, double>> varbin = {make_pair(1.6, 0.2), make_pair(2.0, 0.4), make_pair(2.5, 0.5)};
4999 TH1D* mc = VaryBinWidth("mean", fHMean.GetName("hMinv_bg", step), fNofSimEvents, fBwVarBg);
5000 //TH1D* mc = VaryBinWidth("mean", "hMinvPM_sameEv", fNofSimEvents, fBwVarBg);
5001 TH1D* re = VaryBinWidth("fastsim", "hfsc_MinvBg_" + stepname, fNofFastSimEvents, fBwVarBg);
5002 TH1D* coc = VaryBinWidth("cocktail_" + stepname, "", fBwVarBg);
5003 TH1D* rat1 = (TH1D*) re->Clone();
5004 TH1D* rat2 = (TH1D*) re->Clone();
5005 rat2->Add(coc);
5006 rat1->Divide(mc);
5007 rat2->Divide(mc);
5008 fHMean.fHM.CreateCanvas(cName + "Types/PM_wwo-Cocktail", cName + "Types/PM_wwo-Cocktail", 800, 800);
5009 DrawH1({rat1, rat2}, {"B_{FS}/B_{MC}", "(B_{FS} + Coc)/B_{MC}"}, kLinear, kLog, true, 0.65, 0.75, 0.95, 0.9,
5010 "hist");
5011 }
5012
5013 // Compare "MinvBg" with "MinvPM" from Fast Simulations
5014 {
5015 TH1D* bg1 = VaryBinWidth("fastsim", "hfsc_MinvPM_sameEv_elid", fNofFastSimEvents, fBwVarBg);
5016 TH1D* bg2 = VaryBinWidth("fastsim", "hfsc_MinvBg_elid", fNofFastSimEvents, fBwVarBg);
5017 TH1D* rat = (TH1D*) bg1->Clone();
5018 rat->Divide(bg2);
5019 rat->GetYaxis()->SetTitle("Ratio");
5020 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Types/FastSimBgs", cName + "Types/FastSimBgs", 1600, 800);
5021 c->Divide(2, 1);
5022 c->cd(1);
5023 DrawH1({bg1, bg2}, {"hMinv_bg_elid", "hMinvPM_sameEv"}, kLinear, kLog, true, 0.6, 0.7, 0.95, 0.9, "hist");
5024 c->cd(2);
5025 DrawH1(rat, kLinear, kLinear, "hist");
5026 }
5027
5028 for (auto step : fHMean.fAnaSteps) {
5029 if (step != ELmvmAnaStep::ElId) continue;
5030 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
5031 //vector<pair<double, double>> varbin = {make_pair(1.1, 0.1), make_pair(1.5, 0.2), make_pair(2.5, 0.5)};
5032 vector<pair<double, double>> varbin = fBwVarBg2;
5033
5034 // Draw single background contributions
5035 {
5036 string hName = "hMinvBgSource2_" + fHMean.fAnaStepNames[static_cast<int>(step)] + "_";
5037 TH1D* gg = VaryBinWidth("mean", hName + "gg", varbin);
5038 TH1D* pipi = VaryBinWidth("mean", hName + "pipi", varbin);
5039 TH1D* pi0pi0 = VaryBinWidth("mean", hName + "pi0pi0", varbin);
5040 TH1D* oo = VaryBinWidth("mean", hName + "oo", varbin);
5041 TH1D* gpi = VaryBinWidth("mean", hName + "gpi", varbin);
5042 TH1D* gpi0 = VaryBinWidth("mean", hName + "gpi0", varbin);
5043 TH1D* go = VaryBinWidth("mean", hName + "go", varbin);
5044 TH1D* pipi0 = VaryBinWidth("mean", hName + "pipi0", varbin);
5045 TH1D* pio = VaryBinWidth("mean", hName + "pio", varbin);
5046 TH1D* pi0o = VaryBinWidth("mean", hName + "pi0o", varbin);
5047
5048 vector<LmvmDrawMinvData> drawData;
5049 drawData.emplace_back(gpi0, kBlack, kBlack, 1, -1, "#gamma - #pi^{0}");
5050 drawData.emplace_back(pi0pi0, kGray + 1, kGray + 1, 1, -1, "#pi^{0} - #pi^{0}");
5051 drawData.emplace_back(gg, kCyan + 2, kCyan + 4, 2, -1, "#gamma - #gamma");
5052 drawData.emplace_back(pipi0, kGreen - 3, kGreen + 3, 2, -1, "#pi^{#pm}_{mis} - #pi^{0}");
5053 drawData.emplace_back(pi0o, kRed - 4, kRed + 2, 1, -1, "#pi^{0} - o.");
5054 drawData.emplace_back(gpi, kOrange + 7, kOrange + 4, 2, -1, "#gamma - #pi^{#pm}_{mis}");
5055 drawData.emplace_back(go, kAzure + 2, kAzure + 3, 2, -1, "#gamma - o.");
5056 drawData.emplace_back(pipi, kOrange - 2, kOrange - 3, 4, 3112, "#pi^{#pm}_{mis} - #pi^{#pm}_{mis}");
5057 drawData.emplace_back(pio, kMagenta - 3, kMagenta - 2, 4, 3018, "#pi^{#pm}_{mis} - o.");
5058 drawData.emplace_back(oo, -1, kRed + 2, 4, -1, "o. - o.");
5059
5060 string cNameFull = cName + "Composition/comp_" + fHMean.fAnaStepNames[static_cast<int>(step)];
5061 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1000, 1000);
5062
5063 TH1D* h0 = nullptr;
5064 TLegend* leg = new TLegend(0.75, 0.35, 0.92, 0.9);
5065 for (size_t i = 0; i < drawData.size(); i++) {
5066 const auto& d = drawData[i];
5067 d.fH->GetYaxis()->SetLabelSize(0.05);
5068 d.fH->GetYaxis()->SetRangeUser(2e-7, 3e-3);
5069 if (d.fFillColor != -1) d.fH->SetFillColor(d.fFillColor);
5070 if (d.fFillStyle != -1) d.fH->SetFillStyle(d.fFillStyle);
5071 leg->AddEntry(d.fH, d.fLegend.c_str(), "f");
5072 DrawH1(d.fH, kLinear, kLinear, (h0 == nullptr) ? "hist" : "hist,same", d.fLineColor, d.fLineWidth, 0);
5073 if (h0 == nullptr) h0 = d.fH;
5074 }
5075
5076 leg->SetFillColor(kWhite);
5077 leg->Draw();
5078 fHMean.DrawSimDataLabel(.57, 1.5e-3, 0.03);
5079 gPad->SetLogy(true);
5080 }
5081
5082 // Draw sum of single contributions
5083 {
5084 string hName = "hMinvBgSource2_" + fHMean.fAnaStepNames[static_cast<int>(step)] + "_";
5085 string cNameFull = cName + "Composition/sum_" + fHMean.fAnaStepNames[static_cast<int>(step)];
5086
5087 TH1D* physBg = fHMean.H1Clone(hName + "gg");
5088 physBg->Add(fHMean.H1(hName + "gpi0"));
5089 physBg->Add(fHMean.H1(hName + "pi0pi0"));
5090
5091 TH1D* cPi = fHMean.H1Clone(hName + "pipi");
5092 cPi->Add(fHMean.H1Clone(hName + "gpi"));
5093 cPi->Add(fHMean.H1Clone(hName + "pipi0"));
5094 cPi->Add(fHMean.H1Clone(hName + "pio"));
5095
5096 TH1D* rest = fHMean.H1Clone(hName + "oo");
5097 rest->Add(fHMean.H1Clone(hName + "go"));
5098 rest->Add(fHMean.H1Clone(hName + "pi0o"));
5099
5100 TH1D* physBg2 = VaryBinWidth(physBg, fBwVarBg2);
5101 TH1D* cPi2 = VaryBinWidth(cPi, fBwVarBg2);
5102 TH1D* rest2 = VaryBinWidth(rest, fBwVarBg2);
5103 physBg2->GetYaxis()->SetRangeUser(1e-7, 1e-2);
5104
5105 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1000, 1000);
5106 DrawH1({physBg2, cPi2, rest2}, {"Phys. BG", "BG w. misid. #pi^{#pm}", "Rest"}, kLinear, kLog, true, 0.7, 0.8,
5107 0.95, 0.91, "h");
5108 fHMean.DrawSimDataLabel(.15, 2.7e-7, 0.03);
5109
5110 //check if all bg pair combinations are considered
5111 if (step == ELmvmAnaStep::ElId || step == ELmvmAnaStep::GammaCut) {
5112 TH1D* bgRat = static_cast<TH1D*>(physBg2->Clone());
5113 bgRat->Add(cPi2);
5114 bgRat->Add(rest2);
5115
5116 TH1D* bg = fHMean.H1Clone("hMinv", ELmvmSrc::Bg, step);
5117 bg->Add(fHMean.H1("hMinv", ELmvmSrc::Gamma, step), -1.);
5118 TH1D* bg2 = VaryBinWidth(bg, fBwVarBg);
5119
5120 int nBins = bgRat->GetNbinsX();
5121 for (int i = 1; i <= nBins; i++) {
5122 if (bgRat->GetBinContent(i) == 0)
5123 bgRat->SetBinContent(i, 2);
5124 else {
5125 double r = bgRat->GetBinContent(i) / bg2->GetBinContent(i);
5126 bgRat->SetBinContent(i, r);
5127 }
5128 }
5129
5130 bgRat->SetMinimum(0.95);
5131 bgRat->SetMaximum(1.05);
5132
5133 string cNameFull2 = cName + "Composition/Ratio_" + fHMean.fAnaStepNames[static_cast<int>(step)];
5134 fHMean.fHM.CreateCanvas(cNameFull2, cNameFull2, 800, 800);
5135 DrawH1(bgRat, kLinear, kLinear, "hist");
5136 }
5137 }
5138 } //step loop
5139
5140 // Symmetry of misidentifications
5141 /*for (const string histo : {"hMinv", "hMinvCombPM_same"}) {
5142 TH1D* tt = VaryBinWidth("mean", histo + "_tt", fBwVarBg);
5143 TH1D* tm = VaryBinWidth("mean", histo + "_tm", fBwVarBg);
5144 TH1D* mt = VaryBinWidth("mean", histo + "_mt", fBwVarBg);
5145 TH1D* mm = VaryBinWidth("mean", histo + "_mm", fBwVarBg);
5146 TH1D* bg = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Bg, ELmvmAnaStep::ElId), fBwVarBg);
5147 TH1D* coc = VaryBinWidth("cocktail_elid", "", fBwVarBg);
5148 TH1D* gamma = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Gamma, ELmvmAnaStep::ElId), fBwVarBg);
5149
5150 string legText = "#sum ee_{i} / B_{MC}";
5151 TH1D* sum;
5152 //sum->Sumw2();
5153 sum = (TH1D*) tt->Clone();
5154 sum->Add(tm);
5155 sum->Add(mt);
5156 sum->Add(mm);
5157 if (histo == "hMinvCombPM_same") {
5158 sum->Add(coc, -1.);
5159 sum->Add(gamma, -1.);
5160 legText = "#(){ #(){ #sum ee_{i} } - coc - #gamma} / B_{MC}";
5161 }
5162
5163 TH1D* ratio = (TH1D*) sum->Clone();
5164 ratio->Divide(bg);
5165 ratio->GetYaxis()->SetTitle("Ratio");
5166
5167 tt->GetYaxis()->SetRangeUser(1e-6, 5e-3);
5168 ratio->GetYaxis()->SetRangeUser(0., 2.);
5169 string cNameFull = cName + "Misid-Symm/" + histo;
5170 TCanvas* c = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 1600, 800);
5171 c->Divide(2, 1);
5172 c->cd(1);
5173 DrawH1({tt, tm, mt, mm}, {"e^{+}_{true} e^{-}_{true}", "e^{+}_{true} e^{-}_{mis.}", "e^{+}_{mis.} e^{-}_{true}", "e^{+}_{mis.} e^{-}_{mis.}"}, kLinear, kLog, true, 0.78, 0.75, 0.95, 0.91, "hist");
5174 fHMean.DrawAnaStepOnPad(ELmvmAnaStep::ElId);
5175 c->cd(2);
5176 DrawH1({ratio}, {legText}, kLinear, kLinear, true, 0.6, 0.8, 0.95, 0.91, "p");
5177 }*/
5178
5179 // Draw Background Pair PDGs seperate for diff. minv regions
5180 {
5181 TLine* lineH = new TLine(0., 4., 4., 4.);
5182 TLine* lineV = new TLine(4., 0., 4., 4.);
5183 lineH->SetLineWidth(6.);
5184 lineV->SetLineWidth(6.);
5185 for (const string type : {"pRec"}) { // "pMc",
5186 vector<double> v_pm, v_pp, v_mm, v_pm_el, v_pp_el, v_mm_el; // for charge symmetries
5187 for (const string comb : {"PM", "PP", "MM"}) {
5188 for (int iMinv = 0; iMinv <= 24; iMinv++) {
5189 string hName = "hBgPairPdg" + comb + "_" + type + "_" + Cbm::NumberToString(iMinv, 0);
5190 string text = Cbm::NumberToString(100 * iMinv, 0) + " #leq m_{inv} < "
5191 + Cbm::NumberToString(100 * (iMinv + 1), 0) + " MeV/c^{2} (ID)";
5192 TH2D* h = fHMean.H2Clone(hName);
5193 h->GetZaxis()->SetRangeUser(1e-15, 1e-3);
5194 vector<string> label = {"e_{signal}", "e_{#pi^{0}}", "e_{#gamma}", "e_{o.}",
5195 "#pi^{#pm}_{mis}", "proton", "kaon", "other"};
5196 for (size_t y = 1; y <= label.size(); y++) {
5197 h->GetXaxis()->SetBinLabel(y, label[y - 1].c_str());
5198 h->GetYaxis()->SetBinLabel(y, label[y - 1].c_str());
5199 }
5200 double I = h->Integral(1, h->GetNbinsX(), 1, h->GetNbinsX());
5201 double ITrue = h->Integral(1, 4, 1, 4);
5202 if (comb == "PM") {
5203 v_pm.push_back(I);
5204 v_pm_el.push_back(ITrue);
5205 }
5206 else if (comb == "PP") {
5207 v_pp.push_back(I);
5208 v_pp_el.push_back(ITrue);
5209 }
5210 else if (comb == "MM") {
5211 v_mm.push_back(I);
5212 v_mm_el.push_back(ITrue);
5213 }
5214 string xTitle = "PDG +";
5215 string yTitle = "PDG -";
5216 if (comb == "PP") yTitle = "PDG +";
5217 if (comb == "MM") xTitle = "PDG -";
5218 h->GetXaxis()->SetTitle(xTitle.c_str());
5219 h->GetYaxis()->SetTitle(yTitle.c_str());
5220 string cNameFull = cName + "PairPdg/" + type + "/" + comb + "/" + Cbm::NumberToString(iMinv, 0);
5221 fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 900, 600);
5222 DrawH2(h, kLinear, kLinear, kLog, "colz");
5223 DrawTextOnPad(text, 0.05, 0.9, 0.7, 0.99);
5224 DrawTextOnPad("I = " + Cbm::NumberToString(I, 2) + " / Event", 0.12, 0.8, 0.5, 0.89);
5225 DrawTextOnPad("I_{true} = " + Cbm::NumberToString(ITrue, 2) + " / Event", 0.15, 0.42, 0.43, 0.51);
5226 lineH->Draw();
5227 lineV->Draw();
5228 }
5229 }
5230 LOG(warn) << "PairYieldSymmetry: Check Calculation of Symmetry Ratios!!!";
5231 // Histograms for charge symmetries
5232 TH1D* hSymm_ppmm = new TH1D(("hSymm_ppmm_" + type).c_str(), "hSymm_ppmm; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5233 TH1D* hSymm_pppm = new TH1D(("hSymm_pppm_" + type).c_str(), "hSymm_pppm; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5234 TH1D* hSymm_mmpm = new TH1D(("hSymm_mmpm_" + type).c_str(), "hSymm_mmpm; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5235 TH1D* hSymm_ppmm_el =
5236 new TH1D(("hSymm_ppmm_" + type + "_el").c_str(), "hSymm_ppmm_el; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5237 TH1D* hSymm_pppm_el =
5238 new TH1D(("hSymm_pppm_" + type + "_el").c_str(), "hSymm_pppm_el; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5239 TH1D* hSymm_mmpm_el =
5240 new TH1D(("hSymm_mmpm_" + type + "_el").c_str(), "hSymm_mmpm_el; M_{ee} [GeV/c^{2}]; Ratio", 25, 0., 2.5);
5241 for (int iB = 1; iB <= hSymm_ppmm->GetNbinsX(); iB++) {
5242 double ppmm = v_pp[iB - 1] / v_mm[iB - 1];
5243 double pppm = v_pp[iB - 1] / v_pm[iB - 1];
5244 double mmpm = v_mm[iB - 1] / v_pm[iB - 1];
5245 double ppmmEl = v_pp_el[iB - 1] / v_mm_el[iB - 1];
5246 double pppmEl = v_pp_el[iB - 1] / v_pm_el[iB - 1];
5247 double mmpmEl = v_mm_el[iB - 1] / v_pm_el[iB - 1];
5248 //LOG(info) << "all: iB = " << iB << ", pm = " << v_pm[iB-1] << ", pp = " << v_pp[iB-1] << ", mm = " << v_mm[iB-1] << ", pp/mm = " << ppmm << ", pp/pm = " << pppm << ", mm/pm = " << mmpm;
5249 hSymm_ppmm->SetBinContent(iB, ppmm);
5250 hSymm_pppm->SetBinContent(iB, pppm);
5251 hSymm_mmpm->SetBinContent(iB, mmpm);
5252 hSymm_ppmm_el->SetBinContent(iB, ppmmEl);
5253 hSymm_pppm_el->SetBinContent(iB, pppmEl);
5254 hSymm_mmpm_el->SetBinContent(iB, mmpmEl);
5255 }
5256 vector<pair<double, double>> varbin = fBwVarBg5;
5257 TH1D* hSymm_ppmm2 = VaryBinWidth(hSymm_ppmm, varbin);
5258 TH1D* hSymm_pppm2 = VaryBinWidth(hSymm_pppm, varbin);
5259 TH1D* hSymm_mmpm2 = VaryBinWidth(hSymm_mmpm, varbin);
5260 TH1D* hSymm_ppmm_el2 = VaryBinWidth(hSymm_ppmm_el, varbin);
5261 TH1D* hSymm_pppm_el2 = VaryBinWidth(hSymm_pppm_el, varbin);
5262 TH1D* hSymm_mmpm_el2 = VaryBinWidth(hSymm_mmpm_el, varbin);
5263 hSymm_ppmm2->GetYaxis()->SetRangeUser(0., 1.2);
5264 hSymm_pppm2->GetYaxis()->SetRangeUser(0., 1.2);
5265 hSymm_mmpm2->GetYaxis()->SetRangeUser(0., 1.2);
5266 hSymm_ppmm_el2->GetYaxis()->SetRangeUser(0., 1.2);
5267 hSymm_pppm_el2->GetYaxis()->SetRangeUser(0., 1.2);
5268 hSymm_mmpm_el2->GetYaxis()->SetRangeUser(0., 1.2);
5269 hSymm_ppmm->GetYaxis()->SetRangeUser(0., 1.2);
5270 hSymm_pppm->GetYaxis()->SetRangeUser(0., 1.2);
5271 hSymm_mmpm->GetYaxis()->SetRangeUser(0., 1.2);
5272 hSymm_ppmm_el->GetYaxis()->SetRangeUser(0., 1.2);
5273 hSymm_pppm_el->GetYaxis()->SetRangeUser(0., 1.2);
5274 hSymm_mmpm_el->GetYaxis()->SetRangeUser(0., 1.2);
5275 string cNameSymm = cName + "PairPdg/ChargeSymmetries_" + type;
5276 TCanvas* c = fHMean.fHM.CreateCanvas(cNameSymm, cNameSymm, 1600, 800);
5277 c->Divide(2, 1);
5278 c->cd(1);
5279 DrawH1({hSymm_ppmm2, hSymm_pppm2, hSymm_mmpm2}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, 0.72, 0.7,
5280 0.91, 0.91, "hist");
5281 DrawTextOnPad("Charge Symmetries (all)", 0.1, 0.9, 0.8, 0.99);
5282 c->cd(2);
5283 DrawH1({hSymm_ppmm_el2, hSymm_pppm_el2, hSymm_mmpm_el2}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true,
5284 0.72, 0.7, 0.91, 0.91, "hist");
5285 DrawTextOnPad("Charge Symmetries (electrons)", 0.05, 0.9, 0.85, 0.99);
5286
5287 TCanvas* ct = fHMean.fHM.CreateCanvas(cNameSymm + "_test", cNameSymm + "_test", 1600, 800);
5288 ct->Divide(2, 1);
5289 ct->cd(1);
5290 DrawH1({hSymm_ppmm, hSymm_pppm, hSymm_mmpm}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, 0.72, 0.7, 0.91,
5291 0.91, "hist");
5292 DrawTextOnPad("Charge Symmetries (all)", 0.1, 0.9, 0.8, 0.99);
5293 ct->cd(2);
5294 DrawH1({hSymm_ppmm_el, hSymm_pppm_el, hSymm_mmpm_el}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, 0.72,
5295 0.7, 0.91, 0.91, "hist");
5296 DrawTextOnPad("Charge Symmetries (electrons)", 0.05, 0.9, 0.85, 0.99);
5297 }
5298 }
5299
5300 // Compare Background from all vs. only UrQMD particles
5301 {
5303 TH1D* bg = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Bg, step), fBwVarSig);
5304 TH1D* bgU = VaryBinWidth("mean", fHMean.GetName("hMinv_urqmdAll", ELmvmSrc::Bg, step), fBwVarSig);
5305 TH1D* bgUEl = VaryBinWidth("mean", fHMean.GetName("hMinv_urqmdEl", ELmvmSrc::Bg, step), fBwVarSig);
5306 TH1D* rat1 = (TH1D*) bgU->Clone();
5307 TH1D* rat2 = (TH1D*) bgUEl->Clone();
5308 rat1->Divide(bg);
5309 rat2->Divide(bg);
5310 rat1->GetYaxis()->SetTitle("Ratio");
5311 rat2->GetYaxis()->SetTitle("Ratio");
5312 bg->GetYaxis()->SetRangeUser(2e-7, 1e-2);
5313 rat1->GetYaxis()->SetRangeUser(0., 1.2);
5314 TCanvas* c = fHMean.fHM.CreateCanvas("Background/Categories", "Background/Categories", 1600, 800);
5315 c->Divide(2, 1);
5316 c->cd(1);
5317 DrawH1({bg, bgU, bgUEl}, {"B_{MC} (all)", "B_{MC} (UrQMD)", "B_{MC} (UrQMD electrons)"}, kLinear, kLog, true, 0.65,
5318 0.75, 0.91, 0.9, "p");
5319 c->cd(2);
5320 DrawH1({rat1, rat2}, {"B_{MC}(UrQMD) / B_{MC}(all)", "B_{MC}(UrQMD-El) / B_{MC}(all)"}, kLinear, kLinear, true,
5321 0.65, 0.75, 0.91, 0.9, "p");
5322 }
5323
5324 // Study: Investigate impact of elid cut variation on CB and RE background
5325 /*bool doBgStudy = true;
5326 if (doBgStudy) {
5327 string dir = "/lustre/cbm/users/criesen/data/studies/BG_ReVsCb/";
5328 ELmvmAnaStep step = ELmvmAnaStep::ElId;
5329 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
5330 vector<TH1D*> histsRE, histsCB;
5331 vector<string> set = {"set8", "set9", "set10", "set11", "set12"}; // "set5"
5332 for (const string& iSet : set) {
5333 LmvmHist HMRE, HMCB;
5334
5335 // Fast Simulation Background
5336 TFile* fileRE = new TFile((dir + "randomevent." + iSet + ".root").c_str());
5337 HMRE.fHM.ReadFromFile(fileRE);
5338 double nofFastSimEv = HMRE.H1("hre_EventNumber")->GetEntries();
5339 HMRE.fHM.ScaleByPattern("hre.*_Minv.*", 1. / nofFastSimEv);
5340 TH1D* hRe = HMRE.H1Clone("hre_MinvBg_" + stepname);
5341 histsRE.push_back(hRe);
5342
5343 // Combinatorial Background
5344 TFile* fileCB = new TFile((dir + "evmix." + iSet + ".root").c_str());
5345 HMCB.fHM.ReadFromFile(fileCB);
5346 double fNofEvMixEvents = HMCB.H1("hmx_EventNumber")->GetEntries();
5347 HMCB.fHM.ScaleByPattern("hmx_Minv.*", 1. / fNofEvMixEvents);
5348 string hCbName = "hmx_Minv";
5349 TH1D* pmSame = HMCB.H1Clone(hCbName + "PM_sameEv", step);
5350 TH1D* ppSame = HMCB.H1Clone(hCbName + "PP_sameEv", step);
5351 TH1D* mmSame = HMCB.H1Clone(hCbName + "MM_sameEv", step);
5352 TH1D* pmMixed = HMCB.H1Clone(hCbName + "PM_mixedEv", step);
5353 TH1D* ppMixed = HMCB.H1Clone(hCbName + "PP_mixedEv", step);
5354 TH1D* mmMixed = HMCB.H1Clone(hCbName + "MM_mixedEv", step);
5355
5356 // Geometric Mean
5357 TH1D* hGeomSame = (TH1D*) pmSame->Clone();
5358 TH1D* hGeomMix = (TH1D*) pmSame->Clone();
5359 for (int iB = 1; iB <= hGeomSame->GetNbinsX(); iB++) {
5360 double cppSame = ppSame->GetBinContent(iB);
5361 double cmmSame = mmSame->GetBinContent(iB);
5362 double cSame = std::sqrt(cppSame * cmmSame);
5363 hGeomSame->SetBinContent(iB, cSame);
5364 double cppMix = ppMixed->GetBinContent(iB);
5365 double cmmMix = mmMixed->GetBinContent(iB);
5366 double cMix = std::sqrt(cppMix * cmmMix);
5367 hGeomMix->SetBinContent(iB, cMix);
5368 }
5369
5370 // k Factor
5371 TH1D* hK = (TH1D*) pmMixed->Clone();
5372 hK->Divide(hGeomMix);
5373 hK->Scale(0.5);
5374
5375 // Normalization Range
5376 int ChangeBin = pmSame->FindBin(fCbChange);
5377 int NormRangeMinBin = pmSame->FindBin(fCbNormRangeMin);
5378 int NormRangeMaxBin = pmSame->FindBin(fCbNormRangeMax);
5379 double normPPInt = ppSame->Integral(NormRangeMinBin, NormRangeMaxBin) / ppMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
5380 double normMMInt = mmSame->Integral(NormRangeMinBin, NormRangeMaxBin) / mmMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
5381
5382 // Calculate Combinatorial Background
5383 TH1D* hCb = (TH1D*) pmSame->Clone();
5384 for (int iB = 1; iB <= hCb->GetNbinsX(); iB++) {
5385 double k = hK->GetBinContent(iB);
5386 double pp = ppMixed->GetBinContent(iB);
5387 double mm = mmMixed->GetBinContent(iB);
5388 double cb = (iB < ChangeBin) ? 2. * k * hGeomSame->GetBinContent(iB) : 2. * k * std::sqrt(normPPInt * pp * normMMInt * mm);
5389 hCb->SetBinContent(iB, cb);
5390 }
5391 histsCB.push_back(hCb);
5392 }
5393
5394 vector<TH1*> hRatRe, hRatCb, hRatCbRe;
5395 vector<string> leg;
5396 for (size_t iH = 1; iH < set.size(); iH++) {
5397 TH1D* ratRe = histsRE[iH];
5398 TH1D* ratCb = histsCB[iH];
5399 ratRe->Divide(histsRE[0]);
5400 ratCb->Divide(histsCB[0]);
5401 TH1D* ratRe2 = VaryBinWidth(ratRe, fBwVarRat);
5402 TH1D* ratCb2 = VaryBinWidth(ratCb, fBwVarRat);
5403 TH1D* ratCbRe2 = (TH1D*) ratCb2->Clone();
5404 ratCbRe2->Divide(ratRe2);
5405 ratRe2->GetYaxis()->SetRangeUser(0.5, 1.);
5406 ratCb2->GetYaxis()->SetRangeUser(0.5, 1.);
5407 ratCbRe2->GetYaxis()->SetRangeUser(0.95, 1.0);
5408 ratCb2->GetYaxis()->SetTitle("Ratio Backgrounds");
5409 ratRe2->GetYaxis()->SetTitle("Ratio Backgrounds");
5410 ratCbRe2->GetYaxis()->SetTitle("Ratio Backgrounds");
5411 hRatRe.push_back(ratRe2);
5412 hRatCb.push_back(ratCb2);
5413 hRatCbRe.push_back(ratCbRe2);
5414 string legtext = set[iH] + "/" + set[0];
5415 leg.push_back(legtext);
5416 }
5417
5418 TCanvas* c = fHMean.fHM.CreateCanvas(cName + "Study/CutImpact_all", cName + "Study/CutImpact_all", 2400, 800);
5419 c->Divide(3, 1);
5420 c->cd(1);
5421 DrawH1(hRatCb, leg, kLinear, kLinear, true, 0.75, 0.7, 0.95, 0.92, "hist");
5422 DrawTextOnPad("Combinatorial Background", 0.15, 0.9, 0.8, 0.99);
5423 c->cd(2);
5424 DrawH1(hRatRe, leg, kLinear, kLinear, true, 0.75, 0.7, 0.95, 0.92, "hist");
5425 DrawTextOnPad("Fast Simulation Background", 0.15, 0.9, 0.8, 0.99);
5426 c->cd(3);
5427 DrawH1(hRatCbRe, leg, kLinear, kLinear, true, 0.75, 0.7, 0.95, 0.92, "hist");
5428 DrawTextOnPad("Background: CB_{calc} / B_{FS}", 0.1, 0.9, 0.73, 0.99);
5429
5430 for (size_t iH = 0; iH < hRatCb.size(); iH++) {
5431 TH1D* ratCb = (TH1D*) hRatCb[iH]->Clone();
5432 TH1D* ratRe = (TH1D*) hRatRe[iH]->Clone();
5433 TH1D* ratCbRe = (TH1D*) ratCb->Clone();
5434 ratCbRe->Divide(ratRe);
5435 ratCb->GetYaxis()->SetTitle("Ratio Backgrounds");
5436 ratCbRe->GetYaxis()->SetRangeUser(0.95, 1.05);
5437 string cNameFull = cName + "Study/CutImpact_" + set[iH+1] ;
5438 TCanvas* c2 = fHMean.fHM.CreateCanvas(cNameFull, cNameFull, 800, 1600);
5439 c2->Divide(1, 2);
5440 c2->cd(1);
5441 DrawH1({ratCb, ratRe}, {"Ratio CB_{calc}", "Ratio B_{FS}"}, kLinear, kLinear, true, 0.75, 0.78, 0.95, 0.92, "hist");
5442 DrawTextOnPad(leg[iH], 0.3, 0.9, 0.7, 0.99);
5443 c2->cd(2);
5444 DrawH1(ratCbRe, kLinear, kLinear, "hist");
5445 DrawTextOnPad(leg[iH], 0.3, 0.9, 0.7, 0.99);
5446 }
5447 }*/
5448}
5449
5451{
5452 for (const ELmvmAnaStep step : fHMean.fAnaSteps) {
5453 string cName = "MinvPt/" + fHMean.fAnaStepNames[static_cast<int>(step)];
5454 fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1000, 1000);
5455 DrawH2(GetCocktailMinv<TH2D>("hMinvPt", step, false), kLinear, kLinear, kLog, "colz");
5456 }
5457}
5458
5460{
5461 string folder = "CombinatorialBackground/";
5462 TH1D* time = fHEvMix.H1Clone("hmx_time");
5463 fHMean.fHM.CreateCanvas("CombinatorialBackground/time", "CombinatorialBackground/time", 800, 800);
5464 DrawH1(time, kLinear, kLinear, "hist");
5465
5466 // Check pair yields with yields from analysis
5467 {
5468 vector<int> canvas = {1, 4, 2, 5, 3, 6};
5469 for (const string evMode : {"sameEv", "mixedEv"}) {
5470 string cName = folder + "PairYields/CheckWithSim_" + evMode;
5471 TCanvas* c = fHMean.fHM.CreateCanvas(cName, cName, 2400, 1600);
5472 c->Divide(3, 2);
5473 int iC = 0;
5474 for (const string comb : {"PM", "PP", "MM"}) {
5475 TH1D* sim = VaryBinWidth("mean", "hMinv" + comb + "_" + evMode, fBwVarBg5);
5476 TH1D* cb = VaryBinWidth("evmix", "hmx_Minv" + comb + "_" + evMode + "_elid", fBwVarBg5);
5477 TH1D* r = (TH1D*) cb->Clone();
5478 r->Divide(sim);
5479 r->GetYaxis()->SetTitle("Ratio");
5480 r->GetYaxis()->SetRangeUser(.95, 1.05);
5481 c->cd(canvas[iC]);
5482 iC++;
5483 DrawH1({sim, cb}, {"Simulation", "CB Procedure"}, kLinear, kLog, true, 0.6, 0.7, 0.92, 0.9, "hist");
5484 DrawTextOnPad(comb, 0.3, 0.9, 0.7, 0.99);
5485 c->cd(canvas[iC]);
5486 iC++;
5487 DrawH1(r, kLinear, kLinear, "hist");
5488 DrawTextOnPad(comb, 0.3, 0.9, 0.7, 0.99);
5489 }
5490 }
5491 }
5492
5493 // Draw PM, MM, PP in one plot (ID)
5494 {
5496 for (const string cat : {"", "_trueEl"}) { //, "_urqmdEl", "_urqmdAll"}) {
5497 for (const string ev : {"sameEv", "mixedEv"}) {
5498 string cName = folder + "PairYields/AllCombs_" + ev + cat;
5499 TCanvas* c = fHMean.fHM.CreateCanvas(cName.c_str(), cName.c_str(), 1600, 800);
5500 c->Divide(2, 1);
5501 double nEvents =
5502 (ev == "sameEv") ? fNofEvMixEvents : fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]);
5503 vector<pair<double, double>> varbin = fBwVarBg4;
5504 if (ev == "mixedEv") varbin = fBwVarOrig;
5505 TH1D* pm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPM" + cat + "_" + ev, step), nEvents, varbin);
5506 TH1D* pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP" + cat + "_" + ev, step), nEvents, varbin);
5507 TH1D* mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM" + cat + "_" + ev, step), nEvents, varbin);
5508 TH1D* ppmm = (TH1D*) pp->Clone();
5509 ppmm->Divide(mm);
5510 TH1D* pppm = (TH1D*) pp->Clone();
5511 TH1D* mmpm = (TH1D*) mm->Clone();
5512 pppm->Divide(pm);
5513 mmpm->Divide(pm);
5514 ppmm->GetYaxis()->SetTitle("Ratio");
5515 ppmm->GetYaxis()->SetRangeUser(0., 1.2);
5516 c->cd(1);
5517 DrawH1({pm, pp, mm}, {"e+e-", "e+e+", "e-e-"}, kLinear, kLog, true, 0.8, 0.7, 0.95, 0.9, "pe");
5518 fHMean.DrawAnaStepOnPad(step);
5519 DrawTextOnPad("fCbNormFactor = " + Cbm::NumberToString(fCbNormFactor[static_cast<int>(step)], 0), 0.11, 0.15,
5520 0.68, 0.25);
5521 c->cd(2);
5522 DrawH1({ppmm, pppm, mmpm}, {"++/--", "++/+-", "--/+-"}, kLinear, kLinear, true, 0.77, 0.77, 0.95, 0.95, "pe");
5523 fHMean.DrawAnaStepOnPad(step);
5524 }
5525 }
5526 }
5527
5528 // Compare like-sign pairs of same and mixed events
5529 {
5531 string stepstr = fHMean.fAnaStepNames[static_cast<int>(step)];
5532 for (const string cat : {"", "_trueEl"}) { //, "_urqmdEl", "_urqmdAll"}) {
5533 TH1D* ppSame = VaryBinWidth("evmix", "hmx_MinvPP" + cat + "_sameEv_" + stepstr, fNofEvMixEvents, fBwVarBg);
5534 TH1D* mmSame = VaryBinWidth("evmix", "hmx_MinvMM" + cat + "_sameEv_" + stepstr, fNofEvMixEvents, fBwVarBg);
5535 TH1D* ppMix = VaryBinWidth("evmix", "hmx_MinvPP" + cat + "_mixedEv_" + stepstr,
5536 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5537 TH1D* mmMix = VaryBinWidth("evmix", "hmx_MinvMM" + cat + "_mixedEv_" + stepstr,
5538 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5539
5540 int minBin = ppSame->FindBin(fCbNormRangeMin);
5541 int maxBin = ppSame->FindBin(fCbNormRangeMax);
5542 double nP = ppSame->Integral(minBin, maxBin) / ppMix->Integral(minBin, maxBin);
5543 double nM = mmSame->Integral(minBin, maxBin) / mmMix->Integral(minBin, maxBin);
5544 ppMix->Scale(nP);
5545 mmMix->Scale(nM);
5546 mmSame->Scale(0.1);
5547 mmMix->Scale(0.1);
5548 ppSame->GetYaxis()->SetRangeUser(1e-8, 5e-3);
5549 TH1D* ppSame2 = (TH1D*) ppSame->Clone();
5550 TH1D* mmSame2 = (TH1D*) mmSame->Clone();
5551 TH1D* ppMix2 = (TH1D*) ppMix->Clone();
5552 TH1D* mmMix2 = (TH1D*) mmMix->Clone();
5553 ppSame2->GetXaxis()->SetRangeUser(0.3, 1.2);
5554 mmSame2->GetXaxis()->SetRangeUser(0.3, 1.2);
5555 ppMix2->GetXaxis()->SetRangeUser(0.3, 1.2);
5556 mmMix2->GetXaxis()->SetRangeUser(0.3, 1.2);
5557 ppSame2->GetYaxis()->SetRangeUser(1e-6, 5e-3);
5558 TCanvas* c = fHMean.fHM.CreateCanvas(folder + "PairYields/Likesign/likesign" + cat,
5559 folder + "PairYields/Likesign/likesign" + cat, 1600, 800);
5560 c->Divide(2, 1);
5561 c->cd(1);
5562 DrawH1({ppSame, ppMix, mmSame, mmMix},
5563 {"N_{e^{+}e^{+}}^{same}", "N_{e^{+}e^{+}}^{mixed} #upoint n_{+}", "N_{e^{-}e^{-}}^{same} #upoint 0.1",
5564 "N_{e^{-}e^{-}}^{mixed} #upoint n_{-} #upoint 0.1"},
5565 kLinear, kLog, true, 0.7, 0.75, 0.95, 0.99, "pe");
5566 fHMean.DrawAnaStepOnPad(step);
5567 c->cd(2);
5568 DrawH1({ppSame2, ppMix2, mmSame2, mmMix2},
5569 {"N_{e^{+}e^{+}}^{same}", "N_{e^{+}e^{+}}^{mixed} #upoint n_{+}", "N_{e^{-}e^{-}}^{same} #upoint 0.1",
5570 "N_{e^{-}e^{-}}^{mixed} #upoint n_{-} #upoint 0.1"},
5571 kLinear, kLog, true, 0.7, 0.75, 0.95, 0.99, "pe");
5572 fHMean.DrawAnaStepOnPad(step);
5573 DrawTextOnPad("Norm. Range: " + Cbm::NumberToString(fCbNormRangeMin, 1) + " - "
5574 + Cbm::NumberToString(fCbNormRangeMax, 1) + " GeV",
5575 0.06, 0.15, 0.55, 0.32);
5576 DrawTextOnPad("n_{+} = " + Cbm::NumberToString(nP, 3) + ", n_{-} = " + Cbm::NumberToString(nM, 3), 0.06, 0.1,
5577 0.56, 0.25);
5578 }
5579 }
5580
5581 // Draw MM/PP ratio for same events (steps)
5582 {
5583 for (const string cat : {"", "_trueEl"}) { //, "_urqmdEl", "_urqmdAll"}) {
5584 TCanvas* c = fHMean.fHM.CreateCanvas(folder + "PairYields/Likesign/Ratio_" + cat,
5585 folder + "PairYields/Likesign/Ratio_" + cat, 1800, 1800);
5586 c->Divide(3, 3);
5587 int i = 1;
5588 for (auto step : fHMean.fAnaSteps) {
5589 if (step < ELmvmAnaStep::ElId) continue;
5590 TH1D* pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP" + cat + "_sameEv", step), fBwVarBg3);
5591 TH1D* mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM" + cat + "_sameEv", step), fBwVarBg3);
5592 TH1D* r = (TH1D*) mm->Clone();
5593 r->Divide(pp);
5594 r->GetYaxis()->SetRangeUser(0., 5.);
5595 r->GetYaxis()->SetTitle("Ratio e^{-}e^{-}/e^{+}e^{+}");
5596 c->cd(i++);
5597 DrawH1(r, kLinear, kLinear, "hist");
5598 fHMean.DrawAnaStepOnPad(step);
5599 }
5600 }
5601 }
5602
5603 // Draw Geometric Mean for same and mixed (mixed normalized)
5604 {
5605 for (const string cat : {"", "_trueEl"}) { //, "_urqmdEl", "_urqmdAll"}) {
5606 fHMean.fHM.CreateCanvas(folder + "GeometricMean/GeomMean" + cat, folder + "GeometricMean/GeomMean" + cat, 800,
5607 800);
5608 //TCanvas* c = fHMean.fHM.CreateCanvas(cName + "GeometricMean", cName + "GeometricMean", 1800, 1800);
5609 //c->Divide(3, 3);
5610 //int i = 1;
5611 for (auto step : fHMean.fAnaSteps) {
5612 if (step != ELmvmAnaStep::ElId) continue;
5613 //c->cd(i++);
5614 TH1D* same = VaryBinWidth("mean", fHMean.GetName("hCbGeom" + cat + "_sameEv", step), fBwVarBg);
5615 TH1D* mixed = VaryBinWidth("mean", fHMean.GetName("hCbGeom" + cat + "_mixedEv", step), fBwVarBg);
5616 int minBin = same->FindBin(fCbNormRangeMin);
5617 int maxBin = same->FindBin(fCbNormRangeMax);
5618 double scale = same->Integral(minBin, maxBin) / mixed->Integral(minBin, maxBin);
5619 mixed->Scale(scale);
5620 same->GetYaxis()->SetRangeUser(1e-7, 5e-3);
5621 same->GetXaxis()->SetTitle("M_{ee} [GeV/c^{2}]");
5622 DrawH1({same, mixed}, {"geom. mean (same)", "geom. mean (mixed)"}, kLinear, kLog, true, 0.6, 0.8, 0.99, 0.95,
5623 "hist");
5624 fHMean.DrawAnaStepOnPad(step);
5625 DrawTextOnPad("Factor mixed/same: " + Cbm::NumberToString(1. / scale, 0), 0.12, 0.15, 0.62, 0.35);
5626 }
5627 }
5628 }
5629
5630 // Draw k factor (steps)
5631 {
5632 for (const string cat : {"", "_trueEl"}) { //, "_urqmdEl", "_urqmdAll"}) {
5633 TCanvas* c =
5634 fHMean.fHM.CreateCanvas(folder + "/k-Factor/steps" + cat, folder + "/k-Factor/steps" + cat, 2400, 2400);
5635 c->Divide(3, 3);
5636 int iC = 1;
5637 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
5638 if (step < ELmvmAnaStep::ElId) continue;
5639 TH1D* k = VaryBinWidth("mean", fHMean.GetName("hCbK_raw" + cat, step),
5640 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5641 k->GetYaxis()->SetRangeUser(0.6, 1.4);
5642 k->GetYaxis()->SetTitle("#it{k} Factor");
5643 c->cd(iC++);
5644 DrawH1(k, kLinear, kLinear, "pe");
5645 fHMean.DrawAnaStepOnPad(step);
5646 }
5647 }
5648 }
5649
5650 // Draw k factor (raw) with its components
5651 {
5653 TH1D* k = VaryBinWidth("mean", fHMean.GetName("hCbK_raw", step), fBwVarBg);
5654 TH1D* pm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPM_mixedEv", step), fBwVarBg);
5655 TH1D* pp = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPP_mixedEv", step), fBwVarBg);
5656 TH1D* mm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvMM_mixedEv", step), fBwVarBg);
5657 TH1D* g = VaryBinWidth("mean", fHMean.GetName("hCbGeom_mixedEv", step), fBwVarBg);
5658 TH1D* g2 = (TH1D*) g->Clone();
5659 g2->Scale(2.);
5660 TH1D* k2 = (TH1D*) pm->Clone();
5661 for (int iB = 1; iB <= pm->GetNbinsX(); iB++) {
5662 double con = pm->GetBinContent(iB) / (2 * std::sqrt(pp->GetBinContent(iB) * mm->GetBinContent(iB)));
5663 k2->SetBinContent(iB, con);
5664 }
5665 k->GetYaxis()->SetTitle("#it{k} Factor");
5666 k->GetYaxis()->SetRangeUser(0.6, 1.2);
5667 TCanvas* c = fHMean.fHM.CreateCanvas(folder + "/k-Factor/components", folder + "/k-Factor/components", 2400, 800);
5668 c->Divide(3, 1);
5669 c->cd(1);
5670 DrawH1({pm, pp, mm, g, g2}, {"#LT b^{#pm} #GT", "#LT b^{++} #GT", "#LT b^{--} #GT", "Geom. Mean", "2 * Geom. Mean"},
5671 kLinear, kLog, true, 0.75, 0.65, 0.99, 0.95, "p");
5672 fHMean.DrawAnaStepOnPad(step);
5673 DrawTextOnPad("Mixed Events", 0.12, 0.12, 0.4, 0.25);
5674 c->cd(2);
5675 DrawH1({k, k2}, {"k", "k2"}, kLinear, kLinear, true, 0.8, 0.8, 0.9, 0.9, "hist");
5676 fHMean.DrawAnaStepOnPad(step);
5677 c->cd(3);
5678 TH1D* gmean1 = VaryBinWidth("mean", fHMean.GetName("hCbGeom_mixedEv", step), fBwVarBg);
5679 TH1D* gmean2 = (TH1D*) pm->Clone();
5680 for (int iB = 1; iB <= gmean2->GetNbinsX(); iB++) {
5681 double con = std::sqrt(pp->GetBinContent(iB) * mm->GetBinContent(iB));
5682 gmean2->SetBinContent(iB, con);
5683 }
5684 DrawH1({gmean1, gmean2}, {"standard", "calc. new"}, kLinear, kLog, true, 0.75, 0.65, 0.99, 0.95, "p");
5685 DrawTextOnPad("Geometric Mean (mixed ev.)", 0.2, 0.9, 0.8, 0.99);
5686 }
5687
5688 // Draw k factor: raw and fitted
5689 {
5691 TCanvas* c = fHMean.fHM.CreateCanvas(folder + "/k-Factor/categories", folder + "/k-Factor/categories", 1600, 800);
5692 c->Divide(2, 1);
5693 int iC = 1;
5694 for (const string cat : {"_raw", "_fit"}) {
5695 TH1D* kAll = VaryBinWidth("mean", fHMean.GetName("hCbK" + cat, step), fBwVarBg);
5696 //TH1D* kEl = VaryBinWidth("mean", fHMean.GetName("hCbK" + cat + "_trueEl", step), fBwVarBg);
5697 //TH1D* kUAll = VaryBinWidth("mean", fHMean.GetName("hCbK_urqmdAll" + cat, step), fBwVarBg);
5698 //TH1D* kUEl = VaryBinWidth("mean", fHMean.GetName("hCbK_urqmdEl" + cat, step), fBwVarBg);
5699 kAll->GetYaxis()->SetTitle("#it{k} Factor");
5700 kAll->GetYaxis()->SetRangeUser(0.6, 1.2);
5701 c->cd(iC++);
5702 //DrawH1({kAll, kEl, kUAll, kUEl}, {"PLUTO + UrQMD", "PLUTO + UrQMD (el)", "UrQMD", "UrQMD (el)"}, kLinear, kLinear, true, 0.65, 0.8, 0.99, 0.95, "p");
5703 //DrawH1({kAll, kEl}, {"PLUTO + UrQMD", "PLUTO + UrQMD (el)"}, kLinear, kLinear, true, 0.65, 0.8, 0.99, 0.95, "p");
5704 DrawH1(kAll, kLinear, kLinear, "h");
5705 fHMean.DrawAnaStepOnPad(step);
5706 }
5707 }
5708
5709 // Draw k factor in dependance on various quantities
5710 {
5711 // Px, Py
5712 for (const string cat : {"", "_mother"}) {
5713 TH2D* pxPM = fHMean.H2Clone("hMinvCombPM_px" + cat);
5714 TH2D* pxPP = fHMean.H2Clone("hMinvCombPP_px" + cat);
5715 TH2D* pxMM = fHMean.H2Clone("hMinvCombMM_px" + cat);
5716 TH2D* pyPM = fHMean.H2Clone("hMinvCombPM_py" + cat);
5717 TH2D* pyPP = fHMean.H2Clone("hMinvCombPP_py" + cat);
5718 TH2D* pyMM = fHMean.H2Clone("hMinvCombMM_py" + cat);
5719 TH2D* kPx = (TH2D*) pxPM->Clone();
5720 TH2D* kPy = (TH2D*) pyPM->Clone();
5721 for (int iX = 1; iX <= pxPM->GetXaxis()->GetNbins(); iX++) {
5722 for (int iY = 1; iY <= pxPM->GetYaxis()->GetNbins(); iY++) {
5723 double kx =
5724 pxPM->GetBinContent(iX, iY) / (2 * std::sqrt(pxPP->GetBinContent(iX, iY) * pxMM->GetBinContent(iX, iY)));
5725 double ky =
5726 pyPM->GetBinContent(iX, iY) / (2 * std::sqrt(pyPP->GetBinContent(iX, iY) * pyMM->GetBinContent(iX, iY)));
5727 kPx->SetBinContent(iX, iY, kx);
5728 kPy->SetBinContent(iX, iY, ky);
5729 }
5730 }
5731 kPx->GetZaxis()->SetRangeUser(0., 2.);
5732 kPy->GetZaxis()->SetRangeUser(0., 2.);
5733 kPx->GetXaxis()->SetTitle("P_{X_{1}} [GeV/c]");
5734 kPx->GetYaxis()->SetTitle("P_{X_{2}} [GeV/c]");
5735 kPy->GetXaxis()->SetTitle("P_{Y_{1}} [GeV/c]");
5736 kPy->GetYaxis()->SetTitle("P_{Y_{2}} [GeV/c]");
5737 kPx->GetZaxis()->SetTitle("#it{k} Factor");
5738 kPy->GetZaxis()->SetTitle("#it{k} Factor");
5739 TCanvas* cP =
5740 fHMean.fHM.CreateCanvas(folder + "k-Factor/dep_Pt" + cat, folder + "k-Factor/dep_Pt" + cat, 1600, 800);
5741 cP->Divide(2, 1);
5742 cP->cd(1);
5743 DrawH2(kPx, kLinear, kLinear, kLinear, "colz");
5744 cP->cd(2);
5745 DrawH2(kPy, kLinear, kLinear, kLinear, "colz");
5746
5747 // Vertex in X-Y plane
5748 TH2D* RPM = fHMean.H2Clone("hMinvCombPM_R" + cat);
5749 TH2D* RPP = fHMean.H2Clone("hMinvCombPP_R" + cat);
5750 TH2D* RMM = fHMean.H2Clone("hMinvCombMM_R" + cat);
5751 TH2D* kR = (TH2D*) RPM->Clone();
5752 for (int iX = 1; iX <= RPM->GetXaxis()->GetNbins(); iX++) {
5753 for (int iY = 1; iY <= RPM->GetYaxis()->GetNbins(); iY++) {
5754 double k =
5755 RPM->GetBinContent(iX, iY) / (2 * std::sqrt(RPP->GetBinContent(iX, iY) * RMM->GetBinContent(iX, iY)));
5756 kR->SetBinContent(iX, iY, k);
5757 }
5758 }
5759 kR->GetZaxis()->SetRangeUser(0., 2.);
5760 kR->GetZaxis()->SetTitle("#it{k} Factor");
5761 fHMean.fHM.CreateCanvas(folder + "k-Factor/dep_Vertex" + cat, folder + "k-Factor/dep_Vertex" + cat, 800, 800);
5762 DrawH2(kR, kLinear, kLinear, kLinear, "colz");
5763 }
5764
5765 // Angle and Minv
5766 TH2D* aPM = fHMean.H2Clone("hMinvCombPM_theta-minv");
5767 TH2D* aPP = fHMean.H2Clone("hMinvCombPP_theta-minv");
5768 TH2D* aMM = fHMean.H2Clone("hMinvCombMM_theta-minv");
5769 TH2D* kAngle = (TH2D*) aPM->Clone();
5770 for (int iA = 1; iA <= aPM->GetXaxis()->GetNbins(); iA++) {
5771 for (int iM = 1; iM <= aPM->GetYaxis()->GetNbins(); iM++) {
5772 double den = (2 * std::sqrt(aPP->GetBinContent(iA, iM) * aMM->GetBinContent(iA, iM)));
5773 double k = (den == 0) ? 0 : aPM->GetBinContent(iA, iM) / den;
5774 kAngle->SetBinContent(iA, iM, k);
5775 }
5776 }
5777 kAngle->GetZaxis()->SetRangeUser(0., 2.);
5778 kAngle->GetZaxis()->SetTitle("#it{k} Factor");
5779 fHMean.fHM.CreateCanvas(folder + "k-Factor/dep_theta-minv", folder + "k-Factor/dep_theta-minv", 800, 800);
5780 DrawH2(kAngle, kLinear, kLinear, kLinear, "colz");
5781 kAngle->SetMarkerSize(2.);
5782 }
5783
5784 // Background: Vs. MC-BG
5785 {
5786 for (const string cat : {"", "_trueEl", "_urqmdAll", "_urqmdEl"}) {
5787 TCanvas* c =
5788 fHMean.fHM.CreateCanvas(folder + "Background/VsMcBg" + cat, folder + "Background/VsMcBg" + cat, 1600, 2400);
5789 c->Divide(2, 3);
5790 int iC = 1;
5791 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
5792 string stepname = fHMean.fAnaStepNames[static_cast<int>(step)];
5793 TH1D* cbc = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
5794 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarSig);
5795 TH1D* mcb = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat + "_bg", step), fNofSimEvents, fBwVarSig);
5796 cbc->GetYaxis()->SetRangeUser(1e-7, 2e-2);
5797 TH1D* r = (TH1D*) cbc->Clone();
5798 r->Divide(mcb);
5799 r->GetYaxis()->SetRangeUser(0.5, 1.4);
5800 r->GetYaxis()->SetTitle("Ratio");
5801 c->cd(iC++);
5802 DrawH1({cbc, mcb}, {"CB_{calc}", "B_{MC}"}, kLinear, kLog, true, 0.65, 0.75, 0.95, 0.9, "p");
5803 fHMean.DrawAnaStepOnPad(step);
5804 c->cd(2);
5805 DrawH1({r}, {"CB_{calc} / B_{MC}"}, kLinear, kLinear, true, 0.75, 0.87, 0.95, 0.95, "p");
5806 fHMean.DrawAnaStepOnPad(step);
5807 }
5808 }
5809 }
5810
5811 // CB for various categories
5812 {
5814 TH1D* pu = VaryBinWidth("mean", fHMean.GetName("hCbBg", step),
5815 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5816 TH1D* puEl = VaryBinWidth("mean", fHMean.GetName("hCbBg_trueEl", step),
5817 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5818 TH1D* u = VaryBinWidth("mean", fHMean.GetName("hCbBg_urqmdAll", step),
5819 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5820 TH1D* uEl = VaryBinWidth("mean", fHMean.GetName("hCbBg_urqmdEl", step),
5821 fNofEvMixEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5822 pu->GetYaxis()->SetRangeUser(1e-7, 1e-2);
5823 fHMean.fHM.CreateCanvas(folder + "Background/CbTypes", folder + "Background/CbTypes", 800, 800);
5824 DrawH1({pu, puEl, u, uEl}, {"PLUTO + UrQMD", "PLUTO + UrQMD (electrons)", "UrQMD", "UrQMD (electrons)"}, kLinear,
5825 kLog, true, 0.55, 0.78, 0.99, 0.95, "pe");
5826 fHMean.DrawAnaStepOnPad(step);
5827 DrawTextOnPad("fCbChange = " + Cbm::NumberToString(fCbChange, 0), 0.14, 0.24, 0.33, 0.28);
5828 DrawTextOnPad("fCbNormRangeMin = " + Cbm::NumberToString(fCbNormRangeMin, 0), 0.12, 0.20, 0.38, 0.24);
5829 DrawTextOnPad("fCbNormRangeMax = " + Cbm::NumberToString(fCbNormRangeMax, 0), 0.11, 0.16, 0.39, 0.20);
5830 }
5831
5832 //Draw Combinatorial Signal with N+-same, CB, Cocktail
5833 {
5834 for (const string type : {"Mc", "Npm"}) {
5835 for (const string cat : {""}) { //, "_trueEl", "_urqmdEl", "_urqmdAll"}) {
5836 //TCanvas* c = fHMean.fHM.CreateCanvas(folder + "Signal/VsInput_" + type + cat, folder + "Signal/VsInput_" + type + cat, 1800, 1800);
5837 //c->Divide(3, 3);
5838 //int i = 1;
5839 fHMean.fHM.CreateCanvas(folder + "Signal/VsInput" + type + cat, folder + "Signal/VsInput_" + type + cat, 800,
5840 800);
5841 for (auto step : fHMean.fAnaSteps) {
5842 if (step != ELmvmAnaStep::ElId) continue;
5843 //c->cd(i++);
5844 TH1D* sig = VaryBinWidth("mean", fHMean.GetName("hCbSig" + type + cat, step), fBwVarSig);
5845 TH1D* coc =
5846 VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", fNofFastSimEvents, fBwVarSig);
5847 TH1D* npm =
5848 VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPM" + cat + "_sameEv", step), fNofSimEvents, fBwVarSig);
5849 for (int iB = 1; iB <= sig->GetNbinsX(); iB++) {
5850 double bW = sig->GetBinWidth(iB);
5851 double N = npm->GetBinContent(iB) * fNofSimEvents * bW;
5852 double err = std::sqrt(N) / (bW * fNofSimEvents);
5853 sig->SetBinError(iB, err);
5854 }
5855 sig->GetYaxis()->SetRangeUser(1e-10, 5e-2);
5856 //string sigLabel = (type == "Npm") ? "Signal = N_{same}^{+-} + Cocktail - CB_{calc}" : "Signal = B_{MC} + Cocktail - CB_{calc}";
5857 string sigLabel = "Signal";
5858 //DrawH1({sig, coc}, {sigLabel, "MC Cocktail"}, kLinear, kLog, true, 0.47, 0.77, 0.91, 0.9, "pe");
5859 DrawH1({sig, coc}, {sigLabel, "MC Cocktail"}, kLinear, kLog, true, 0.65, 0.78, 0.91, 0.91, "pe");
5860 //fHMean.DrawAnaStepOnPad(step);
5861 }
5862 }
5863 }
5864 }
5865
5866 // Compare N+-, BG+Coc, BG and CB after ElID step
5867 {
5869
5870 for (const string cat : {"", "_trueEl"}) {
5871 TH1D* npm = VaryBinWidth("evmix", fHMean.GetName("hmx_MinvPM" + cat + "_sameEv", step), fNofSimEvents, fBwVarBg);
5872 TH1D* cb = VaryBinWidth("mean", fHMean.GetName("hCbBg" + cat, step),
5873 fNofSimEvents * std::sqrt(fCbNormFactor[static_cast<int>(step)]), fBwVarBg);
5874 TH1D* bg = VaryBinWidth("mean", fHMean.GetName("hMinv" + cat, ELmvmSrc::Bg, step), fNofSimEvents, fBwVarBg);
5875 TH1D* coc = VaryBinWidth("cocktail" + cat + "_" + fHMean.fAnaStepNames[static_cast<int>(step)], "",
5877 TH1D* sbg = (TH1D*) bg->Clone();
5878 sbg->Add(coc);
5879
5880 TH1D* ratS = (TH1D*) npm->Clone();
5881 TH1D* ratB = (TH1D*) cb->Clone();
5882 ratS->Divide(sbg);
5883 ratB->Divide(bg);
5884
5885 TCanvas* c =
5886 fHMean.fHM.CreateCanvas(folder + "Signal/N+-VsBgCoc" + cat, folder + "Signal/N+-VsBgCoc" + cat, 1800, 900);
5887 c->Divide(2, 1);
5888 c->cd(1);
5889 npm->GetYaxis()->SetRangeUser(1e-9, 2e-2);
5890 DrawH1({npm, sbg, cb, bg}, {"N^{+-}_{same}", "B_{MC} + Cocktail", "CB_{calc}", "B_{MC}"}, kLinear, kLog, true,
5891 0.7, 0.7, 0.99, 0.95, "p");
5892 fHMean.DrawAnaStepOnPad(step);
5893 c->cd(2);
5894 ratS->GetYaxis()->SetTitle("Ratio");
5895 ratS->GetYaxis()->SetRangeUser(0., 2.);
5896 ratB->GetYaxis()->SetRangeUser(0., 2.);
5897 DrawH1({ratS, ratB}, {"N^{+-}_{same} / B_{MC}+Coc", "CB_{calc} / B_{MC}"}, kLinear, kLinear, true, 0.7, 0.8, 0.99,
5898 0.95, "p");
5899 fHMean.DrawAnaStepOnPad(step);
5900 }
5901 }
5902}
5903
5905{
5906 vector<TH1*> hists;
5907 vector<pair<double, double>> varbin = fBwVarSig;
5909 TH1D* bg = VaryBinWidth("mean", fHMean.GetName("hMinv", ELmvmSrc::Bg, step), varbin);
5910 TH1D* cbg = VaryBinWidth("cocktail_" + fHMean.fAnaStepNames[static_cast<int>(step)], "", varbin);
5911 cbg->Divide(bg);
5912 cbg->GetYaxis()->SetTitle("Cocktail/Background");
5913 cbg->GetYaxis()->SetRangeUser(9e-4, 11);
5914 hists.push_back(cbg);
5915 }
5916
5917 fHMean.fHM.CreateCanvas("SignalToBg/SignalToBg", "SignalToBg/SignalToBg", 1000, 1000);
5918 DrawH1(hists, {"El-ID", "TT cut", "P_{t} cut"}, kLinear, kLog, true, 0.62, 0.7, 0.92, 0.92, "hist");
5919 //DrawH1(hists, {"El-ID"}, kLinear, kLog, true, 0.7, 0.82, 0.92, 0.92, "hist");
5920}
5921
5923{
5924 // Load and scale histograms from LmvmFastSim and make them globally available.
5925 // Histograms from LmvmTask have to be scaled with 'fNofSimEvents' and number of jobs of LmvmFastSim procedure.
5926 // Histograms that are created and filled in LmvmFastSim procedure have to be scaled with fNofFastSimEvents.
5927 TFile* fastsimfile = new TFile((fDataDir + "/Background/FastSim/fastsim.all.root").c_str());
5928 fHFastSim.fHM.ReadFromFile(fastsimfile);
5929 fNofFastSimEvents = fHFastSim.H1("hfs_EventNumber")->GetEntries();
5930 LOG(info) << "Nof FastSim Events = " << fNofFastSimEvents;
5931 fNofFastSimJobs = fHFastSim.H1("hfs_nofJobs")->GetEntries();
5932 for (ELmvmSignal signal : fHMean.fSignals) {
5933 int nofEventsSig = (int) fH[static_cast<int>(signal)]->H1("hEventNumber")->GetEntries();
5934 string sigName = fHMean.fSignalNames[static_cast<int>(signal)];
5935 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp)_mult_pluto_" + sigName + "_.*", 1. / (nofEventsSig * fNofFastSimJobs));
5936 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp)_multCorr_pluto_" + sigName + "_.*",
5937 1. / (nofEventsSig * fNofFastSimJobs));
5938 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp)_mom_pluto_" + sigName + ".*", 1. / (nofEventsSig * fNofFastSimJobs));
5939 }
5940 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp)_mult_urqmd_.*", 1. / (fNofSimEvents * fNofFastSimJobs));
5941 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp)_mom_urqmd_.*", 1. / (fNofSimEvents * fNofFastSimJobs));
5942 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp).*Rndm_urqmd_.*", 1. / fNofFastSimEvents);
5943 double scaleFS = 1.0;
5944 if (!IsCloseTo(scaleFS, 1.0, 1e-3))
5945 LOG(warn) << "Mind: Histos '(hfsc|hfsp).*_Minv.*' are scaled with factor " << scaleFS << "!";
5946 fHFastSim.fHM.ScaleByPattern("(hfsc|hfsp).*_Minv.*", scaleFS / fNofFastSimEvents);
5947 for (const string cat : {"", "_trueEl", "_urqmdAll", "_urqmdEl"}) {
5948 for (ELmvmAnaStep step : fHMean.fAnaStepsFS) {
5949 fHMean.CreateHByClone(fHFastSim.H1Clone("hfsc_MinvBg" + cat, step),
5950 "hfsc_MinvBg" + cat + "_" + fHMean.fAnaStepNames[static_cast<int>(step)]);
5951 if (cat == "" || cat == "_trueEl")
5952 fHMean.CreateHByClone(fHFastSim.H1Clone("hfsp_MinvBg" + cat, step),
5953 "hfsp_MinvBg" + cat + "_" + fHMean.fAnaStepNames[static_cast<int>(step)]);
5954 }
5955 }
5956 vector<TH1*> hnamesC = fHFastSim.fHM.H1Vector("hfsc_.*");
5957 vector<TH1*> hnamesP = fHFastSim.fHM.H1Vector("hfsp_.*");
5958 if (hnamesC.size() >= 1)
5959 fDoChargeBased = true;
5960 else
5961 LOG(error) << "Fast Simulation: No charge-based histograms."; // Charge-based is standard and should exist
5962 if (hnamesP.size() >= 1)
5963 fDoParticleBased = true;
5964 else
5965 LOG(info) << "Fast Simulation: No particle-based histograms."; // Optional
5966 LOG(info) << "hnamesC.size() = " << hnamesC.size()
5967 << " ->fDoChargeBased = " << fDoChargeBased; // TODO: delete this line!
5968 LOG(info) << "hnamesP.size() = " << hnamesP.size()
5969 << " ->fDoParticleBased = " << fDoParticleBased; // TODO: delete this line!
5970}
5971
5973{
5974 fCbNormFactor.resize(fHMean.fNofAnaSteps);
5975 string hName = "hmx_Minv";
5976 string cbName = "hCb";
5977
5978 TFile* file = new TFile((fDataDir + "Background/EventMix/eventmix.all.root").c_str());
5979 fHEvMix.fHM.ReadFromFile(file);
5980 fNofEvMixEvents = fHEvMix.H1("hmx_EventNumber")->GetEntries();
5981 fNofEvMixJobs = fHEvMix.H1("hmx_nofJobs")->GetEntries();
5982 fEvMixDepth = 1000 * fHEvMix.H1("hmx_NofFilesToMix")->GetEntries() / fNofEvMixJobs; // usually 1000 events per file
5983 LOG(info) << "fNofEvMixEvents: " << fNofEvMixEvents;
5984 LOG(info) << "fNofEvMixJobs: " << fNofEvMixJobs;
5985 LOG(info) << "fEvMixDepth: " << fEvMixDepth << " events.";
5986 fHEvMix.fHM.ScaleByPattern("hmx_Minv.*", 1. / fNofEvMixEvents);
5987 double diff = fNofEvMixEvents / fNofSimEvents;
5988 if (diff <= 0.995 || diff >= 1.005)
5989 LOG(warn) << "Number of LmvmEventMix Events differs significantly from number of simulated events!";
5990 // Check that minv histos from LmvmEventMix have same properties as minv histos from LmvmTask
5991 TH1D* h1 = fHMean.H1Clone("hMinv", ELmvmSrc::Bg, ELmvmAnaStep::ElId);
5992 TH1D* h2 = fHEvMix.H1Clone("hmx_MinvPM_sameEv", ELmvmAnaStep::ElId);
5993 if ((h1->GetNbinsX() != h2->GetNbinsX()) || (h1->GetXaxis()->GetBinLowEdge(1) != h2->GetXaxis()->GetBinLowEdge(1))
5994 || (h1->GetXaxis()->GetBinUpEdge(h1->GetNbinsX()) != (h2->GetXaxis()->GetBinUpEdge(h2->GetNbinsX()))))
5995 LOG(error) << "LmvmDrawAll::CalculateCombBGHistos: Minv histograms from LmvmTask and LmvmEventMix do not agree!";
5996
5997 // Calculate
5998 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
5999 if (step < ELmvmAnaStep::ElId) continue;
6000 for (const string cat : {"", "_trueEl", "_urqmdAll", "_urqmdEl"}) {
6001 TH1D* pmSame = fHEvMix.H1Clone(hName + "PM" + cat + "_sameEv", step);
6002 TH1D* ppSame = fHEvMix.H1Clone(hName + "PP" + cat + "_sameEv", step);
6003 TH1D* mmSame = fHEvMix.H1Clone(hName + "MM" + cat + "_sameEv", step);
6004 TH1D* pmMixed = fHEvMix.H1Clone(hName + "PM" + cat + "_mixedEv", step);
6005 TH1D* ppMixed = fHEvMix.H1Clone(hName + "PP" + cat + "_mixedEv", step);
6006 TH1D* mmMixed = fHEvMix.H1Clone(hName + "MM" + cat + "_mixedEv", step);
6007
6008 // Geometric mean
6009 TH1D* hGeomSame = fHMean.CreateHByClone(fHEvMix.H1Clone(fHMean.GetName(hName + "MM" + cat + "_sameEv", step)),
6010 fHMean.GetName(cbName + "Geom" + cat + "_sameEv", step));
6011 TH1D* hGeomMixed = fHMean.CreateHByClone(fHEvMix.H1Clone(fHMean.GetName(hName + "MM" + cat + "_sameEv", step)),
6012 fHMean.GetName(cbName + "Geom" + cat + "_mixedEv", step));
6013
6014 for (int iB = 1; iB <= hGeomSame->GetNbinsX(); iB++) {
6015 double cppSame = ppSame->GetBinContent(iB);
6016 double cmmSame = mmSame->GetBinContent(iB);
6017 double cSame = std::sqrt(cppSame * cmmSame);
6018 hGeomSame->SetBinContent(iB, cSame);
6019 double cppMix = ppMixed->GetBinContent(iB);
6020 double cmmMix = mmMixed->GetBinContent(iB);
6021 double cMix = std::sqrt(cppMix * cmmMix);
6022 hGeomMixed->SetBinContent(iB, cMix);
6023 }
6024
6025 // k factor ("raw", "fit" and "one")
6026 //"raw"
6027 TH1D* hKRaw = (TH1D*) pmMixed->Clone();
6028 hKRaw->Divide(hGeomMixed);
6029 hKRaw->Scale(0.5);
6030 fHMean.fHM.Add(fHMean.GetName(cbName + "K_raw" + cat, step), hKRaw);
6031
6032 // "fit": Fitting k factor with a constant at higher inv. masses
6033 TH1D* hKFit = (TH1D*) hKRaw->Clone();
6034 double kFitMin = 1.0;
6035 int changeBinK = hKFit->FindBin(kFitMin);
6036 hKFit->Fit("pol0", "Q", "", kFitMin, hKFit->GetMaximum());
6037 TF1* func = hKFit->GetFunction("pol0");
6038 double mean = (func != nullptr) ? func->GetParameter(0) : 0;
6039 for (int iB = changeBinK; iB <= hKFit->GetNbinsX(); iB++) {
6040 hKFit->SetBinContent(iB, mean);
6041 }
6042 fHMean.fHM.Add(fHMean.GetName(cbName + "K_fit" + cat, step), hKRaw);
6043
6044 // "one": Set k factor to value 1 from certain minv on
6045 TH1D* hKOne = (TH1D*) hKRaw->Clone();
6046 double kOneStart = 0.7;
6047 int binOneStart = hKRaw->FindBin(kOneStart);
6048 for (int iB = binOneStart; iB <= hKRaw->GetNbinsX(); iB++) {
6049 hKOne->SetBinContent(iB, 1.);
6050 }
6051 fHMean.fHM.Add(fHMean.GetName(cbName + "K_one" + cat, step), hKRaw);
6052
6053 // Set hKRaw, hKFit or hKOne as standard for k here:
6054 TH1D* hK = (TH1D*) hKRaw->Clone(); // Will be used as standard for k factor; decide: hKRaw, hKFit or hKOne!
6055 fHMean.fHM.Add(fHMean.GetName(cbName + "K" + cat, step), hK);
6056
6057 // Calculate combinatorial BG from same (m < fCbChange) and mixed (m >= fCbChange) events data
6058 // At first, calculate normalisation factor between same and mixed events in given range
6059 fCbChange = 0.4;
6060 fCbNormRangeMin = 0.4;
6061 fCbNormRangeMax = 0.7;
6062 int ChangeBin = pmSame->FindBin(fCbChange);
6063 int NormRangeMinBin = pmSame->FindBin(fCbNormRangeMin);
6064 int NormRangeMaxBin = pmSame->FindBin(fCbNormRangeMax);
6065 double normPPInt =
6066 ppSame->Integral(NormRangeMinBin, NormRangeMaxBin) / ppMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
6067 double normMMInt =
6068 mmSame->Integral(NormRangeMinBin, NormRangeMaxBin) / mmMixed->Integral(NormRangeMinBin, NormRangeMaxBin);
6069
6070 fCbNormFactor[static_cast<int>(step)] = 1. / ((normPPInt + normMMInt) / 2.);
6071
6072 // Combinatorial BG
6073 TH1D* hBc = fHMean.CreateHByClone(fHEvMix.H1Clone(fHMean.GetName(hName + "MM" + cat + "_sameEv", step)),
6074 fHMean.GetName(cbName + "Bg" + cat, step));
6075 for (int iB = 1; iB <= hBc->GetNbinsX(); iB++) {
6076 double k = hK->GetBinContent(iB);
6077 double geomMeanMixNormed = hGeomMixed->GetBinContent(iB) * std::sqrt(normPPInt * normMMInt);
6078 double cb = (iB < ChangeBin) ? 2. * k * hGeomSame->GetBinContent(iB) : 2. * k * geomMeanMixNormed;
6079 hBc->SetBinContent(iB, cb);
6080 }
6081
6082 // Combinatorial BG without mixed event data (except k)
6083 TH1D* hBcSame = fHMean.CreateHByClone<TH1D>(cbName + "Geom" + cat + "_sameEv", cbName + "BgSame" + cat, step);
6084 hBcSame->Multiply(hK);
6085 hBcSame->Scale(2.);
6086
6087 // Calculate signal from CB subtraction
6088 // Signal = N+-_{same} - CB_{calc}
6089 TH1D* hSigNpm = fHEvMix.H1Clone(hName + "PM" + cat + "_sameEv", step);
6090 fHMean.fHM.Add(fHMean.GetName(cbName + "SigNpm" + cat, step), hSigNpm);
6091 hSigNpm->Add(fHMean.H1(cbName + "Bg" + cat, step), -1.);
6092
6093 // Signal = Coc+BG - CB_{calc}
6094 TH1D* hSigCoc = fHMean.H1Clone("hMinv" + cat + "_bg", step);
6095 fHMean.fHM.Add(fHMean.GetName(cbName + "SigMc" + cat, step), hSigCoc);
6096 hSigCoc->Add(GetCocktailMinvH1("hMinv" + cat, step, false));
6097 hSigCoc->Add(fHMean.H1(cbName + "Bg" + cat, step), -1.);
6098
6099 // Calculate errors via error propagation formula for histograms with various bin widths and add to fHM
6100 for (auto bwv : fBwVarAll) {
6101 // Get basic histograms for number of entries (to estimate error)
6102 TH1D* h_s_pm = VaryBinWidth("evmix", fHMean.GetName(hName + "PM" + cat + "_sameEv", step), bwv);
6103 TH1D* h_s_pp = VaryBinWidth("evmix", fHMean.GetName(hName + "PP" + cat + "_sameEv", step), bwv);
6104 TH1D* h_s_mm = VaryBinWidth("evmix", fHMean.GetName(hName + "MM" + cat + "_sameEv", step), bwv);
6105 TH1D* h_m_pm = VaryBinWidth("evmix", fHMean.GetName(hName + "PM" + cat + "_mixedEv", step), bwv);
6106 TH1D* h_m_pp = VaryBinWidth("evmix", fHMean.GetName(hName + "PP" + cat + "_mixedEv", step), bwv);
6107 TH1D* h_m_mm = VaryBinWidth("evmix", fHMean.GetName(hName + "MM" + cat + "_mixedEv", step), bwv);
6108
6109 string tag = "";
6110 if (bwv == fBwVarOrig)
6111 tag = fBwVarAllTags[0];
6112 else if (bwv == fBwVarReg)
6113 tag = fBwVarAllTags[1];
6114 else if (bwv == fBwVarBg)
6115 tag = fBwVarAllTags[2];
6116 else if (bwv == fBwVarSig)
6117 tag = fBwVarAllTags[3];
6118 else if (bwv == fBwVarSig2)
6119 tag = fBwVarAllTags[4];
6120 else if (bwv == fBwVarSig3)
6121 tag = fBwVarAllTags[5];
6122 else
6123 LOG(error) << "LmvmDrawAll::CalculateCombBGHistos: Check bwVar-tag assignment!";
6124 TH1D* bg = VaryBinWidth("mean", cbName + "Bg" + cat, step, bwv);
6125 TH1D* sigMc = VaryBinWidth("mean", cbName + "SigMc" + cat, step, bwv);
6126 TH1D* sigNpm = VaryBinWidth("mean", cbName + "SigNpm" + cat, step, bwv);
6127
6128 TH1D* approxerror =
6129 (TH1D*) bg->Clone(); // to compare exact calulcated error with approximated // TODO: delete this block
6130 TH1D* trueerror = (TH1D*) bg->Clone();
6131 approxerror->Reset();
6132 trueerror->Reset();
6133
6134 int nofBins = h_s_pm->GetNbinsX();
6135 double bW2 = h_s_pm->GetBinWidth(1);
6136 for (int iB = 1; iB <= nofBins; iB++) {
6137 double N_s_pm = h_s_pm->GetBinContent(iB) * fNofEvMixEvents * bW2;
6138 double N_s_pp = h_s_pp->GetBinContent(iB) * fNofEvMixEvents * bW2;
6139 double N_s_mm = h_s_mm->GetBinContent(iB) * fNofEvMixEvents * bW2;
6140 double N_m_pm = h_m_pm->GetBinContent(iB) * fNofEvMixEvents * fEvMixDepth * bW2;
6141 double N_m_pp = h_m_pp->GetBinContent(iB) * fNofEvMixEvents * fEvMixDepth * bW2;
6142 double N_m_mm = h_m_mm->GetBinContent(iB) * fNofEvMixEvents * fEvMixDepth * bW2;
6143
6144 // derivatives of CB_{calc} w.r. to according value
6145 double d_m_pm = std::sqrt(N_s_pp * N_s_mm / (N_m_pp * N_m_mm));
6146 double d_m_pp =
6147 -0.5 * N_m_pm * std::pow(N_m_mm, -1. / 2.) * std::pow(N_m_pp, -3. / 2.) * std::sqrt(N_s_pp * N_s_mm);
6148 double d_m_mm =
6149 -0.5 * N_m_pm * std::pow(N_m_mm, -3. / 2.) * std::pow(N_m_pp, -1. / 2.) * std::sqrt(N_s_pp * N_s_mm);
6150 double d_s_pp = 0.5 * N_m_pm * std::sqrt(N_s_mm) * std::pow(N_m_pp * N_m_mm * N_s_pp, -1. / 2.);
6151 double d_s_mm = 0.5 * N_m_pm * std::sqrt(N_s_pp) * std::pow(N_m_pp * N_m_mm * N_s_mm, -1. / 2.);
6152
6153 // contributions to error propagation
6154 double f_m_pm = std::pow(d_m_pm * std::sqrt(N_m_pm), 2);
6155 double f_m_pp = std::pow(d_m_pp * std::sqrt(N_m_pp), 2);
6156 double f_m_mm = std::pow(d_m_mm * std::sqrt(N_m_mm), 2);
6157 double f_s_pp = std::pow(d_s_pp * std::sqrt(N_s_pp), 2);
6158 double f_s_mm = std::pow(d_s_mm * std::sqrt(N_s_mm), 2);
6159
6160 // final error propagation values
6161 double errorBc = std::sqrt(f_m_pm + f_m_pp + f_m_mm + f_s_pp + f_s_mm) / (bW2 * fNofEvMixEvents);
6162 double errorBc2 =
6163 std::sqrt(normPPInt * normMMInt) * std::sqrt(N_m_pm) / (bW2 * fNofEvMixEvents * fEvMixDepth);
6164 double errorSig = std::sqrt(N_s_pm + std::pow(errorBc, 2)) / (bW2 * fNofEvMixEvents);
6165 double errorSig2 = std::sqrt(N_s_pm / std::pow(bW2 * fNofEvMixEvents, 2)
6166 + std::pow(errorBc2 / (bW2 * fNofEvMixEvents * fEvMixDepth), 2));
6167
6168 if (iB < ChangeBin) bg->SetBinError(iB, errorBc);
6169 if (iB >= ChangeBin) bg->SetBinError(iB, errorBc2);
6170 if (iB < ChangeBin) sigMc->SetBinError(iB, errorSig);
6171 if (iB >= ChangeBin) sigMc->SetBinError(iB, errorSig2);
6172 if (iB < ChangeBin) sigNpm->SetBinError(iB, errorSig);
6173 if (iB >= ChangeBin) sigNpm->SetBinError(iB, errorSig2);
6174
6175 // Compare exact error with approximated // TODO: delete
6176 double errappr = std::sqrt(N_s_mm + N_s_pp) / (bW2 * fNofEvMixEvents);
6177 double errappr2 =
6178 std::sqrt(N_m_pp + N_m_mm) / (bW2 * fNofEvMixEvents * fEvMixDepth * fCbNormFactor[static_cast<int>(step)]);
6179 if (iB < ChangeBin) {
6180 trueerror->SetBinContent(iB, errorBc);
6181 approxerror->SetBinContent(iB, errappr);
6182 }
6183 if (iB >= ChangeBin) {
6184 trueerror->SetBinContent(iB, errorBc2);
6185 approxerror->SetBinContent(iB, errappr2);
6186 }
6187 } // iB
6188 fHMean.CreateHByClone(bg, fHMean.GetName(cbName + "Bg" + cat + "_" + tag, step));
6189 fHMean.CreateHByClone(sigMc, fHMean.GetName(cbName + "SigMc" + cat + "_" + tag, step));
6190 fHMean.CreateHByClone(sigNpm, fHMean.GetName(cbName + "SigNpm" + cat + "_" + tag, step));
6191 if (step == ELmvmAnaStep::ElId && cat == "" && bwv == fBwVarOrig) {
6192 fHMean.fHM.CreateCanvas("CombinatorialBackground/Error", "CombinatorialBackground/Error", 800, 800);
6193 DrawH1({trueerror, approxerror}, {"exact error", "approx. error"}, kLinear, kLog, true, 0.65, 0.75, 0.89,
6194 0.88, "hist");
6195 }
6196 } // ..bwVar
6197 } // ..cat
6198 } // ..steps
6199 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
6200 double f = fCbNormFactor[static_cast<int>(step)];
6201 LOG(info) << "fCbNormFactor[" << fHMean.fAnaStepNames[static_cast<int>(step)] << "]: " << f;
6202 }
6203 cout << endl;
6204}
6205
6206void LmvmDrawAll::CalcCutEffRange(double minMinv, double maxMinv)
6207{
6208 stringstream ss1;
6209 ss1 << "hCutEff_" << minMinv << "to" << maxMinv;
6210 fHMean.CreateH1(ss1.str() + "_bg", "Analysis step", "Efficiency [%]", fHMean.fNofAnaSteps, 0, fHMean.fNofAnaSteps);
6211 fHMean.CreateH1(ss1.str() + "_s", "Analysis step", "Efficiency [%]", fHMean.fNofAnaSteps, 0, fHMean.fNofAnaSteps);
6212 TH1D* hS = fHMean.H1(ss1.str() + "_s");
6213 TH1D* hBg = fHMean.H1(ss1.str() + "_bg");
6214 int x = 1;
6215 TH1D* cocktail = GetCocktailMinvH1("hMinv", ELmvmAnaStep::ElId, false);
6216 int binMin = cocktail->FindBin(minMinv);
6217 int binMax = cocktail->FindBin(maxMinv);
6218 double sIntElId = cocktail->Integral(binMin, binMax);
6219 double bgIntElId = fHMean.H1("hMinv", ELmvmSrc::Bg, ELmvmAnaStep::ElId)->Integral(binMin, binMax);
6220 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
6221 if (step < ELmvmAnaStep::ElId) continue;
6222 if (!fUseMvd && (step == ELmvmAnaStep::Mvd1Cut || step == ELmvmAnaStep::Mvd2Cut)) continue;
6223
6224 double effS = 100. * GetCocktailMinvH1("hMinv", step, false)->Integral(binMin, binMax) / sIntElId;
6225 double effB = 100. * fHMean.H1("hMinv", ELmvmSrc::Bg, step)->Integral(binMin, binMax) / bgIntElId;
6226
6227 hBg->GetXaxis()->SetBinLabel(x, fHMean.fAnaStepLatex[static_cast<int>(step)].c_str());
6228 hBg->SetBinContent(x, effB);
6229 hS->SetBinContent(x, effS);
6230 x++;
6231 }
6232
6233 hBg->GetXaxis()->SetLabelSize(0.06);
6234 hBg->GetXaxis()->SetRange(1, x - 1);
6235 hS->GetXaxis()->SetRange(1, x - 1);
6236
6237 stringstream ss;
6238 ss << "lmvmAll_cutEff_" << minMinv << "to" << maxMinv;
6239 fHMean.fHM.CreateCanvas(ss.str(), ss.str(), 1000, 1000);
6240 DrawH1({hBg, hS}, {"B_{MC}", "Cocktail"}, kLinear, kLinear, true, 0.75, 0.85, 1.0, 1.0, "hist");
6241 hBg->SetLineWidth(4);
6242 hS->SetLineWidth(4);
6243 hBg->SetMinimum(1);
6244 hBg->SetMaximum(110);
6245
6246 stringstream ss2;
6247 ss2 << minMinv << "<M [GeV/c^2]<" << maxMinv;
6248 TText* t = new TText(0.5, hBg->GetMaximum() + 5, ss2.str().c_str());
6249 t->Draw();
6250}
6251
6252TH1D* LmvmDrawAll::SBgRange(double minMinv, double maxMinv)
6253{
6254 stringstream ss;
6255 ss << "hSBgRatio_" << minMinv << "to" << maxMinv;
6256 fHMean.CreateH1(ss.str(), "Analysis step", "Cocktail/BG", fHMean.fNofAnaSteps, 0, fHMean.fNofAnaSteps);
6257 TH1D* hSBg = fHMean.H1(ss.str());
6258 hSBg->GetXaxis()->SetLabelSize(0.06);
6259 int x = 1;
6260 TH1D* cocktail = GetCocktailMinvH1("hMinv", ELmvmAnaStep::ElId, false);
6261 int binMin = cocktail->FindBin(minMinv);
6262 int binMax = cocktail->FindBin(maxMinv);
6263 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
6264 if (step < ELmvmAnaStep::ElId) continue;
6265 if (!fUseMvd && (step == ELmvmAnaStep::Mvd1Cut || step == ELmvmAnaStep::Mvd2Cut)) continue;
6266
6267 double intS = 100. * GetCocktailMinvH1("hMinv", step, false)->Integral(binMin, binMax);
6268 double intBg = 100. * fHMean.H1("hMinv", ELmvmSrc::Bg, step)->Integral(binMin, binMax);
6269 double sbg = intS / intBg;
6270
6271 hSBg->GetXaxis()->SetBinLabel(x, fHMean.fAnaStepLatex[static_cast<int>(step)].c_str());
6272 hSBg->SetBinContent(x, sbg);
6273 x++;
6274 }
6275 hSBg->GetXaxis()->SetRange(1, x - 1);
6276 return hSBg;
6277}
6278
6280{
6281 TH1D* h1 = SBgRange(0.0, 0.2);
6282 TH1D* h2 = SBgRange(0.2, 0.6);
6283 TH1D* h3 = SBgRange(0.6, 1.2);
6284
6285 fHMean.fHM.CreateCanvas("SignalToBg/Ranges", "SignalToBg/Ranges", 1000, 1000);
6286 DrawH1({h1, h2, h3}, {"0.0<M [GeV/c^{2}]<0.2", "0.2<M [GeV/c^{2}]<0.6", "0.6<M [GeV/c^{2}]<1.2"}, kLinear, kLog, true,
6287 0.25, 0.83, 0.75, 0.99, "hist");
6288 h1->SetMinimum(0.9 * std::min({h1->GetMinimum(), h2->GetMinimum(), h3->GetMinimum()}));
6289 h1->SetMaximum(1.1 * std::max({h1->GetMaximum(), h2->GetMaximum(), h3->GetMaximum()}));
6290 h1->SetLineWidth(4);
6291 h2->SetLineWidth(4);
6292 h3->SetLineWidth(4);
6293
6294 TH1D* h4 = SBgRange(0.5, 0.6);
6295 fHMean.fHM.CreateCanvas("SignalToBg/Range05to06", "SignalToBg/Range05to06", 1000, 1000);
6296 DrawH1(h4, kLinear, kLinear);
6297 h4->SetLineWidth(4);
6298}
6299
6301{
6302 TCanvas* cFit = fHMean.fHM.CreateCanvas("SignalToBg/SignalFit", "SignalToBg/SignalFit", 1000, 1000);
6303 ofstream resultFile(fOutputDir + "/lmvmAll_results.txt");
6304 for (auto signal : fHMean.fSignals) {
6305 string signalName = fHMean.fSignalNames[static_cast<int>(signal)];
6306 fHMean.CreateH1("hSBgRatio_" + signalName, "Analysis steps", "S/BG", fHMean.fNofAnaSteps, 0, fHMean.fNofAnaSteps);
6307 TH1D* hSBg = fHMean.H1("hSBgRatio_" + signalName);
6308 hSBg->GetXaxis()->SetLabelSize(0.06);
6309 hSBg->SetLineWidth(4);
6310 int x = 1;
6311 for (ELmvmAnaStep step : fHMean.fAnaSteps) {
6312 if (step < ELmvmAnaStep::ElId) continue;
6313 if (!fUseMvd && (step == ELmvmAnaStep::Mvd1Cut || step == ELmvmAnaStep::Mvd2Cut)) continue;
6314 cFit->cd(x);
6315 LmvmSBgResultData result = CalculateSBgResult(signal, step);
6316
6317 hSBg->GetXaxis()->SetBinLabel(x, fHMean.fAnaStepLatex[static_cast<int>(step)].c_str());
6318 if (result.fSBgRatio < 1000.) hSBg->SetBinContent(x, result.fSBgRatio);
6319 x++;
6320 resultFile << signalName << " " << fHMean.fAnaStepNames[static_cast<int>(step)] << " " << result.fSignallEff
6321 << " " << result.fSBgRatio << " " << result.fFitMean << " " << result.fFitSigma;
6322 }
6323 hSBg->GetXaxis()->SetRange(1, x - 1);
6324 fHMean.fHM.CreateCanvas("SignalToBg/" + signalName, "SignalToBg/" + signalName, 1000, 1000);
6325 DrawH1(hSBg);
6326 hSBg->SetLineWidth(4);
6327 }
6328 resultFile.close();
6329}
6330
6332{
6333 TH1D* s = H(signal)->H1("hMinv", ELmvmSrc::Signal, step);
6334 TH1D* bg = H(signal)->H1("hMinv", ELmvmSrc::Bg, step);
6335
6336 if (s->GetEntries() < 10) return LmvmSBgResultData(0., 0., 0., 0.);
6337
6338 TH1D* sClone = static_cast<TH1D*>(s->Clone());
6339 if (signal == ELmvmSignal::Phi)
6340 sClone->Fit("gaus", "Q", "", 0.95, 1.05);
6341 else if (signal == ELmvmSignal::Omega)
6342 sClone->Fit("gaus", "Q", "", 0.69, 0.81);
6343 else
6344 sClone->Fit("gaus", "Q");
6345
6346 TF1* func = sClone->GetFunction("gaus");
6347 double mean = (func != nullptr) ? func->GetParameter("Mean") : 0.;
6348 double sigma = (func != nullptr) ? func->GetParameter("Sigma") : 0.;
6349 int minInd = s->FindBin(mean - 2. * sigma);
6350 int maxInd = s->FindBin(mean + 2. * sigma);
6351
6352 double sumSignal = 0.;
6353 double sumBg = 0.;
6354 for (int i = minInd + 1; i <= maxInd - 1; i++) {
6355 sumSignal += s->GetBinContent(i);
6356 sumBg += bg->GetBinContent(i);
6357 }
6358 double sbg = (sumBg != 0.) ? sumSignal / sumBg : 0.;
6359
6360 double eff = 100. * H(signal)->H1("hPtYPairSignal", step)->GetEntries()
6361 / H(signal)->H1("hPtYPairSignal", ELmvmAnaStep::Mc)->GetEntries();
6362
6363 return LmvmSBgResultData(sbg, eff, mean, sigma);
6364}
6365
6366void LmvmDrawAll::CheckMemory(const string& text)
6367{
6368 static ProcInfo_t info;
6369 const float toMB = 1.f / 1024.f;
6370 gSystem->GetProcInfo(&info);
6371 cout << Form((text + ": Memory res|vir: %g|%g Mbytes\n").c_str(), info.fMemResident * toMB, info.fMemVirtual * toMB);
6372 cout << endl;
6373}
6374
6376{
6377 if (fOutputDir != "") {
6378 gSystem->mkdir(fOutputDir.c_str(), true);
6379 TFile* f = TFile::Open(string(fFileName).c_str(), "RECREATE");
6380 fHMean.WriteToFile();
6381 f->Close();
6382 }
6383}
6384
6386{
6387 cout << "Images output dir:" << fOutputDir << endl;
6388 fHMean.fHM.SaveCanvasToImage(fOutputDir, "png");
6389}
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.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
bool first
@ Signal
Definition LmvmDef.h:24
@ Gamma
Definition LmvmDef.h:27
ELmvmSignal
Definition LmvmDef.h:62
ELmvmAnaStep
Definition LmvmDef.h:34
const double pi
Generates beam ions for transport simulation.
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.
TNamed * GetObject(const std::string &name) const
void ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
Data class with information on a STS local track.
std::vector< std::vector< std::pair< double, double > > > fBwVarAll
std::vector< std::pair< double, double > > fBwVarOmega
LmvmHist * H(ELmvmSignal signal)
void DrawMinv(ELmvmAnaStep step)
double fNofEvMixEvents
Definition LmvmDrawAll.h:60
void DrawPtYAndTofM2Misid()
void DrawMinvOfficialStyle()
Draw invariant mass spectra in official style.
void SBgRangeAll()
Draw S/BG vs plots for different mass ranges.
void CreateMeanHistSparse(const std::string &name)
void DrawMultiplicities(TH1D *plus, TH1D *minus, TH1D *plusrandom, TH1D *minusrandom, std::string cName, std::string hText)
void CalculateHistErrors(TH1D *h, double nofEvents)
Calculates errors of (normalized) histograms.
TH1D * GetCocktailMinvH1(const std::string &name, ELmvmAnaStep step, bool scaleAll)
std::string fDataDir
Definition LmvmDrawAll.h:35
TH1D * SBgRange(double minMinv, double maxMinv)
Create S/BG vs cuts for specified invariant mass range.
TH1D * GetHalfHisto(TH1D *h, std::string opt, const std::string &label)
void CheckoutTemperatureParams()
bool fDoParticleBased
Definition LmvmDrawAll.h:54
void CheckMemory(const std::string &text)
std::vector< double > fParamB
TH1D * GetCBForNormRange(const std::string hName, ELmvmAnaStep step, double rangeStart, double rangeEnd)
TH1D * GetSymmetry(TH1D *h)
double fNofFastSimEvents
Definition LmvmDrawAll.h:49
void DrawLikeSignCorrelations()
TH1D * CalculateHistRatioWithErrors(TH1D *hNom, TH1D *hDenom, double nEvNom, double nEvDenom)
Calculates ratios of histograms with errors.
std::vector< std::pair< double, double > > fBwVarOrig
void DrawBetaMomSpectra()
void DrawSBgResults()
Draw properties of misidentified particles in comparison with not-misidentified.
void CheckoutAddFunction2()
void DrawMomentumUrqmd()
void CreateMeanHist(const std::string &name, int nofRebins=-1)
int fTempGraphCounter
bool IsCloseTo(double value, double refValue, double tol)
void DrawEfficiency()
void CheckVaryBinWidth()
std::vector< std::pair< double, double > > fBwVarSig
double fNofSimEvents
Definition LmvmDrawAll.h:48
void CalculateSignal()
Calculate Signal from Fast Simulations and Combinatorial Background.
double fCbChange
Definition LmvmDrawAll.h:61
void DrawSBgVsMinv()
Draw S/Bg vs minv.
void DrawSignalCBNormRangeDependent(std::string hName, std::string cName, ELmvmAnaStep step)
TH1D * VaryBinWidth(TH1D *h, double nEvents, std::vector< std::pair< double, double > > binValues)
Main variable bin width method. Returns copy of provided histogram with varied bin width....
std::vector< std::pair< double, double > > fBwVarBg4
std::vector< std::pair< double, double > > fBwVarBg2
double fNofFastSimJobs
Definition LmvmDrawAll.h:50
void DrawMomentum()
void DrawRapidity()
void DrawTemperatureGraph(TH1D *h, ELmvmAnaStep step, double startfit, double endfit, bool DoCorrectX)
void CheckoutTemperatureFitRange(TH1D *h, std::string name)
void DrawSignificancesAll()
void DrawCandProperties()
void DrawMomRecoPrecision()
void DrawBackground()
double fRebinMinv
Definition LmvmDrawAll.h:46
void DrawEfficiencyCorrection()
std::vector< LmvmHist * > fH
Definition LmvmDrawAll.h:41
void CalculateCombBGHistos()
Calculate Combinatorial BG.
void DrawTemperature()
void DrawSignificance(TH2D *hEl, TH2D *hBg, const std::string &name, double minZ, double maxZ, const std::string &option)
int fNofEvMixJobs
Definition LmvmDrawAll.h:57
std::string fOutputDir
Definition LmvmDrawAll.h:36
void CheckoutTemperatureFitRangeAll()
void DrawMomPluto()
void DrawPurityHistText(TH2D *h)
void CheckoutTemperatureParamB()
void ChargeSymmetry()
void CalculateCBFromFastSimEvents()
Calculate Combinatorial BG from Fast Simulations.
void DrawRichProperties()
void DrawMinvPtAll()
std::vector< std::pair< double, double > > fBwVarBg
void CheckoutTemperatureInitParams()
void DrawFastSimHistos()
void DrawSuppression()
void SaveCanvasToImage()
Save all created canvases to images.
void DrawFastSimHistosParticleBased()
void CheckoutAddFunction()
LmvmHist fHEvMix
Definition LmvmDrawAll.h:44
std::vector< std::pair< double, double > > fBwVarSig2
LmvmHist fHFastSim
Definition LmvmDrawAll.h:43
std::string fFileName
Definition LmvmDrawAll.h:37
LmvmHist fHMean
Definition LmvmDrawAll.h:42
void InvestigateMisid()
Draw properties of misidentified particles.
void DrawHistFromFile(const std::string &fileInmed, const std::string &fileQgp, const std::string &fileOmega, const std::string &filePhi, const std::string &fileOmegaD, const std::string &dataDir="", bool useMvd=false)
std::vector< double > fCbNormFactor
Definition LmvmDrawAll.h:64
void LoadFastSimHistos()
Load histograms from LmvmFastSim and set related global variabled.
std::vector< std::pair< double, double > > fBwVarPhi
std::vector< std::pair< double, double > > fBwVarCock
std::vector< std::pair< double, double > > fBwVarReg
std::vector< std::string > fBwVarAllTags
void DrawSystematicErrorFsSignal()
TH1D * GetSignal(ELmvmAnaStep step, std::vector< std::pair< double, double > > bwVar)
Returns signal (calc. from Fast Simulations and Comb. Background) with varied bin width and with erro...
void DrawCombinatorialBackground()
Draw invariant mass spectra for all signal types for specified analysis step with BG reduced by combi...
void CreateMeanHistAll()
std::vector< std::pair< double, double > > fBwVarSig3
void DrawElidCuts()
void SaveHist()
Save histograms for the study report.
bool fDoChargeBased
Definition LmvmDrawAll.h:53
std::vector< std::pair< double, double > > fBwVarBg3
void InitialiseCocktailFitParams()
void CalcCutEffRange(double minMinv, double maxMinv)
Calculate cut efficiency in specified invariant mass region.
double fCbNormRangeMax
Definition LmvmDrawAll.h:63
std::vector< std::pair< double, double > > fBwVarBg5
void DrawGTrackVertex()
LmvmSBgResultData CalculateSBgResult(ELmvmSignal signal, ELmvmAnaStep step)
void DrawSignal()
double fCbNormRangeMin
Definition LmvmDrawAll.h:62
void DrawMinvScaleValues()
T * GetCocktailMinv(const std::string &name, ELmvmAnaStep step, bool scaleAll)
void DrawMomentumMisidVsTrue()
CbmHistManager fHM
Definition LmvmHist.h:195
TH2D * H2Clone(const std::string &name)
Definition LmvmHist.h:142
TH2D * H2(const std::string &name)
Definition LmvmHist.h:133
std::string GetName(const std::string &name, ELmvmAnaStep step)
TH1D * H1Clone(const std::string &name)
Definition LmvmHist.h:141
TNamed * GetObject(const std::string &name)
Definition LmvmHist.h:130
TH1D * H1(const std::string &name)
Definition LmvmHist.h:132
double fSignallEff
Definition LmvmDef.h:139
static double GetMassScaleQgp(double minv)
static double GetMassScaleInmed(double minv)
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:66
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34
@ N
Do not fit the time component.
Definition KfDefs.h:133
Hash for CbmL1LinkKey.