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 */
6 //_________________________________________________________________________
7 // Class utility for Calorimeter specific selection methods ///
11 //-- Author: Gustavo Conesa (LPSC-Grenoble)
12 //////////////////////////////////////////////////////////////////////////////
14 // --- ROOT system ---
17 #include <TObjArray.h>
20 #include <TGeoMatrix.h>
22 //--- ANALYSIS system ---
25 class AliAODPWG4Particle;
26 class AliAODCaloCluster;
28 class AliPHOSGeoUtils;
29 class AliEMCALGeometry;
30 #include "AliEMCALRecoUtils.h"
32 class AliCalorimeterUtils : public TObject {
35 AliCalorimeterUtils() ; // ctor
36 virtual ~AliCalorimeterUtils() ;//virtual dtor
38 virtual void InitParameters();
39 virtual void Print(const Option_t * opt) const ;
41 virtual Int_t GetDebug() const { return fDebug ; }
42 virtual void SetDebug(Int_t d) { fDebug = d ; }
44 //virtual void Init();
48 Bool_t AreNeighbours(const TString calo, const Int_t absId1, const Int_t absId2) const ;
50 Int_t GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells) ;
52 Int_t GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells,
53 Int_t *absIdList, Float_t *maxEList) ;
55 Float_t GetLocalMaximaCutE() const { return fLocMaxCutE ; }
56 void SetLocalMaximaCutE(Float_t cut) { fLocMaxCutE = cut ; }
58 Float_t GetLocalMaximaCutEDiff() const { return fLocMaxCutEDiff ; }
59 void SetLocalMaximaCutEDiff(Float_t c) { fLocMaxCutEDiff = c ; }
61 Int_t GetMaxEnergyCell(AliVCaloCells* cells, const AliVCluster* clu, Float_t & fraction) const ;
63 void SplitEnergy(const Int_t absId1, const Int_t absId2,
66 //Float_t & e1, Float_t & e2,
67 AliAODCaloCluster *cluster1,
68 AliAODCaloCluster *cluster2,
69 const Int_t nMax, const Int_t eventNumber = 0);//, Int_t *absIdList, Float_t *maxEList,
71 void SwitchOnClusterPlot() { fPlotCluster = kTRUE ; }
72 void SwitchOffClusterPlot() { fPlotCluster = kFALSE ; }
74 //Calorimeters Geometry Methods
75 AliEMCALGeometry * GetEMCALGeometry() const { return fEMCALGeo ; }
76 TString EMCALGeometryName() const { return fEMCALGeoName ; }
77 void SetEMCALGeometryName(TString name) { fEMCALGeoName = name ; }
78 void InitEMCALGeometry(Int_t runnumber = 180000) ;
79 Bool_t IsEMCALGeoMatrixSet() const { return fEMCALGeoMatrixSet ; }
81 AliPHOSGeoUtils * GetPHOSGeometry() const { return fPHOSGeo ; }
82 TString PHOSGeometryName() const { return fPHOSGeoName ; }
83 void SetPHOSGeometryName(TString name) { fPHOSGeoName = name ; }
84 void InitPHOSGeometry(Int_t runnumber = 180000) ;
85 Bool_t IsPHOSGeoMatrixSet() const { return fPHOSGeoMatrixSet ; }
87 void AccessGeometry(AliVEvent* inputEvent) ;
89 void SwitchOnLoadOwnEMCALGeometryMatrices() { fLoadEMCALMatrices = kTRUE ; }
90 void SwitchOffLoadOwnEMCALGeometryMatrices() { fLoadEMCALMatrices = kFALSE ; }
91 void SetEMCALGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fEMCALMatrix[i] = m ; }
93 void SwitchOnLoadOwnPHOSGeometryMatrices() { fLoadPHOSMatrices = kTRUE ; }
94 void SwitchOffLoadOwnPHOSGeometryMatrices() { fLoadPHOSMatrices = kFALSE ; }
95 void SetPHOSGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fPHOSMatrix[i] = m ; }
98 Bool_t IsBadChannelsRemovalSwitchedOn() const { return fRemoveBadChannels ; }
99 void SwitchOnBadChannelsRemoval () { fRemoveBadChannels = kTRUE ;
100 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
101 if(!fPHOSBadChannelMap) InitPHOSBadChannelStatusMap() ; }
102 void SwitchOffBadChannelsRemoval() { fRemoveBadChannels = kFALSE ;
103 fEMCALRecoUtils->SwitchOffBadChannelsRemoval() ; }
105 Bool_t IsDistanceToBadChannelRecalculated() const { return IsDistanceToBadChannelRecalculated() ; }
106 void SwitchOnDistToBadChannelRecalculation () { fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation() ; }
107 void SwitchOffDistToBadChannelRecalculation() { fEMCALRecoUtils->SwitchOffDistToBadChannelRecalculation(); }
109 void InitPHOSBadChannelStatusMap () ;
111 Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const {
112 return fEMCALRecoUtils->GetEMCALChannelStatus(iSM,iCol,iRow); }//Channel is ok by default
114 Int_t GetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow) const {
115 if(fPHOSBadChannelMap)return (Int_t) ((TH2I*)fPHOSBadChannelMap->At(imod))->GetBinContent(iCol,iRow);
116 else return 0 ; }//Channel is ok by default
118 void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
119 fEMCALRecoUtils->SetEMCALChannelStatus(iSM,iCol,iRow,c) ; }
121 void SetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
122 if(!fPHOSBadChannelMap) InitPHOSBadChannelStatusMap() ;
123 ((TH2I*)fPHOSBadChannelMap->At(imod))->SetBinContent(iCol,iRow,c) ; }
125 void SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALRecoUtils->SetEMCALChannelStatusMap(iSM,h) ; }
126 void SetPHOSChannelStatusMap(Int_t imod , TH2I* h) { fPHOSBadChannelMap ->AddAt(h,imod) ; }
128 TH2I * GetEMCALChannelStatusMap(Int_t iSM) const { return fEMCALRecoUtils->GetEMCALChannelStatusMap(iSM) ; }
129 TH2I * GetPHOSChannelStatusMap(Int_t imod) const { return (TH2I*)fPHOSBadChannelMap->At(imod) ; }
131 void SetEMCALChannelStatusMap(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelStatusMap(map) ; }
132 void SetPHOSChannelStatusMap (TObjArray *map) { fPHOSBadChannelMap = map ; }
134 Bool_t ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells);
136 // Mask clusters in front of frame, EMCAL only
137 Int_t GetNMaskCellColumns() const { return fNMaskCellColumns;}
138 void SetNMaskCellColumns(Int_t n) {
139 if(n > fNMaskCellColumns) { delete [] fMaskCellColumns ; fMaskCellColumns = new Int_t[n] ; }
140 fNMaskCellColumns = n ; }
141 void SetMaskCellColumn(Int_t ipos, Int_t icol) {
142 if(ipos < fNMaskCellColumns) fMaskCellColumns[ipos] = icol;
143 else printf("Not set, position larger than allocated set size first") ; }
144 Bool_t MaskFrameCluster(const Int_t iSM, const Int_t ieta) const ;
147 //Calorimeter indexes information
148 Int_t GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent* inputEvent) const;
149 Int_t GetModuleNumber(AliVCluster * cluster) const;
150 Int_t GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t &iRCU) const ;
152 //Modules fiducial region
153 Bool_t CheckCellFiducialRegion(AliVCluster* cluster, AliVCaloCells* cells, AliVEvent * event, Int_t iev=0) const ;
154 void SetNumberOfCellsFromPHOSBorder(Int_t n) { fNCellsFromPHOSBorder = n ; }
155 Int_t GetNumberOfCellsFromPHOSBorder() const { return fNCellsFromPHOSBorder ; }
156 void SetNumberOfCellsFromEMCALBorder(Int_t n) { fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(n) ; }
157 Int_t GetNumberOfCellsFromEMCALBorder() const { return fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(); }
158 void SwitchOnNoFiducialBorderInEMCALEta0() { fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0() ; }
159 void SwitchOffNoFiducialBorderInEMCALEta0() { fEMCALRecoUtils->SwitchOffNoFiducialBorderInEMCALEta0() ; }
160 Bool_t IsEMCALNoBorderAtEta0() const { return fEMCALRecoUtils->IsEMCALNoBorderAtEta0() ; }
163 Bool_t IsRecalibrationOn() const { return fRecalibration ; }
164 void SwitchOnRecalibration() { fRecalibration = kTRUE ;
165 InitPHOSRecalibrationFactors(); fEMCALRecoUtils->SwitchOnRecalibration() ; }
166 void SwitchOffRecalibration() { fRecalibration = kFALSE;
167 fEMCALRecoUtils->SwitchOffRecalibration() ; }
169 void InitPHOSRecalibrationFactors () ;
171 Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const {
172 return fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(iSM , iCol, iRow) ; }
174 Float_t GetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow) const {
175 if(fPHOSRecalibrationFactors)
176 return (Float_t) ((TH2F*)fPHOSRecalibrationFactors->At(imod))->GetBinContent(iCol,iRow);
179 void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
180 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(iSM,iCol,iRow,c) ; }
182 void SetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
183 if(!fPHOSRecalibrationFactors) InitPHOSRecalibrationFactors();
184 ((TH2F*)fPHOSRecalibrationFactors->At(imod))->SetBinContent(iCol,iRow,c) ; }
186 void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) { fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(iSM,h) ; }
187 void SetPHOSChannelRecalibrationFactors(Int_t imod , TH2F* h) { fPHOSRecalibrationFactors ->AddAt(h,imod) ; }
189 TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const { return fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(iSM) ; }
190 TH2F * GetPHOSChannelRecalibrationFactors(Int_t imod) const { return (TH2F*)fPHOSRecalibrationFactors->At(imod) ; }
192 void SetEMCALChannelRecalibrationFactors(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(map) ; }
193 void SetPHOSChannelRecalibrationFactors (TObjArray *map) { fPHOSRecalibrationFactors = map;}
195 void RecalibrateCellTime (Double_t & time, const TString calo, const Int_t absId, const Int_t bunchCrossNumber) const ;
196 void RecalibrateCellAmplitude(Float_t & amp, const TString calo, const Int_t absId) const ;
197 Float_t RecalibrateClusterEnergy(AliVCluster* cluster, AliVCaloCells * cells);
199 // Run dependent energy calibrations (EMCAL)
201 void SwitchOffRunDepCorrection() { fEMCALRecoUtils->SwitchOffRunDepCorrection() ; }
202 void SwitchOnRunDepCorrection() { fEMCALRecoUtils->SwitchOnRunDepCorrection() ; }
204 // Time Recalibration (EMCAL)
206 Bool_t IsTimeRecalibrationOn() const { return fEMCALRecoUtils->IsTimeRecalibrationOn() ; }
207 void SwitchOffTimeRecalibration() { fEMCALRecoUtils->SwitchOffTimeRecalibration() ; }
208 void SwitchOnTimeRecalibration() { fEMCALRecoUtils->SwitchOnTimeRecalibration() ; }
210 Float_t GetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID) const
211 { fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactor(bc, absID) ; }
213 void SetEMCALChannelTimeRecalibrationFactor(const Int_t bc, const Int_t absID, Double_t c = 0)
214 { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactor(bc, absID, c) ; }
216 TH1F * GetEMCALChannelTimeRecalibrationFactors(const Int_t bc)const { return fEMCALRecoUtils-> GetEMCALChannelTimeRecalibrationFactors(bc) ; }
217 void SetEMCALChannelTimeRecalibrationFactors(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(map) ; }
218 void SetEMCALChannelTimeRecalibrationFactors(const Int_t bc , TH1F* h) { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(bc , h) ; }
220 //EMCAL specific utils for the moment
221 void SetEMCALRecoUtils(AliEMCALRecoUtils * ru) { fEMCALRecoUtils = ru ; }
222 AliEMCALRecoUtils* GetEMCALRecoUtils() const { return fEMCALRecoUtils ; }
224 Bool_t IsCorrectionOfClusterEnergyOn() const { return fCorrectELinearity ; }
225 void SwitchOnCorrectClusterLinearity() { fCorrectELinearity = kTRUE ; }
226 void SwitchOffCorrectClusterLinearity() { fCorrectELinearity = kFALSE ; }
227 void CorrectClusterEnergy(AliVCluster *cl);
229 Bool_t IsRecalculationOfClusterPositionOn() const { return fRecalculatePosition ; }
230 void SwitchOnRecalculateClusterPosition() { fRecalculatePosition = kTRUE ; }
231 void SwitchOffRecalculateClusterPosition() { fRecalculatePosition = kFALSE ; }
232 void RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu);
233 void RecalculateClusterShowerShapeParameters(AliVCaloCells* cells, AliVCluster* clu){
234 fEMCALRecoUtils->RecalculateClusterShowerShapeParameters((AliEMCALGeometry*)fEMCALGeo, cells, clu) ; }
236 void RecalculateClusterDistanceToBadChannel(AliVCaloCells* cells, AliVCluster* clu){
237 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel((AliEMCALGeometry*)fEMCALGeo, cells, clu) ; }
239 void RecalculateClusterPID(AliVCluster* clu) { fEMCALRecoUtils->RecalculateClusterPID(clu) ; }
241 // *** Track Matching ***
243 AliVTrack * GetMatchedTrack(const AliVCluster * cluster, const AliVEvent * event, const Int_t index = 0) const ;
246 void RecalculateClusterTrackMatching(AliVEvent * event, TObjArray* clusterArray = 0x0) ;
248 void GetMatchedResiduals(Int_t index, Float_t &dR, Float_t &dZ) {
249 if (fRecalculateMatching) fEMCALRecoUtils->GetMatchedResiduals(index,dR,dZ) ; }
251 //This could be used for PHOS ...
252 void SwitchOnRecalculateClusterTrackMatching() { fRecalculateMatching = kTRUE ; }
253 void SwitchOffRecalculateClusterTrackMatching() { fRecalculateMatching = kFALSE ; }
254 Bool_t IsRecalculationOfClusterTrackMatchingOn() const { return fRecalculateMatching ; }
256 Float_t GetCutZ() const { return fCutZ ; } // PHOS only
257 void SetCutZ(Float_t z) { fCutZ = z ; } // PHOS only
260 Float_t GetCutR() const { return fCutR ; } // PHOS and EMCAL
261 void SetCutR(Float_t r) { fCutR = r ; // PHOS and EMCA
262 fEMCALRecoUtils->SetCutR(r) ; }
264 Float_t GetCutEta() const { return fCutEta ; } // EMCAL only
265 void SetCutEta(Float_t e) { fCutEta = e ; // EMCAL only
266 fEMCALRecoUtils->SetCutEta(e) ; }
268 Float_t GetCutPhi() const { return fCutPhi ; } // EMCAL only
269 void SetCutPhi(Float_t p) { fCutPhi = p ; // EMCAL only
270 fEMCALRecoUtils->SetCutPhi(p) ; }
271 // OADB options settings
273 void AccessOADB(AliVEvent * event) ;
277 void SwitchOnEMCALOADB() { fOADBForEMCAL = kTRUE ; }
278 void SwitchOffEMCALOADB() { fOADBForEMCAL = kFALSE ; }
280 void SwitchOnPHOSOADB() { fOADBForPHOS = kTRUE ; }
281 void SwitchOffPHOSOADB() { fOADBForPHOS = kFALSE ; }
283 void SetEMCALOADBFilePath(TString path) { fOADBFilePathEMCAL = path ; }
284 void SetPHOSOADBFilePath (TString path) { fOADBFilePathPHOS = path ; }
289 Int_t fDebug; // Debugging level
290 TString fEMCALGeoName; // Name of geometry to use for EMCAL.
291 TString fPHOSGeoName; // Name of geometry to use for PHOS.
292 AliEMCALGeometry * fEMCALGeo ; //! EMCAL geometry pointer
293 AliPHOSGeoUtils * fPHOSGeo ; //! PHOS geometry pointer
294 Bool_t fEMCALGeoMatrixSet; // Check if the transformation matrix is set for EMCAL
295 Bool_t fPHOSGeoMatrixSet ; // Check if the transformation matrix is set for PHOS
296 Bool_t fLoadEMCALMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
297 TGeoHMatrix * fEMCALMatrix[12]; // Geometry matrices with alignments
298 Bool_t fLoadPHOSMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
299 TGeoHMatrix * fPHOSMatrix[5]; // Geometry matrices with alignments
300 Bool_t fRemoveBadChannels; // Check the channel status provided and remove clusters with bad channels
301 TObjArray * fPHOSBadChannelMap; // Array of histograms with map of bad channels, PHOS
302 Int_t fNCellsFromPHOSBorder; // Number of cells from PHOS border the cell with maximum amplitude has to be.
303 Int_t fNMaskCellColumns; // Number of masked columns
304 Int_t* fMaskCellColumns; //[fNMaskCellColumns] list of masked cell collumn
305 Bool_t fRecalibration; // Switch on or off the recalibration
306 TObjArray * fPHOSRecalibrationFactors; // Array of histograms with map of recalibration factors, PHOS
307 AliEMCALRecoUtils* fEMCALRecoUtils; // EMCAL utils for cluster rereconstruction
308 Bool_t fRecalculatePosition; // Recalculate cluster position
309 Bool_t fCorrectELinearity ; // Correct cluster energy linearity
310 Bool_t fRecalculateMatching; // Recalculate cluster position
311 Float_t fCutR; // dR cut on matching (PHOS)
312 Float_t fCutZ; // dZ cut on matching (EMCAL/PHOS)
313 Float_t fCutEta; // dEta cut on matching (EMCAL)
314 Float_t fCutPhi; // dPhi cut on matching (EMCAL)
315 Float_t fLocMaxCutE; // Local maxima cut must have more than this energy
316 Float_t fLocMaxCutEDiff; // Local maxima cut, when aggregating cells, next can be a bit higher
317 Bool_t fPlotCluster; // Plot cluster in splitting method
318 Bool_t fOADBSet ; // AODB parameters already set
319 Bool_t fOADBForEMCAL ; // Get calibration from OADB for EMCAL
320 Bool_t fOADBForPHOS ; // Get calibration from OADB for PHOS
321 TString fOADBFilePathEMCAL ; // Default path $ALICE_ROOT/OADB/EMCAL, if needed change
322 TString fOADBFilePathPHOS ; // Default path $ALICE_ROOT/OADB/PHOS, if needed change
324 AliCalorimeterUtils( const AliCalorimeterUtils & cu) ; // cpy ctor
325 AliCalorimeterUtils & operator = (const AliCalorimeterUtils & cu) ; // cpy assignment
327 ClassDef(AliCalorimeterUtils,13)
331 #endif //ALICALORIMETERUTILS_H