]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALRecoUtils.h
coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.h
index 21b2cb207e14709553756649c104136f7c5e4015..baa5866d3e157df9274b4cca2800e464b07bfdb1 100644 (file)
@@ -27,6 +27,8 @@ class TH2F;
 class AliVCluster;
 class AliVCaloCells;
 class AliVEvent;
+class AliESDEvent;
+#include "AliLog.h"
 
 // EMCAL includes
 class AliEMCALGeometry;
@@ -42,6 +44,9 @@ public:
   AliEMCALRecoUtils(const AliEMCALRecoUtils&); 
   AliEMCALRecoUtils& operator=(const AliEMCALRecoUtils&); 
   virtual ~AliEMCALRecoUtils() ;  
+  
+  void     InitParameters();
+  
   void     Print(const Option_t*) const;
 
   //enums
@@ -63,7 +68,7 @@ public:
   
   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 +103,7 @@ public:
   void     SetW0(Float_t w0)                             { fW0  = w0                ; }
 
   //-----------------------------------------------------
-  //Non Linearity
+  // Non Linearity
   //-----------------------------------------------------
 
   Float_t  CorrectClusterEnergyLinearity(AliVCluster* clu) ;
@@ -121,20 +126,22 @@ 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  ; 
@@ -160,11 +167,8 @@ public:
                                                            SwitchOnRecalibration()           ; }
   void     SetRunDependentCorrections(Int_t runnumber);
       
-  //-----------------------------------------------------
-  // Time Recalibration
-  //-----------------------------------------------------
-  
-  void     RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & time);
+  // 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 ; }
@@ -172,25 +176,25 @@ public:
     if(!fEMCALTimeRecalibrationFactors)InitEMCALTimeRecalibrationFactors() ; }
   void     InitEMCALTimeRecalibrationFactors() ;
   
-  Float_t  GetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID) const { 
+  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      ; }
+  void     SetNumberOfCellsFromEMCALBorder(const Int_t n){ fNCellsFromEMCALBorder = n      ; }
   Int_t    GetNumberOfCellsFromEMCALBorder()      const  { return fNCellsFromEMCALBorder   ; }
     
   void     SwitchOnNoFiducialBorderInEMCALEta0()         { fNoEMCALBorderAtEta0 = kTRUE    ; }
@@ -225,7 +229,7 @@ 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
@@ -242,10 +246,19 @@ 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    FindMatchedCluster(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom);
+  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);
+  
+  static Bool_t ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *trkParam, Double_t emcalR, 
+                                               Double_t mass, Double_t step, Float_t &eta, Float_t &phi);
+  static Bool_t ExtrapolateTrackToPosition(AliExternalTrackParam *trkParam, const Float_t *clsPos, 
+                                           Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi);
+  static Bool_t ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, AliVCluster *cluster, 
+                                           Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi);
+  Bool_t        ExtrapolateTrackToCluster (AliExternalTrackParam *trkParam, AliVCluster *cluster, 
+                                           Float_t &tmpEta, Float_t &tmpPhi);
+
   UInt_t   FindMatchedPosForCluster(Int_t clsIndex) const;
   UInt_t   FindMatchedPosForTrack(Int_t trkIndex)   const;
   
@@ -257,6 +270,9 @@ public:
   Bool_t   IsClusterMatched(Int_t clsIndex)         const;
   Bool_t   IsTrackMatched(Int_t trkIndex)           const;
 
+  void     SetClusterMatchedToTrack (const AliESDEvent *event);
+  
+  void     SetTracksMatchedToCluster(const AliESDEvent *event);  
 
   void     SwitchOnCutEtaPhiSum()                     { fCutEtaPhiSum      = kTRUE    ; 
                                                         fCutEtaPhiSeparate = kFALSE   ; }
@@ -266,24 +282,38 @@ public:
   Float_t  GetCutR()                            const { return fCutR                  ; }
   Float_t  GetCutEta()                          const { return fCutEta                ; }
   Float_t  GetCutPhi()                          const { return fCutPhi                ; }
+  Double_t GetClusterWindow()                   const { return fClusterWindow         ; }
   void     SetCutR(Float_t cutR)                      { fCutR   = cutR                ; }
   void     SetCutEta(Float_t cutEta)                  { fCutEta = cutEta              ; }
   void     SetCutPhi(Float_t cutPhi)                  { fCutPhi = cutPhi              ; }
+  void     SetClusterWindow(Double_t window)          { fClusterWindow = window       ; }
   void     SetCutZ(Float_t cutZ)                      { printf("Obsolete fucntion of cutZ=%1.1f\n",cutZ) ; } //Obsolete
 
   Double_t GetMass()                            const { return fMass                  ; }
-  Double_t GetStep()                            const { return fStep                  ; }
+  Double_t GetStep()                            const { return fStepCluster           ; }
+  Double_t GetStepSurface()                     const { return fStepSurface           ; }
   void     SetMass(Double_t mass)                     { fMass = mass                  ; }
-  void     SetStep(Double_t step)                     { fStep = 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    ; } 
+   
+  void     SetExoticCellFractionCut(Float_t f)        { fExoticCellFraction     = f    ; }
+  void     SetExoticCellDiffTimeCut(Float_t dt)       { fExoticCellDiffTime     = dt   ; }
+  void     SetExoticCellMinAmplitudeCut(Float_t ma)   { fExoticCellMinAmplitude = ma   ; }
+  
+  Bool_t   IsExoticCluster(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, AliEMCALGeometry *geom, AliVCaloCells* cells, const Int_t bc =-1);
 
   //Track Cuts 
   Bool_t   IsAccepted(AliESDtrack *track);
@@ -319,8 +349,7 @@ public:
   Bool_t   GetDCAToVertex2D()                  const { return fCutDCAToVertex2D        ; }
 
 
-private:
-  
+private:  
   //Position recalculation
   Float_t    fMisalTransShift[15];       // Shift parameters
   Float_t    fMisalRotShift[15];         // Shift parameters
@@ -360,8 +389,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
@@ -377,8 +410,10 @@ private:
   Float_t    fCutR;                      // sqrt(dEta^2+dPhi^2) cut on matching
   Float_t    fCutEta;                    // dEta cut on matching
   Float_t    fCutPhi;                    // dPhi cut on matching
+  Double_t   fClusterWindow;             // Select clusters in the window to be matched
   Double_t   fMass;                      // Mass hypothesis of the track
-  Double_t   fStep;                      // Length of each step used in extrapolation in the unit of cm.
+  Double_t   fStepSurface;               // Length of step to extrapolate tracks to EMCal surface
+  Double_t   fStepCluster;               // Length of step to extrapolate tracks to clusters
 
   // Track cuts  
   Int_t      fTrackCutsType;             // Esd track cuts type for matching
@@ -392,9 +427,9 @@ private:
   Bool_t     fCutAcceptKinkDaughters;    // Accepting kink daughters?
   Float_t    fCutMaxDCAToVertexXY;       // Track-to-vertex cut in max absolute distance in xy-plane
   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. Tracks are accepted if sqrt((DCAXY / fCutMaxDCAToVertexXY)^2 + (DCAZ / fCutMaxDCAToVertexZ)^2) < 1 AND sqrt((DCAXY / fCutMinDCAToVertexXY)^2 + (DCAZ / fCutMinDCAToVertexZ)^2) > 1
+  Bool_t     fCutDCAToVertex2D;          // If true a 2D DCA cut is made.
   
-  ClassDef(AliEMCALRecoUtils, 14)
+  ClassDef(AliEMCALRecoUtils, 17)
   
 };