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