1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
25 //-----------------------------------------------------------------
27 #include <TLorentzVector.h>
28 #include "AliESDCaloCluster.h"
30 ClassImp(AliESDCaloCluster)
32 //_______________________________________________________________________
33 AliESDCaloCluster::AliESDCaloCluster() :
36 fEMCALCluster(kFALSE),
38 fTrackMatched(kFALSE),
47 fEmcCpvDistance(9999),
48 fDistToBadChannel(9999),
49 fNumberOfPrimaries(-1),
50 fListOfPrimaries(0x0),
57 // The default ESD constructor
59 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
60 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
63 //_______________________________________________________________________
64 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
67 fClusterType(clus.fClusterType),
68 fEMCALCluster(clus.fEMCALCluster),
69 fPHOSCluster(clus.fPHOSCluster),
70 fTrackMatched(clus.fTrackMatched),
71 fEnergy(clus.fEnergy),
72 fDispersion(clus.fDispersion),
74 fPrimaryIndex(clus.fPrimaryIndex),
78 fNExMax(clus.fNExMax),
79 fEmcCpvDistance(clus.fEmcCpvDistance),
80 fDistToBadChannel(clus.fDistToBadChannel),
81 fNumberOfPrimaries(clus.fNumberOfPrimaries),
82 fListOfPrimaries(0x0),
83 fNumberOfDigits(clus.fNumberOfDigits),
89 // The copy constructor
91 fGlobalPos[0] = clus.fGlobalPos[0];
92 fGlobalPos[1] = clus.fGlobalPos[1];
93 fGlobalPos[2] = clus.fGlobalPos[2];
95 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
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];
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];
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];
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];
121 //_______________________________________________________________________
122 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
124 // assignment operator
126 if(&source == this) return *this;
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;
140 fNExMax = source.fNExMax;
141 fEmcCpvDistance = source.fEmcCpvDistance;
142 fDistToBadChannel = source.fDistToBadChannel ;
143 fNumberOfPrimaries = source.fNumberOfPrimaries;
144 delete fListOfPrimaries; fListOfPrimaries=0x0;
146 fNumberOfDigits = source.fNumberOfDigits;
147 delete fDigitAmplitude; fDigitAmplitude=0x0;
148 delete fDigitTime; fDigitTime = 0x0;
149 delete fDigitIndex; fDigitIndex = 0x0;
151 fGlobalPos[0] = source.fGlobalPos[0];
152 fGlobalPos[1] = source.fGlobalPos[1];
153 fGlobalPos[2] = source.fGlobalPos[2];
155 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
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];
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];
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];
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];
185 //_______________________________________________________________________
186 AliESDCaloCluster::~AliESDCaloCluster(){
188 // This is destructor according Coding Conventrions
190 // AliESDCaloCluster is the owner of the arrays
191 // even if they are created outside
192 delete[] fListOfPrimaries;
193 delete[] fDigitAmplitude;
195 delete[] fDigitIndex;
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
206 // The negative weights are set to 0.
207 // In case all the weights are non-positive they are replaced by
208 // uniform probabilities
210 Int_t n = AliPID::kSPECIESN;
212 Float_t uniform = 1./(Float_t)n;
215 for (Int_t i=0; i<n; i++)
225 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
227 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
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
236 Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
237 fGlobalPos[1]*fGlobalPos[1]+
238 fGlobalPos[2]*fGlobalPos[2] ) ;
240 p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;