// J.L. Klay (LLNL)
//-----------------------------------------------------------------
+#include <TLorentzVector.h>
#include "AliESDCaloCluster.h"
ClassImp(AliESDCaloCluster)
fID(0),
fClusterType(-1),
fEMCALCluster(kFALSE),
+ fPHOSCluster(kFALSE),
fEnergy(-1),
fDispersion(-1),
fChi2(-1),
+ fPrimaryIndex(-1),
+ fM20(0),
+ fM02(0),
+ fM11(0),
+ fNExMax(0),
+ fEmcCpvDistance(9999),
+ fNumberOfPrimaries(-1),
+ fListOfPrimaries(0x0),
fNumberOfDigits(0),
- fDigitAmplitude(0),
- fDigitTime(0),
- fDigitIndex(0)
+ fDigitAmplitude(0x0),
+ fDigitTime(0x0),
+ fDigitIndex(0x0)
{
//
// The default ESD constructor
fID(clus.fID),
fClusterType(clus.fClusterType),
fEMCALCluster(clus.fEMCALCluster),
+ fPHOSCluster(clus.fPHOSCluster),
fEnergy(clus.fEnergy),
fDispersion(clus.fDispersion),
fChi2(clus.fChi2),
- fNumberOfDigits(clus.fNumberOfDigits)
+ fPrimaryIndex(clus.fPrimaryIndex),
+ fM20(clus.fM20),
+ fM02(clus.fM02),
+ fM11(clus.fM11),
+ fNExMax(clus.fNExMax),
+ fEmcCpvDistance(clus.fEmcCpvDistance),
+ fNumberOfPrimaries(clus.fNumberOfPrimaries),
+ fListOfPrimaries(0x0),
+ fNumberOfDigits(clus.fNumberOfDigits),
+ fDigitAmplitude(0x0),
+ fDigitTime(0x0),
+ fDigitIndex(0x0)
{
//
// The copy constructor
for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
- fDigitAmplitude = clus.fDigitAmplitude;
- fDigitTime = clus.fDigitTime;
- fDigitIndex = clus.fDigitIndex;
+ if (clus.fNumberOfDigits > 0) {
+ if (clus.fDigitAmplitude) {
+ fDigitAmplitude = new UShort_t[clus.fNumberOfDigits];
+ for (Int_t i=0; i<clus.fNumberOfDigits; i++)
+ fDigitAmplitude[i]=clus.fDigitAmplitude[i];
+ }
+ if (clus.fDigitTime) {
+ fDigitTime = new UShort_t[clus.fNumberOfDigits];
+ for (Int_t i=0; i<clus.fNumberOfDigits; i++)
+ fDigitTime[i]=clus.fDigitTime[i];
+ }
+ if (clus.fDigitIndex) {
+ fDigitIndex = new UShort_t[clus.fNumberOfDigits];
+ for (Int_t i=0; i<clus.fNumberOfDigits; i++)
+ fDigitIndex[i]=clus.fDigitIndex[i];
+ }
+ if (clus.fListOfPrimaries) {
+ fListOfPrimaries = new UShort_t[clus.fNumberOfPrimaries];
+ for (Int_t i=0; i<clus.fNumberOfPrimaries; i++)
+ fListOfPrimaries[i]=clus.fListOfPrimaries[i];
+ }
+ }
+}
+
+//_______________________________________________________________________
+AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
+{
+ // assignment operator
+
+ if(&source == this) return *this;
+
+ fID = source.fID;
+ fClusterType = source.fClusterType;
+ fEMCALCluster = source.fEMCALCluster;
+ fPHOSCluster = source.fPHOSCluster;
+ fEnergy = source.fEnergy;
+ fDispersion = source.fDispersion;
+ fChi2 = source.fChi2;
+ fPrimaryIndex = source.fPrimaryIndex;
+ fM20 = source.fM20;
+ fM02 = source.fM02;
+ fM11 = source.fM11;
+ fNExMax = source.fNExMax;
+ fEmcCpvDistance = source.fEmcCpvDistance;
+
+ fNumberOfPrimaries = source.fNumberOfPrimaries;
+ delete fListOfPrimaries; fListOfPrimaries=0x0;
+
+ fNumberOfDigits = source.fNumberOfDigits;
+ delete fDigitAmplitude; fDigitAmplitude=0x0;
+ delete fDigitTime; fDigitTime = 0x0;
+ delete fDigitIndex; fDigitIndex = 0x0;
+
+ fGlobalPos[0] = source.fGlobalPos[0];
+ fGlobalPos[1] = source.fGlobalPos[1];
+ fGlobalPos[2] = source.fGlobalPos[2];
+
+ for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
+
+ if (source.fNumberOfDigits > 0) {
+ if (source.fDigitAmplitude) {
+ fDigitAmplitude = new UShort_t[source.fNumberOfDigits];
+ for (Int_t i=0; i<source.fNumberOfDigits; i++)
+ fDigitAmplitude[i]=source.fDigitAmplitude[i];
+ }
+ if (source.fDigitTime) {
+ fDigitTime = new UShort_t[source.fNumberOfDigits];
+ for (Int_t i=0; i<source.fNumberOfDigits; i++)
+ fDigitTime[i]=source.fDigitTime[i];
+ }
+ if (source.fDigitIndex) {
+ fDigitIndex = new UShort_t[source.fNumberOfDigits];
+ for (Int_t i=0; i<source.fNumberOfDigits; i++)
+ fDigitIndex[i]=source.fDigitIndex[i];
+ }
+ if (source.fListOfPrimaries) {
+ fListOfPrimaries = new UShort_t[source.fNumberOfPrimaries];
+ for (Int_t i=0; i<source.fNumberOfPrimaries; i++)
+ fListOfPrimaries[i]=source.fListOfPrimaries[i];
+ }
+ }
+
+ return *this;
}
//
// This is destructor according Coding Conventrions
//
- //printf("Delete cluster\n");
-
- //Not sure why but it won't let me delete these in the dtor here.
- //The Reconstruction gives me the error
- //*** glibc detected *** double free or corruption (!prev):
- //0x0c1550b0 ***
- /*
- if(fDigitAmplitude)
- delete[] fDigitAmplitude;
- if(fDigitTime)
- delete[] fDigitTime;
- if(fDigitIndex)
- delete[] fDigitIndex;
- */
+ // AliESDCaloCluster is the owner of the arrays
+ // even if they are created outside
+ delete[] fListOfPrimaries;
+ delete[] fDigitAmplitude;
+ delete[] fDigitTime;
+ delete[] fDigitIndex;
+
}
//_______________________________________________________________________
for (Int_t i=0; i<n; i++) fPID[i] = uniform;
}
+
+//_______________________________________________________________________
+void AliESDCaloCluster::GetMomentum(TLorentzVector& p) {
+ // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
+ // identified as photons or pi0 (overlapped gamma) produced on the vertex
+
+ Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
+ fGlobalPos[1]*fGlobalPos[1]+
+ fGlobalPos[2]*fGlobalPos[2] ) ;
+
+ p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;
+
+}