]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALRecoUtils.h
Move option to reclusterizer with calibrated amplitudes from NxN to mother Clusterize...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.h
1 #ifndef ALIEMCALRECOUTILS_H
2 #define ALIEMCALRECOUTILS_H
3
4 /* $Id: AliEMCALRecoUtils.h 33808 2009-07-15 09:48:08Z gconesab $ */
5
6 ///////////////////////////////////////////////////////////////////////////////
7 //
8 // Class AliEMCALRecoUtils
9 // Some utilities to recalculate the cluster position or energy linearity
10 //
11 //
12 // Author:  Gustavo Conesa (LPSC- Grenoble) 
13 ///////////////////////////////////////////////////////////////////////////////
14
15 //Root includes
16 #include "TNamed.h"
17 #include "TMath.h"
18 #include "TObjArray.h"
19 #include "TH2F.h"
20
21 //AliRoot includes
22 class AliVCluster;
23 class AliVCaloCells;
24 #include "AliLog.h"
25 class AliEMCALGeometry;
26 class AliEMCALPIDUtils;
27
28 class AliEMCALRecoUtils : public TNamed {
29   
30 public:
31   
32   AliEMCALRecoUtils();
33   AliEMCALRecoUtils(const AliEMCALRecoUtils&); 
34   AliEMCALRecoUtils& operator=(const AliEMCALRecoUtils&); 
35   virtual ~AliEMCALRecoUtils() ;
36   
37   enum NonlinearityFunctions{kPi0MC=0,kPi0GammaGamma=1,kPi0GammaConversion=2,kNoCorrection=3};
38   enum PositionAlgorithms{kUnchanged=-1,kPosTowerIndex=0, kPosTowerGlobal=1};
39   enum ParticleType{kPhoton=0, kElectron=1,kHadron =2, kUnknown=-1};
40   
41   //Position recalculation
42   void     RecalculateClusterPosition(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
43   void     RecalculateClusterPositionFromTowerIndex (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
44   void     RecalculateClusterPositionFromTowerGlobal(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu); 
45   
46   Float_t  GetCellWeight(const Float_t eCell, const Float_t eCluster) const { return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster ));}
47   
48   Float_t  GetDepth(const Float_t eCluster, const Int_t iParticle, const Int_t iSM) const ; 
49   
50   void     GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu, 
51                             Int_t & absId,  Int_t& iSupMod, Int_t& ieta, Int_t& iphi);
52   
53   Float_t  GetMisalTransShift(const Int_t i) const {
54     if(i < 15 ){return fMisalTransShift[i]; }
55     else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)); return 0.;}
56   }
57   Float_t* GetMisalTransShiftArray() {return fMisalTransShift; }
58
59   void     SetMisalTransShift(const Int_t i, const Float_t shift) {
60     if(i < 15 ){fMisalTransShift[i] = shift; }
61     else { AliInfo(Form("Index %d larger than 15, do nothing\n",i));}
62   }
63   void     SetMisalTransShiftArray(Float_t * misal) 
64   { for(Int_t i = 0; i < 15; i++)fMisalTransShift[i] = misal[i]; }
65
66   Float_t  GetMisalRotShift(const Int_t i) const {
67     if(i < 15 ){return fMisalRotShift[i]; }
68     else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)); return 0.;}
69   }
70   Float_t* GetMisalRotShiftArray() {return fMisalRotShift; }
71   
72   void     SetMisalRotShift(const Int_t i, const Float_t shift) {
73     if(i < 15 ){fMisalRotShift[i] = shift; }
74     else { AliInfo(Form("Index %d larger than 15, do nothing\n",i));}
75   }
76   void     SetMisalRotShiftArray(Float_t * misal) 
77   { for(Int_t i = 0; i < 15; i++)fMisalRotShift[i] = misal[i]; }
78   
79   Int_t    GetParticleType() const         {return  fParticleType    ;}
80   void     SetParticleType(Int_t particle) {fParticleType = particle ;}
81   
82   Int_t    GetPositionAlgorithm() const    {return fPosAlgo;}
83   void     SetPositionAlgorithm(Int_t alg) {fPosAlgo = alg ;}
84   
85   Float_t  GetW0() const     {return fW0;}
86   void     SetW0(Float_t w0) {fW0  = w0 ;}
87
88   //Non Linearity
89   
90   Float_t CorrectClusterEnergyLinearity(AliVCluster* clu);
91   
92   Float_t  GetNonLinearityParam(const Int_t i) const {
93     if(i < 6 ){return fNonLinearityParams[i]; }
94     else { AliInfo(Form("Index %d larger than 6, do nothing\n",i)); return 0.;}
95   }
96   void     SetNonLinearityParam(const Int_t i, const Float_t param) {
97     if(i < 6 ){fNonLinearityParams[i] = param; }
98     else { AliInfo(Form("Index %d larger than 6, do nothing\n",i));}
99   }
100   
101   Int_t GetNonLinearityFunction() const    {return fNonLinearityFunction;}
102   void  SetNonLinearityFunction(Int_t fun) {fNonLinearityFunction = fun ;}
103   
104   void Print(const Option_t*) const;
105   
106   //Recalibration
107   void RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells);
108
109   Bool_t IsRecalibrationOn()  const { return fRecalibration ; }
110   void SwitchOnRecalibration()    {fRecalibration = kTRUE ; InitEMCALRecalibrationFactors();}
111   void SwitchOffRecalibration()   {fRecalibration = kFALSE ; }
112   
113   void InitEMCALRecalibrationFactors() ;
114   
115   Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const { 
116     if(fEMCALRecalibrationFactors) return (Float_t) ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->GetBinContent(iCol,iRow); 
117     else return 1;}
118         
119   void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) { 
120     if(!fEMCALRecalibrationFactors) InitEMCALRecalibrationFactors();
121     ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c);}  
122   
123   TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const {return (TH2F*)fEMCALRecalibrationFactors->At(iSM);}      
124   void SetEMCALChannelRecalibrationFactors(TObjArray *map)      {fEMCALRecalibrationFactors = map;}
125   void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) {fEMCALRecalibrationFactors->AddAt(h,iSM);}
126
127   //Modules fiducial region, remove clusters in borders
128   Bool_t CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells) ;
129   void   SetNumberOfCellsFromEMCALBorder(Int_t n) {fNCellsFromEMCALBorder = n; }
130   Int_t  GetNumberOfCellsFromEMCALBorder() const  {return fNCellsFromEMCALBorder; }
131     
132   void   SwitchOnNoFiducialBorderInEMCALEta0()  {fNoEMCALBorderAtEta0 = kTRUE; }
133   void   SwitchOffNoFiducialBorderInEMCALEta0() {fNoEMCALBorderAtEta0 = kFALSE; }
134   Bool_t IsEMCALNoBorderAtEta0()                {return fNoEMCALBorderAtEta0;}
135   
136   // Bad channels
137   Bool_t IsBadChannelsRemovalSwitchedOn()  const { return fRemoveBadChannels ; }
138   void SwitchOnBadChannelsRemoval ()  {fRemoveBadChannels = kTRUE  ; InitEMCALBadChannelStatusMap();}
139   void SwitchOffBadChannelsRemoval()  {fRemoveBadChannels = kFALSE ; }
140         
141   void InitEMCALBadChannelStatusMap() ;
142         
143   Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const { 
144     if(fEMCALBadChannelMap) return (Int_t) ((TH2I*)fEMCALBadChannelMap->At(iSM))->GetBinContent(iCol,iRow); 
145     else return 0;}//Channel is ok by default
146         
147   void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) { 
148     if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ;
149     ((TH2I*)fEMCALBadChannelMap->At(iSM))->SetBinContent(iCol,iRow,c);}
150         
151   TH2I * GetEMCALChannelStatusMap(Int_t iSM) const {return (TH2I*)fEMCALBadChannelMap->At(iSM);}
152   void   SetEMCALChannelStatusMap(TObjArray *map)  {fEMCALBadChannelMap = map;}
153         
154   Bool_t ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, Int_t nCells);
155  
156   //Recalculate other cluster parameters
157   void RecalculateClusterPID(AliVCluster * cluster);
158   AliEMCALPIDUtils * GetPIDUtils() { return fPIDUtils;}
159
160   void RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
161
162
163 private:
164   
165   Float_t fMisalTransShift[15];   // Shift parameters
166   Float_t fMisalRotShift[15];     // Shift parameters
167   Int_t   fNonLinearityFunction;  // Non linearity function choice
168   Float_t fNonLinearityParams[6]; // Parameters for the non linearity function
169   Int_t   fParticleType;          // Particle type for depth calculation
170   Int_t   fPosAlgo;               // Position recalculation algorithm
171   Float_t fW0;                    // Weight0
172   
173   Bool_t     fRecalibration;             // Switch on or off the recalibration
174   TObjArray* fEMCALRecalibrationFactors; // Array of histograms with map of recalibration factors, EMCAL
175   Bool_t     fRemoveBadChannels;         // Check the channel status provided and remove clusters with bad channels
176   TObjArray* fEMCALBadChannelMap;        // Array of histograms with map of bad channels, EMCAL
177   Int_t      fNCellsFromEMCALBorder;     // Number of cells from EMCAL border the cell with maximum amplitude has to be.
178   Bool_t     fNoEMCALBorderAtEta0;       // Do fiducial cut in EMCAL region eta = 0?
179
180   AliEMCALPIDUtils * fPIDUtils;               // Recalculate PID parameters
181   
182   ClassDef(AliEMCALRecoUtils, 5)
183   
184 };
185
186 #endif // ALIEMCALRECOUTILS_H
187
188