CbmRoot
Loading...
Searching...
No Matches
CbmAnaJpsiSuperEvent.cxx
Go to the documentation of this file.
1/* Copyright (C) 2015-2021 UGiessen, JINR-LIT
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Adrian Amatus Weber */
4
5/*
6 * CbmAnaJpsiSuperEvent.cxx
7 *
8 * Created on: Jun 25, 2015
9 * Author: slebedev
10 */
12
13#include "CbmAnaJpsiCuts.h"
15#include "CbmAnaJpsiUtils.h"
16#include "CbmDrawHist.h"
17#include "CbmHistManager.h"
18#include "CbmReportElement.h"
19#include "CbmUtils.h"
20
21#include "TCanvas.h"
22#include "TClonesArray.h"
23#include "TDirectory.h"
24#include "TFile.h"
25#include "TFolder.h"
26#include "TH1.h"
27#include "TLatex.h"
28#include "TMarker.h"
29#include "TPad.h"
30#include "TTree.h"
31
32#include <boost/assign/list_of.hpp>
33
34#include <iostream>
35#include <map>
36using namespace std;
37
38using boost::assign::list_of;
40using Cbm::Split;
41using std::cout;
42using std::endl;
43using std::map;
44
46 : TObject()
47 , fFileNames()
48 , fMinusCandidates()
49 , fPlusCandidates()
50 , fOutputFile("")
51 , fHM(NULL)
52 , fCuts()
53 , fRunAfterPtCut(kTRUE)
54 , fRunAfterIdCut(kTRUE)
55{
56}
57
59
61{
62 cout << "-I- Run" << endl;
63
64 InitHist();
65
67
69
70 Draw();
71
73 TFile* oldFile = gFile;
74 TDirectory* oldDir = gDirectory;
75
76 TFile* file = new TFile(fOutputFile.c_str(), "RECREATE");
78
80 gFile = oldFile;
81 gDirectory = oldDir;
82
83 file->Close();
84
85 cout << "-I- Output file:" << fOutputFile << endl;
86}
87
89{
90 fHM = new CbmHistManager();
91 fHM->Create1<TH1D>("fh_se_bg_minv_reco", "fh_se_bg_minv_reco;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
92 fHM->Create1<TH1D>("fh_se_bg_minv_chi2prim", "fh_se_bg_minv_chi2prim;M_{ee} [GeV/c^{2}];particles/event", 4000, 0,
93 4.);
94 fHM->Create1<TH1D>("fh_se_bg_minv_elid", "fh_se_bg_minv_elid;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
95 fHM->Create1<TH1D>("fh_se_bg_minv_ptcut", "fh_se_bg_minv_ptcut;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
96
97 fHM->Create1<TH1D>("fh_se_event_number", "fh_se_event_number;a.u.;Number of events", 1, 0, 1.);
98
99 fHM->Create1<TH1D>("fh_se_bg_participants_minv_gg",
100 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
101 fHM->Create1<TH1D>("fh_se_bg_participants_minv_gp",
102 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
103 fHM->Create1<TH1D>("fh_se_bg_participants_minv_go",
104 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
105 fHM->Create1<TH1D>("fh_se_bg_participants_minv_pg",
106 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
107 fHM->Create1<TH1D>("fh_se_bg_participants_minv_pp",
108 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
109 fHM->Create1<TH1D>("fh_se_bg_participants_minv_po",
110 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
111 fHM->Create1<TH1D>("fh_se_bg_participants_minv_og",
112 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
113 fHM->Create1<TH1D>("fh_se_bg_participants_minv_op",
114 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
115 fHM->Create1<TH1D>("fh_se_bg_participants_minv_oo",
116 "fh_se_bg_participants_minv_gg;M_{ee} [GeV/c^{2}];particles/event", 4000, 0, 4.);
117
118 fHM->Create1<TH1D>("fh_SE_PdgCode_of Others_BG", "fh_SE_PdgCode_of Others_BG;PDGCode;Tracks per Event", 500, -0.5,
119 499.5);
120
121 fHM->Create1<TH1D>("fh_se_bg_mismatch_minv_ptCut", "fh_se_bg_mismatch_minv_ptCut;M_{ee} [GeV/c^{2}];particles/event",
122 4000, 0., 4.);
123 fHM->Create1<TH1D>("fh_se_bg_truematch_minv_ptCut",
124 "fh_se_bg_truematch_minv_ptCut;M_{ee} [GeV/c^{2}];particles/event", 4000, 0., 4.);
125 fHM->Create1<TH1D>("fh_se_bg_truematch_el_minv_ptCut",
126 "fh_se_bg_truematch_el_minv_ptCut;M_{ee} [GeV/c^{2}];particles/event", 4000, 0., 4.);
127 fHM->Create1<TH1D>("fh_se_bg_truematch_notel_minv_ptCut",
128 "fh_se_bg_truematch_notel_minv_ptCut;M_{ee} [GeV/c^{2}];particles/event", 4000, 0., 4.);
129
130 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_0", "fh_se_bg_minv_diff_ptcuts_0;M_{ee} [GeV/c^{2}];particles/event",
131 4000, 0., 4.);
132 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_1", "fh_se_bg_minv_diff_ptcuts_1;M_{ee} [GeV/c^{2}];particles/event",
133 4000, 0., 4.);
134 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_2", "fh_se_bg_minv_diff_ptcuts_2;M_{ee} [GeV/c^{2}];particles/event",
135 4000, 0., 4.);
136 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_3", "fh_se_bg_minv_diff_ptcuts_3;M_{ee} [GeV/c^{2}];particles/event",
137 4000, 0., 4.);
138 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_4", "fh_se_bg_minv_diff_ptcuts_4;M_{ee} [GeV/c^{2}];particles/event",
139 4000, 0., 4.);
140 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_5", "fh_se_bg_minv_diff_ptcuts_5;M_{ee} [GeV/c^{2}];particles/event",
141 4000, 0., 4.);
142 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_6", "fh_se_bg_minv_diff_ptcuts_6;M_{ee} [GeV/c^{2}];particles/event",
143 4000, 0., 4.);
144 fHM->Create1<TH1D>("fh_se_bg_minv_diff_ptcuts_7", "fh_se_bg_minv_diff_ptcuts_7;M_{ee} [GeV/c^{2}];particles/event",
145 4000, 0., 4.);
146}
147
148
150{
151 fMinusCandidates.clear();
152 fPlusCandidates.clear();
153 cout << "-I- ReadCandidates" << endl;
154 cout << "-I- fFileNames.size:" << fFileNames.size() << endl;
155
157 TFile* oldFile = gFile;
158 TDirectory* oldDir = gDirectory;
159
160 for (UInt_t iFile = 0; iFile < fFileNames.size(); iFile++) {
161 cout << "-I- Reading file No " << iFile << " path:" << fFileNames[iFile] << endl;
162 TFile* f = new TFile(fFileNames[iFile].c_str(), "R");
163 LOG_IF(fatal, !f) << "Could not open file " << fFileNames[iFile].c_str();
164 TTree* t = f->Get<TTree>("cbmsim");
165 TFolder* fd = f->Get<TFolder>("cbmout");
166 if (fd == NULL) continue;
167 TClonesArray* candidates = (TClonesArray*) fd->FindObjectAny("JpsiCandidates");
168 t->SetBranchAddress(candidates->GetName(), &candidates);
169 Int_t nofEvents = t->GetEntriesFast();
170 cout << "-I- Number of events in file: " << nofEvents << endl;
171 for (Int_t iEv = 0; iEv < nofEvents; iEv++) {
172 fHM->H1("fh_se_event_number")->Fill(0.5);
173 t->GetEntry(iEv);
174 Int_t nofCandidates = candidates->GetEntriesFast();
175 //cout << "-I- nofCandidates:" << nofCandidates << endl;
176 for (Int_t iCand = 0; iCand < nofCandidates; iCand++) {
177 CbmAnaJpsiCandidate* cand = (CbmAnaJpsiCandidate*) candidates->At(iCand);
178
179 if (cand->fIsMcSignalElectron) continue;
180
181 Bool_t isIdCut = (cand->fChi2Prim < fCuts.fChiPrimCut && cand->fIsElectron);
182 Bool_t isPtCut = (isIdCut && cand->fMomentum.Perp() > fCuts.fPtCut);
183 Bool_t isGoodId = fRunAfterIdCut ? (isIdCut) : true;
184 Bool_t isGood = fRunAfterPtCut ? (isPtCut) : true;
185 if (cand->fCharge < 0) {
187 if (isGoodId) {
188 if (isGood) fMinusCandidates.push_back(candM);
189 }
190 }
191 else {
193 if (isGoodId) {
194 if (isGood) fPlusCandidates.push_back(candP);
195 }
196 }
197 }
198 }
199 f->Close();
200 delete f;
201 }
203 gFile = oldFile;
204 gDirectory = oldDir;
205
206 cout << "-I- fMinusCandidates.size:" << fMinusCandidates.size() << endl;
207 cout << "-I- fPlusCandidates.size:" << fPlusCandidates.size() << endl;
208 cout << "-I- number of events:" << fHM->H1("fh_se_event_number")->GetEntries() << endl;
209}
210
212{
213 cout << "-I- DoSuperEvent" << endl;
214
215 Int_t nofMinus = fMinusCandidates.size();
216 Int_t nofPlus = fPlusCandidates.size();
217 for (Int_t iM = 0; iM < nofMinus; iM++) {
218 if (iM % 1000 == 0) cout << 100. * iM / nofMinus << "% done" << endl;
220 for (Int_t iP = 0; iP < nofPlus; iP++) {
223 Bool_t isChi2Primary = (candM->fChi2Prim < fCuts.fChiPrimCut && candP->fChi2Prim < fCuts.fChiPrimCut);
224 Bool_t isEl = (candM->fIsElectron && candP->fIsElectron);
225 Bool_t isPtCut = (candM->fMomentum.Perp() > fCuts.fPtCut && candP->fMomentum.Perp() > fCuts.fPtCut);
226
227 Bool_t isSignal = candP->fIsMcSignalElectron && candM->fIsMcSignalElectron;
228 //Bool_t isPi0 = (candP->fIsMcPi0Electron && candM->fIsMcPi0Electron && candP->fStsMcMotherId == candM->fStsMcMotherId);
229 //Bool_t isGamma = (candP->fIsMcGammaElectron && candM->fIsMcGammaElectron && candP->fStsMcMotherId == candM->fStsMcMotherId);
230 Bool_t isBG =
231 !isSignal; // (!isGamma) && (!isPi0);// && (!(candP->fIsMcSignalElectron || candM->fIsMcSignalElectron));
232
233 if (!isBG) continue;
234 fHM->H1("fh_se_bg_minv_reco")->Fill(pRec.fMinv);
235 if (isChi2Primary) fHM->H1("fh_se_bg_minv_chi2prim")->Fill(pRec.fMinv);
236 if (isChi2Primary && isEl) fHM->H1("fh_se_bg_minv_elid")->Fill(pRec.fMinv);
237 if (isChi2Primary && isEl && isPtCut) {
238 fHM->H1("fh_se_bg_minv_ptcut")->Fill(pRec.fMinv);
239
240 if (candM->fIsMcGammaElectron) {
241 if (candP->fIsMcGammaElectron) {
242 fHM->H1("fh_se_bg_participants_minv_gg")->Fill(pRec.fMinv); //gamma + gamma
243 }
244 else if (candP->fIsMcPi0Electron) {
245 fHM->H1("fh_se_bg_participants_minv_gp")->Fill(pRec.fMinv); //gamma + Pi0
246 }
247 else {
248 fHM->H1("fh_se_bg_participants_minv_go")->Fill(pRec.fMinv); //gamma + other
249 fHM->H1("fh_SE_PdgCode_of Others_BG")->Fill((double) candP->fMcPdg - 0.5);
250 }
251 }
252 else if (candM->fIsMcPi0Electron) {
253 if (candP->fIsMcGammaElectron) {
254 fHM->H1("fh_se_bg_participants_minv_gp")->Fill(pRec.fMinv); //pi0 + gamma
255 }
256 else if (candP->fIsMcPi0Electron) {
257 fHM->H1("fh_se_bg_participants_minv_pp")->Fill(pRec.fMinv); //pi0 + Pi0
258 }
259 else {
260 fHM->H1("fh_se_bg_participants_minv_po")->Fill(pRec.fMinv); //pi0 + other
261 fHM->H1("fh_SE_PdgCode_of Others_BG")->Fill((double) candP->fMcPdg - 0.5);
262 }
263 }
264 else {
265 fHM->H1("fh_SE_PdgCode_of Others_BG")->Fill((double) candM->fMcPdg - 0.5);
266 if (candP->fIsMcGammaElectron) {
267 fHM->H1("fh_se_bg_participants_minv_go")->Fill(pRec.fMinv); //other + gamma
268 }
269 else if (candP->fIsMcPi0Electron) {
270 fHM->H1("fh_se_bg_participants_minv_po")->Fill(pRec.fMinv); //other + Pi0
271 }
272 else {
273 fHM->H1("fh_se_bg_participants_minv_oo")->Fill(pRec.fMinv); //other + other
274 fHM->H1("fh_SE_PdgCode_of Others_BG")->Fill((double) candP->fMcPdg - 0.5);
275 }
276 }
277
278 Bool_t isMismatch = (candP->fIsMismatch || candM->fIsMismatch);
279 if (isBG && isMismatch) fHM->H1("fh_se_bg_mismatch_minv_ptCut")->Fill(pRec.fMinv);
280 if (isBG && !isMismatch) {
281 fHM->H1("fh_se_bg_truematch_minv_ptCut")->Fill(pRec.fMinv);
282 if (candP->fMcPdg == 11 && candM->fMcPdg == 11) fHM->H1("fh_se_bg_truematch_el_minv_ptCut")->Fill(pRec.fMinv);
283 if (candP->fMcPdg != 11 || candM->fMcPdg != 11)
284 fHM->H1("fh_se_bg_truematch_notel_minv_ptCut")->Fill(pRec.fMinv);
285 }
286 }
287
288 if (isChi2Primary && isEl && pRec.fPt < 0.4) { fHM->H1("fh_se_bg_minv_diff_ptcuts_0")->Fill(pRec.fMinv); }
289 if (isChi2Primary && isEl && pRec.fPt >= 0.4 && pRec.fPt < 0.8) {
290 fHM->H1("fh_se_bg_minv_diff_ptcuts_1")->Fill(pRec.fMinv);
291 }
292 if (isChi2Primary && isEl && pRec.fPt >= 0.8 && pRec.fPt < 1.2) {
293 fHM->H1("fh_se_bg_minv_diff_ptcuts_2")->Fill(pRec.fMinv);
294 }
295 if (isChi2Primary && isEl && pRec.fPt >= 1.2 && pRec.fPt < 1.6) {
296 fHM->H1("fh_se_bg_minv_diff_ptcuts_3")->Fill(pRec.fMinv);
297 }
298 if (isChi2Primary && isEl && pRec.fPt >= 1.6 && pRec.fPt < 2.0) {
299 fHM->H1("fh_se_bg_minv_diff_ptcuts_4")->Fill(pRec.fMinv);
300 }
301 if (isChi2Primary && isEl && pRec.fPt >= 2.0 && pRec.fPt < 2.4) {
302 fHM->H1("fh_se_bg_minv_diff_ptcuts_5")->Fill(pRec.fMinv);
303 }
304 if (isChi2Primary && isEl && pRec.fPt >= 2.4 && pRec.fPt < 3.0) {
305 fHM->H1("fh_se_bg_minv_diff_ptcuts_6")->Fill(pRec.fMinv);
306 }
307 if (isChi2Primary && isEl && pRec.fPt >= 3.0 && pRec.fPt < 6.0) {
308 fHM->H1("fh_se_bg_minv_diff_ptcuts_7")->Fill(pRec.fMinv);
309 }
310 }
311 }
312}
313
315{
316 TCanvas* c = new TCanvas("jpsi_se_bg_minv", "jpsi_se_bg_minv", 1200, 1200);
317
318 fHM->RebinByPattern("fh_se_bg_minv.*", 20);
319 fHM->ScaleByPattern("fh_se_bg_minv.*", 20);
320
321 c->Divide(2, 2);
322 c->cd(1);
323 DrawH1(fHM->H1("fh_se_bg_minv_reco"));
325 c->cd(2);
326 DrawH1(fHM->H1("fh_se_bg_minv_chi2prim"));
328 c->cd(3);
329 DrawH1(fHM->H1("fh_se_bg_minv_elid"));
331 c->cd(4);
332 fHM->H1("fh_se_bg_minv_ptcut")->SetMinimum(1e-11);
333 gPad->SetLogy();
334 DrawH1(fHM->H1("fh_se_bg_minv_ptcut"));
336}
337
338
@ kJpsiReco
@ kJpsiPtCut
@ kJpsiElId
@ kJpsiChi2Prim
ClassImp(CbmConverterManager)
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
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)
Helper functions for drawing 1D and 2D histograms and graphs.
Histogram manager.
Abstract class for basic report elements (headers, tables, images etc.).
Double_t fChiPrimCut
static const std::vector< std::string > fAnaStepsLatex
static CbmAnaJpsiKinematicParams KinematicParamsWithCandidates(const CbmAnaJpsiCandidate *candP, const CbmAnaJpsiCandidate *candM)
std::vector< CbmAnaJpsiCandidate > fMinusCandidates
std::vector< CbmAnaJpsiCandidate > fPlusCandidates
std::vector< std::string > fFileNames
Histogram manager.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void WriteToFile()
Write all objects to current opened file.
void RebinByPattern(const std::string &pattern, Int_t ngroup)
Rebin histograms which name matches specified pattern.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:67
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34
Hash for CbmL1LinkKey.