]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDCaloCluster.cxx
From Christian Holm Christensen.
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
index b75177e222c0ab484dcddf2b8f9272426cbacdbb..15b55e0111a6277d11953f4b60264e31cedf0f3d 100644 (file)
@@ -31,24 +31,25 @@ ClassImp(AliESDCaloCluster)
 
 //_______________________________________________________________________
 AliESDCaloCluster::AliESDCaloCluster() : 
-  fID(0),
-  fClusterType(-1),
-  fEMCALCluster(kFALSE),
-  fPHOSCluster(kFALSE),
-  fEnergy(-1),
-  fDispersion(-1),
-  fChi2(-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),
-  fTracksMatched(0x0),
-  fLabels(0x0),
-  fDigitAmplitude(0x0),
-  fDigitTime(0x0),
-  fDigitIndex(0x0)
+  fClusterType(kUndef), fTOF(0.)
 {
   //
   // The default ESD constructor 
@@ -60,24 +61,25 @@ AliESDCaloCluster::AliESDCaloCluster() :
 //_______________________________________________________________________
 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) : 
   TObject(clus),
-  fID(clus.fID),
-  fClusterType(clus.fClusterType),
-  fEMCALCluster(clus.fEMCALCluster),
-  fPHOSCluster(clus.fPHOSCluster),
+  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),
   fM20(clus.fM20),
   fM02(clus.fM02),
-  fM11(clus.fM11),
-  fNExMax(clus.fNExMax),
   fEmcCpvDistance(clus.fEmcCpvDistance),
   fDistToBadChannel(clus.fDistToBadChannel),
-  fTracksMatched(clus.fTracksMatched?new TArrayS(*clus.fTracksMatched):0x0),
-  fLabels(clus.fLabels?new TArrayS(*clus.fLabels):0x0),
-  fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),
-  fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),
-  fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0)
+  fID(clus.fID),
+  fNExMax(clus.fNExMax),
+  fClusterType(clus.fClusterType),
+  fTOF(clus.fTOF)
 {
   //
   // The copy constructor 
@@ -88,6 +90,22 @@ AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
 
   for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[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.fCellsAmpFraction){
+      fCellsAmpFraction = new Double32_t[clus.fNCells];
+      for (Int_t i=0; i<clus.fNCells; i++)
+       fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
+    }
+    
+  }
+
 }
 
 //_______________________________________________________________________
@@ -96,37 +114,121 @@ 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;
   fEnergy = source.fEnergy;
   fDispersion = source.fDispersion;
   fChi2 = source.fChi2;
   fM20 = source.fM20;
   fM02 = source.fM02;
-  fM11 = source.fM11;
-  fNExMax = source.fNExMax;
   fEmcCpvDistance = source.fEmcCpvDistance;
   fDistToBadChannel = source.fDistToBadChannel ;
+  for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
+  fID = source.fID;
 
-  fGlobalPos[0] = source.fGlobalPos[0];
-  fGlobalPos[1] = source.fGlobalPos[1];
-  fGlobalPos[2] = source.fGlobalPos[2];
+  fNCells= source.fNCells;
 
-  for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
+  if (source.fNCells > 0) {
+    if(source.fCellsAbsId){
+      if(fNCells != source.fNCells){
+       delete [] fCellsAbsId;
+       fCellsAbsId = new UShort_t[source.fNCells];
+      }
+      for (Int_t i=0; i<source.fNCells; i++)
+       fCellsAbsId[i]=source.fCellsAbsId[i];
+    }
+    
+    if(source.fCellsAmpFraction){
+      if(fNCells != source.fNCells){
+       delete [] 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;
+  fTOF = source.fTOF;
+
+  //not in use
+  if(source.fTracksMatched){
+    // assign or copy construct
+    if(fTracksMatched) *fTracksMatched = *source.fTracksMatched;
+    else fTracksMatched = new TArrayI(*source.fTracksMatched);
+  }
+  else{
+    delete fTracksMatched;
+    fTracksMatched = 0;
+  }
+
+  if(source.fLabels){
+    // assign or copy construct
+    if(fLabels) *fLabels = *source.fLabels;
+    else fLabels = new TArrayI(*source.fLabels);
+  }
+  else{
+    delete fLabels;
+    fLabels = 0;
+  }
+
+
+  if(source.fDigitAmplitude){
+    // assign or copy construct
+    if(fDigitAmplitude) *fDigitAmplitude = *source.fDigitAmplitude;
+    else fDigitAmplitude = new TArrayS(*source.fDigitAmplitude);
+  }
+  else{
+    delete fDigitAmplitude;
+    fDigitAmplitude = 0;
+  }
+
+
+
+  if(source.fDigitTime){
+    // assign or copy construct
+    if(fDigitTime) *fDigitTime = *source.fDigitTime;
+    else fDigitTime = new TArrayS(*source.fDigitTime);
+  }
+  else{
+    delete fDigitTime;
+    fDigitTime = 0;
+  }
 
-  fTracksMatched = source.fTracksMatched?new TArrayS(*source.fTracksMatched):0x0;
-  fLabels = source.fLabels?new TArrayS(*source.fLabels):0x0;
-  fDigitAmplitude = source.fDigitAmplitude?new TArrayS(*source.fDigitAmplitude):0x0;
-  fDigitTime = source.fDigitTime?new TArrayS(*source.fDigitTime):0x0;
-  fDigitIndex = source.fDigitIndex?new TArrayS(*source.fDigitIndex):0x0;
 
+
+  if(source.fDigitIndex){
+    // assign or copy construct
+    if(fDigitIndex) *fDigitIndex = *source.fDigitIndex;
+    else fDigitIndex = new TArrayS(*source.fDigitIndex);
+  }
+  else{
+    delete fDigitIndex;
+    fDigitIndex = 0;
+  }
+  
   return *this;
 
 }
 
+void AliESDCaloCluster::Copy(TObject &obj) const {
+  
+  // this overwrites the virtual TOBject::Copy()
+  // to allow run time copying without casting
+  // in AliESDEvent
+
+  if(this==&obj)return;
+  AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj);
+  if(!robj)return; // not an AliESDCluster
+  *robj = *this;
+
+}
 
 //_______________________________________________________________________
 AliESDCaloCluster::~AliESDCaloCluster(){ 
@@ -135,10 +237,11 @@ AliESDCaloCluster::~AliESDCaloCluster(){
   //
   delete fTracksMatched;
   delete fLabels;
-  delete fDigitAmplitude;
-  delete fDigitTime;
-  delete fDigitIndex;
-
+  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;
 }
 
 //_______________________________________________________________________
@@ -193,24 +296,23 @@ void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
   p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r,  fEnergy*fGlobalPos[1]/r,  fEnergy*fGlobalPos[2]/r,  fEnergy) ; 
   
 }
-// Sep 7, 2007
-Int_t AliESDCaloCluster::GetTrueDigitAmplitude(Int_t i, Double_t cc)
-{
-  static Int_t amp=0; // amp is integer now
-  amp = 0;
-  if(i>=0 && i<fDigitAmplitude->GetSize() && cc>0.0) {
-    // true formula
-    amp = Int_t(Double_t(fDigitAmplitude->At(i))/500./cc+0.5);
-  }
-  return amp;
-}
 
-Double_t AliESDCaloCluster::GetTrueDigitEnergy(Int_t i, Double_t cc)
+//_______________________________________________________________________
+void  AliESDCaloCluster::SetCellsAbsId(UShort_t *array)
 {
-  return Double_t(GetTrueDigitAmplitude(i,cc)) * cc;
+    //  Set the array of cell absId numbers 
+    if (fNCells) {
+       fCellsAbsId = new  UShort_t[fNCells];
+       for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
+    }
 }
 
-Double_t AliESDCaloCluster::GetRecalibratedDigitEnergy(Int_t i, Double_t ccOld, Double_t ccNew)
+//_______________________________________________________________________
+void  AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
 {
-  return Double_t(GetTrueDigitAmplitude(i,ccOld)) * ccNew;
+    //  Set the array of cell amplitude fraction
+    if (fNCells) {
+       fCellsAmpFraction = new  Double32_t[fNCells];
+       for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
+    }
 }