CbmRoot
CbmKresConversionBG.cxx
Go to the documentation of this file.
1 
14 #include "CbmKresConversionBG.h"
15 
16 #include "FairRootManager.h"
17 
18 
19 using namespace std;
20 
22 
24 
26  FairRootManager* ioman = FairRootManager::Instance();
27  if (nullptr == ioman) {
28  Fatal("CbmKresConversionBG::Init", "RootManager not instantised!");
29  }
30 
31  fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
32  if (nullptr == fMcTracks) {
33  Fatal("CbmKresConversionBG::Init", "No MCTrack array!");
34  }
35 }
36 
38  CbmMCTrack* mctrack2,
39  CbmMCTrack* mctrack3,
40  CbmMCTrack* mctrack4,
41  Double_t invmassRecoPi0,
42  vector<TH1*> BGCases) {
43  /*
44  BGCases[0] = Case1 --> correctly reconstructed signal
45  BGCases[1] = Case2 --> gammas are wrongly combined, but 4 particles come from one pi0
46  BGCases[2] = Case3 --> gammas combined correctly, but not from one pi0 (combinatorial BG == Event Mixing Technique)
47  BGCases[3] = Case4 --> 3 lepptons from one pi0, fourth is from somewhere
48  BGCases[4] = Case5 --> one gamma correctly combined, second is wrongly
49  BGCases[5] = Case6 --> both gammas are wrongly combined
50  BGCases[6] = Case7 --> 1 from 4 particles are not electrons
51  BGCases[7] = Case8 --> 2 from 4 particles are not electrons
52  BGCases[8] = Case9 --> 3 from 4 particles are not electrons
53  BGCases[9] = Case10 --> 4 from 4 particles are not electrons
54 
55  BGCases[10] = PdgCase8
56  BGCases[11] = PdgCase8mothers
57  BGCases[12] = sameMIDcase8
58  BGCases[13] = sameGRIDcase8
59  BGCases[14] = Case1ZYPos
60  BGCases[15] = sameMIDcase8_mothedPDG // useless. Almost the same like BGCases[11]
61  BGCases[16] = PdgCase8NonEComeFromTarget
62  BGCases[17] = PdgCase8NonE_NOT_FromTarget
63  BGCases[18] = PdgCase8motherNonE
64  BGCases[19] = Case8ElFromDalitz
65  BGCases[20] = Case8NonElFrom_pn
66  BGCases[21] = Case8NonElFrom_eta
67  BGCases[22] = Case8NonElFrom_kaon
68  BGCases[23] = sameMIDcase8NonEPdg
69  BGCases[24] = sameMIDcase8NonEMotherPdg
70  BGCases[25] = sameMIDcase8NonEMotherIM
71  BGCases[26] = sameMIDcase8NonEPdgFromTarget
72  BGCases[27] = sameMIDcase8NonEComeFromTargetIM
73  BGCases[28] = sameMIDcase8NonEComeFromTargetP
74  BGCases[29] = sameMIDcase8NonEComeFromTargetPt
75  */
76 
77  int pdg1 = mctrack1->GetPdgCode();
78  int pdg2 = mctrack2->GetPdgCode();
79  int pdg3 = mctrack3->GetPdgCode();
80  int pdg4 = mctrack4->GetPdgCode();
81  int motherId1 = mctrack1->GetMotherId();
82  int motherId2 = mctrack2->GetMotherId();
83  int motherId3 = mctrack3->GetMotherId();
84  int motherId4 = mctrack4->GetMotherId();
85 
86  int NumOfOthers = 0;
87  if (TMath::Abs(pdg1) != 11) NumOfOthers++;
88  if (TMath::Abs(pdg2) != 11) NumOfOthers++;
89  if (TMath::Abs(pdg3) != 11) NumOfOthers++;
90  if (TMath::Abs(pdg4) != 11) NumOfOthers++;
91 
92  // cases 7-10
93  if (NumOfOthers == 4) BGCases[9]->Fill(invmassRecoPi0);
94  if (NumOfOthers == 3) BGCases[8]->Fill(invmassRecoPi0);
95  // case 8 !!!!
96  if (NumOfOthers == 2) {
97  BGCases[7]->Fill(invmassRecoPi0);
98  BGCases[10]->Fill(pdg1);
99  BGCases[10]->Fill(pdg2);
100  BGCases[10]->Fill(pdg3);
101  BGCases[10]->Fill(pdg4);
102 
103  CbmMCTrack* mother1 = nullptr;
104  CbmMCTrack* mother2 = nullptr;
105  CbmMCTrack* mother3 = nullptr;
106  CbmMCTrack* mother4 = nullptr;
107  if (TMath::Abs(pdg1) == 11)
108  mother1 = (CbmMCTrack*) fMcTracks->At(motherId1);
109  if (TMath::Abs(pdg2) == 11)
110  mother2 = (CbmMCTrack*) fMcTracks->At(motherId2);
111  if (TMath::Abs(pdg3) == 11)
112  mother3 = (CbmMCTrack*) fMcTracks->At(motherId3);
113  if (TMath::Abs(pdg4) == 11)
114  mother4 = (CbmMCTrack*) fMcTracks->At(motherId4);
115 
116  CbmMCTrack* mother1N = nullptr;
117  CbmMCTrack* mother2N = nullptr;
118  CbmMCTrack* mother3N = nullptr;
119  CbmMCTrack* mother4N = nullptr;
120  if (TMath::Abs(pdg1) != 11 && motherId1 != -1)
121  mother1N = (CbmMCTrack*) fMcTracks->At(motherId1);
122  if (TMath::Abs(pdg2) != 11 && motherId2 != -1)
123  mother2N = (CbmMCTrack*) fMcTracks->At(motherId2);
124  if (TMath::Abs(pdg3) != 11 && motherId3 != -1)
125  mother3N = (CbmMCTrack*) fMcTracks->At(motherId3);
126  if (TMath::Abs(pdg4) != 11 && motherId4 != -1)
127  mother4N = (CbmMCTrack*) fMcTracks->At(motherId4);
128 
129  if (nullptr != mother1) BGCases[11]->Fill(mother1->GetPdgCode());
130  if (nullptr != mother2) BGCases[11]->Fill(mother2->GetPdgCode());
131  if (nullptr != mother3) BGCases[11]->Fill(mother3->GetPdgCode());
132  if (nullptr != mother4) BGCases[11]->Fill(mother4->GetPdgCode());
133 
134  std::vector<int> testM;
135  if (TMath::Abs(pdg1) == 11) testM.push_back(motherId1);
136  if (TMath::Abs(pdg2) == 11) testM.push_back(motherId2);
137  if (TMath::Abs(pdg3) == 11) testM.push_back(motherId3);
138  if (TMath::Abs(pdg4) == 11) testM.push_back(motherId4);
139 
140  if (testM.size() == 2 && testM[0] == testM[1]) {
141  BGCases[12]->Fill(invmassRecoPi0);
142  if (testM[0] != -1) {
143  CbmMCTrack* Mam = (CbmMCTrack*) fMcTracks->At(testM[0]);
144  BGCases[15]->Fill(Mam->GetPdgCode());
145  if (Mam->GetPdgCode() == 111) BGCases[19]->Fill(invmassRecoPi0);
146  }
147 
148  if (TMath::Abs(pdg1) != 11 && motherId1 != -1) {
149  BGCases[23]->Fill(pdg1);
150  BGCases[24]->Fill(mother1N->GetPdgCode());
151  BGCases[25]->Fill(invmassRecoPi0);
152  }
153  if (TMath::Abs(pdg2) != 11 && motherId2 != -1) {
154  BGCases[23]->Fill(pdg2);
155  BGCases[24]->Fill(mother2N->GetPdgCode());
156  BGCases[25]->Fill(invmassRecoPi0);
157  }
158  if (TMath::Abs(pdg3) != 11 && motherId3 != -1) {
159  BGCases[23]->Fill(pdg3);
160  BGCases[24]->Fill(mother3N->GetPdgCode());
161  BGCases[25]->Fill(invmassRecoPi0);
162  }
163  if (TMath::Abs(pdg4) != 11 && motherId4 != -1) {
164  BGCases[23]->Fill(pdg4);
165  BGCases[24]->Fill(mother4N->GetPdgCode());
166  BGCases[25]->Fill(invmassRecoPi0);
167  }
168 
169  if (TMath::Abs(pdg1) != 11 && motherId1 == -1) {
170  BGCases[26]->Fill(pdg1);
171  BGCases[27]->Fill(invmassRecoPi0, 0.5);
172  BGCases[28]->Fill(mctrack1->GetP());
173  BGCases[29]->Fill(mctrack1->GetPt());
174  }
175  if (TMath::Abs(pdg2) != 11 && motherId2 == -1) {
176  BGCases[26]->Fill(pdg2);
177  BGCases[27]->Fill(invmassRecoPi0, 0.5);
178  BGCases[28]->Fill(mctrack2->GetP());
179  BGCases[29]->Fill(mctrack2->GetPt());
180  }
181  if (TMath::Abs(pdg3) != 11 && motherId3 == -1) {
182  BGCases[26]->Fill(pdg3);
183  BGCases[27]->Fill(invmassRecoPi0, 0.5);
184  BGCases[28]->Fill(mctrack3->GetP());
185  BGCases[29]->Fill(mctrack3->GetPt());
186  }
187  if (TMath::Abs(pdg4) != 11 && motherId4 == -1) {
188  BGCases[26]->Fill(pdg4);
189  BGCases[27]->Fill(invmassRecoPi0, 0.5);
190  BGCases[28]->Fill(mctrack4->GetP());
191  BGCases[29]->Fill(mctrack4->GetPt());
192  }
193  }
194 
195  std::vector<int> testGR;
196  if (TMath::Abs(pdg1) == 11 && nullptr != mother1)
197  testGR.push_back(mother1->GetMotherId());
198  if (TMath::Abs(pdg2) == 11 && nullptr != mother2)
199  testGR.push_back(mother2->GetMotherId());
200  if (TMath::Abs(pdg3) == 11 && nullptr != mother3)
201  testGR.push_back(mother3->GetMotherId());
202  if (TMath::Abs(pdg4) == 11 && nullptr != mother4)
203  testGR.push_back(mother4->GetMotherId());
204 
205  if (testGR.size() == 2) {
206  if (testGR[0] == testGR[1]) { BGCases[13]->Fill(invmassRecoPi0); }
207  }
208 
209  testGR.clear();
210  testM.clear();
211 
212 
213  if (TMath::Abs(pdg1) != 11 && motherId1 == -1)
214  BGCases[16]->Fill(mctrack1->GetPdgCode());
215  if (TMath::Abs(pdg2) != 11 && motherId2 == -1)
216  BGCases[16]->Fill(mctrack2->GetPdgCode());
217  if (TMath::Abs(pdg3) != 11 && motherId3 == -1)
218  BGCases[16]->Fill(mctrack3->GetPdgCode());
219  if (TMath::Abs(pdg4) != 11 && motherId4 == -1)
220  BGCases[16]->Fill(mctrack4->GetPdgCode());
221 
222 
223  if (TMath::Abs(pdg1) != 11 && nullptr != mother1N) {
224  BGCases[18]->Fill(mother1N->GetPdgCode());
225  BGCases[17]->Fill(pdg1);
226  if (mother1N->GetPdgCode() == 2112 || mother1N->GetPdgCode() == 2212)
227  BGCases[20]->Fill(invmassRecoPi0);
228  if (mother1N->GetPdgCode() == 221) BGCases[21]->Fill(invmassRecoPi0);
229  if (mother1N->GetPdgCode() == 310) BGCases[22]->Fill(invmassRecoPi0);
230  }
231  if (TMath::Abs(pdg2) != 11 && nullptr != mother2N) {
232  BGCases[18]->Fill(mother2N->GetPdgCode());
233  BGCases[17]->Fill(pdg2);
234  if (mother2N->GetPdgCode() == 2112 || mother2N->GetPdgCode() == 2212)
235  BGCases[20]->Fill(invmassRecoPi0);
236  if (mother2N->GetPdgCode() == 221) BGCases[21]->Fill(invmassRecoPi0);
237  if (mother2N->GetPdgCode() == 310) BGCases[22]->Fill(invmassRecoPi0);
238  }
239  if (TMath::Abs(pdg3) != 11 && nullptr != mother3N) {
240  BGCases[18]->Fill(mother3N->GetPdgCode());
241  BGCases[17]->Fill(pdg3);
242  if (mother3N->GetPdgCode() == 2112 || mother3N->GetPdgCode() == 2212)
243  BGCases[20]->Fill(invmassRecoPi0);
244  if (mother3N->GetPdgCode() == 221) BGCases[21]->Fill(invmassRecoPi0);
245  if (mother3N->GetPdgCode() == 310) BGCases[22]->Fill(invmassRecoPi0);
246  }
247  if (TMath::Abs(pdg4) != 11 && nullptr != mother4N) {
248  BGCases[18]->Fill(mother4N->GetPdgCode());
249  BGCases[17]->Fill(pdg4);
250  if (mother4N->GetPdgCode() == 2112 || mother4N->GetPdgCode() == 2212)
251  BGCases[20]->Fill(invmassRecoPi0);
252  if (mother4N->GetPdgCode() == 221) BGCases[21]->Fill(invmassRecoPi0);
253  if (mother4N->GetPdgCode() == 310) BGCases[22]->Fill(invmassRecoPi0);
254  }
255  }
256 
257  if (NumOfOthers == 1) BGCases[6]->Fill(invmassRecoPi0);
258  // cases 1-6
259  if (NumOfOthers == 0) {
260  if (motherId1 != -1 && motherId2 != -1 && motherId3 != -1
261  && motherId4 != -1) {
262  CbmMCTrack* mother1 = (CbmMCTrack*) fMcTracks->At(motherId1);
263  CbmMCTrack* mother2 = (CbmMCTrack*) fMcTracks->At(motherId2);
264  CbmMCTrack* mother3 = (CbmMCTrack*) fMcTracks->At(motherId3);
265  CbmMCTrack* mother4 = (CbmMCTrack*) fMcTracks->At(motherId4);
266  if (nullptr != mother1 && nullptr != mother2 && nullptr != mother3
267  && nullptr != mother4) {
268  // int mcMotherPdg1 = mother1->GetPdgCode();
269  // int mcMotherPdg2 = mother2->GetPdgCode();
270  // int mcMotherPdg3 = mother3->GetPdgCode();
271  // int mcMotherPdg4 = mother4->GetPdgCode();
272  int grandmotherId1 = mother1->GetMotherId();
273  int grandmotherId2 = mother2->GetMotherId();
274  int grandmotherId3 = mother3->GetMotherId();
275  int grandmotherId4 = mother4->GetMotherId();
276  // case 1
277  if (motherId1 == motherId2 && motherId3 == motherId4
278  && grandmotherId1 == grandmotherId3) {
279  if (grandmotherId1 != -1) {
280  CbmMCTrack* grm1 = (CbmMCTrack*) fMcTracks->At(grandmotherId1);
281  if (
282  nullptr != grm1
283  && grm1->GetPdgCode()
284  == 111) { // && mctrack1->GetStartZ() < 4.5 && mctrack3->GetStartZ() < 4.5){
285  BGCases[0]->Fill(invmassRecoPi0);
286  BGCases[14]->Fill(mctrack1->GetStartZ(), mctrack1->GetStartY());
287  BGCases[14]->Fill(mctrack3->GetStartZ(), mctrack3->GetStartY());
288  }
289  }
290  }
291  if (motherId1 != motherId2 && motherId3 != motherId4) {
292  if (grandmotherId1 == grandmotherId3
293  && grandmotherId1 == grandmotherId4
294  && grandmotherId1 == grandmotherId2) {
295  BGCases[1]->Fill(invmassRecoPi0);
296  } else {
297  BGCases[5]->Fill(invmassRecoPi0);
298  }
299  }
300 
301  if (motherId1 == motherId2 && motherId3 == motherId4
302  && grandmotherId1 != grandmotherId3)
303  BGCases[2]->Fill(invmassRecoPi0);
304 
305  if ((motherId1 == motherId2 && motherId3 != motherId4)
306  || (motherId1 != motherId2 && motherId3 == motherId4)) {
307  if ((grandmotherId1 == grandmotherId3
308  && grandmotherId1 == grandmotherId4
309  && grandmotherId1 != grandmotherId2)
310  || (grandmotherId1 == grandmotherId2
311  && grandmotherId1 == grandmotherId4
312  && grandmotherId1 != grandmotherId3)
313  || (grandmotherId1 == grandmotherId2
314  && grandmotherId1 == grandmotherId3
315  && grandmotherId1 != grandmotherId4)
316  || (grandmotherId2 == grandmotherId3
317  && grandmotherId2 == grandmotherId4
318  && grandmotherId2 != grandmotherId1)
319  || (grandmotherId2 == grandmotherId1
320  && grandmotherId2 == grandmotherId4
321  && grandmotherId2 != grandmotherId3)
322  || (grandmotherId2 == grandmotherId1
323  && grandmotherId2 == grandmotherId3
324  && grandmotherId2 != grandmotherId4)
325  || (grandmotherId3 == grandmotherId1
326  && grandmotherId3 == grandmotherId2
327  && grandmotherId3 != grandmotherId4)
328  || (grandmotherId3 == grandmotherId1
329  && grandmotherId3 == grandmotherId4
330  && grandmotherId3 != grandmotherId2)
331  || (grandmotherId3 == grandmotherId2
332  && grandmotherId3 == grandmotherId4
333  && grandmotherId3 != grandmotherId1)
334  || (grandmotherId4 == grandmotherId1
335  && grandmotherId4 == grandmotherId2
336  && grandmotherId4 != grandmotherId3)
337  || (grandmotherId4 == grandmotherId1
338  && grandmotherId4 == grandmotherId3
339  && grandmotherId4 != grandmotherId2)
340  || (grandmotherId4 == grandmotherId2
341  && grandmotherId4 == grandmotherId3
342  && grandmotherId4 != grandmotherId1)) {
343  BGCases[3]->Fill(invmassRecoPi0);
344  } else {
345  BGCases[4]->Fill(invmassRecoPi0);
346  }
347  }
348  }
349  }
350  }
351 }
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
CbmKresConversionBG::Exec
void Exec(CbmMCTrack *mctrack1, CbmMCTrack *mctrack2, CbmMCTrack *mctrack3, CbmMCTrack *mctrack4, Double_t invmassRecoPi0, vector< TH1 * > BGCases)
Definition: CbmKresConversionBG.cxx:37
CbmMCTrack::GetStartZ
Double_t GetStartZ() const
Definition: CbmMCTrack.h:77
CbmKresConversionBG::CbmKresConversionBG
CbmKresConversionBG()
Definition: CbmKresConversionBG.cxx:21
CbmMCTrack::GetPt
Double_t GetPt() const
Definition: CbmMCTrack.h:99
CbmMCTrack::GetStartY
Double_t GetStartY() const
Definition: CbmMCTrack.h:76
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmKresConversionBG.h
PairAnalysisStyler::Fill
static Int_t Fill[]
Definition: PairAnalysisStyleDefs.h:82
CbmKresConversionBG::~CbmKresConversionBG
virtual ~CbmKresConversionBG()
Definition: CbmKresConversionBG.cxx:23
CbmMCTrack::GetP
Double_t GetP() const
Definition: CbmMCTrack.h:100
CbmKresConversionBG::Init
void Init()
Definition: CbmKresConversionBG.cxx:25