]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALClusterizer.cxx
put different cluster parameters (time, n cells, n SM) in the AOD particle, recover...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizer.cxx
index 7d6410da7a84ee13c336794387f2e0457ee4bdd2..bd3ae91b6c3fa868e6111ada53bd1d6ce8c09e1f 100644 (file)
@@ -25,8 +25,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 // --- ROOT system ---
-#include "TClonesArray.h"
-#include "TTree.h"
+#include <TTree.h>
 #include <TFile.h> 
 class TFolder;
 #include <TMath.h> 
@@ -69,11 +68,11 @@ AliEMCALClusterizer::AliEMCALClusterizer():
   fGeom(NULL),
   fCalibData(NULL), 
   fCaloPed(NULL),
-  fADCchannelECA(0.),fADCpedestalECA(0.),
+  fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(0.),
   fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
   fDefaultInit(kFALSE),fToUnfold(kFALSE),
   fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
-  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
+  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),fRejectBelowThreshold(0),
   fClusterUnfolding(NULL)
 {
   // ctor
@@ -91,11 +90,11 @@ AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry* geometry):
   fGeom(geometry),
   fCalibData(NULL), 
   fCaloPed(NULL),
-  fADCchannelECA(0.),fADCpedestalECA(0.),
+  fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(0.),
   fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
   fDefaultInit(kFALSE),fToUnfold(kFALSE),
   fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
-  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
+  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),fRejectBelowThreshold(0),
   fClusterUnfolding(NULL)
 {
   // Ctor with the indication of the file where header Tree and digits Tree are stored.
@@ -130,11 +129,11 @@ AliEMCALClusterizer::AliEMCALClusterizer(AliEMCALGeometry *geometry,
   fGeom(geometry),
   fCalibData(calib),
   fCaloPed(caloped),
-  fADCchannelECA(0.),fADCpedestalECA(0.),
+  fADCchannelECA(0.),fADCpedestalECA(0.), fTimeECA(0.),
   fTimeMin(-1.),fTimeMax(1.),fTimeCut(1.),
   fDefaultInit(kFALSE),fToUnfold(kFALSE),
   fNumberOfECAClusters(0), fECAClusteringThreshold(0.),
-  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),
+  fECALocMaxCut(0.),fECAW0(0.),fMinECut(0.),fRejectBelowThreshold(0),
   fClusterUnfolding(NULL)
 {
   // ctor, geometry and calibration are initialized elsewhere.
@@ -158,24 +157,58 @@ AliEMCALClusterizer::~AliEMCALClusterizer()
   //Already deleted in AliEMCALReconstructor.
 
   if(fClusterUnfolding) delete fClusterUnfolding;
+
+  // make sure we delete the rec points array
+  DeleteRecPoints();
+
+  //Delete digits array
+  DeleteDigits();
+
+}
+
+//____________________________________________________________________________
+void AliEMCALClusterizer::DeleteRecPoints()
+{
+  // free the cluster array
+  if (fRecPoints) 
+    {
+      AliDebug(2, "Deleting fRecPoints.");
+      fRecPoints->Delete();
+      delete fRecPoints;
+      fRecPoints = 0;
+    }
+}
+
+//____________________________________________________________________________
+void AliEMCALClusterizer::DeleteDigits()
+{
+  // free the digits array
+  if (fDigitsArr) 
+    {
+      AliDebug(2, "Deleting fDigitsArr.");
+      fDigitsArr->Clear("C");
+      delete fDigitsArr;
+      fDigitsArr = 0;
+    }
 }
 
 //____________________________________________________________________________
-Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, const Int_t absId) 
+void AliEMCALClusterizer::Calibrate(Float_t & amp, Float_t & time, const Int_t absId) 
 {
-  // Convert digitized amplitude into energy.
-  // Calibration parameters are taken from calibration data base for raw data,
-  // or from digitizer parameters for simulated data.
+  // Convert digitized amplitude into energy, calibrate time
+  // Calibration parameters are taken from OCDB : OCDB/EMCAL/Calib/Data
 
   //Return energy with default parameters if calibration is not available
-  if (!fCalibData&&!fCaloPed) {
+  if (!fCalibData && !fCaloPed) {
     if (fIsInputCalibrated == kTRUE)
     {
       AliDebug(10, Form("Input already calibrated!"));
-      return amp;
-    }    
-    
-    return -fADCpedestalECA + amp * fADCchannelECA ; 
+      return ;
+    }
+    else{
+      AliFatal("OCDB calibration and bad map parameters are not available");
+      return;
+    }   
   }
   
   if (fGeom==0)
@@ -195,7 +228,9 @@ Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, co
     //assert(0); // GCB: This aborts reconstruction of raw simulations 
     //where simulation had more SM than default geometry, 
     //change to return 0, to avoid aborting good generations.
-    return 0;
+    amp  = 0;
+    time = 0;
+    return ;
   }
     
   fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
@@ -208,22 +243,27 @@ Float_t AliEMCALClusterizer::Calibrate(const Float_t amp, const Float_t time, co
     Int_t channelStatus = (Int_t)(fCaloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
     if(channelStatus == AliCaloCalibPedestal::kHot || channelStatus == AliCaloCalibPedestal::kDead) {
       AliDebug(2,Form("Tower from SM %d, ieta %d, iphi %d is BAD : status %d !!!",iSupMod,ieta,iphi, channelStatus));
-      return 0;
+      amp  = 0 ;
+      time = 0 ;
+      return ;
     }
   }
-  //Check if time is too large or too small, indication of a noisy channel, remove in this case
-  if(time > fTimeMax || time < fTimeMin) return 0;
     
-  if (fIsInputCalibrated)
+  if (fIsInputCalibrated || !fCalibData)
   {
     AliDebug(10, Form("Input already calibrated!"));
-    return amp;
+    return ;
   }
          
+  Int_t bc = 0; // Get somehow the bunch crossing number
+
   fADCchannelECA  = fCalibData->GetADCchannel (iSupMod,ieta,iphi);
   fADCpedestalECA = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
-      
-  return -fADCpedestalECA + amp * fADCchannelECA ;        
+  fTimeECA        = fCalibData->GetTimeChannel(iSupMod,ieta,iphi, bc);
+  
+  time -= fTimeECA ;
+  amp   = amp * fADCchannelECA - fADCpedestalECA ;  
+  
 }
 
 //____________________________________________________________________________
@@ -331,15 +371,21 @@ void AliEMCALClusterizer::InitParameters(const AliEMCALRecParam* recParam)
   fECAClusteringThreshold = recParam->GetClusteringThreshold();
   fECAW0                  = recParam->GetW0();
   fMinECut                = recParam->GetMinECut();    
+  fRejectBelowThreshold   = recParam->GetRejectBelowThreshold();
   fToUnfold               = recParam->GetUnfold();
   fECALocMaxCut           = recParam->GetLocMaxCut();
   fTimeCut                = recParam->GetTimeCut();
   fTimeMin                = recParam->GetTimeMin();
   fTimeMax                = recParam->GetTimeMax();
-    
+  
+  //For NxN
+  SetNRowDiff(recParam->GetNRowDiff());
+  SetNColDiff(recParam->GetNColDiff());
+  
   AliDebug(1,Form("Reconstruction parameters: fECAClusteringThreshold=%.3f GeV, fECAW=%.3f, fMinECut=%.3f GeV, "
-                  "fToUnfold=%d, fECALocMaxCut=%.3f GeV, fTimeCut=%e s,fTimeMin=%e s,fTimeMax=%e s",
-                  fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax));
+                  "fToUnfold=%d, fECALocMaxCut=%.3f GeV, fTimeCut=%e s,fTimeMin=%e s,fTimeMax=%e s,fRejectBelowThreshold=%d",
+                  fECAClusteringThreshold,fECAW0,fMinECut,fToUnfold,fECALocMaxCut,fTimeCut, fTimeMin, fTimeMax, 
+                 fRejectBelowThreshold));
 
   if (fToUnfold) {
     Int_t i=0;
@@ -466,12 +512,15 @@ void AliEMCALClusterizer::SetInput(TTree *digitsTree)
   // Read the digits from the input tree
 
   TBranch *branch = digitsTree->GetBranch("EMCAL");
-  if (!branch) { 
+  if (!branch)
+  {
     AliError("can't get the branch with the EMCAL digits !");
     return;
   }
-  if (!fDigitsArr)
-    fDigitsArr = new TClonesArray("AliEMCALDigit",100);
+  
+  if (!fDigitsArr) fDigitsArr = new TClonesArray("AliEMCALDigit",100);
+  else             fDigitsArr->Clear("C"); // avoid leak
+    
   branch->SetAddress(&fDigitsArr);
   branch->GetEntry(0);
 }