]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDCaloCluster.cxx
enabling keyword substitution
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 /* $Log $ */
18
19 //-----------------------------------------------------------------
20 //           Implementation of the ESD Calorimeter cluster class
21 //   ESD = Event Summary Data
22 //   This is the class to deal with during the phisics analysis of data
23 //
24 //   J.L. Klay (LLNL)
25 //-----------------------------------------------------------------
26
27 #include <TLorentzVector.h>
28 #include "AliESDCaloCluster.h"
29
30 ClassImp(AliESDCaloCluster)
31
32 //_______________________________________________________________________
33 AliESDCaloCluster::AliESDCaloCluster() : 
34   TObject(),
35   fTracksMatched(0x0),
36   fLabels(0x0),
37   fNCells(0),
38   fCellsAbsId(0x0),
39   fCellsAmpFraction(0x0),
40   fDigitAmplitude(0x0),//not in use
41   fDigitTime(0x0),//not in use
42   fDigitIndex(0x0),//not in use
43   fEnergy(0),
44   fDispersion(0),
45   fChi2(0),
46   fM20(0),
47   fM02(0),
48   fM11(0),
49   fEmcCpvDistance(1024),
50   fDistToBadChannel(1024),
51   fID(0),
52   fNExMax(0),
53   fClusterType(kUndef)
54 {
55   //
56   // The default ESD constructor 
57   //
58   fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
59   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
60 }
61
62 //_______________________________________________________________________
63 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) : 
64   TObject(clus),
65   fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
66   fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
67   fNCells(clus.fNCells),
68   fCellsAbsId(),
69   fCellsAmpFraction(),
70   fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),//not in use
71   fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),//not in use
72   fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0),//not in use
73   fEnergy(clus.fEnergy),
74   fDispersion(clus.fDispersion),
75   fChi2(clus.fChi2),
76   fM20(clus.fM20),
77   fM02(clus.fM02),
78   fM11(clus.fM11),
79   fEmcCpvDistance(clus.fEmcCpvDistance),
80   fDistToBadChannel(clus.fDistToBadChannel),
81   fID(clus.fID),
82   fNExMax(clus.fNExMax),
83   fClusterType(clus.fClusterType)
84 {
85   //
86   // The copy constructor 
87   //
88   fGlobalPos[0] = clus.fGlobalPos[0];
89   fGlobalPos[1] = clus.fGlobalPos[1];
90   fGlobalPos[2] = clus.fGlobalPos[2];
91
92   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
93
94   if (clus.fNCells > 0) {
95
96     if(clus.fCellsAbsId){
97       fCellsAbsId = new UShort_t[clus.fNCells];
98       for (Int_t i=0; i<clus.fNCells; i++)
99         fCellsAbsId[i]=clus.fCellsAbsId[i];
100     }
101     
102     if(clus.fCellsAmpFraction){
103       fCellsAmpFraction = new Double32_t[clus.fNCells];
104       for (Int_t i=0; i<clus.fNCells; i++)
105         fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
106     }
107     
108   }
109
110 }
111
112 //_______________________________________________________________________
113 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
114 {
115   // assignment operator
116
117   if(&source == this) return *this;
118   TObject::operator=(source);
119
120   fGlobalPos[0] = source.fGlobalPos[0];
121   fGlobalPos[1] = source.fGlobalPos[1];
122   fGlobalPos[2] = source.fGlobalPos[2];
123
124
125   fEnergy = source.fEnergy;
126   fDispersion = source.fDispersion;
127   fChi2 = source.fChi2;
128   fM20 = source.fM20;
129   fM02 = source.fM02;
130   fM11 = source.fM11;
131   fEmcCpvDistance = source.fEmcCpvDistance;
132   fDistToBadChannel = source.fDistToBadChannel ;
133   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
134   fID = source.fID;
135
136   fNCells= source. fNCells;
137   if (source.fNCells > 0) {
138     
139     if(source.fCellsAbsId){
140       fCellsAbsId = new UShort_t[source.fNCells];
141       for (Int_t i=0; i<source.fNCells; i++)
142         fCellsAbsId[i]=source.fCellsAbsId[i];
143     }
144     
145     if(source.fCellsAmpFraction){
146       fCellsAmpFraction = new Double32_t[source.fNCells];
147       for (Int_t i=0; i<source.fNCells; i++)
148         fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
149     }
150     
151   }
152
153   fNExMax = source.fNExMax;
154   fClusterType = source.fClusterType;
155
156   //not in use
157   delete fTracksMatched;
158   fTracksMatched = source.fTracksMatched?new TArrayI(*source.fTracksMatched):0x0;
159   delete fLabels;
160   fLabels = source.fLabels?new TArrayI(*source.fLabels):0x0;
161   
162   delete fDigitAmplitude;
163   fDigitAmplitude = source.fDigitAmplitude?new TArrayS(*source.fDigitAmplitude):0x0;
164   
165   delete fDigitTime;
166   fDigitTime = source.fDigitTime?new TArrayS(*source.fDigitTime):0x0;
167   
168   delete fDigitIndex;
169   fDigitIndex = source.fDigitIndex?new TArrayS(*source.fDigitIndex):0x0;
170   
171   return *this;
172
173 }
174
175
176 //_______________________________________________________________________
177 AliESDCaloCluster::~AliESDCaloCluster(){ 
178   //
179   // This is destructor according Coding Conventions 
180   //
181   delete fTracksMatched;
182   delete fLabels;
183   delete fDigitAmplitude;  //not in use
184   delete fDigitTime;  //not in use
185   delete fDigitIndex;  //not in use
186   if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
187   if(fCellsAbsId) delete[] fCellsAbsId;  fCellsAbsId = 0;
188 }
189
190 //_______________________________________________________________________
191 void AliESDCaloCluster::SetPid(const Float_t *p) {
192   // Sets the probability of each particle type
193   // Copied from AliESDtrack SetPIDValues
194   // This function copies "n" PID weights from "scr" to "dest"
195   // and normalizes their sum to 1 thus producing conditional
196   // probabilities.
197   // The negative weights are set to 0.
198   // In case all the weights are non-positive they are replaced by
199   // uniform probabilities
200
201   Int_t n = AliPID::kSPECIESN;
202
203   Float_t uniform = 1./(Float_t)n;
204
205   Float_t sum = 0;
206   for (Int_t i=0; i<n; i++)
207     if (p[i]>=0) {
208       sum+=p[i];
209       fPID[i] = p[i];
210     }
211     else {
212       fPID[i] = 0;
213     }
214
215   if(sum>0)
216     for (Int_t i=0; i<n; i++) fPID[i] /= sum;
217   else
218     for (Int_t i=0; i<n; i++) fPID[i] = uniform;
219
220 }
221
222 //_______________________________________________________________________
223 void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
224   // Returns TLorentzVector with momentum of the cluster. Only valid for clusters 
225   // identified as photons or pi0 (overlapped gamma) produced on the vertex
226   //Vertex can be recovered with esd pointer doing:  
227   //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
228
229   if(vertex){//calculate direction from vertex
230     fGlobalPos[0]-=vertex[0];
231     fGlobalPos[1]-=vertex[1];
232     fGlobalPos[2]-=vertex[2];
233   }
234   
235   Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
236                             fGlobalPos[1]*fGlobalPos[1]+
237                             fGlobalPos[2]*fGlobalPos[2]   ) ; 
238
239   p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r,  fEnergy*fGlobalPos[1]/r,  fEnergy*fGlobalPos[2]/r,  fEnergy) ; 
240   
241 }