]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSEmcRecPoint.cxx
wagon for photon isolation spectra analysis with CaloTrackCorr frame
[u/mrichter/AliRoot.git] / PHOS / AliPHOSEmcRecPoint.cxx
index 188b9d3b36a0335e25569ab058387f788932b5f8..efca0fc5bbca6947b6ffa3cf0ecdb824ee48b90c 100644 (file)
@@ -60,6 +60,9 @@
  
 ClassImp(AliPHOSEmcRecPoint)
 
+Long64_t AliPHOSEmcRecPoint::fgInstCount=0;
+
+
 //____________________________________________________________________________
 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() : 
   AliPHOSRecPoint(),
@@ -67,6 +70,7 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
   fEnergyList(0), fTime(-1.), fNExMax(0),
   fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
   fPhixe(0.), fDistToBadCrystal(-1),fDebug(0)
+  ,fInstCount(0)
 {
   // ctor
   fMulDigit   = 0 ;  
@@ -75,7 +79,8 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
 
   fLambda[0] = 0.;
   fLambda[1] = 0.;
-
+  fInstCount=fgInstCount++;
+  if (gDebug==-10) AliInfo(Form("0Create instance %lld",fInstCount));
 }
 
 //____________________________________________________________________________
@@ -85,6 +90,7 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
   fEnergyList(0), fTime(-1.), fNExMax(0),
   fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
   fPhixe(0.), fDistToBadCrystal(-1), fDebug(0)
+  ,fInstCount(0)
 {
   // ctor
   fMulDigit   = 0 ;  
@@ -93,6 +99,8 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
   
   fLambda[0] = 0.;
   fLambda[1] = 0.;
+  fInstCount=fgInstCount++;
+   if (gDebug==-10) AliInfo(Form("1Create instance %lld",fInstCount));
 }
 
 //____________________________________________________________________________
@@ -102,6 +110,7 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
   fEnergyList(0), fTime(rp.fTime), fNExMax(rp.fNExMax),
   fM2x(rp.fM2x), fM2z(rp.fM2z), fM3x(rp.fM3x), fM4z(rp.fM4z),
   fPhixe(rp.fPhixe), fDistToBadCrystal(rp.fDistToBadCrystal), fDebug(rp.fDebug)
+  ,fInstCount(0)
 {
   // cpy ctor
   fMulDigit   = rp.fMulDigit ;  
@@ -113,6 +122,8 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
   for(Int_t i=0; i<2; i++) {
     fLambda[i] = rp.fLambda[i];
   }
+  fInstCount=fgInstCount++;
+   if (gDebug==-10) AliInfo(Form("2Create instance %lld",fInstCount));
 }
 
 //____________________________________________________________________________
@@ -121,6 +132,9 @@ AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
   // dtor
   if ( fEnergyList )
     delete[] fEnergyList ; 
+   if (gDebug==-10) AliInfo(Form("Delete instance %lld (%lld)",fInstCount, fgInstCount));
+  if (fInstCount>=fgInstCount-1) fgInstCount--;
+
 }
 
 //____________________________________________________________________________
@@ -740,8 +754,10 @@ void  AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
   Float_t emax=0.;
   Int_t imaxDigit=0;
   for(Int_t id=0; id<GetDigitsMultiplicity(); id++){
-    if(emax<fEnergyList[id])
+    if(emax<fEnergyList[id]){
       imaxDigit=id ;
+      emax=fEnergyList[id];
+    }
   }
   digit = static_cast<AliPHOSDigit *>(digits->At( fDigitsList[imaxDigit] )) ; 
   Int_t nprimaries = digit->GetNprimary() ;
@@ -784,8 +800,9 @@ void  AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
     if(fTracksList)delete [] fTracksList;
     fTracksList = new Int_t[fMulTrack] ;
   }
-  for(Int_t index = 0; index < fMulTrack; index++)
+  for(Int_t index = 0; index < fMulTrack; index++){
     fTracksList[index] = tempo[index] ;
+  }
   
   delete [] tempo ;
   
@@ -977,11 +994,11 @@ void AliPHOSEmcRecPoint::EvalTime(TClonesArray * /*digits*/)
 */  
 }
 //____________________________________________________________________________
-void AliPHOSEmcRecPoint::Purify(Float_t threshold){
+void AliPHOSEmcRecPoint::Purify(Float_t threshold, const TClonesArray * digits){
   //Removes digits below threshold
 
-  Int_t * tempo = new Int_t[fMaxDigit]; 
-  Float_t * tempoE =  new Float_t[fMaxDigit];
+  Int_t tempo[fMaxDigit]; 
+  Float_t tempoE[fMaxDigit];
 
   Int_t mult = 0 ;
   for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
@@ -991,8 +1008,43 @@ void AliPHOSEmcRecPoint::Purify(Float_t threshold){
       mult++ ;
     }
   }
-  
-  fMulDigit = mult ;
+
+  if(mult==0){ //too soft cluster
+    fMulDigit =0 ;
+    fAmp = 0.; //Recalculate total energy
+  }
+    
+  //Remove non-connected cells
+  Int_t index[mult] ;
+  Bool_t used[mult] ;
+  for(Int_t i=0; i<mult; i++) used[i]=0 ;
+  Int_t inClu=0 ;
+  Double_t eMax=0. ;
+  //find maximum
+  for(Int_t iDigit=0; iDigit<mult; iDigit++) {
+    if(eMax<tempoE[iDigit]){
+      eMax=tempoE[iDigit];
+      index[0]=iDigit ;
+      inClu=1 ;
+    }
+  }
+  if(mult>0)
+    used[index[0]]=kTRUE ; //mark as used
+  for(Int_t i=0; i<inClu; i++){
+    AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(tempo[index[i]]) ; 
+    for(Int_t iDigit=0 ;iDigit<mult; iDigit++){
+      if(used[iDigit]) //already used
+        continue ;
+      AliPHOSDigit * digitN = (AliPHOSDigit *) digits->At(tempo[iDigit]) ;     
+      if(AreNeighbours(digit,digitN)){
+       index[inClu]= iDigit ;
+       inClu++ ;
+       used[iDigit]=kTRUE ;
+      }
+    }
+  }
+     
+  fMulDigit = inClu ;
   delete [] fDigitsList ;
   delete [] fEnergyList ;
   fDigitsList = new Int_t[fMulDigit];
@@ -1000,14 +1052,10 @@ void AliPHOSEmcRecPoint::Purify(Float_t threshold){
 
   fAmp = 0.; //Recalculate total energy
   for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
-     fDigitsList[iDigit] = tempo[iDigit];
-     fEnergyList[iDigit] = tempoE[iDigit] ;
-     fAmp+=tempoE[iDigit];
-  }
-      
-  delete [] tempo ;
-  delete [] tempoE ;
-
+     fDigitsList[iDigit] = tempo[index[iDigit]];
+     fEnergyList[iDigit] = tempoE[index[iDigit]] ;
+     fAmp+=tempoE[index[iDigit]];
+  }      
 }
 //____________________________________________________________________________
 void AliPHOSEmcRecPoint::Print(Option_t *) const