]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALRecoUtils.h
9c0d58c6fd927b88c9495efd64a1788f9b4360e5
[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{kPosTowerIndex=0, kPosTowerGlobal};
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 private:
127   
128   Float_t fMisalTransShift[15];   // Shift parameters
129   Float_t fMisalRotShift[15];     // Shift parameters
130   Int_t   fNonLinearityFunction;  // Non linearity function choice
131   Float_t fNonLinearityParams[6]; // Parameters for the non linearity function
132   Int_t   fParticleType;          // Particle type for depth calculation
133   Int_t   fPosAlgo;               // Position recalculation algorithm
134   Float_t fW0;                    // Weight0
135   Bool_t       fRecalibration;             //  Switch on or off the recalibration
136   TObjArray  * fEMCALRecalibrationFactors; // Array of histograms with map of recalibration factors, EMCAL
137
138   ClassDef(AliEMCALRecoUtils, 3)
139   
140 };
141
142 #endif // ALIEMCALRECOUTILS_H
143
144