]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDCaloCluster.cxx
New data members: distance to bad channels from the center of a reconstructed cluster...
[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   fID(0),
35   fClusterType(-1),
36   fEMCALCluster(kFALSE),
37   fPHOSCluster(kFALSE),
38   fTrackMatched(kFALSE),
39   fEnergy(-1),
40   fDispersion(-1),
41   fChi2(-1),
42   fPrimaryIndex(-1),
43   fM20(0),
44   fM02(0),
45   fM11(0),
46   fNExMax(0),
47   fEmcCpvDistance(9999),
48   fDistToBadChannel(9999),
49   fNumberOfPrimaries(-1),
50   fListOfPrimaries(0x0),
51   fNumberOfDigits(0),
52   fDigitAmplitude(0x0),
53   fDigitTime(0x0),
54   fDigitIndex(0x0)
55 {
56   //
57   // The default ESD constructor 
58   //
59   fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
60   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
61 }
62
63 //_______________________________________________________________________
64 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) : 
65   TObject(clus),
66   fID(clus.fID),
67   fClusterType(clus.fClusterType),
68   fEMCALCluster(clus.fEMCALCluster),
69   fPHOSCluster(clus.fPHOSCluster),
70   fTrackMatched(clus.fTrackMatched),
71   fEnergy(clus.fEnergy),
72   fDispersion(clus.fDispersion),
73   fChi2(clus.fChi2),
74   fPrimaryIndex(clus.fPrimaryIndex),
75   fM20(clus.fM20),
76   fM02(clus.fM02),
77   fM11(clus.fM11),
78   fNExMax(clus.fNExMax),
79   fEmcCpvDistance(clus.fEmcCpvDistance),
80   fDistToBadChannel(clus.fDistToBadChannel),
81   fNumberOfPrimaries(clus.fNumberOfPrimaries),
82   fListOfPrimaries(0x0),
83   fNumberOfDigits(clus.fNumberOfDigits),
84   fDigitAmplitude(0x0),
85   fDigitTime(0x0),
86   fDigitIndex(0x0)
87 {
88   //
89   // The copy constructor 
90   //
91   fGlobalPos[0] = clus.fGlobalPos[0];
92   fGlobalPos[1] = clus.fGlobalPos[1];
93   fGlobalPos[2] = clus.fGlobalPos[2];
94
95   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
96
97   if (clus.fNumberOfDigits > 0) {
98     if (clus.fDigitAmplitude) {
99       fDigitAmplitude = new UShort_t[clus.fNumberOfDigits];
100       for (Int_t i=0; i<clus.fNumberOfDigits; i++)
101         fDigitAmplitude[i]=clus.fDigitAmplitude[i];
102     }
103     if (clus.fDigitTime) {
104       fDigitTime = new UShort_t[clus.fNumberOfDigits];
105       for (Int_t i=0; i<clus.fNumberOfDigits; i++)
106         fDigitTime[i]=clus.fDigitTime[i];
107     }
108     if (clus.fDigitIndex) {
109       fDigitIndex = new UShort_t[clus.fNumberOfDigits];
110       for (Int_t i=0; i<clus.fNumberOfDigits; i++)
111         fDigitIndex[i]=clus.fDigitIndex[i];
112     }
113    if (clus.fListOfPrimaries) {
114       fListOfPrimaries = new UShort_t[clus.fNumberOfPrimaries];
115       for (Int_t i=0; i<clus.fNumberOfPrimaries; i++)
116         fListOfPrimaries[i]=clus.fListOfPrimaries[i];
117     }
118   }
119 }
120
121 //_______________________________________________________________________
122 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
123 {
124   // assignment operator
125
126   if(&source == this) return *this;
127
128   fID = source.fID;
129   fClusterType = source.fClusterType;
130   fEMCALCluster = source.fEMCALCluster;
131   fPHOSCluster = source.fPHOSCluster;
132   fTrackMatched = source.fTrackMatched;
133   fEnergy = source.fEnergy;
134   fDispersion = source.fDispersion;
135   fChi2 = source.fChi2;
136   fPrimaryIndex = source.fPrimaryIndex;
137   fM20 = source.fM20;
138   fM02 = source.fM02;
139   fM11 = source.fM11;
140   fNExMax = source.fNExMax;
141   fEmcCpvDistance = source.fEmcCpvDistance;
142   fDistToBadChannel = source.fDistToBadChannel ;
143   fNumberOfPrimaries = source.fNumberOfPrimaries;
144   delete fListOfPrimaries; fListOfPrimaries=0x0;
145
146   fNumberOfDigits = source.fNumberOfDigits;
147   delete fDigitAmplitude; fDigitAmplitude=0x0;
148   delete fDigitTime; fDigitTime = 0x0;
149   delete fDigitIndex; fDigitIndex = 0x0;
150
151   fGlobalPos[0] = source.fGlobalPos[0];
152   fGlobalPos[1] = source.fGlobalPos[1];
153   fGlobalPos[2] = source.fGlobalPos[2];
154
155   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
156
157   if (source.fNumberOfDigits > 0) {
158     if (source.fDigitAmplitude) {
159       fDigitAmplitude = new UShort_t[source.fNumberOfDigits];
160       for (Int_t i=0; i<source.fNumberOfDigits; i++)
161         fDigitAmplitude[i]=source.fDigitAmplitude[i];
162     }
163     if (source.fDigitTime) {
164       fDigitTime = new UShort_t[source.fNumberOfDigits];
165       for (Int_t i=0; i<source.fNumberOfDigits; i++)
166         fDigitTime[i]=source.fDigitTime[i];
167     }
168     if (source.fDigitIndex) {
169       fDigitIndex = new UShort_t[source.fNumberOfDigits];
170       for (Int_t i=0; i<source.fNumberOfDigits; i++)
171         fDigitIndex[i]=source.fDigitIndex[i];
172     }
173    if (source.fListOfPrimaries) {
174       fListOfPrimaries = new UShort_t[source.fNumberOfPrimaries];
175       for (Int_t i=0; i<source.fNumberOfPrimaries; i++)
176         fListOfPrimaries[i]=source.fListOfPrimaries[i];
177     }
178   }
179
180   return *this;
181
182 }
183
184
185 //_______________________________________________________________________
186 AliESDCaloCluster::~AliESDCaloCluster(){ 
187   //
188   // This is destructor according Coding Conventrions 
189   //
190   // AliESDCaloCluster is the owner of the arrays
191   // even if they are created outside
192   delete[] fListOfPrimaries;
193   delete[] fDigitAmplitude;
194   delete[] fDigitTime;
195   delete[] fDigitIndex;
196
197 }
198
199 //_______________________________________________________________________
200 void AliESDCaloCluster::SetPid(const Float_t *p) {
201   // Sets the probability of each particle type
202   // Copied from AliESDtrack SetPIDValues
203   // This function copies "n" PID weights from "scr" to "dest"
204   // and normalizes their sum to 1 thus producing conditional
205   // probabilities.
206   // The negative weights are set to 0.
207   // In case all the weights are non-positive they are replaced by
208   // uniform probabilities
209
210   Int_t n = AliPID::kSPECIESN;
211
212   Float_t uniform = 1./(Float_t)n;
213
214   Float_t sum = 0;
215   for (Int_t i=0; i<n; i++)
216     if (p[i]>=0) {
217       sum+=p[i];
218       fPID[i] = p[i];
219     }
220     else {
221       fPID[i] = 0;
222     }
223
224   if(sum>0)
225     for (Int_t i=0; i<n; i++) fPID[i] /= sum;
226   else
227     for (Int_t i=0; i<n; i++) fPID[i] = uniform;
228
229 }
230
231 //_______________________________________________________________________
232 void AliESDCaloCluster::GetMomentum(TLorentzVector& p) {
233   // Returns TLorentzVector with momentum of the cluster. Only valid for clusters 
234   // identified as photons or pi0 (overlapped gamma) produced on the vertex
235   
236   Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
237                             fGlobalPos[1]*fGlobalPos[1]+
238                             fGlobalPos[2]*fGlobalPos[2]   ) ; 
239
240   p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r,  fEnergy*fGlobalPos[1]/r,  fEnergy*fGlobalPos[2]/r,  fEnergy) ; 
241   
242 }