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),
46 fEmcCpvDistance(9999),
53 // The default ESD constructor
55 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
56 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
59 //_______________________________________________________________________
60 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
63 fClusterType(clus.fClusterType),
64 fEMCALCluster(clus.fEMCALCluster),
65 fPHOSCluster(clus.fPHOSCluster),
66 fEnergy(clus.fEnergy),
67 fDispersion(clus.fDispersion),
69 fPrimaryIndex(clus.fPrimaryIndex),
73 fNExMax(clus.fNExMax),
74 fEmcCpvDistance(clus.fEmcCpvDistance),
75 fNumberOfDigits(clus.fNumberOfDigits),
81 // The copy constructor
83 fGlobalPos[0] = clus.fGlobalPos[0];
84 fGlobalPos[1] = clus.fGlobalPos[1];
85 fGlobalPos[2] = clus.fGlobalPos[2];
87 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
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];
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];
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];
108 //_______________________________________________________________________
109 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
111 // assignment operator
113 if(&source == this) return *this;
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;
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;
133 fGlobalPos[0] = source.fGlobalPos[0];
134 fGlobalPos[1] = source.fGlobalPos[1];
135 fGlobalPos[2] = source.fGlobalPos[2];
137 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
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];
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];
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];
162 //_______________________________________________________________________
163 AliESDCaloCluster::~AliESDCaloCluster(){
165 // This is destructor according Coding Conventrions
167 // AliESDCaloCluster is the owner of the arrays
168 // even if they are created outside
170 delete[] fDigitAmplitude;
172 delete[] fDigitIndex;
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
183 // The negative weights are set to 0.
184 // In case all the weights are non-positive they are replaced by
185 // uniform probabilities
187 Int_t n = AliPID::kSPECIESN;
189 Float_t uniform = 1./(Float_t)n;
192 for (Int_t i=0; i<n; i++)
202 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
204 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
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
213 Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
214 fGlobalPos[1]*fGlobalPos[1]+
215 fGlobalPos[2]*fGlobalPos[2] ) ;
217 p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;