]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALRecoUtils.h
from Francesco Blanco - skip a few min/max settings
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.h
index 9b83e7ccde9925a30861303d80d480669a992b4b..c3c7e492facebb879d5123cc79e5f9e3ead5d35b 100644 (file)
@@ -27,6 +27,7 @@ class TH2F;
 class AliVCluster;
 class AliVCaloCells;
 class AliVEvent;
+#include "AliLog.h"
 
 // EMCAL includes
 class AliEMCALGeometry;
@@ -42,10 +43,13 @@ public:
   AliEMCALRecoUtils(const AliEMCALRecoUtils&); 
   AliEMCALRecoUtils& operator=(const AliEMCALRecoUtils&); 
   virtual ~AliEMCALRecoUtils() ;  
+  
+  void     InitParameters();
+  
   void     Print(const Option_t*) const;
 
   //enums
-  enum     NonlinearityFunctions{kPi0MC=0,kPi0GammaGamma=1,kPi0GammaConversion=2,kNoCorrection=3,kBeamTest=4,kBeamTestCorrected=5};
+  enum     NonlinearityFunctions{kPi0MC=0,kPi0GammaGamma=1,kPi0GammaConversion=2,kNoCorrection=3,kBeamTest=4,kBeamTestCorrected=5,kPi0MCv2=6,kPi0MCv3=7};
   enum     PositionAlgorithms{kUnchanged=-1,kPosTowerIndex=0, kPosTowerGlobal=1};
   enum     ParticleType{kPhoton=0, kElectron=1,kHadron =2, kUnknown=-1};
   enum     { kNCuts = 11 }; //track matching
@@ -55,15 +59,15 @@ public:
   //Position recalculation
   //-----------------------------------------------------
 
-  void     RecalculateClusterPosition               (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
-  void     RecalculateClusterPositionFromTowerIndex (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
-  void     RecalculateClusterPositionFromTowerGlobal(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
+  void     RecalculateClusterPosition               (const AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
+  void     RecalculateClusterPositionFromTowerIndex (const AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
+  void     RecalculateClusterPositionFromTowerGlobal(const AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
   
   Float_t  GetCellWeight(const Float_t eCell, const Float_t eCluster) const { return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster )) ; }
   
   Float_t  GetDepth(const Float_t eCluster, const Int_t iParticle, const Int_t iSM) const ; 
   
-  void     GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu, 
+  void     GetMaxEnergyCell(const AliEMCALGeometry *geom, AliVCaloCells* cells, const AliVCluster* clu, 
                             Int_t & absId,  Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared);
   
   Float_t  GetMisalTransShift(const Int_t i)       const { if(i < 15 ) { return fMisalTransShift[i] ; }
@@ -98,7 +102,7 @@ public:
   void     SetW0(Float_t w0)                             { fW0  = w0                ; }
 
   //-----------------------------------------------------
-  //Non Linearity
+  // Non Linearity
   //-----------------------------------------------------
 
   Float_t  CorrectClusterEnergyLinearity(AliVCluster* clu) ;
@@ -121,25 +125,28 @@ public:
   // MC clusters energy smearing
   //-----------------------------------------------------
   
-  Float_t  SmearClusterEnergy(AliVCluster* clu) ;
+  Float_t  SmearClusterEnergy(const AliVCluster* clu) ;
   void     SwitchOnClusterEnergySmearing()               { fSmearClusterEnergy = kTRUE         ; }
   void     SwitchOffClusterEnergySmearing()              { fSmearClusterEnergy = kFALSE        ; }
   Bool_t   IsClusterEnergySmeared()                const { return fSmearClusterEnergy          ; }   
   void     SetSmearingParameters(Int_t i, Float_t param) { if(i < 3){ fSmearClusterParam[i] = param ; }
                                                            else     { AliInfo(Form("Index %d larger than 2, do nothing\n",i)) ; } }
-  
   //-----------------------------------------------------
-  // Energy Recalibration
+  // Recalibration
   //-----------------------------------------------------
-  
-  void     RecalibrateCells(AliEMCALGeometry* geom, AliVCaloCells * cells, Int_t bc) ; // Energy and Time
-  void     RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells, const Int_t bc=0) ; // Energy and time
+  Bool_t   AcceptCalibrateCell(const Int_t absId, const Int_t bc,
+                               Float_t & amp, Double_t & time, AliVCaloCells* cells) ; // Energy and Time
+  void     RecalibrateCells(AliVCaloCells * cells, Int_t bc) ; // Energy and Time
+  void     RecalibrateClusterEnergy(const AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells, const Int_t bc=-1) ; // Energy and time
+  void     ResetCellsCalibrated()                        { fCellsRecalibrated = kFALSE; }
 
+  // Energy recalibration
   Bool_t   IsRecalibrationOn()                     const { return fRecalibration ; }
   void     SwitchOffRecalibration()                      { fRecalibration = kFALSE ; }
   void     SwitchOnRecalibration()                       { fRecalibration = kTRUE  ; 
                                                            if(!fEMCALRecalibrationFactors)InitEMCALRecalibrationFactors() ; }
   void     InitEMCALRecalibrationFactors() ;
+  TObjArray* GetEMCALRecalibrationFactorsArray()   const { return fEMCALRecalibrationFactors ; }
 
   TH2F *   GetEMCALChannelRecalibrationFactors(Int_t iSM)     const { return (TH2F*)fEMCALRecalibrationFactors->At(iSM) ; }    
   void     SetEMCALChannelRecalibrationFactors(TObjArray *map)      { fEMCALRecalibrationFactors = map                  ; }
@@ -155,42 +162,42 @@ public:
     ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c) ; }
   
   //Recalibrate channels energy with run dependent corrections
+  Bool_t   IsRunDepRecalibrationOn()               const { return fUseRunCorrectionFactors ; }
+
   void     SwitchOffRunDepCorrection()                   { fUseRunCorrectionFactors = kFALSE ; }
   void     SwitchOnRunDepCorrection()                    { fUseRunCorrectionFactors = kTRUE  ; 
-                                                           SwitchOnRecalibration()           ; }
-  void     SetRunDependentCorrections(Int_t runnumber);
-      
-  //-----------------------------------------------------
-  // Time Recalibration
-  //-----------------------------------------------------
-  
-  void     RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & time);
+                                                           SwitchOnRecalibration()           ; }      
+  // Time Recalibration  
+  void     RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & time) const;
   
   Bool_t   IsTimeRecalibrationOn()                 const { return fTimeRecalibration   ; }
   void     SwitchOffTimeRecalibration()                  { fTimeRecalibration = kFALSE ; }
   void     SwitchOnTimeRecalibration()                   { fTimeRecalibration = kTRUE  ; 
     if(!fEMCALTimeRecalibrationFactors)InitEMCALTimeRecalibrationFactors() ; }
   void     InitEMCALTimeRecalibrationFactors() ;
-  
-  Float_t  GetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID) const { 
+  TObjArray* GetEMCALTimeRecalibrationFactorsArray() const { return fEMCALTimeRecalibrationFactors ; }
+
+  Float_t  GetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID) const { 
     if(fEMCALTimeRecalibrationFactors) 
       return (Float_t) ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->GetBinContent(absID); 
-    else return 1 ; } 
+    else return 0 ; } 
        
-  void     SetEMCALChannelTimeRecalibrationFactor(Int_t bc,Int_t absID, Double_t c = 1) { 
+  void     SetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID, Double_t c = 0) { 
     if(!fEMCALTimeRecalibrationFactors) InitEMCALTimeRecalibrationFactors() ;
     ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->SetBinContent(absID,c) ; }  
   
-  TH1F *   GetEMCALChannelTimeRecalibrationFactors(Int_t bc)      const { return (TH1F*)fEMCALTimeRecalibrationFactors->At(bc) ; }     
-  void     SetEMCALChannelTimeRecalibrationFactors(TObjArray *map)      { fEMCALTimeRecalibrationFactors = map                 ; }
-  void     SetEMCALChannelTimeRecalibrationFactors(Int_t bc , TH1F* h)  { fEMCALTimeRecalibrationFactors->AddAt(h,bc)          ; }
+  TH1F *   GetEMCALChannelTimeRecalibrationFactors(const Int_t bc)const       { return (TH1F*)fEMCALTimeRecalibrationFactors->At(bc) ; }       
+  void     SetEMCALChannelTimeRecalibrationFactors(TObjArray *map)            { fEMCALTimeRecalibrationFactors = map                 ; }
+  void     SetEMCALChannelTimeRecalibrationFactors(const Int_t bc , TH1F* h)  { fEMCALTimeRecalibrationFactors->AddAt(h,bc)          ; }
   
   //-----------------------------------------------------
   // Modules fiducial region, remove clusters in borders
   //-----------------------------------------------------
 
-  Bool_t   CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells) ;
-  void     SetNumberOfCellsFromEMCALBorder(Int_t n)      { fNCellsFromEMCALBorder = n      ; }
+  Bool_t   CheckCellFiducialRegion(const AliEMCALGeometry* geom, 
+                                   const AliVCluster* cluster, 
+                                   AliVCaloCells* cells) ;
+  void     SetNumberOfCellsFromEMCALBorder(const Int_t n){ fNCellsFromEMCALBorder = n      ; }
   Int_t    GetNumberOfCellsFromEMCALBorder()      const  { return fNCellsFromEMCALBorder   ; }
     
   void     SwitchOnNoFiducialBorderInEMCALEta0()         { fNoEMCALBorderAtEta0 = kTRUE    ; }
@@ -211,6 +218,7 @@ public:
   void     SwitchOnDistToBadChannelRecalculation()       { fRecalDistToBadChannels = kTRUE  ; 
                                                            if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ; }
   
+  TObjArray* GetEMCALBadChannelStatusMapArray()     const { return fEMCALBadChannelMap ; }
   void     InitEMCALBadChannelStatusMap() ;
        
   Int_t    GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const { 
@@ -225,14 +233,19 @@ public:
   void     SetEMCALChannelStatusMap(TObjArray *map)      { fEMCALBadChannelMap = map                  ; }
   void     SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALBadChannelMap->AddAt(h,iSM)          ; }
 
-  Bool_t   ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, const Int_t nCells);
+  Bool_t   ClusterContainsBadChannel(const AliEMCALGeometry* geom, const UShort_t* cellList, const Int_t nCells);
  
   //-----------------------------------------------------
   // Recalculate other cluster parameters
   //-----------------------------------------------------
 
-  void     RecalculateClusterDistanceToBadChannel (AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
-  void     RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
+  void     RecalculateClusterDistanceToBadChannel (const AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
+  void     RecalculateClusterShowerShapeParameters(const AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
+  void     RecalculateClusterShowerShapeParameters(const AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster,
+                                                   Float_t & l0,   Float_t & l1,   
+                                                   Float_t & disp, Float_t & dEta, Float_t & dPhi,
+                                                   Float_t & sEta, Float_t & sPhi, Float_t & sEtaPhi);
+
   void     RecalculateClusterPID(AliVCluster * cluster);
 
   AliEMCALPIDUtils * GetPIDUtils() { return fPIDUtils;}
@@ -242,23 +255,39 @@ public:
   // Track matching
   //----------------------------------------------------
 
-  Bool_t   ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, AliVCluster *cluster, Float_t &tmpEta, Float_t &tmpPhi);
-
-  void     FindMatches(AliVEvent *event, TObjArray * clusterArr=0x0, AliEMCALGeometry *geom=0x0);
-  Int_t    FindMatchedClusterInEvent(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom, Float_t &dEta, Float_t &dPhi);
-  Int_t    FindMatchedClusterInClusterArr(AliExternalTrackParam *emcalParam, AliExternalTrackParam *trkParam, TObjArray * clusterArr, Float_t &dEta, Float_t &dPhi);
-
-  UInt_t   FindMatchedPosForCluster(Int_t clsIndex) const;
-  UInt_t   FindMatchedPosForTrack(Int_t trkIndex)   const;
-  
-  void     GetMatchedResiduals(Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
-  void     GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
+  void     FindMatches(AliVEvent *event, TObjArray * clusterArr=0x0, const AliEMCALGeometry *geom=0x0);
+  Int_t    FindMatchedClusterInEvent(const AliESDtrack *track, const AliVEvent *event, 
+                                     const AliEMCALGeometry *geom, Float_t &dEta, Float_t &dPhi);
+  Int_t    FindMatchedClusterInClusterArr(const AliExternalTrackParam *emcalParam, 
+                                          AliExternalTrackParam *trkParam, 
+                                          const TObjArray * clusterArr, 
+                                          Float_t &dEta, Float_t &dPhi);
+  
+  static Bool_t ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *trkParam, 
+                                               const Double_t emcalR, const Double_t mass, const Double_t step, 
+                                               Float_t &eta, Float_t &phi);
+  static Bool_t ExtrapolateTrackToPosition(AliExternalTrackParam *trkParam, const Float_t *clsPos, 
+                                           const Double_t mass, const Double_t step, 
+                                           Float_t &tmpEta, Float_t &tmpPhi);
+  static Bool_t ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, const AliVCluster *cluster, 
+                                           const Double_t mass, const Double_t step,
+                                           Float_t &tmpEta, Float_t &tmpPhi);
+  Bool_t        ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, const AliVCluster *cluster, 
+                                           Float_t &tmpEta, Float_t &tmpPhi);
+
+  UInt_t   FindMatchedPosForCluster(const Int_t clsIndex) const;
+  UInt_t   FindMatchedPosForTrack  (const Int_t trkIndex) const;
+  
+  void     GetMatchedResiduals       (const Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
+  void     GetMatchedClusterResiduals(const Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
   Int_t    GetMatchedTrackIndex(Int_t clsIndex);
   Int_t    GetMatchedClusterIndex(Int_t trkIndex);
   
-  Bool_t   IsClusterMatched(Int_t clsIndex)         const;
-  Bool_t   IsTrackMatched(Int_t trkIndex)           const;
+  Bool_t   IsClusterMatched(const Int_t clsIndex)         const;
+  Bool_t   IsTrackMatched  (const Int_t trkIndex)         const;
 
+  void     SetClusterMatchedToTrack (const AliVEvent *event);
+  void     SetTracksMatchedToCluster(const AliVEvent *event);  
 
   void     SwitchOnCutEtaPhiSum()                     { fCutEtaPhiSum      = kTRUE    ; 
                                                         fCutEtaPhiSeparate = kFALSE   ; }
@@ -279,17 +308,36 @@ public:
   Double_t GetStep()                            const { return fStepCluster           ; }
   Double_t GetStepSurface()                     const { return fStepSurface           ; }
   void     SetMass(Double_t mass)                     { fMass = mass                  ; }
-  void     SetStep(Double_t step)                     { fStepCluster = step           ; }
-  void     SetStepSurface(Double_t step)              { fStepSurface = step           ; }
+  void     SetStep(Double_t step)                     { fStepSurface = step           ; }
+  void     SetStepCluster(Double_t step)              { fStepCluster = step           ; }
  
-  //Cluster cut
-  Bool_t   IsGoodCluster(AliVCluster *cluster, AliEMCALGeometry *geom, AliVCaloCells* cells);
-  Bool_t   IsExoticCluster(AliVCluster *cluster) const ;
-
-  void     SwitchOnRejectExoticCluster()              { fRejectExoticCluster=kTRUE     ; }
-  void     SwitchOffRejectExoticCluster()             { fRejectExoticCluster=kFALSE    ; }
+  // Exotic cells / clusters
+  
+  Bool_t   IsExoticCell(const Int_t absId, AliVCaloCells* cells, const Int_t bc =-1) ;
+  void     SwitchOnRejectExoticCell()                 { fRejectExoticCells = kTRUE     ; }
+  void     SwitchOffRejectExoticCell()                { fRejectExoticCells = kFALSE    ; } 
+  Bool_t   IsRejectExoticCell()                 const { return fRejectExoticCells      ; }
+   
+  Float_t  GetECross(const Int_t absID, const Double_t tcell,
+                     AliVCaloCells* cells, const Int_t bc);
+  
+  Float_t  GetExoticCellFractionCut()           const { return fExoticCellFraction     ; }
+  Float_t  GetExoticCellDiffTimeCut()           const { return fExoticCellDiffTime     ; }
+  Float_t  GetExoticCellMinAmplitudeCut()       const { return fExoticCellMinAmplitude ; }
+  
+  void     SetExoticCellFractionCut(Float_t f)        { fExoticCellFraction     = f    ; }
+  void     SetExoticCellDiffTimeCut(Float_t dt)       { fExoticCellDiffTime     = dt   ; }
+  void     SetExoticCellMinAmplitudeCut(Float_t ma)   { fExoticCellMinAmplitude = ma   ; }
+  
+  Bool_t   IsExoticCluster(const AliVCluster *cluster, AliVCaloCells* cells, const Int_t bc=0) ;
+  void     SwitchOnRejectExoticCluster()              { fRejectExoticCluster = kTRUE   ;
+                                                        fRejectExoticCells   = kTRUE   ; }
+  void     SwitchOffRejectExoticCluster()             { fRejectExoticCluster = kFALSE  ; }
   Bool_t   IsRejectExoticCluster()              const { return fRejectExoticCluster    ; }
-
+  
+  //Cluster cut
+  Bool_t   IsGoodCluster(AliVCluster *cluster, const AliEMCALGeometry *geom, 
+                         AliVCaloCells* cells, const Int_t bc =-1);
 
   //Track Cuts 
   Bool_t   IsAccepted(AliESDtrack *track);
@@ -354,7 +402,6 @@ private:
   
   // Recalibrate with run dependent corrections, energy
   Bool_t     fUseRunCorrectionFactors;   // Use Run Dependent Correction
-  Bool_t     fRunCorrectionFactorsSet;   // Run Correction set at leat once
     
   // Bad Channels
   Bool_t     fRemoveBadChannels;         // Check the channel status provided and remove clusters with bad channels
@@ -365,8 +412,12 @@ private:
   Int_t      fNCellsFromEMCALBorder;     // Number of cells from EMCAL border the cell with maximum amplitude has to be.
   Bool_t     fNoEMCALBorderAtEta0;       // Do fiducial cut in EMCAL region eta = 0?
   
-  // Cluster cuts
+  // Exotic cell / cluster
   Bool_t     fRejectExoticCluster;       // Switch on or off exotic cluster rejection
+  Bool_t     fRejectExoticCells;         // Remove exotic cells
+  Float_t    fExoticCellFraction;        // Good cell if fraction < 1-ecross/ecell
+  Float_t    fExoticCellDiffTime;        // If time of candidate to exotic and close cell is too different (in ns), it must be noisy, set amp to 0
+  Float_t    fExoticCellMinAmplitude;    // Check for exotic only if amplitud is larger than this value
   
   // PID
   AliEMCALPIDUtils * fPIDUtils;          // Recalculate PID parameters
@@ -401,7 +452,7 @@ private:
   Float_t    fCutMaxDCAToVertexZ;        // Track-to-vertex cut in max absolute distance in z-plane
   Bool_t     fCutDCAToVertex2D;          // If true a 2D DCA cut is made.
   
-  ClassDef(AliEMCALRecoUtils, 15)
+  ClassDef(AliEMCALRecoUtils, 18)
   
 };