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