AliPhysics  aaf9c62 (aaf9c62)
AliAODConversionPhoton.cxx
Go to the documentation of this file.
1 #include "AliAODMCParticle.h"
2 #include "AliAODMCHeader.h"
5 
6 using namespace std;
7 
9 
13  fCaloClusterRef(-1),
14  fDCArPrimVtx(0),
15  fDCAzPrimVtx(0),
16  fInvMassPair(0),
17  fNCaloPhotonMCLabels(0),
18  fNCaloPhotonMotherMCLabels(0),
19  fCaloPhotonMCFlags(0),
20  fPairedId(-1),
21  fCaloPhoton(kFALSE),
22  fUseForMesonPair(kTRUE)
23 {
24  // initialize calo photon MC labels
25  for (Int_t i =0; i<50; i++){
26  fCaloPhotonMCLabels[i]=-1;
27  }
28  for (Int_t i =0; i<20; i++){
29  fCaloPhotonMotherMCLabels[i]=-1;
30  }
31  //Standard constructor
32 }
33 
35 AliAODConversionParticle(kfphoton),
37  fCaloClusterRef(-1),
38  fDCArPrimVtx(0),
39  fDCAzPrimVtx(0),
40  fInvMassPair(0),
41  fNCaloPhotonMCLabels(0),
42  fNCaloPhotonMotherMCLabels(0),
43  fCaloPhotonMCFlags(0),
44  fPairedId(-1),
45  fCaloPhoton(kFALSE),
46  fUseForMesonPair(kTRUE)
47 {
48  //Constructor from kfphoton
49  // puts the mass to zero and store dilepton mass
50  SetMass(kfphoton->M());
51 
52  //SetE(P());
53  // initialize calo photon MC labels
54  for (Int_t i =0; i<50; i++){
55  fCaloPhotonMCLabels[i]=-1;
56  }
57  for (Int_t i =0; i<20; i++){
59  }
60 
61 }
62 
66  fCaloClusterRef(-1),
67  fDCArPrimVtx(0),
68  fDCAzPrimVtx(0),
69  fInvMassPair(0),
73  fPairedId(-1),
74  fCaloPhoton(kFALSE),
75  fUseForMesonPair(kTRUE)
76 {
77  //Constructor from TLorentzVector
78 
79  // initialize calo photon MC labels
80  for (Int_t i =0; i<50; i++){
81  fCaloPhotonMCLabels[i]=-1;
82  }
83  for (Int_t i =0; i<20; i++){
85  }
86 }
87 
88 
89 
91 AliAODConversionParticle(original),
92 AliConversionPhotonBase(original),
94  fDCArPrimVtx(original.fDCArPrimVtx),
95  fDCAzPrimVtx(original.fDCAzPrimVtx),
96  fInvMassPair(original.fInvMassPair),
100  fPairedId(original.fPairedId),
101  fCaloPhoton(original.fCaloPhoton),
103 {
104  //Copy constructor
105 
106  // initialize calo photon MC labels
107  for (Int_t i =0; i<50; i++){
109  }
110  for (Int_t i =0; i<20; i++){
112  }
113 }
114 
116 {
117  // empty standard destructor
118 }
119 
121 {
122  // assignment operator
123  return *this;
124 }
125 
128 
129  Double_t primCo[3] = {primVertex->GetX(),primVertex->GetY(),primVertex->GetZ()};
130 
131  Double_t absoluteP = TMath::Sqrt(TMath::Power(GetPx(),2) + TMath::Power(GetPy(),2) + TMath::Power(GetPz(),2));
132  Double_t p[3] = {GetPx()/absoluteP,GetPy()/absoluteP,GetPz()/absoluteP};
133  Double_t CP[3];
134 
135  CP[0] = fConversionPoint[0] - primCo[0];
136  CP[1] = fConversionPoint[1] - primCo[1];
137  CP[2] = fConversionPoint[2] - primCo[2];
138 
139  Double_t Lambda = - (CP[0]*p[0]+CP[1]*p[1]+CP[2]*p[2])/(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
140 
141  Double_t S[3];
142  S[0] = fConversionPoint[0] + p[0]*Lambda;
143  S[1] = fConversionPoint[1] + p[1]*Lambda;
144  S[2] = fConversionPoint[2] + p[2]*Lambda;
145 
146  fDCArPrimVtx = TMath::Sqrt( TMath::Power(primCo[0]-S[0],2) + TMath::Power(primCo[1]-S[1],2));
147  fDCAzPrimVtx = primCo[2]-S[2];
148 
149  return;
150 }
151 
152 
153 void AliAODConversionPhoton::SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort){
154 
155  Bool_t isPhoton = kFALSE; // largest contribution to cluster is photon
156  Bool_t isElectron = kFALSE; // largest contribution to cluster is electron
157  Bool_t isConversion = kFALSE; // largest contribution to cluster is converted electron
158  Bool_t isConversionFullyContained = kFALSE; // largest contribution to cluster is converted electron, second electron has been found in same cluster
159  Bool_t isMerged = kFALSE; // cluster contains more than one particle from the same decay
160  Bool_t isMergedPartConv = kFALSE; // cluster contains more than one particle from the same decay and at least one of the particles came from a conversion
161  Bool_t isDalitz = kFALSE; // this cluster was created by a particle stemming from a dalitz decay
162  Bool_t isDalitzMerged = kFALSE; // this cluster was created by a particle stemming from a dalitz decay and more than one particle of the dalitz decay is contained in the cluster
163  Bool_t isPhotonWithElecMother = kFALSE; // this cluster is from a photon with an electron as mother
164  Bool_t isShower = kFALSE; // this cluster contains as a largest contribution a particle from a shower or radiative process
165  Bool_t isSubLeadingEM = kFALSE; // cluster contains at least one electron or photon from a pi0, eta or eta_prime in subleading contribution
166  Bool_t isElectronFromFragPhoton = kFALSE; // largest contribution to cluster is from converted electron, but photon stems from fragmentation photon ( q -> q gamma)
167 
168  TParticle* Photon = 0x0;
169  if (fNCaloPhotonMCLabels==0) return;
170 
171  if (enableSort){
172  // sort the array according to the energy of contributing particles
173  if (fNCaloPhotonMCLabels>1){
174  // cout << "start sorting" << endl;
175  Int_t* sortIdx = new Int_t[fNCaloPhotonMCLabels];
176  Double_t* energyPerPart = new Double_t[fNCaloPhotonMCLabels];
177  Long_t* orginalContrib = new Long_t[fNCaloPhotonMCLabels];
178  for (Int_t i = 0; i < fNCaloPhotonMCLabels; i++){
179  orginalContrib[i] = fCaloPhotonMCLabels[i];
180  if (fCaloPhotonMCLabels[i]> -1){
181  TParticle* dummy = mcEvent->Particle(fCaloPhotonMCLabels[i]);
182  if (dummy){
183  energyPerPart[i] = dummy->Energy();
184  // suppress energy of hadrons !!! DIRTY hack !!!
185  if (!(TMath::Abs(dummy->GetPdgCode())== 11 || TMath::Abs(dummy->GetPdgCode())== 22)){
186  // cout << "suppressed hadron energy for:" << dummy->GetPdgCode() << endl;
187  energyPerPart[i]= 0.25; // put energy to mip
188  }
189  }
190  } else {
191  energyPerPart[i] = 0;
192  }
193  }
194 
195  TMath::Sort(fNCaloPhotonMCLabels,energyPerPart,sortIdx);
196  for(Int_t index = 0; index < fNCaloPhotonMCLabels; index++) {
197  fCaloPhotonMCLabels[index] = orginalContrib [sortIdx[index]] ;
198 
199  }
200  delete [] sortIdx;
201  delete [] energyPerPart;
202  delete [] orginalContrib;
203  }
204  }
205 
206  if(GetCaloPhotonMCLabel(0)>-1) Photon = mcEvent->Particle(GetCaloPhotonMCLabel(0));
207 
208  if(Photon == NULL){
209  return;
210  }
211 
212  Int_t particleMotherLabel = Photon->GetMother(0);
213  Int_t particleGrandMotherLabel = -1;
214  Int_t particleGrandMotherX2Label = -1;
215  Int_t particleGrandMotherX3Label = -1;
216  Int_t particleGrandMotherX4Label = -1;
217  Int_t particleGrandMotherX5Label = -1;
218  Int_t particleGrandMotherX6Label = -1;
219  Int_t particleGrandMotherX7Label = -1;
220 
221  Int_t particleMotherPDG = -1;
222  Int_t particleGrandMotherPDG = -1;
223  Int_t particleGrandMotherX2PDG = -1;
224  Int_t particleGrandMotherX3PDG = -1;
225  Int_t particleGrandMotherX4PDG = -1;
226  Int_t particleGrandMotherX5PDG = -1;
227  Int_t particleGrandMotherX6PDG = -1;
228 
229  Int_t particleMotherNDaugthers = 0;
230  Int_t particleGrandMotherNDaugthers = 0;
231 
232  if (particleMotherLabel > -1){
233  particleMotherNDaugthers = mcEvent->Particle(Photon->GetMother(0))->GetNDaughters();
234  particleGrandMotherLabel = mcEvent->Particle(Photon->GetMother(0))->GetMother(0);
235  particleMotherPDG = mcEvent->Particle(Photon->GetMother(0))->GetPdgCode();
236  if (particleGrandMotherLabel > -1){
237  particleGrandMotherPDG = mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode();
238  particleGrandMotherNDaugthers = mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetNDaughters();
239  particleGrandMotherX2Label = mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0);
240  if (particleGrandMotherX2Label > -1){
241  particleGrandMotherX2PDG = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetPdgCode();
242  particleGrandMotherX3Label = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0);
243  if (particleGrandMotherX3Label > -1){
244  particleGrandMotherX3PDG = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetPdgCode();
245  particleGrandMotherX4Label = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0);
246  if (particleGrandMotherX4Label > -1){
247  particleGrandMotherX4PDG = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetPdgCode();
248  particleGrandMotherX5Label = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0);
249  if (particleGrandMotherX5Label > -1){
250  particleGrandMotherX5PDG = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetPdgCode();
251  particleGrandMotherX6Label = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0);
252  if (particleGrandMotherX6Label > -1){
253  particleGrandMotherX6PDG = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetPdgCode();
254  particleGrandMotherX7Label = mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(mcEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0))->GetMother(0);
255  }
256  }
257  }
258  }
259  }
260  }
261  }
262 
263  //determine mother/grandmother of leading particle and if it is pion/eta/eta_prime: fill array fCaloPhotonMotherMCLabels at position 0
264  if (particleMotherLabel > -1){
265  if( TMath::Abs(particleMotherPDG) == 111 || TMath::Abs(particleMotherPDG) == 221 || TMath::Abs(particleMotherPDG) == 331 ){
266  fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
268  } else if (particleGrandMotherLabel > -1 && TMath::Abs(particleMotherPDG) == 22 &&
269  (TMath::Abs(particleGrandMotherPDG) == 111 || TMath::Abs(particleGrandMotherPDG) == 221 || TMath::Abs(particleGrandMotherPDG) == 331) ){
270  fCaloPhotonMotherMCLabels[0] = particleGrandMotherLabel;
272  } else {
273  fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
275  }
276  }
277 
278  // Check whether the first contribution was photon
279  if(TMath::Abs(mcEvent->Particle(GetCaloPhotonMCLabel(0))->GetPdgCode()) == 22){
280  isPhoton = kTRUE;
281  // did it decay via the dalitz channel
282  if (particleMotherLabel > -1 && particleMotherNDaugthers == 3)
283  isDalitz = kTRUE;
284  // Test whether particle stems from a shower or radiation
285  if (TMath::Abs(particleMotherPDG) == 11){ // check whether photon stems from electron
286  isPhotonWithElecMother = kTRUE;
287  if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
288  if (TMath::Abs(particleGrandMotherPDG) == 22 )
289  isShower = kTRUE; // check whether grandmother is a photon (meaning this is most likely a shower)
290  }
291  }
292  }
293 
294  // Check whether the first contribution was electron
295  if( TMath::Abs(mcEvent->Particle(GetCaloPhotonMCLabel(0))->GetPdgCode()) == 11 ){
296  isElectron = kTRUE;
297  if (particleMotherLabel > -1) {
298  // was it a conversion
299  if (TMath::Abs(particleMotherPDG) == 22)
300  isConversion = kTRUE;
301  // did it decay via the dalitz channel
302  if (particleGrandMotherLabel > -1 && particleGrandMotherNDaugthers == 3 )
303  isDalitz = kTRUE;
304  }
305  if (particleGrandMotherLabel > -1){ // check whether electron has a grandmother
306  if (TMath::Abs(particleGrandMotherPDG) == 11 || TMath::Abs(particleGrandMotherPDG) == 22){ // test whether electron has photon or electron as grandmother (meaning will most likely be a shower)
307  isShower = kTRUE;
308  }
309  }
310  // consider the rare case, where the conversion electron stems from photon, which stems from electron, which stems from photon, ...
311  if (isConversion && TMath::Abs(particleGrandMotherPDG) == 11 && particleGrandMotherX2PDG == 22){
312  SetCaloPhotonMCLabel(0,particleGrandMotherLabel);
313  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX3Label;
314  if (TMath::Abs(particleGrandMotherX3PDG) == 11 && particleGrandMotherX4PDG == 22 ){
315  SetCaloPhotonMCLabel(0,particleGrandMotherX3Label);
316  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX5Label;
317  if (TMath::Abs(particleGrandMotherX5PDG) == 11 && particleGrandMotherX6PDG == 22 ){
318  SetCaloPhotonMCLabel(0,particleGrandMotherX5Label);
319  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX7Label;
320  }
321  }
322  }
323 
324  // consider the case, where a photon stems from a photon which stems from a photon etc...which is common for frag. photons
325  if (particleMotherLabel > -1){
326  TParticle *dummyMother = mcEvent->Particle(particleMotherLabel);
327  Bool_t originReached = kFALSE;
328  if (dummyMother){
329  while (dummyMother->GetPdgCode() == 22 && !originReached){ // follow conversion photon's history, as long as the mother is a photon
330  if (dummyMother->GetMother(0) > -1){
331  dummyMother = mcEvent->Particle(dummyMother->GetMother(0));
332  if (TMath::Abs(dummyMother->GetPdgCode()) == 11){ // in case of additional conversion skip to photon's grandma, which should be a photon
333  if (dummyMother->GetMother(0) > -1){
334  dummyMother = mcEvent->Particle(dummyMother->GetMother(0));
335  } else {
336  originReached = kTRUE;
337  }
338  } else {
339  originReached = kTRUE;
340  }
341  isElectronFromFragPhoton = (TMath::Abs(dummyMother->GetPdgCode()) < 6);// photon stems from quark = fragmentation photon
342  } else {
343  originReached = kTRUE;
344  }
345  }
346  }
347  }
348  }
349 
350  Bool_t enablePrintOuts = kFALSE;
351 // if (fNCaloPhotonMCLabels>2)
352 // enablePrintOuts = kTRUE;
353 
354  // check whether there were other contributions to the cluster
355  if (fNCaloPhotonMCLabels>1){
356  TParticle* dummyPart =NULL;
357 
358  for (Int_t i = 1; i< fNCaloPhotonMCLabels; i++){
359  if (i > 49) continue; // abort if more than 50 entries to the cluster have been checked (more are not stored in these objects)
360  if (enablePrintOuts) cout << "checking particle: " << i << endl;
361  if (GetCaloPhotonMCLabel(i) < 0) continue;
362  dummyPart = mcEvent->Particle(GetCaloPhotonMCLabel(i));
363  Int_t dummyPartMotherLabel = dummyPart->GetMother(0);
364  Int_t dummyPartGrandMotherLabel = -1;
365  Int_t dummyPartMotherPDG = -1;
366  Int_t dummyPartGrandMotherPDG = -1;
367  // check whether this particle has a mother & obtain the pdg code
368  if (dummyPartMotherLabel > -1){
369  dummyPartGrandMotherLabel = mcEvent->Particle(dummyPart->GetMother(0))->GetMother(0);
370  dummyPartMotherPDG = mcEvent->Particle(dummyPart->GetMother(0))->GetPdgCode();
371  // check whether this particle has a grandmother & obtain its pdg code
372  if (dummyPartGrandMotherLabel > -1){
373  dummyPartGrandMotherPDG = mcEvent->Particle(mcEvent->Particle(dummyPart->GetMother(0))->GetMother(0))->GetPdgCode();
374  }
375  }
376  // largest contribution was from photon and is not from shower or electron mother
377  if (isPhoton && (!isShower || !isPhotonWithElecMother )){
378  if (enablePrintOuts) cout << "lead gamma" << endl;
379  if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
380  if (dummyPartMotherLabel == particleMotherLabel)
381  isMerged = kTRUE; // test whether current and first particle have the same mother => i.e. other gamma from decay or dalitz electron
382  if (dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother
383  // check whether particle is an electron from a conversion of a photon from the original mother
384  if (TMath::Abs(dummyPart->GetPdgCode()) == 11 && dummyPartGrandMotherLabel == particleMotherLabel )
385  isMergedPartConv = kTRUE;
386  // check whether particle is an electron from a dalitz decay from the original mother
387  if (TMath::Abs(dummyPart->GetPdgCode()) == 11 && dummyPartMotherLabel == particleMotherLabel )
388  isDalitzMerged = kTRUE;
389  }
390  }
391  }
392 
393  // largest contribution was from electron & not a from a shower
394  if (isElectron && !isShower){
395  if (enablePrintOuts) cout << "lead electron" << endl;
396  if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
397  if ( TMath::Abs(dummyPart->GetPdgCode()) == 11 && isConversion && dummyPartMotherLabel == particleMotherLabel ) {
398  isConversionFullyContained = kTRUE; // test whether conversion is fully contained in cluster
399  if (enablePrintOuts) cout << "found full conversion" << endl;
400  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 11) { // current particle is an electron
401  if (enablePrintOuts) cout << "current is electron" << endl;
402  // check whether current particle is a shower
403  Bool_t isShowerCurrent = kFALSE;
404  if (TMath::Abs(dummyPartGrandMotherPDG) == 11)
405  isShowerCurrent = kTRUE;
406  if (TMath::Abs(dummyPartGrandMotherPDG) == 22)
407  isShowerCurrent = kTRUE;
408 
409  // check whether current particle is a conversion
410  Bool_t isConvCurrent = kFALSE;
411  if (TMath::Abs(dummyPartMotherPDG) == 22 && !isShowerCurrent)
412  isConvCurrent = kTRUE;
413 
414  if (enablePrintOuts) cout << "conv current: " << isConvCurrent << "\t shower current: " << isShowerCurrent << endl;
415  // check whether orginal electron and this electron stem from the same particle and electron originated in dalitz decay
416  if( dummyPartMotherLabel == particleMotherLabel && TMath::Abs(particleMotherPDG) != 22 && !isShowerCurrent ) {
417  isDalitzMerged = kTRUE;
418  isMerged = kTRUE;
419  // both particles are from conversions
420  } else if (isConversion && isConvCurrent){
421  if (particleGrandMotherLabel > -1 && dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother and current particle has one as well
422  // check whether orginal electron and this electron stem from the same particle and electron stems from conversion
423  if( dummyPartGrandMotherLabel == particleGrandMotherLabel && !isShowerCurrent )
424  isMergedPartConv = kTRUE;
425  }
426  // check whether current electron is from conversion & orginal e are from same mother
427  } else if (dummyPartGrandMotherLabel > -1 && isConvCurrent){
428  if (dummyPartGrandMotherLabel == particleMotherLabel && (TMath::Abs(particleMotherPDG) == 111 || TMath::Abs(particleMotherPDG) == 221 || TMath::Abs(particleMotherPDG) == 331) ){
429  isDalitzMerged = kTRUE;
430  isMerged = kTRUE;
431  }
432  // check whether current electron & orginal e is from conversion are from same mother
433  } else if (isConversion && particleGrandMotherLabel > -1){
434  if (dummyPartMotherLabel == particleGrandMotherLabel && (TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) ){
435  isDalitzMerged = kTRUE;
436  isMerged = kTRUE;
437  }
438  }
439  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 22){ // test whether this particle is a photon
440  // check whether current particle is a shower
441  Bool_t isShowerCurrent = kFALSE;
442  if (TMath::Abs(dummyPartMotherPDG) == 11)
443  isShowerCurrent = kTRUE;
444  if (TMath::Abs(dummyPartMotherPDG) == 22)
445  isShowerCurrent = kTRUE;
446 
447  // check whether orginal electron and this photon stem from the same particle and electron originated in dalitz
448  if( dummyPartMotherLabel == particleMotherLabel && !isShowerCurrent ) {
449  isDalitzMerged = kTRUE;
450  isMerged = kTRUE;
451  } else if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
452  // check whether orginal electron and this photon stem from the same particle and electron stems from conversion
453  if( dummyPartMotherLabel == particleGrandMotherLabel && !isShowerCurrent )
454  isMergedPartConv = kTRUE;
455  }
456  }
457  }
458  }
459 
460 
461  if (dummyPartMotherLabel > -1){ // test whether particle has a mother
462  if (TMath::Abs(dummyPart->GetPdgCode()) == 22){ // test whether particle is a photon
463  //check if photon directly comes from a pion/eta/eta_prime decay
464  Bool_t helpN = true;
465  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
466  if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
467  helpN = false;
468  }
469  }
470  if (helpN){
472  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
473  }
474  if ((TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) && !isPhoton && !isElectron)
475  isSubLeadingEM = kTRUE;
476  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 11){ //test whether particle is an electron
477  //check if electron comes from a pion decay
478  if ( TMath::Abs(dummyPartMotherPDG) != 22 ){
479  Bool_t helpN = true;
480  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
481  if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
482  helpN = false;
483  }
484  }
485  if (helpN){
487  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
488  }
489  if ((TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) && !isPhoton && !isElectron)
490  isSubLeadingEM = kTRUE;
491  } else if (dummyPartGrandMotherLabel > -1){ //if it is not a dalitz decay, test whether particle has a grandmother
492  //check if it is a conversion electron that has pion/eta/eta_prime as grandmother
493  if ( (TMath::Abs(dummyPartGrandMotherPDG) == 111 || TMath::Abs(dummyPartGrandMotherPDG) == 221 || TMath::Abs(dummyPartGrandMotherPDG) == 331)){
494 
495  Bool_t helpN = true;
496  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
497  if (fCaloPhotonMotherMCLabels[j] == dummyPartGrandMotherLabel){ //check if grandmother is already contained in fCaloPhotonMotherMCLabels
498  helpN = false;
499  }
500  }
501  if (helpN){
502  fCaloPhotonMotherMCLabels[fNCaloPhotonMotherMCLabels] = dummyPartGrandMotherLabel;
503  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
504  }
505  if (!isPhoton && !isElectron)
506  isSubLeadingEM = kTRUE;
507  }
508  }
509  }
510  }
511  }
512  }
513  fCaloPhotonMCFlags = isPhoton *1 + isElectron *2 + isConversion*4+ isConversionFullyContained *8 + isMerged *16 + isMergedPartConv*32 + isDalitz *64 + isDalitzMerged *128 + isPhotonWithElecMother *256 + isShower * 512 + isSubLeadingEM * 1024 + isElectronFromFragPhoton * 2048;
514 }
515 
516 void AliAODConversionPhoton::SetCaloPhotonMCFlagsAOD(AliVEvent* event, Bool_t enableSort){
517 
518  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
519  if (!AODMCTrackArray) return;
520 
521  Bool_t isPhoton = kFALSE; // largest contribution to cluster is photon
522  Bool_t isElectron = kFALSE; // largest contribution to cluster is electron
523  Bool_t isConversion = kFALSE; // largest contribution to cluster is converted electron
524  Bool_t isConversionFullyContained = kFALSE; // largest contribution to cluster is converted electron, second electron has been found in same cluster
525  Bool_t isMerged = kFALSE; // largest contribution to cluster is photon, second photon or electron from dalitz has been found in same cluster
526  Bool_t isMergedPartConv = kFALSE; // cluster contains more than one particle from the same decay and at least one of the particles came from a conversion
527  Bool_t isDalitz = kFALSE; // this cluster was created by a particle stemming from a dality decay
528  Bool_t isDalitzMerged = kFALSE; // this cluster was created by a particle stemming from a dality decay and more than one particle of the dalitz decay is contained in the cluster
529  Bool_t isPhotonWithElecMother = kFALSE; // this cluster is from a photon with an electron as mother
530  Bool_t isShower = kFALSE; // this cluster contains as a largest contribution a particle from a shower or radiative process
531  Bool_t isSubLeadingEM = kFALSE; // cluster contains at least one electron or photon from a pi0 or eta in subleading contribution
532  Bool_t isElectronFromFragPhoton = kFALSE; // largest contribution to cluster is from converted electron, but photon stems from fragmentation photon ( q -> q gamma)
533 
534  AliAODMCParticle* Photon;
535  AliAODMCParticle* PhotonMother;
536  AliAODMCParticle* PhotonGrandMother;
537 
538  if (fNCaloPhotonMCLabels==0) return;
539  Photon = (AliAODMCParticle*) AODMCTrackArray->At(GetCaloPhotonMCLabel(0));
540 
541  if (enableSort){
542  // sort the array according to the energy of contributing particles
543  if (fNCaloPhotonMCLabels>1){
544  // cout << "start sorting" << endl;
545  Int_t* sortIdx = new Int_t[fNCaloPhotonMCLabels];
546  Double_t* energyPerPart = new Double_t[fNCaloPhotonMCLabels];
547  Long_t* orginalContrib = new Long_t[fNCaloPhotonMCLabels];
548  for (Int_t i = 0; i < fNCaloPhotonMCLabels; i++){
549  orginalContrib[i] = fCaloPhotonMCLabels[i];
550  if (fCaloPhotonMCLabels[i]> -1){
551  AliAODMCParticle* dummy = (AliAODMCParticle*) AODMCTrackArray->At(GetCaloPhotonMCLabel(i));
552  energyPerPart[i] = dummy->E();
553  // suppress energy of hadrons !!! DIRTY hack !!!
554  if (!(TMath::Abs(dummy->GetPdgCode())== 11 || TMath::Abs(dummy->GetPdgCode())== 22)){
555  // cout << "suppressed hadron energy" << endl;
556  energyPerPart[i]= 0.25; // put energy to mip
557  }
558  } else {
559  energyPerPart[i] = 0;
560  }
561  }
562 
563  TMath::Sort(fNCaloPhotonMCLabels,energyPerPart,sortIdx);
564  for(Int_t index = 0; index < fNCaloPhotonMCLabels; index++) {
565  fCaloPhotonMCLabels[index] = orginalContrib [sortIdx[index]] ;
566 
567  }
568  delete [] sortIdx;
569  delete [] energyPerPart;
570  delete [] orginalContrib;
571  }
572  }
573 
574  if(Photon == NULL){
575  return;
576  }
577 
578  Int_t particleMotherLabel = Photon->GetMother();
579  Int_t particleGrandMotherLabel = -1;
580  Int_t particleMotherPDG = -1;
581  Int_t particleGrandMotherPDG = -1;
582  Int_t particleMotherNDaugthers = 0;
583  Int_t particleGrandMotherNDaugthers = 0;
584  Int_t particleGrandMotherX2Label = -1;
585  Int_t particleGrandMotherX3Label = -1;
586  Int_t particleGrandMotherX4Label = -1;
587  Int_t particleGrandMotherX5Label = -1;
588  Int_t particleGrandMotherX6Label = -1;
589  Int_t particleGrandMotherX7Label = -1;
590  Int_t particleGrandMotherX2PDG = -1;
591  Int_t particleGrandMotherX3PDG = -1;
592  Int_t particleGrandMotherX4PDG = -1;
593  Int_t particleGrandMotherX5PDG = -1;
594  Int_t particleGrandMotherX6PDG = -1;
595 
596  if (particleMotherLabel > -1){
597  PhotonMother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
598  particleMotherNDaugthers = PhotonMother->GetNDaughters();
599  particleGrandMotherLabel = PhotonMother->GetMother();
600  particleMotherPDG = PhotonMother->GetPdgCode();
601  if (particleGrandMotherLabel > -1){
602  PhotonGrandMother = (AliAODMCParticle*) AODMCTrackArray->At(PhotonMother->GetMother());
603  particleGrandMotherPDG = PhotonGrandMother->GetPdgCode();
604  particleGrandMotherNDaugthers = PhotonGrandMother->GetNDaughters();
605  AliAODMCParticle* dummyGMM = NULL;
606 
607  particleGrandMotherX2Label = PhotonGrandMother->GetMother();
608  if (particleGrandMotherX2Label > -1){
609  dummyGMM = (AliAODMCParticle*) AODMCTrackArray->At(particleGrandMotherX2Label);
610  particleGrandMotherX2PDG = dummyGMM->GetPdgCode();
611  particleGrandMotherX3Label = dummyGMM->GetMother();
612  if (particleGrandMotherX3Label > -1){
613  dummyGMM = (AliAODMCParticle*) AODMCTrackArray->At(particleGrandMotherX3Label);
614  particleGrandMotherX3PDG = dummyGMM->GetPdgCode();
615  particleGrandMotherX4Label = dummyGMM->GetMother();
616  if (particleGrandMotherX4Label > -1){
617  dummyGMM = (AliAODMCParticle*) AODMCTrackArray->At(particleGrandMotherX4Label);
618  particleGrandMotherX4PDG = dummyGMM->GetPdgCode();
619  particleGrandMotherX5Label = dummyGMM->GetMother();
620  if (particleGrandMotherX5Label > -1){
621  dummyGMM = (AliAODMCParticle*) AODMCTrackArray->At(particleGrandMotherX5Label);
622  particleGrandMotherX5PDG = dummyGMM->GetPdgCode();
623  particleGrandMotherX6Label = dummyGMM->GetMother();
624  if (particleGrandMotherX6Label > -1){
625  dummyGMM = (AliAODMCParticle*) AODMCTrackArray->At(particleGrandMotherX6Label);
626  particleGrandMotherX6PDG = dummyGMM->GetPdgCode();
627  particleGrandMotherX7Label = dummyGMM->GetMother();
628  }
629  }
630  }
631  }
632  }
633  }
634  }
635 
636  //determine mother/grandmother of leading particle and if it is pion/eta/eta_prime: fill array fCaloPhotonMotherMCLabels at position 0
637  if (particleMotherLabel > -1){
638  if( TMath::Abs(particleMotherPDG) == 111 || TMath::Abs(particleMotherPDG) == 221 || TMath::Abs(particleMotherPDG) == 331 ){
639  fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
641  } else if (TMath::Abs(particleMotherPDG) == 22 && particleGrandMotherLabel > -1){
642  if ( TMath::Abs(particleMotherPDG) == 22 && (TMath::Abs(particleGrandMotherPDG) == 111 || TMath::Abs(particleGrandMotherPDG) == 221 || TMath::Abs(particleGrandMotherPDG) == 331) ){
643  fCaloPhotonMotherMCLabels[0] = particleGrandMotherLabel;
645  }
646  } else {
647  fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
649  }
650  }
651 
652  // Check whether the first contribution was photon
653  if(TMath::Abs(Photon->GetPdgCode()) == 22){
654  isPhoton = kTRUE;
655  // did it decay via the dalitz channel
656  if (particleMotherLabel > -1 && particleMotherNDaugthers == 3)
657  isDalitz = kTRUE;
658  // Test whether particle stems from a shower or radiation
659  if (TMath::Abs(particleMotherPDG) == 11){ // check whether photon stems from electron
660  isPhotonWithElecMother = kTRUE;
661  if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
662  if (TMath::Abs(particleGrandMotherPDG) == 22 )
663  isShower = kTRUE; // check whether grandmother is a photon (meaning this is most likely a shower)
664  }
665  }
666  }
667  // Check whether the first contribution was electron
668  if(TMath::Abs(Photon->GetPdgCode()) == 11 ){
669  isElectron = kTRUE;
670  if (particleMotherLabel > -1) {
671  // was it a conversion
672  if (TMath::Abs(particleMotherPDG) == 22)
673  isConversion = kTRUE;
674  // did it decay via the dalitz channel
675  if (particleGrandMotherLabel > -1 && particleGrandMotherNDaugthers == 3 )
676  isDalitz = kTRUE;
677  }
678  if (particleGrandMotherLabel > -1){ // check whether electron has a grandmother
679  if (TMath::Abs(particleGrandMotherPDG) == 11 || TMath::Abs(particleGrandMotherPDG) == 22){ // test whether electron has photon or electron as grandmother (meaning will most likely be a shower)
680  isShower = kTRUE;
681  }
682  }
683  // consider the rare case, where the conversion electron stems from photon, which stems from electron, which stems from photon, ...
684  if (isConversion && TMath::Abs(particleGrandMotherPDG) == 11 && particleGrandMotherX2PDG == 22){
685  SetCaloPhotonMCLabel(0,particleGrandMotherLabel);
686  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX3Label;
687  if (TMath::Abs(particleGrandMotherX3PDG) == 11 && particleGrandMotherX4PDG == 22 ){
688  SetCaloPhotonMCLabel(0,particleGrandMotherX3Label);
689  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX5Label;
690  if (TMath::Abs(particleGrandMotherX5PDG) == 11 && particleGrandMotherX6PDG == 22 ){
691  SetCaloPhotonMCLabel(0,particleGrandMotherX5Label);
692  fCaloPhotonMotherMCLabels[0] = particleGrandMotherX7Label;
693  }
694  }
695  }
696 
697  // consider the case, where a photon stems from a photon which stems from a photon etc...which is common for frag. photons
698  if (particleMotherLabel > -1){
699  AliAODMCParticle* dummyMother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
700  if (dummyMother){
701  Bool_t originReached = kFALSE;
702  while (dummyMother->GetPdgCode() == 22 && !originReached){ // follow conversion photon's history, as long as the mother is a photon
703  if (dummyMother->GetMother() > -1){
704  dummyMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyMother->GetMother());
705  if (TMath::Abs(dummyMother->GetPdgCode()) == 11){ // in case of additional conversion skip to photon's grandma, which should be a photon
706  if (dummyMother->GetMother() > -1){
707  dummyMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyMother->GetMother());
708  } else {
709  originReached = kTRUE;
710  }
711  } else {
712  originReached = kTRUE;
713  }
714  isElectronFromFragPhoton = (TMath::Abs(dummyMother->GetPdgCode()) < 6);// photon stems from quark = fragmentation photon
715  } else {
716  originReached = kTRUE;
717  }
718  }
719  }
720  }
721  }
722 
723 
724 
725  // check whether there were other contributions to the cluster
726  if (fNCaloPhotonMCLabels>1){
727  AliAODMCParticle* dummyPart = NULL;
728  AliAODMCParticle* dummyPartMother = NULL;
729  AliAODMCParticle* dummyPartGrandMother = NULL;
730  for (Int_t i = 1; i< fNCaloPhotonMCLabels; i++){
731  if (i > 49) continue; // abort if more than 50 entries to the cluster have been checked (more are not stored in these objects)
732  dummyPart = (AliAODMCParticle*) AODMCTrackArray->At(GetCaloPhotonMCLabel(i));
733  Int_t dummyPartMotherLabel = dummyPart->GetMother();
734  Int_t dummyPartGrandMotherLabel = -1;
735  Int_t dummyPartMotherPDG = -1;
736  Int_t dummyPartGrandMotherPDG = -1;
737 
738  // check whether this particle has a mother & obtain the pdg code
739  if (dummyPartMotherLabel > -1){
740  dummyPartMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyPart->GetMother());
741  dummyPartGrandMotherLabel = dummyPartMother->GetMother();
742  dummyPartMotherPDG = dummyPartMother->GetPdgCode();
743  // check whether this particle has a grandmother & obtain its pdg code
744  if (dummyPartGrandMotherLabel > -1){
745  dummyPartGrandMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyPartMother->GetMother());
746  dummyPartGrandMotherPDG = dummyPartGrandMother->GetPdgCode();
747  }
748  }
749 
750 
751  // largest contribution was from photon and is not from shower or electron mother
752  if (isPhoton && (!isShower || !isPhotonWithElecMother )){
753  if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
754  if (dummyPartMotherLabel == particleMotherLabel)
755  isMerged = kTRUE; // test whether current and first particle have the same mother => i.e. other gamma from decay or dalitz electron
756  if (dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother
757  // check whether particle is an electron from a conversion of a photon from the original mother
758  if (TMath::Abs(dummyPart->GetPdgCode()) == 11 && dummyPartGrandMotherLabel == particleMotherLabel )
759  isMergedPartConv = kTRUE;
760  // check whether particle is an electron from a dalitz decay from the original mother
761  if (TMath::Abs(dummyPart->GetPdgCode()) == 11 && dummyPartMotherLabel == particleMotherLabel )
762  isDalitzMerged = kTRUE;
763  }
764  }
765  }
766 
767  // largest contribution was from electron & not a from a shower
768  if (isElectron && !isShower){
769  if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
770  if ( TMath::Abs(dummyPart->GetPdgCode()) == 11 && isConversion && dummyPartMotherLabel == particleMotherLabel ) {
771  isConversionFullyContained = kTRUE; // test whether conversion is fully contained in cluster
772  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 11) { // current particle is an electron
773 
774  // check whether current particle is a shower
775  Bool_t isShowerCurrent = kFALSE;
776  if (TMath::Abs(dummyPartGrandMotherPDG) == 11)
777  isShowerCurrent = kTRUE;
778  if (TMath::Abs(dummyPartGrandMotherPDG) == 22)
779  isShowerCurrent = kTRUE;
780 
781  // check whether current particle is a conversion
782  Bool_t isConvCurrent = kFALSE;
783  if (TMath::Abs(dummyPartMotherPDG) == 22 && !isShowerCurrent)
784  isConvCurrent = kTRUE;
785 
786  // check whether orginal electron and this electron stem from the same particle and electron originated in dalitz decay
787  if( dummyPartMotherLabel == particleMotherLabel && TMath::Abs(particleMotherPDG) != 22 && !isShowerCurrent ) {
788  isDalitzMerged = kTRUE;
789  isMerged = kTRUE;
790  // both particles are from conversions
791  } else if (isConversion && isConvCurrent){
792  if (particleGrandMotherLabel > -1 && dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother and current particle has one as well
793  // check whether orginal electron and this electron stem from the same particle and electron stems from conversion
794  if( dummyPartGrandMotherLabel == particleGrandMotherLabel && !isShowerCurrent )
795  isMergedPartConv = kTRUE;
796  }
797  // check whether current electron is from conversion & orginal e are from same mother
798  } else if (dummyPartGrandMotherLabel > -1 && isConvCurrent){
799  if (dummyPartGrandMotherLabel == particleMotherLabel && (TMath::Abs(particleMotherPDG) == 111 || TMath::Abs(particleMotherPDG) == 221 || TMath::Abs(particleMotherPDG) == 331) ){
800  isDalitzMerged = kTRUE;
801  isMerged = kTRUE;
802  }
803  // check whether current electron & orginal e is from conversion are from same mother
804  } else if (isConversion && particleGrandMotherLabel > -1){
805  if (dummyPartMotherLabel == particleGrandMotherLabel && (TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) ){
806  isDalitzMerged = kTRUE;
807  isMerged = kTRUE;
808  }
809  }
810  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 22){ // test whether this particle is a photon
811  // check whether current particle is a shower
812  Bool_t isShowerCurrent = kFALSE;
813  if (TMath::Abs(dummyPartMotherPDG) == 11)
814  isShowerCurrent = kTRUE;
815  if (TMath::Abs(dummyPartMotherPDG) == 22)
816  isShowerCurrent = kTRUE;
817 
818  // check whether orginal electron and this photon stem from the same particle and electron originated in dalitz
819  if( dummyPartMotherLabel == particleMotherLabel && !isShowerCurrent ) {
820  isDalitzMerged = kTRUE;
821  isMerged = kTRUE;
822  } else if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
823  // check whether orginal electron and this photon stem from the same particle and electron stems from conversion
824  if( dummyPartMotherLabel == particleGrandMotherLabel && !isShowerCurrent )
825  isMergedPartConv = kTRUE;
826  }
827  }
828  }
829  }
830 
831  if (dummyPartMotherLabel > -1){ // test whether particle has a mother
832  if (TMath::Abs(dummyPart->GetPdgCode()) == 22){ // test whether particle is a photon
833  //check if photon directly comes from a pion/eta/eta_prime decay
834  Bool_t helpN = true;
835  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
836  if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
837  helpN = false;
838  }
839  }
840  if (helpN){
842  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
843  }
844  if ((TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) && !isPhoton && !isElectron)
845  isSubLeadingEM = kTRUE;
846  } else if (TMath::Abs(dummyPart->GetPdgCode()) == 11){ //test whether particle is an electron
847  //check if electron comes from a pion decay
848  if ( TMath::Abs(dummyPartMotherPDG) != 22 ){
849  Bool_t helpN = true;
850  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
851  if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
852  helpN = false;
853  }
854  }
855  if (helpN){
857  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
858  }
859  if ((TMath::Abs(dummyPartMotherPDG) == 111 || TMath::Abs(dummyPartMotherPDG) == 221 || TMath::Abs(dummyPartMotherPDG) == 331) && !isPhoton && !isElectron)
860  isSubLeadingEM = kTRUE;
861  } else if (dummyPartGrandMotherLabel > -1){ //if it is not a dalitz decay, test whether particle has a grandmother
862  //check if it is a conversion electron that has pion/eta/eta_prime as grandmother
863  if ( (TMath::Abs(dummyPartGrandMotherPDG) == 111 || TMath::Abs(dummyPartGrandMotherPDG) == 221 || TMath::Abs(dummyPartGrandMotherPDG) == 331)){
864 
865  Bool_t helpN = true;
866  for(Int_t j=0; j<fNCaloPhotonMotherMCLabels; j++){
867  if (fCaloPhotonMotherMCLabels[j] == dummyPartGrandMotherLabel){ //check if grandmother is already contained in fCaloPhotonMotherMCLabels
868  helpN = false;
869  }
870  }
871  if (helpN){
872  fCaloPhotonMotherMCLabels[fNCaloPhotonMotherMCLabels] = dummyPartGrandMotherLabel;
873  fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
874  }
875  if (!isPhoton && !isElectron)
876  isSubLeadingEM = kTRUE;
877  }
878  }
879  }
880  }
881  }
882  }
883  fCaloPhotonMCFlags = isPhoton *1 + isElectron *2 + isConversion*4+ isConversionFullyContained *8 + isMerged *16 + isMergedPartConv*32 + isDalitz *64 + isDalitzMerged *128 + isPhotonWithElecMother *256 + isShower * 512 + isSubLeadingEM * 1024 + isElectronFromFragPhoton * 2048;;
884 }
885 
886 //_____________________________________________________________________________
887 // prints information of MC particles contributing to cluster
888 //_____________________________________________________________________________
890  cout << endl << endl << "particles contributing: " << endl;
891  for (Int_t i =0 ; i < fNCaloPhotonMCLabels; i++ ){
892  TParticle *dummy = NULL;
893  if (fCaloPhotonMCLabels[i]>0){
894  dummy = (TParticle*)mcEvent->Particle(fCaloPhotonMCLabels[i]);
895  cout << i << "\t"<< fCaloPhotonMCLabels[i] << "\t pdg code: " <<dummy->GetPdgCode() << "\t prod radius: "<< dummy->R() << "\t energy: " << dummy->Energy() ;
896  if (dummy->GetMother(0) > -1){
897  TParticle* dummyMother = (TParticle*)mcEvent->Particle(dummy->GetMother(0));
898  cout << "\t mother part: " << dummy->GetMother(0) << "\t mother pdg code: " << dummyMother->GetPdgCode() << "\t energy: " << dummyMother->Energy() << endl;
899  if (dummyMother->GetMother(0) > -1){
900  TParticle* dummyGrandMother = (TParticle*)mcEvent->Particle(dummyMother->GetMother(0));
901  cout << "\t grandmother part: " << dummyMother->GetMother(0) << "\t grandmother pdg code: " << dummyGrandMother->GetPdgCode() << "\t energy: " << dummyGrandMother->Energy() << endl;
902  } else {
903  cout << endl;
904  }
905  } else {
906  cout << endl;
907  }
908  }
909 // if (dummy) delete dummy;
910  }
911  cout << "mothers contributing: " << endl;
912  for (Int_t i =0 ; i < fNCaloPhotonMotherMCLabels; i++ ){
913  TParticle *dummy = NULL;
914  if (fCaloPhotonMotherMCLabels[i]>0){
915  dummy = (TParticle*)mcEvent->Particle(fCaloPhotonMotherMCLabels[i]);
916  cout << i << "\t"<< fCaloPhotonMotherMCLabels[i] << "\t pdg code: " <<dummy->GetPdgCode() << "\t prod radius: "<< dummy->R() << "\t energy: " << dummy->Energy() << endl;
917 
918 
919  }
920 // if (dummy) delete dummy;
921  }
922 }
923 
924 //_____________________________________________________________________________
925 // prints information of cluster as it is flagged
926 //_____________________________________________________________________________
928  cout << fCaloPhotonMCFlags << "\t photon: " << IsLargestComponentPhoton() << "\t electron: " << IsLargestComponentElectron() << "\t conversion: " << IsConversion() << "\t conversion full: "
929  << IsConversionFullyContained() << "\t merged: " << IsMerged() << "\t merged p.conv: " << IsMergedPartConv() << "\t Dalitz: " << IsDalitz() << "\t Dalitz merged: " << IsDalitzMerged()
930  << "\t rad: " << IsPhotonWithElecMother() << "\t shower: " << IsShower() << "\t no EM lead: " << IsEMNonLeading() << "\t EM sub lead: " << IsSubLeadingEM() << endl;
931 }
virtual Double_t GetPy() const
double Double_t
Definition: External.C:58
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
virtual Double_t GetPz() const
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
AliAODConversionPhoton & operator=(const AliAODConversionPhoton &g)
void PrintCaloMCLabelsAndInfo(AliMCEvent *mcEvent)
int Int_t
Definition: External.C:63
virtual Double_t GetPx() const
bool Bool_t
Definition: External.C:53
void CalculateDistanceOfClossetApproachToPrimVtx(const AliVVertex *primVertex)
void SetCaloPhotonMCFlagsAOD(AliVEvent *event, Bool_t enableSort)