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