]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliCalorimeterUtils.h
Added possibility to recalibrate CaloClusters during the analysis
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliCalorimeterUtils.h
1 #ifndef ALICALORIMETERUTILS_H
2 #define ALICALORIMETERUTILS_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice     */
5 /* $Id:  $ */
6
7 //_________________________________________________________________________
8 // Class utility for Calorimeter specific selection methods                ///
9 //
10 //
11 //
12 //-- Author: Gustavo Conesa (LPSC-Grenoble) 
13 //////////////////////////////////////////////////////////////////////////////
14
15 // --- ROOT system ---
16 #include "TObject.h" 
17 #include "TString.h"
18 #include "TObjArray.h"
19 class TArrayF;  
20 #include "TH2I.h"
21
22 //--- ANALYSIS system ---
23 class AliVEvent;
24 class AliAODPWG4Particle;
25 class AliAODCaloCluster;
26 class AliAODCaloCells;
27 class AliESDCaloCluster;
28 class AliESDCaloCells;
29 #include "AliPHOSGeoUtils.h"
30 #include "AliEMCALGeoUtils.h"
31
32 class AliCalorimeterUtils : public TObject {
33
34 public: 
35   
36   AliCalorimeterUtils() ; // ctor
37   AliCalorimeterUtils(const AliCalorimeterUtils & g) ; // cpy ctor
38   virtual ~AliCalorimeterUtils() ;//virtual dtor
39
40 private:
41   AliCalorimeterUtils & operator = (const AliCalorimeterUtils & g) ;//cpy assignment
42
43 public:
44   
45   virtual void InitParameters();
46   virtual void Print(const Option_t * opt) const;
47
48   virtual Int_t GetDebug()         const { return fDebug ; }
49   virtual void  SetDebug(Int_t d)        { fDebug = d ; }
50         
51   //virtual void Init();
52         
53   //Calorimeters Geometry Methods
54   AliEMCALGeoUtils * GetEMCALGeometry() const { return fEMCALGeo;}
55   TString  EMCALGeometryName()          const { return fEMCALGeoName ; }  
56   void  SetEMCALGeometryName(TString name)    { fEMCALGeoName = name ; }
57   void InitEMCALGeometry() ; 
58   Bool_t IsEMCALGeoMatrixSet()          const { return fEMCALGeoMatrixSet; }
59         
60   AliPHOSGeoUtils * GetPHOSGeometry() const { return fPHOSGeo;} 
61   TString  PHOSGeometryName()         const { return fPHOSGeoName ; }  
62   void  SetPHOSGeometryName(TString name)   { fPHOSGeoName = name ; }
63   void InitPHOSGeometry() ; 
64   Bool_t IsPHOSGeoMatrixSet()         const {return fPHOSGeoMatrixSet ; }
65
66   void SetGeometryTransformationMatrices(AliVEvent* inputEvent) ;
67         
68   // Bad channels
69   Bool_t IsBadChannelsRemovalSwitchedOn()  const { return fRemoveBadChannels ; }
70   void SwitchOnBadChannelsRemoval()    {fRemoveBadChannels = kTRUE ; }
71   void SwitchOffBadChannelsRemoval()   {fRemoveBadChannels = kFALSE ; }
72         
73   void InitEMCALBadChannelStatusMap() ;
74   void InitPHOSBadChannelStatusMap () ;
75
76   Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const { 
77     if(fEMCALBadChannelMap->GetEntries()>0) return (Int_t) ((TH2I*)fEMCALBadChannelMap->At(iSM))->GetBinContent(iCol,iRow); 
78     else return -1;}
79
80   Int_t GetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow) const { 
81     if(fPHOSBadChannelMap->GetEntries()>0)return (Int_t) ((TH2I*)fPHOSBadChannelMap->At(imod))->GetBinContent(iCol,iRow); 
82     else return -1;}
83   
84   void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) { 
85     if(!fEMCALBadChannelMap->GetEntries())InitEMCALBadChannelStatusMap() ;
86     ((TH2I*)fEMCALBadChannelMap->At(iSM))->SetBinContent(iCol,iRow,c);}
87   
88   void SetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
89         if(!fPHOSBadChannelMap->GetEntries()) InitPHOSBadChannelStatusMap() ; 
90         ((TH2I*)fPHOSBadChannelMap->At(imod))->SetBinContent(iCol,iRow,c);}
91     
92   TH2I * GetEMCALChannelStatusMap(Int_t iSM) const {return (TH2I*)fEMCALBadChannelMap->At(iSM);}
93   TH2I * GetPHOSChannelStatusMap(Int_t imod) const {return (TH2I*)fPHOSBadChannelMap->At(imod);}
94
95   void SetEMCALChannelStatusMap(TObjArray *map) {fEMCALBadChannelMap = map;}
96   void SetPHOSChannelStatusMap (TObjArray *map) {fPHOSBadChannelMap  = map;}
97         
98   Bool_t ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells);
99         
100   //Calorimeter indexes information
101   Int_t GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent* inputEvent) const;
102   Int_t GetModuleNumber(AliAODCaloCluster * cluster) const;
103   Int_t GetModuleNumber(AliESDCaloCluster * cluster) const;
104
105   Int_t GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t &iRCU) const ;
106         
107   //Modules fiducial region
108   Bool_t CheckCellFiducialRegion(AliAODCaloCluster* cluster, AliAODCaloCells* cells) const ;
109   Bool_t CheckCellFiducialRegion(AliESDCaloCluster* cluster, AliESDCaloCells* cells) const ;
110         
111   void   SetNumberOfCellsFromEMCALBorder(Int_t n) {fNCellsFromEMCALBorder = n; }
112   Int_t  GetNumberOfCellsFromEMCALBorder() const  {return fNCellsFromEMCALBorder; }
113   void   SetNumberOfCellsFromPHOSBorder(Int_t n)  {fNCellsFromPHOSBorder = n; }
114   Int_t  GetNumberOfCellsFromPHOSBorder() const   {return fNCellsFromPHOSBorder; }
115         
116   void   SwitchOnNoFiducialBorderInEMCALEta0()  {fNoEMCALBorderAtEta0 = kTRUE; }
117   void   SwitchOffNoFiducialBorderInEMCALEta0() {fNoEMCALBorderAtEta0 = kFALSE; }
118         
119   // Recalibration
120   Bool_t IsRecalibrationOn()  const { return fRecalibration ; }
121   void SwitchOnRecalibration()    {fRecalibration = kTRUE ; InitEMCALRecalibrationFactors(); InitPHOSRecalibrationFactors();}
122   void SwitchOffRecalibration()   {fRecalibration = kFALSE ; }
123         
124   void InitEMCALRecalibrationFactors() ;
125   void InitPHOSRecalibrationFactors () ;
126         
127   Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const { 
128           if(fEMCALRecalibrationFactors->GetEntries()>0) return (Float_t) ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->GetBinContent(iCol,iRow); 
129           else return 1;}
130         
131   Float_t GetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow) const { 
132           if(fPHOSRecalibrationFactors->GetEntries()>0)return (Float_t) ((TH2F*)fPHOSRecalibrationFactors->At(imod))->GetBinContent(iCol,iRow); 
133           else return 1;}
134         
135   void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) { 
136           ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c);}
137         
138   void SetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
139           ((TH2F*)fPHOSRecalibrationFactors->At(imod))->SetBinContent(iCol,iRow,c);}
140     
141   void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) {fEMCALRecalibrationFactors->AddAt(h,iSM);}
142   void SetPHOSChannelRecalibrationFactors(Int_t imod , TH2F* h) {fPHOSRecalibrationFactors ->AddAt(h,imod);}
143         
144   TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const {return (TH2F*)fEMCALRecalibrationFactors->At(iSM);}
145   TH2F * GetPHOSChannelRecalibrationFactors(Int_t imod) const {return (TH2F*)fPHOSRecalibrationFactors->At(imod);}
146         
147   void SetEMCALChannelRecalibrationFactors(TObjArray *map) {fEMCALRecalibrationFactors = map;}
148   void SetPHOSChannelRecalibrationFactors (TObjArray *map) {fPHOSRecalibrationFactors  = map;}
149
150   Float_t RecalibrateClusterEnergy(AliESDCaloCluster* cluster, AliESDCaloCells * cells);
151   Float_t RecalibrateClusterEnergy(AliAODCaloCluster* cluster, AliAODCaloCells * cells);
152
153  private:
154
155   Int_t              fDebug;                 //  Debugging level
156   TString            fEMCALGeoName;          //  Name of geometry to use for EMCAL.
157   TString            fPHOSGeoName;           //  Name of geometry to use for PHOS.      
158   AliEMCALGeoUtils * fEMCALGeo ;             //! EMCAL geometry pointer
159   AliPHOSGeoUtils  * fPHOSGeo  ;             //! PHOS  geometry pointer  
160   Bool_t             fEMCALGeoMatrixSet;     //  Check if the transformation matrix is set for EMCAL
161   Bool_t             fPHOSGeoMatrixSet ;     //  Check if the transformation matrix is set for PHOS
162   Bool_t             fRemoveBadChannels;     //  Check the channel status provided and remove clusters with bad channels
163   TObjArray        * fEMCALBadChannelMap;    //! Array of histograms with map of bad channels, EMCAL
164   TObjArray        * fPHOSBadChannelMap;     //! Array of histograms with map of bad channels, PHOS
165   Int_t              fNCellsFromEMCALBorder; //  Number of cells from EMCAL border the cell with maximum amplitude has to be.
166   Int_t              fNCellsFromPHOSBorder;  //  Number of cells from PHOS  border the cell with maximum amplitude has to be.
167   Bool_t             fNoEMCALBorderAtEta0;   //  Do fiducial cut in EMCAL region eta = 0?
168   Bool_t             fRecalibration;         //  Switch on or off the recalibration
169   TObjArray        * fEMCALRecalibrationFactors; //! Array of histograms with map of recalibration factors, EMCAL
170   TObjArray        * fPHOSRecalibrationFactors;  //! Array of histograms with map of recalibration factors, PHOS
171
172   ClassDef(AliCalorimeterUtils,2)
173 } ;
174
175
176 #endif //ALICALORIMETERUTILS_H
177
178
179