BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmKFPartEfficiencies.h
Go to the documentation of this file.
1#ifndef CbmKFPartEfficiencies_H
2#define CbmKFPartEfficiencies_H
3
4#include "CbmL1Counters.h"
5#include "TNamed.h"
6
7class CbmKFPartEfficiencies : public TNamed
8{
9 public:
12 , names()
13 , indices()
14 , fPdgToIndex()
15 , ratio_reco()
16 , mc()
17 , reco()
18 , ratio_ghost()
19 , ratio_bg()
20 , ratio_clone()
21 , ghost()
22 , bg()
23 , clone()
24 {
25 // add total efficiency
26 // AddCounter("piPlus" ,"PiPlus efficiency");
27 // AddCounter("piMinus" ,"PiMinus efficiency");
28 int mPartPDG[nParticles] = {
29 310, 3122, -3122, 3312, -3312, 3322, -3322,
30 3334, -3334, 3212, -3212, 3222, -3222, // strange meson and hyperons
31 313, -313, 323, -323, // K* resonances
32 3224, 3114, -3114, -3224, 3214, -3214, // sigma resonances
33 3124, -3124, // Lambda resonances
34 3324, -3324, 1003314, -1003314, 3314, -3314, // Xi resonances
35 1003334, -1003334, // Omega resonances
36 3000, // exotics
37 333, 113, // vector mesons, hadron chanel
38 100113, 200113, // light vector mesons
39 22, // dielectrons
40 111, 221, // pi0, eta
41 443, 100443, // J/Psi
42 421, -421, 100421, -100421, // D0
43 411, -411, // D+, D-
44 431, -431, // Ds+, Ds-
45 4122, -4122, // Lambdac
46 10421, -10421, 10411, -10411, 20411, -20411,
47 3001 // H->Lambda p pi
48 };
49 TString mPartName[nParticles] = {"ks",
50 "lambda",
51 "lambdab",
52 "xi-",
53 "xi+",
54 "xi0",
55 "xi0b",
56 "omega-",
57 "omega+",
58 "#Sigma^0",
59 "#Sigma^0b",
60 "#Sigma^+",
61 "#Sigma^+b",
62 "k*0",
63 "k*0b",
64 "k*+",
65 "k*-",
66 "sigma*+",
67 "sigma*-",
68 "sigma*+b",
69 "sigma*-b",
70 "sigma*0",
71 "sigma*0b",
72 "lambda*",
73 "lambda*b",
74 "xi*0",
75 "xi*0b",
76 "xi*-_{#Lambda,K}",
77 "xi*+_{#Lambda,K}",
78 "xi*-_{#xi-,#pi0}",
79 "xi*+_{#xi+,#pi0}",
80 "omega*-",
81 "omega*+",
82 "Hdb",
83 "phi_{KK}",
84 "rho_{#pi#pi}",
85 "rho_{ee}",
86 "rho_{#mu#mu}",
87 "gamma",
88 "#pi^{0}",
89 "eta",
90 "J#Psi_ee",
91 "J#Psi_#mu#mu",
92 "D0",
93 "D0b",
94 "D0_4",
95 "D0b_4",
96 "D+",
97 "D-",
98 "Ds+",
99 "Ds-",
100 "lambdac",
101 "lambdacb",
102 "D*0",
103 "D*0b",
104 "D*+",
105 "D*-",
106 "D*+_4",
107 "D*-_4",
108 "H0"};
109 TString mPartTitle[nParticles] = {
110 "KShort ", // 0
111 "Lambda ", // 1
112 "Lambda b ", // 2
113 "Xi- ", // 3
114 "Xi+ ", // 4
115 "Xi0 ", // 5
116 "Xi0 b ", // 6
117 "Omega- ", // 7
118 "Omega+ ", // 8
119 "Sigma0 ", // 9
120 "Sigma0 b ", // 10
121 "Sigma+ ", // 11
122 "Sigma+ b ", // 12
123 "K*0 ", // 13
124 "K*0 b ", // 14
125 "K*+ ", // 15
126 "K*- ", // 16
127 "Sigma*+ ", // 17
128 "Sigma*- ", // 18
129 "Sigma*+ b", // 19
130 "Sigma*- b", // 20
131 "Sigma*0 ", // 21
132 "Sigma*0 b", // 22
133 "Lambda* ", // 23
134 "Lambda* b", // 24
135 "Xi*0 ", // 25
136 "Xi*0 b ", // 26
137 "Xi*-_lk ", // 27
138 "Xi*+_lk ", // 28
139 "Xi*-_XiPi", // 29
140 "Xi*+_XiPi", // 30
141 "Omega*- ", // 31
142 "Omega*+ ", // 32
143 "Hdb ", // 33
144 "phi_kk ", // 34
145 "rho_pipi ", // 35
146 "rho_ee ", // 36
147 "rho_mm ", // 37
148 "gamma ", // 38
149 "Pi0 ", // 39
150 "eta ", // 40
151 "JPsi_ee ", // 41
152 "JPsi_mm ", // 42
153 "D0 ", // 43
154 "D0b ", // 44
155 "D0_4 ", // 45
156 "D0b_4 ", // 46
157 "D+ ", // 47
158 "D- ", // 48
159 "Ds+ ", // 49
160 "Ds- ", // 50
161 "Lambdac ", // 51
162 "Lambdac b", // 52
163 "D*0 ", // 53
164 "D*0 b ", // 54
165 "D*+ ", // 55
166 "D*- ", // 56
167 "D*+_4 ", // 57
168 "D*-_4 ", // 58
169 "H0 " // 59
170 };
171
172 float mPartMHistoMin[nParticles] = {0.3, 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.6, 0.6,
173 0.6, 0.6, 1., 1., 1., 1., 1., 1., 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4,
174 1.4, 1.8, 1.8, 1., 0.6, 0.1, 0.1, 0.1, 0., 0., 0., 1., 1., 1., 1.,
175 1., 1., 1., 1., 1., 1., 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.};
176 float mPartMHistoMax[nParticles] = {1.3, 2., 2., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 2.6, 2.6,
177 2.6, 2.6, 3., 3., 3., 3., 3., 3., 3.4, 3.4, 3.4, 3.4, 3.4, 3.4, 3.4,
178 3.4, 3.8, 3.8, 3., 1.6, 2.1, 2.1, 2.1, 3., 3., 3., 4., 4., 3., 3.,
179 3., 3., 3., 3., 3., 3., 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.8, 3.};
180 // set decay mode
182
183 partDaughterPdg[0].push_back(211); // K0s -> pi+ pi-
184 partDaughterPdg[0].push_back(-211);
185
186 partDaughterPdg[1].push_back(2212); // Lambda -> p pi-
187 partDaughterPdg[1].push_back(-211);
188
189 partDaughterPdg[2].push_back(-2212); // Lambda_bar -> p- pi+
190 partDaughterPdg[2].push_back(211);
191
192 partDaughterPdg[3].push_back(3122); // Xi- -> Lambda pi-
193 partDaughterPdg[3].push_back(-211);
194
195 partDaughterPdg[4].push_back(-3122); // Xi+ -> Lambda_bar pi+
196 partDaughterPdg[4].push_back(211);
197
198 partDaughterPdg[5].push_back(3122); // Xi0 -> Lambda pi0
199 partDaughterPdg[5].push_back(111);
200
201 partDaughterPdg[6].push_back(-3122); // Xi0_bar -> Lambda_bar pi0
202 partDaughterPdg[6].push_back(111);
203
204 partDaughterPdg[7].push_back(3122); // Omega- -> Lambda K-
205 partDaughterPdg[7].push_back(-321);
206
207 partDaughterPdg[8].push_back(-3122); // Omega+ -> Lambda_bar K+
208 partDaughterPdg[8].push_back(321);
209
210 partDaughterPdg[9].push_back(22); // Sigma0 -> Lambda Gamma
211 partDaughterPdg[9].push_back(3122);
212
213 partDaughterPdg[10].push_back(22); // Sigma0_bar -> Lambda_bar Gamma
214 partDaughterPdg[10].push_back(-3122);
215
216 partDaughterPdg[11].push_back(111); // Sigma+ -> p pi0
217 partDaughterPdg[11].push_back(2212);
218
219 partDaughterPdg[12].push_back(111); // Sigma+_bar -> p- pi0
220 partDaughterPdg[12].push_back(-2212);
221
222 partDaughterPdg[13].push_back(321); // K*0 -> K+ pi-
223 partDaughterPdg[13].push_back(-211);
224
225 partDaughterPdg[14].push_back(-321); // K*0_bar -> K- pi+
226 partDaughterPdg[14].push_back(211);
227
228 partDaughterPdg[15].push_back(310); // K*+ -> K0s pi+
229 partDaughterPdg[15].push_back(211);
230
231 partDaughterPdg[16].push_back(310); // K*- -> K0s pi-
232 partDaughterPdg[16].push_back(-211);
233
234 partDaughterPdg[17].push_back(3122); // Sigma+ -> Lambda pi+
235 partDaughterPdg[17].push_back(211);
236
237 partDaughterPdg[18].push_back(3122); // Sigma- -> Lambda pi-
238 partDaughterPdg[18].push_back(-211);
239
240 partDaughterPdg[19].push_back(-3122); // Sigma+_bar -> Lambda_bar pi+
241 partDaughterPdg[19].push_back(211);
242
243 partDaughterPdg[20].push_back(-3122); // Sigma-_bar -> Lambda_bar pi-
244 partDaughterPdg[20].push_back(-211);
245
246 partDaughterPdg[21].push_back(3122); // Sigma*0 -> Lambda pi0
247 partDaughterPdg[21].push_back(111);
248
249 partDaughterPdg[22].push_back(-3122); // Sigma*0_bar -> Lambda_bar pi0
250 partDaughterPdg[22].push_back(111);
251
252 partDaughterPdg[23].push_back(2212); // Lambda* -> p K-
253 partDaughterPdg[23].push_back(-321);
254
255 partDaughterPdg[24].push_back(-2212); // Lambda*_bar -> p- K+
256 partDaughterPdg[24].push_back(321);
257
258 partDaughterPdg[25].push_back(3312); // Xi*0 -> Xi- pi+
259 partDaughterPdg[25].push_back(211);
260
261 partDaughterPdg[26].push_back(-3312); // Xi*0_bar -> Xi+ pi-
262 partDaughterPdg[26].push_back(-211);
263
264 partDaughterPdg[27].push_back(3122); // Xi*- -> Lambda K-
265 partDaughterPdg[27].push_back(-321);
266
267 partDaughterPdg[28].push_back(-3122); // Xi*+ -> Lambda_bar K+
268 partDaughterPdg[28].push_back(321);
269
270 partDaughterPdg[29].push_back(3312); // Xi*- -> Xi- pi0
271 partDaughterPdg[29].push_back(111);
272
273 partDaughterPdg[30].push_back(-3312); // Xi*+ -> Xi+ pi0
274 partDaughterPdg[30].push_back(111);
275
276 partDaughterPdg[31].push_back(3312); // Omega*- -> Xi- pi+ K-
277 partDaughterPdg[31].push_back(211);
278 partDaughterPdg[31].push_back(-321);
279
280 partDaughterPdg[32].push_back(-3312); // Omega*- -> Xi+ pi- K+
281 partDaughterPdg[32].push_back(-211);
282 partDaughterPdg[32].push_back(321);
283
284 partDaughterPdg[33].push_back(3122); // H-dibar -> Lambda Lambda
285 partDaughterPdg[33].push_back(3122);
286
287 partDaughterPdg[34].push_back(321); // phi -> K+ K-
288 partDaughterPdg[34].push_back(-321);
289
290 partDaughterPdg[35].push_back(211); // rho, omega, phi -> pi+ pi-
291 partDaughterPdg[35].push_back(-211);
292
293 partDaughterPdg[36].push_back(11); // rho, omega, phi -> e+ e-
294 partDaughterPdg[36].push_back(-11);
295
296 partDaughterPdg[37].push_back(13); // rho, omega, phi -> mu+ mu-
297 partDaughterPdg[37].push_back(-13);
298
299 partDaughterPdg[38].push_back(11); // gamma -> e+ e-
300 partDaughterPdg[38].push_back(-11);
301
302 partDaughterPdg[39].push_back(22); // pi0 -> gamma gamma
303 partDaughterPdg[39].push_back(22);
304
305 partDaughterPdg[40].push_back(111); // eta -> pi0 pi0
306 partDaughterPdg[40].push_back(111);
307 partDaughterPdg[40].push_back(111);
308
309 partDaughterPdg[41].push_back(11); // JPsi -> e+ e-
310 partDaughterPdg[41].push_back(-11);
311
312 partDaughterPdg[42].push_back(13); // JPsi -> mu+ mu-
313 partDaughterPdg[42].push_back(-13);
314
315 partDaughterPdg[43].push_back(211); // D0 -> pi+ K-
316 partDaughterPdg[43].push_back(-321);
317
318 partDaughterPdg[44].push_back(-211); // D0_bar -> K+ pi-
319 partDaughterPdg[44].push_back(321);
320
321 partDaughterPdg[45].push_back(211); // D0 -> pi+ pi+ pi- K-
322 partDaughterPdg[45].push_back(211);
323 partDaughterPdg[45].push_back(-211);
324 partDaughterPdg[45].push_back(-321);
325
326 partDaughterPdg[46].push_back(-211); // D0_bar -> pi- pi- pi+ K+
327 partDaughterPdg[46].push_back(-211);
328 partDaughterPdg[46].push_back(211);
329 partDaughterPdg[46].push_back(321);
330
331 partDaughterPdg[47].push_back(-321); // D+ -> K- pi+ pi+
332 partDaughterPdg[47].push_back(211);
333 partDaughterPdg[47].push_back(211);
334
335 partDaughterPdg[48].push_back(321); // D- -> K+ pi- pi-
336 partDaughterPdg[48].push_back(-211);
337 partDaughterPdg[48].push_back(-211);
338
339 partDaughterPdg[49].push_back(-321); // Ds+ -> K- K+ pi+
340 partDaughterPdg[49].push_back(321);
341 partDaughterPdg[49].push_back(211);
342
343 partDaughterPdg[50].push_back(321); // Ds- -> K+ K- pi-
344 partDaughterPdg[50].push_back(-321);
345 partDaughterPdg[50].push_back(-211);
346
347 partDaughterPdg[51].push_back(211); // Lambdac -> pi+ K- p
348 partDaughterPdg[51].push_back(-321);
349 partDaughterPdg[51].push_back(2212);
350
351 partDaughterPdg[52].push_back(-211); // Lambdac_bar -> pi- K+ p-
352 partDaughterPdg[52].push_back(321);
353 partDaughterPdg[52].push_back(-2212);
354
355 partDaughterPdg[53].push_back(411); // D*0 -> D+ pi-
356 partDaughterPdg[53].push_back(-211);
357
358 partDaughterPdg[54].push_back(-411); // D*0_bar -> D- pi+
359 partDaughterPdg[54].push_back(211);
360
361 partDaughterPdg[55].push_back(421); // D*+ -> D0 pi+
362 partDaughterPdg[55].push_back(211);
363
364 partDaughterPdg[56].push_back(-421); // D*- -> D0_bar pi-
365 partDaughterPdg[56].push_back(-211);
366
367 partDaughterPdg[57].push_back(421); // D*+ -> D04 pi+
368 partDaughterPdg[57].push_back(211);
369
370 partDaughterPdg[58].push_back(-421); // D*- -> D04_bar pi-
371 partDaughterPdg[58].push_back(-211);
372
373 partDaughterPdg[59].push_back(3122); // H0-> Lambda pi- p
374 partDaughterPdg[59].push_back(-211);
375 partDaughterPdg[59].push_back(2212);
376
377 for (int iP = 0; iP < nParticles; iP++) {
378 partPDG[iP] = mPartPDG[iP];
379 partName[iP] = mPartName[iP];
380 partTitle[iP] = mPartTitle[iP];
381 partMHistoMin[iP] = mPartMHistoMin[iP];
382 partMHistoMax[iP] = mPartMHistoMax[iP];
383 }
384
385 for (int iP = 0; iP < nParticles; iP++) {
386 AddCounter(Form("%s", partName[iP].Data()), Form("%-*s", 14, partTitle[iP].Data()));
387 AddCounter(Form("%s_prim", partName[iP].Data()), Form("%s Prim", partTitle[iP].Data()));
388 AddCounter(Form("%s_sec", partName[iP].Data()), Form("%s Sec ", partTitle[iP].Data()));
389 }
390
391 for (int iP = 0; iP < nParticles; iP++)
392 fPdgToIndex[mPartPDG[iP]] = iP;
393 }
394
396
397 int GetParticleIndex(int pdg)
398 {
399 std::map<int, int>::iterator it;
400 it = fPdgToIndex.find(pdg);
401 if (it != fPdgToIndex.end())
402 return it->second;
403 else
404 return -1;
405 }
406
407 virtual void AddCounter(TString shortname, TString name)
408 {
409 indices[shortname] = names.size();
410 names.push_back(name);
411
412 ratio_reco.AddCounter();
413 mc.AddCounter();
414 reco.AddCounter();
415
416 ratio_ghost.AddCounter();
417 ratio_bg.AddCounter();
418 ratio_clone.AddCounter();
419 ghost.AddCounter();
420 bg.AddCounter();
421 clone.AddCounter();
422 };
423
425 {
426 mc += a.mc;
427 reco += a.reco;
428 ghost += a.ghost;
429 bg += a.bg;
430 clone += a.clone;
431 return *this;
432 };
433
434 void CalcEff()
435 {
436 ratio_reco = reco / mc;
437
439 ratio_ghost = ghost / allReco;
440 ratio_bg = bg / allReco;
441 ratio_clone = clone / allReco;
442 };
443
444 void Inc(bool isReco, int nClones, TString name)
445 {
446 const int index = indices[name];
447
448 mc.counters[index]++;
449 if (isReco)
450 reco.counters[index]++;
451 if (nClones > 0)
452 clone.counters[index] += nClones;
453 };
454
455 void IncReco(bool isGhost, bool isBg, TString name)
456 {
457 const int index = indices[name];
458
459 if (isGhost)
460 ghost.counters[index]++;
461 if (isBg)
462 bg.counters[index]++;
463 };
464
465 void PrintEff()
466 {
467 std::cout.setf(ios::fixed);
468 std::cout.setf(ios::showpoint);
469 std::cout.precision(3);
470 std::cout << "Particle : "
471 << " Eff "
472 << " / " << " Ghost "
473 << " / " << "BackGr "
474 << " / " << "N Ghost"
475 << " / " << "N BackGr"
476 << " / " << "N Reco "
477 << " / " << "N Clone "
478 << " | " << " N MC " << std::endl;
479
480 int NCounters = mc.NCounters;
481 for (int iC = 0; iC < NCounters; iC++) {
482 std::cout << names[iC] << " : " << setw(6) << ratio_reco.counters[iC] << " / " << setw(6)
483 << ratio_ghost.counters[iC] // particles w\o MCParticle
484 << " / " << setw(6) << ratio_bg.counters[iC] // particles with incorrect MCParticle
485 << " / " << setw(6) << ghost.counters[iC] << " / " << setw(7) << bg.counters[iC] << " / "
486 << setw(6) << reco.counters[iC] << " / " << setw(7) << clone.counters[iC] << " | " << setw(6)
487 << mc.counters[iC] << std::endl;
488 }
489 };
490
491 friend std::fstream& operator<<(std::fstream& strm, CbmKFPartEfficiencies& a)
492 {
493
494 strm << a.ratio_reco;
495 strm << a.mc;
496 strm << a.reco;
497 strm << a.ratio_ghost;
498 strm << a.ratio_bg;
499 strm << a.ratio_clone;
500 strm << a.ghost;
501 strm << a.bg;
502 strm << a.clone;
503
504 return strm;
505 }
506
507 friend std::fstream& operator>>(std::fstream& strm, CbmKFPartEfficiencies& a)
508 {
509
510 strm >> a.ratio_reco;
511 strm >> a.mc;
512 strm >> a.reco;
513 strm >> a.ratio_ghost;
514 strm >> a.ratio_bg;
515 strm >> a.ratio_clone;
516 strm >> a.ghost;
517 strm >> a.bg;
518 strm >> a.clone;
519
520 return strm;
521 }
522
523 void AddFromFile(TString fileName)
524 {
525 std::fstream file(fileName.Data(), fstream::in);
526 file >> *this;
527 }
528
529 static const int nParticles = 60;
530 int partPDG[nParticles];
531 TString partName[nParticles];
532 TString partTitle[nParticles];
533 vector<vector<int>> partDaughterPdg;
534 float partMHistoMin[nParticles];
535 float partMHistoMax[nParticles];
536
538
539 private:
540 vector<TString> names; // names counters indexed by index of counter
541 map<TString, int> indices; // indices of counters indexed by a counter shortname
542
543 map<int, int> fPdgToIndex;
544
546
549
553
555 TL1TracksCatCounters<int> bg; // background
556 TL1TracksCatCounters<int> clone; // background
557};
558
559#endif
#define ClassDef(name, id)
char * Form(const char *fmt,...)
float partMHistoMin[nParticles]
TL1TracksCatCounters< double > ratio_bg
map< TString, int > indices
TL1TracksCatCounters< double > ratio_ghost
vector< vector< int > > partDaughterPdg
void Inc(bool isReco, int nClones, TString name)
CbmKFPartEfficiencies & operator+=(CbmKFPartEfficiencies &a)
friend std::fstream & operator<<(std::fstream &strm, CbmKFPartEfficiencies &a)
TString partTitle[nParticles]
float partMHistoMax[nParticles]
TL1TracksCatCounters< int > clone
TL1TracksCatCounters< int > bg
virtual void AddCounter(TString shortname, TString name)
void IncReco(bool isGhost, bool isBg, TString name)
TL1TracksCatCounters< int > reco
TL1TracksCatCounters< int > mc
TString partName[nParticles]
friend std::fstream & operator>>(std::fstream &strm, CbmKFPartEfficiencies &a)
void AddFromFile(TString fileName)
TL1TracksCatCounters< double > ratio_reco
TL1TracksCatCounters< int > ghost
TL1TracksCatCounters< double > ratio_clone
const char * Data() const
counters used for efficiency calculation