Added a new class for the AOD information
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliGammaConversionAODObject.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *
5  * Version 1.0                                                            *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 ////////////////////////////////////////////////
17 //--------------------------------------------- 
18 // Class containing the aod information we need
19 //---------------------------------------------
20 ////////////////////////////////////////////////
21
22 #include "AliGammaConversionAODObject.h"
23 #include "AliAODv0.h"
24 #include "AliStack.h"
25 #include "AliESDEvent.h"
26 #include "AliESDtrack.h"
27 #include "TParticle.h"
28
29 using namespace std;
30
31 ClassImp(AliGammaConversionAODObject)
32
33
34
35 AliGammaConversionAODObject::AliGammaConversionAODObject() :
36   TObject(),
37   fPx(0),
38   fPy(0),
39   fPz(0),
40   fLabel1(-1),
41   fLabel2(-1),
42   fMCStack(NULL),
43   fESDEvent(NULL)
44 {
45         
46 }
47
48
49 AliGammaConversionAODObject::AliGammaConversionAODObject(const AliGammaConversionAODObject & original) :
50   TObject(original),
51   fPx(original.fPx),
52   fPy(original.fPy),
53   fPz(original.fPz),
54   fLabel1(original.fLabel1),
55   fLabel2(original.fLabel2),
56   fMCStack(original.fMCStack),
57   fESDEvent(original.fESDEvent)
58 {
59         
60 }
61
62
63 AliGammaConversionAODObject & AliGammaConversionAODObject::operator = (const AliGammaConversionAODObject & /*source*/)
64 {
65   // assignment operator
66   return *this;
67 }
68
69 Int_t AliGammaConversionAODObject::GetGammaMCLabel() const{
70   // returns the MC label of the gamma (if both electrons have the same mother)
71   Int_t iResult = -1;
72   if(fMCStack != NULL){
73     Int_t mcLabel1= GetElectronMCLabel1();
74     Int_t mcLabel2= GetElectronMCLabel2();
75     if(mcLabel1>=0 && mcLabel2>=0){
76       TParticle *electron1 = fMCStack->Particle(mcLabel1);
77       TParticle *electron2 = fMCStack->Particle(mcLabel2);
78       if(electron1->GetMother(0) == electron2->GetMother(0)){
79         iResult = electron1->GetMother(0);
80       }
81     }
82   }
83   return iResult;
84 }
85
86 Int_t AliGammaConversionAODObject::GetElectronUniqueID() const{
87   // returns the unique id of the electrons if they have the same mother and unique id
88   Int_t iResult = -1;
89   if(fMCStack != NULL){
90     Int_t mcLabel1= GetElectronMCLabel1();
91     Int_t mcLabel2= GetElectronMCLabel2();
92     if(mcLabel1>=0 && mcLabel2>=0){
93       TParticle *electron1 = fMCStack->Particle(mcLabel1);
94       TParticle *electron2 = fMCStack->Particle(mcLabel2);
95       if(electron1->GetMother(0) == electron2->GetMother(0)){
96         if(electron1->GetUniqueID() == electron2->GetUniqueID()){
97           iResult = (Int_t)electron1->GetUniqueID();
98         }
99       }
100     }
101   }
102   return iResult;
103 }
104
105 Int_t AliGammaConversionAODObject::GetElectronMCLabel1() const{
106   //returns the MC label of the first electron
107   Int_t iResult=-1;
108   if(fESDEvent != NULL){
109     if(fLabel1>=0){
110       iResult = (fESDEvent->GetTrack(fLabel1))->GetLabel();
111     }
112   }
113   return iResult;
114 }
115
116 Int_t AliGammaConversionAODObject::GetElectronMCLabel2() const{
117   //returns the MC label of the first electron
118   Int_t iResult=-1;
119   if(fESDEvent != NULL){
120     if(fLabel2>=0){
121       iResult = (fESDEvent->GetTrack(fLabel2))->GetLabel();
122     }
123   }
124   return iResult;
125 }