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