]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODPid.cxx
Fixing leak
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODPid.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
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 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     AOD Pid class to store additional pid information
20 //     Author: Annalisa Mastroserio
21 //-------------------------------------------------------------------------
22
23 #include "AliAODPid.h"
24 #include "AliESDtrack.h"
25 #include "AliLog.h"
26 #include "AliPID.h"
27
28 ClassImp(AliAODPid)
29
30
31 //______________________________________________________________________________
32 AliAODPid::AliAODPid():
33     fITSsignal(0), 
34     fTPCsignal(0),
35     fTPCsignalN(0),
36     fTPCmomentum(0),
37     fTRDnSlices(0),
38     fTRDntls(0),
39     fTRDslices(0x0),
40     fTOFesdsignal(0),
41     fHMPIDsignal(0)
42 {
43   // default constructor
44     for(Int_t i=0; i<kSPECIES; i++) fIntTime[i]   = 0; 
45     for(Int_t i=0; i<5; i++) fHMPIDprobs[i] = 0.;
46     for(Int_t i=0; i<3; i++) fEMCALPosition[i]    = 0.;
47     for(Int_t i=0; i<5; i++) fTOFpidResolution[i] = 0.;
48     for(Int_t i=0; i<6; i++) {
49       fTRDmomentum[i]      = 0.;
50       fTRDncls[i]          = 0;
51     }
52     for(Int_t i=0; i<3; i++) fEMCALMomentum[i]    = 0.;
53     for(Int_t i=0; i<4; i++) fITSdEdxSamples[i]   = 0.;
54 }
55
56 //______________________________________________________________________________
57 AliAODPid::~AliAODPid() 
58 {
59   delete [] fTRDslices;
60   fTRDslices = 0;
61   // destructor
62 }
63
64
65 //______________________________________________________________________________
66 AliAODPid::AliAODPid(const AliAODPid& pid) : 
67   TObject(pid),
68   fITSsignal(pid.fITSsignal), 
69   fTPCsignal(pid.fTPCsignal),
70   fTPCsignalN(pid.fTPCsignalN),
71   fTPCmomentum(pid.fTPCmomentum),
72   fTRDnSlices(pid.fTRDnSlices),
73   fTRDntls(pid.fTRDntls),
74   fTRDslices(0x0),
75   fTOFesdsignal(pid.fTOFesdsignal),
76   fHMPIDsignal(pid.fHMPIDsignal)
77 {
78   // Copy constructor
79   SetTRDsignal(fTRDnSlices, pid.fTRDslices);
80     for(Int_t i=0; i<kSPECIES; i++) fIntTime[i]=pid.fIntTime[i];
81     for(Int_t i=0; i<5; i++) fHMPIDprobs[i] = pid.fHMPIDprobs[i];
82     for(Int_t i=0; i<3; i++) {
83       fEMCALPosition[i]=pid.fEMCALPosition[i];
84       fEMCALMomentum[i]=pid.fEMCALMomentum[i];
85     }
86     for(Int_t i=0; i<6; i++){ 
87       fTRDmomentum[i]=pid.fTRDmomentum[i];
88       fTRDncls[i] = 0;
89     }
90
91     for(Int_t i=0; i<5; i++) fTOFpidResolution[i]=pid.fTOFpidResolution[i];
92
93     for(Int_t i=0; i<4; i++) fITSdEdxSamples[i]=pid.fITSdEdxSamples[i];
94 }
95
96 //______________________________________________________________________________
97 AliAODPid& AliAODPid::operator=(const AliAODPid& pid)
98 {
99   // Assignment operator
100   if(this!=&pid) {
101     // copy stuff
102     fITSsignal=pid.fITSsignal; 
103     fTPCsignal=pid.fTPCsignal;
104     
105     if(pid.fTRDnSlices<=0||(fTRDnSlices!=pid.fTRDnSlices)){
106       // only delete if number changed or is 0
107       delete [] fTRDslices;
108       fTRDslices = 0;
109       if(pid.fTRDnSlices>0) fTRDslices = new Double32_t[fTRDnSlices];
110     }
111     fTRDnSlices=pid.fTRDnSlices;
112     
113     for(Int_t i=0; i< fTRDnSlices; i++) fTRDslices[i]=pid.fTRDslices[i];
114     fTOFesdsignal=pid.fTOFesdsignal;
115     fHMPIDsignal=pid.fHMPIDsignal;
116     for(Int_t i=0; i<kSPECIES; i++) fIntTime[i]=pid.fIntTime[i];
117     for(Int_t i=0; i<5; i++) fHMPIDprobs[i] = pid.fHMPIDprobs[i];
118     for(Int_t i=0; i<6; i++){ 
119       fTRDmomentum[i]=pid.fTRDmomentum[i];
120       fTRDncls[i] = pid.fTRDncls[i];
121     }
122     for(Int_t i=0; i<3; i++) {
123       fEMCALPosition[i]=pid.fEMCALPosition[i];
124       fEMCALMomentum[i]=pid.fEMCALMomentum[i];
125     }
126     for (Int_t i=0; i<5; i++) fTOFpidResolution[i]=pid.fTOFpidResolution[i];
127     for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=pid.fITSdEdxSamples[i];
128   }
129
130   return *this;
131 }
132 //_______________________________________________________________________________
133 void AliAODPid::GetIntegratedTimes(Double_t timeint[kSPECIES]) const
134 {
135  // Returns the array with integrated times for each particle hypothesis
136 for(Int_t i=0; i<kSPECIES; i++) timeint[i]=fIntTime[i];
137 }
138 //_______________________________________________________________________________
139 void AliAODPid::SetIntegratedTimes(Double_t timeint[kSPECIES])
140 {
141  // Returns the array with integrated times for each particle hypothesis
142 for(Int_t i=0; i<kSPECIES; i++) fIntTime[i]=timeint[i];
143 }
144 //_______________________________________________________________________________
145 void AliAODPid::GetEMCALPosition(Double_t emcalpos[3]) const
146 {
147  // Returns the array with extrapolated track position at the EMCAL surface
148   for(Int_t i=0; i<3; i++) emcalpos[i]=fEMCALPosition[i];
149 }
150 //_______________________________________________________________________________
151 void AliAODPid::SetEMCALPosition(Double_t emcpos[3])
152 {
153  // Sets the array with extrapolated track position at the EMCAL surface
154   for(Int_t i=0; i<3; i++) fEMCALPosition[i]=emcpos[i];
155 }
156 //_______________________________________________________________________________
157 void AliAODPid::GetEMCALMomentum(Double_t emcalmom[3]) const
158 {
159  // Returns the array with extrapolated track momentum at the EMCAL surface
160   for(Int_t i=0; i<3; i++) emcalmom[i]=fEMCALMomentum[i];
161 }
162 //_______________________________________________________________________________
163 void AliAODPid::SetEMCALMomentum(Double_t emcmom[3])
164 {
165  // Sets the array with extrapolated track momentum at the EMCAL surface
166   for(Int_t i=0; i<3; i++) fEMCALMomentum[i]=emcmom[i];
167 }
168 //______________________________________________________________________________
169 void AliAODPid::SetTOFpidResolution(Double_t tofPIDres[5])
170 {
171   for (Int_t i=0; i<5; i++) fTOFpidResolution[i]=tofPIDres[i];
172
173 }
174 //______________________________________________________________________________
175 void AliAODPid::GetTOFpidResolution(Double_t tofRes[5]) const
176 {
177   for (Int_t i=0; i<5; i++) tofRes[i]=fTOFpidResolution[i];
178 }
179
180 //______________________________________________________________________________
181 void AliAODPid::SetHMPIDprobs(Double_t hmpPid[5]) 
182 {
183   //
184   // Set the HMPID PID probablities that are read from ESD
185   //  
186   for(Int_t i = 0; i < 5; i++ ) fHMPIDprobs[i] =  hmpPid[i];
187 }
188 //______________________________________________________________________________
189 void AliAODPid::GetHMPIDprobs(Double_t *p) const
190 {
191   //
192   // Set the HMPID PID probablities that are read from ESD
193   //  
194   for(Int_t i = 0; i < AliPID::kSPECIES; i++ ) p[i] =  fHMPIDprobs[i];
195 }
196 //______________________________________________________________________________
197 void AliAODPid::SetITSdEdxSamples(const Double_t s[4])
198 {
199   //
200   // Set the 4 values of dE/dx from individual ITS layers that are read from ESD
201   //  
202   for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
203 }
204 //______________________________________________________________________________
205 void AliAODPid::GetITSdEdxSamples(Double_t s[4]) const
206 {
207   //
208   // Get the 4 values of dE/dx from individual ITS layers that are read from ESD
209   //  
210   for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
211 }