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