]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDCaloCluster.cxx
AliCodeTimer is already in libSTEERBase.so
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
index 74ce659a60a6fd36b3904e3451ab9df2d11a25fd..78f6efa5ea3dbc6ccf6f9f55cf556bc97921cec0 100644 (file)
@@ -31,27 +31,26 @@ ClassImp(AliESDCaloCluster)
 
 //_______________________________________________________________________
 AliESDCaloCluster::AliESDCaloCluster() : 
-  fID(0),
-  fClusterType(-1),
-  fEMCALCluster(kFALSE),
-  fPHOSCluster(kFALSE),
-  fTrackMatched(-1),
-  fEnergy(-1),
-  fDispersion(-1),
-  fChi2(-1),
-  fPrimaryIndex(-1),
+  TObject(),
+  fTracksMatched(0x0),
+  fLabels(0x0),
+  fNCells(0),
+  fCellsAbsId(0x0),
+  fCellsAmpFraction(0x0),
+  fDigitAmplitude(0x0),//not in use
+  fDigitTime(0x0),//not in use
+  fDigitIndex(0x0),//not in use
+  fEnergy(0),
+  fDispersion(0),
+  fChi2(0),
   fM20(0),
   fM02(0),
   fM11(0),
+  fEmcCpvDistance(1024),
+  fDistToBadChannel(1024),
+  fID(0),
   fNExMax(0),
-  fEmcCpvDistance(9999),
-  fDistToBadChannel(9999),
-  fNumberOfPrimaries(-1),
-  fListOfPrimaries(0x0),
-  fNumberOfDigits(0),
-  fDigitAmplitude(0x0),
-  fDigitTime(0x0),
-  fDigitIndex(0x0)
+  fClusterType(kUndef)
 {
   //
   // The default ESD constructor 
@@ -63,27 +62,25 @@ AliESDCaloCluster::AliESDCaloCluster() :
 //_______________________________________________________________________
 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) : 
   TObject(clus),
-  fID(clus.fID),
-  fClusterType(clus.fClusterType),
-  fEMCALCluster(clus.fEMCALCluster),
-  fPHOSCluster(clus.fPHOSCluster),
-  fTrackMatched(clus.fTrackMatched),
+  fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
+  fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
+  fNCells(clus.fNCells),
+  fCellsAbsId(),
+  fCellsAmpFraction(),
+  fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),//not in use
+  fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),//not in use
+  fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0),//not in use
   fEnergy(clus.fEnergy),
   fDispersion(clus.fDispersion),
   fChi2(clus.fChi2),
-  fPrimaryIndex(clus.fPrimaryIndex),
   fM20(clus.fM20),
   fM02(clus.fM02),
   fM11(clus.fM11),
-  fNExMax(clus.fNExMax),
   fEmcCpvDistance(clus.fEmcCpvDistance),
   fDistToBadChannel(clus.fDistToBadChannel),
-  fNumberOfPrimaries(clus.fNumberOfPrimaries),
-  fListOfPrimaries(0x0),
-  fNumberOfDigits(clus.fNumberOfDigits),
-  fDigitAmplitude(0x0),
-  fDigitTime(0x0),
-  fDigitIndex(0x0)
+  fID(clus.fID),
+  fNExMax(clus.fNExMax),
+  fClusterType(clus.fClusterType)
 {
   //
   // The copy constructor 
@@ -94,28 +91,22 @@ AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
 
   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
 
-  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.fNCells > 0) {
+
+    if(clus.fCellsAbsId){
+      fCellsAbsId = new UShort_t[clus.fNCells];
+      for (Int_t i=0; i<clus.fNCells; i++)
+       fCellsAbsId[i]=clus.fCellsAbsId[i];
     }
-   if (clus.fListOfPrimaries) {
-      fListOfPrimaries = new UShort_t[clus.fNumberOfPrimaries];
-      for (Int_t i=0; i<clus.fNumberOfPrimaries; i++)
-       fListOfPrimaries[i]=clus.fListOfPrimaries[i];
+    
+    if(clus.fCellsAmpFraction){
+      fCellsAmpFraction = new Double32_t[clus.fNCells];
+      for (Int_t i=0; i<clus.fNCells; i++)
+       fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
     }
+    
   }
+
 }
 
 //_______________________________________________________________________
@@ -124,59 +115,59 @@ AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
   // assignment operator
 
   if(&source == this) return *this;
+  TObject::operator=(source);
+
+  fGlobalPos[0] = source.fGlobalPos[0];
+  fGlobalPos[1] = source.fGlobalPos[1];
+  fGlobalPos[2] = source.fGlobalPos[2];
+
 
-  fID = source.fID;
-  fClusterType = source.fClusterType;
-  fEMCALCluster = source.fEMCALCluster;
-  fPHOSCluster = source.fPHOSCluster;
-  fTrackMatched = source.fTrackMatched;
   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;
   fDistToBadChannel = source.fDistToBadChannel ;
-  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];
+  fID = source.fID;
 
-  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];
+  fNCells= source. fNCells;
+  if (source.fNCells > 0) {
+    
+    if(source.fCellsAbsId){
+      fCellsAbsId = new UShort_t[source.fNCells];
+      for (Int_t i=0; i<source.fNCells; i++)
+       fCellsAbsId[i]=source.fCellsAbsId[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];
+    
+    if(source.fCellsAmpFraction){
+      fCellsAmpFraction = new Double32_t[source.fNCells];
+      for (Int_t i=0; i<source.fNCells; i++)
+       fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
     }
+    
   }
 
+  fNExMax = source.fNExMax;
+  fClusterType = source.fClusterType;
+
+  //not in use
+  delete fTracksMatched;
+  fTracksMatched = source.fTracksMatched?new TArrayI(*source.fTracksMatched):0x0;
+  delete fLabels;
+  fLabels = source.fLabels?new TArrayI(*source.fLabels):0x0;
+  
+  delete fDigitAmplitude;
+  fDigitAmplitude = source.fDigitAmplitude?new TArrayS(*source.fDigitAmplitude):0x0;
+  
+  delete fDigitTime;
+  fDigitTime = source.fDigitTime?new TArrayS(*source.fDigitTime):0x0;
+  
+  delete fDigitIndex;
+  fDigitIndex = source.fDigitIndex?new TArrayS(*source.fDigitIndex):0x0;
+  
   return *this;
 
 }
@@ -185,15 +176,15 @@ AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
 //_______________________________________________________________________
 AliESDCaloCluster::~AliESDCaloCluster(){ 
   //
-  // This is destructor according Coding Conventrions 
+  // This is destructor according Coding Conventions 
   //
-  // AliESDCaloCluster is the owner of the arrays
-  // even if they are created outside
-  delete[] fListOfPrimaries;
-  delete[] fDigitAmplitude;
-  delete[] fDigitTime;
-  delete[] fDigitIndex;
-
+  delete fTracksMatched;
+  delete fLabels;
+  delete fDigitAmplitude;  //not in use
+  delete fDigitTime;  //not in use
+  delete fDigitIndex;  //not in use
+  if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
+  if(fCellsAbsId) delete[] fCellsAbsId;  fCellsAbsId = 0;
 }
 
 //_______________________________________________________________________
@@ -229,9 +220,17 @@ void AliESDCaloCluster::SetPid(const Float_t *p) {
 }
 
 //_______________________________________________________________________
-void AliESDCaloCluster::GetMomentum(TLorentzVector& p) {
+void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
   // Returns TLorentzVector with momentum of the cluster. Only valid for clusters 
   // identified as photons or pi0 (overlapped gamma) produced on the vertex
+  //Vertex can be recovered with esd pointer doing:  
+  //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
+
+  if(vertex){//calculate direction from vertex
+    fGlobalPos[0]-=vertex[0];
+    fGlobalPos[1]-=vertex[1];
+    fGlobalPos[2]-=vertex[2];
+  }
   
   Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
                            fGlobalPos[1]*fGlobalPos[1]+