]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDCaloCluster.cxx
Getters and setter of vtx type modified.
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
index b506ebf3cac36d632f5d7cafa58ce85283edf98e..3c491c75e97607544b1f0316a24c26121a03b177 100644 (file)
@@ -24,6 +24,7 @@
 //   J.L. Klay (LLNL)
 //-----------------------------------------------------------------
 
+#include <TLorentzVector.h>
 #include "AliESDCaloCluster.h"
 
 ClassImp(AliESDCaloCluster)
@@ -33,13 +34,22 @@ AliESDCaloCluster::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 
@@ -54,10 +64,22 @@ AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
   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 
@@ -68,9 +90,89 @@ AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
 
   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;
 
 }
 
@@ -80,20 +182,13 @@ AliESDCaloCluster::~AliESDCaloCluster(){
   //
   // 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;
+
 }
 
 //_______________________________________________________________________
@@ -127,3 +222,16 @@ void AliESDCaloCluster::SetPid(const Float_t *p) {
     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) ; 
+  
+}