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(TString calo, Int_t absId1, 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(Int_t absId1, Int_t absId2, AliVCluster *cluster, AliVCaloCells* cells,
64 //Float_t & e1, Float_t & e2,
65 AliAODCaloCluster *cluster1, AliAODCaloCluster *cluster2,
66 Int_t nMax, Int_t eventNumber = 0);//, Int_t *absIdList, Float_t *maxEList,
68 void SwitchOnClusterPlot() { fPlotCluster = kTRUE ; }
69 void SwitchOffClusterPlot() { fPlotCluster = kFALSE ; }
71 //Calorimeters Geometry Methods
72 AliEMCALGeometry * GetEMCALGeometry() const { return fEMCALGeo ; }
73 TString EMCALGeometryName() const { return fEMCALGeoName ; }
74 void SetEMCALGeometryName(TString name) { fEMCALGeoName = name ; }
75 void InitEMCALGeometry(Int_t runnumber = 180000) ;
76 Bool_t IsEMCALGeoMatrixSet() const { return fEMCALGeoMatrixSet ; }
78 AliPHOSGeoUtils * GetPHOSGeometry() const { return fPHOSGeo ; }
79 TString PHOSGeometryName() const { return fPHOSGeoName ; }
80 void SetPHOSGeometryName(TString name) { fPHOSGeoName = name ; }
81 void InitPHOSGeometry(Int_t runnumber = 180000) ;
82 Bool_t IsPHOSGeoMatrixSet() const { return fPHOSGeoMatrixSet ; }
84 void AccessGeometry(AliVEvent* inputEvent) ;
86 void SetImportGeometryFromFile(Bool_t import,
88 fImportGeometryFromFile = import ;
89 fImportGeometryFilePath = path ; } // EMCAL
91 void SwitchOnLoadOwnEMCALGeometryMatrices() { fLoadEMCALMatrices = kTRUE ; }
92 void SwitchOffLoadOwnEMCALGeometryMatrices() { fLoadEMCALMatrices = kFALSE ; }
93 void SetEMCALGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fEMCALMatrix[i] = m ; }
95 void SwitchOnLoadOwnPHOSGeometryMatrices() { fLoadPHOSMatrices = kTRUE ; }
96 void SwitchOffLoadOwnPHOSGeometryMatrices() { fLoadPHOSMatrices = kFALSE ; }
97 void SetPHOSGeometryMatrixInSM(TGeoHMatrix* m, Int_t i) { fPHOSMatrix[i] = m ; }
100 Bool_t IsBadChannelsRemovalSwitchedOn() const { return fRemoveBadChannels ; }
101 void SwitchOnBadChannelsRemoval () { fRemoveBadChannels = kTRUE ;
102 fEMCALRecoUtils->SwitchOnBadChannelsRemoval();
103 if(!fPHOSBadChannelMap) InitPHOSBadChannelStatusMap() ; }
104 void SwitchOffBadChannelsRemoval() { fRemoveBadChannels = kFALSE ;
105 fEMCALRecoUtils->SwitchOffBadChannelsRemoval() ; }
107 Bool_t IsDistanceToBadChannelRecalculated() const { return IsDistanceToBadChannelRecalculated() ; }
108 void SwitchOnDistToBadChannelRecalculation () { fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation() ; }
109 void SwitchOffDistToBadChannelRecalculation() { fEMCALRecoUtils->SwitchOffDistToBadChannelRecalculation(); }
111 void InitPHOSBadChannelStatusMap () ;
113 Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const {
114 return fEMCALRecoUtils->GetEMCALChannelStatus(iSM,iCol,iRow); }//Channel is ok by default
116 Int_t GetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow) const {
117 if(fPHOSBadChannelMap) return (Int_t) ((TH2I*)fPHOSBadChannelMap->At(imod))->GetBinContent(iCol,iRow);
118 else return 0 ; }//Channel is ok by default
120 void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
121 fEMCALRecoUtils->SetEMCALChannelStatus(iSM,iCol,iRow,c) ; }
123 void SetPHOSChannelStatus (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
124 if(!fPHOSBadChannelMap) InitPHOSBadChannelStatusMap() ;
125 ((TH2I*)fPHOSBadChannelMap->At(imod))->SetBinContent(iCol,iRow,c) ; }
127 void SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALRecoUtils->SetEMCALChannelStatusMap(iSM,h) ; }
128 void SetPHOSChannelStatusMap(Int_t imod , TH2I* h) { fPHOSBadChannelMap ->AddAt(h,imod) ; }
130 TH2I * GetEMCALChannelStatusMap(Int_t iSM) const { return fEMCALRecoUtils->GetEMCALChannelStatusMap(iSM) ; }
131 TH2I * GetPHOSChannelStatusMap(Int_t imod) const { return (TH2I*)fPHOSBadChannelMap->At(imod) ; }
133 void SetEMCALChannelStatusMap(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelStatusMap(map) ; }
134 void SetPHOSChannelStatusMap (TObjArray *map) { fPHOSBadChannelMap = map ; }
136 Bool_t ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells);
138 // Mask clusters in front of frame, EMCAL only
139 Int_t GetNMaskCellColumns() const { return fNMaskCellColumns;}
140 void SetNMaskCellColumns(Int_t n) {
141 if(n > fNMaskCellColumns) { delete [] fMaskCellColumns ; fMaskCellColumns = new Int_t[n] ; }
142 fNMaskCellColumns = n ; }
143 void SetMaskCellColumn(Int_t ipos, Int_t icol) {
144 if(ipos < fNMaskCellColumns) fMaskCellColumns[ipos] = icol;
145 else printf("Not set, position larger than allocated set size first") ; }
146 Bool_t MaskFrameCluster(Int_t iSM, Int_t ieta) const ;
149 //Calorimeter indexes information
150 Int_t GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent* inputEvent) const;
151 Int_t GetModuleNumber(AliVCluster * cluster) const;
152 Int_t GetModuleNumberCellIndexes(Int_t absId, TString calo, Int_t & icol, Int_t & irow, Int_t &iRCU) const ;
154 //Modules fiducial region
155 Bool_t CheckCellFiducialRegion(AliVCluster* cluster, AliVCaloCells* cells, AliVEvent * event, Int_t iev=0) const ;
156 void SetNumberOfCellsFromPHOSBorder(Int_t n) { fNCellsFromPHOSBorder = n ; }
157 Int_t GetNumberOfCellsFromPHOSBorder() const { return fNCellsFromPHOSBorder ; }
158 void SetNumberOfCellsFromEMCALBorder(Int_t n) { fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(n) ; }
159 Int_t GetNumberOfCellsFromEMCALBorder() const { return fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(); }
160 void SwitchOnNoFiducialBorderInEMCALEta0() { fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0() ; }
161 void SwitchOffNoFiducialBorderInEMCALEta0() { fEMCALRecoUtils->SwitchOffNoFiducialBorderInEMCALEta0() ; }
162 Bool_t IsEMCALNoBorderAtEta0() const { return fEMCALRecoUtils->IsEMCALNoBorderAtEta0() ; }
165 Bool_t IsRecalibrationOn() const { return fRecalibration ; }
166 void SwitchOnRecalibration() { fRecalibration = kTRUE ;
167 InitPHOSRecalibrationFactors(); fEMCALRecoUtils->SwitchOnRecalibration() ; }
168 void SwitchOffRecalibration() { fRecalibration = kFALSE;
169 fEMCALRecoUtils->SwitchOffRecalibration() ; }
171 void InitPHOSRecalibrationFactors () ;
173 Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const {
174 return fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(iSM , iCol, iRow) ; }
176 Float_t GetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow) const {
177 if(fPHOSRecalibrationFactors)
178 return (Float_t) ((TH2F*)fPHOSRecalibrationFactors->At(imod))->GetBinContent(iCol,iRow);
181 void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
182 fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(iSM,iCol,iRow,c) ; }
184 void SetPHOSChannelRecalibrationFactor (Int_t imod, Int_t iCol, Int_t iRow, Double_t c = 1) {
185 if(!fPHOSRecalibrationFactors) InitPHOSRecalibrationFactors();
186 ((TH2F*)fPHOSRecalibrationFactors->At(imod))->SetBinContent(iCol,iRow,c) ; }
188 void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) { fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(iSM,h) ; }
189 void SetPHOSChannelRecalibrationFactors(Int_t imod , TH2F* h) { fPHOSRecalibrationFactors ->AddAt(h,imod) ; }
191 TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const { return fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(iSM) ; }
192 TH2F * GetPHOSChannelRecalibrationFactors(Int_t imod) const { return (TH2F*)fPHOSRecalibrationFactors->At(imod) ; }
194 void SetEMCALChannelRecalibrationFactors(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(map) ; }
195 void SetPHOSChannelRecalibrationFactors (TObjArray *map) { fPHOSRecalibrationFactors = map;}
197 void RecalibrateCellTime (Double_t & time, TString calo, Int_t absId, Int_t bunchCrossNumber) const ;
198 void RecalibrateCellAmplitude(Float_t & amp, TString calo, Int_t absId) const ;
199 Float_t RecalibrateClusterEnergy(AliVCluster* cluster, AliVCaloCells * cells);
201 // Run dependent energy calibrations (EMCAL)
203 void SwitchOffRunDepCorrection() { fRunDependentCorrection = kFALSE ; }
204 void SwitchOnRunDepCorrection() { fRunDependentCorrection = kTRUE ; }
206 // Time Recalibration (EMCAL)
208 Bool_t IsTimeRecalibrationOn() const { return fEMCALRecoUtils->IsTimeRecalibrationOn() ; }
209 void SwitchOffTimeRecalibration() { fEMCALRecoUtils->SwitchOffTimeRecalibration() ; }
210 void SwitchOnTimeRecalibration() { fEMCALRecoUtils->SwitchOnTimeRecalibration() ; }
212 Float_t GetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID) const
213 { return fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactor(bc, absID) ; }
215 void SetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID, Double_t c = 0)
216 { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactor(bc, absID, c) ; }
218 TH1F * GetEMCALChannelTimeRecalibrationFactors(Int_t bc) const { return fEMCALRecoUtils-> GetEMCALChannelTimeRecalibrationFactors(bc) ; }
219 void SetEMCALChannelTimeRecalibrationFactors(TObjArray *map) { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(map) ; }
220 void SetEMCALChannelTimeRecalibrationFactors(Int_t bc , TH1F* h) { fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(bc , h) ; }
222 //EMCAL specific utils for the moment
223 void SetEMCALRecoUtils(AliEMCALRecoUtils * ru) { fEMCALRecoUtils = ru ; }
224 AliEMCALRecoUtils* GetEMCALRecoUtils() const { return fEMCALRecoUtils ; }
226 Bool_t IsCorrectionOfClusterEnergyOn() const { return fCorrectELinearity ; }
227 void SwitchOnCorrectClusterLinearity() { fCorrectELinearity = kTRUE ; }
228 void SwitchOffCorrectClusterLinearity() { fCorrectELinearity = kFALSE ; }
229 void CorrectClusterEnergy(AliVCluster *cl);
231 Bool_t IsRecalculationOfClusterPositionOn() const { return fRecalculatePosition ; }
232 void SwitchOnRecalculateClusterPosition() { fRecalculatePosition = kTRUE ; }
233 void SwitchOffRecalculateClusterPosition() { fRecalculatePosition = kFALSE ; }
234 void RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu);
235 void RecalculateClusterShowerShapeParameters(AliVCaloCells* cells, AliVCluster* clu){
236 fEMCALRecoUtils->RecalculateClusterShowerShapeParameters((AliEMCALGeometry*)fEMCALGeo, cells, clu) ; }
238 void RecalculateClusterDistanceToBadChannel(AliVCaloCells* cells, AliVCluster* clu){
239 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel((AliEMCALGeometry*)fEMCALGeo, cells, clu) ; }
241 void RecalculateClusterPID(AliVCluster* clu) { fEMCALRecoUtils->RecalculateClusterPID(clu) ; }
243 // *** Track Matching ***
245 AliVTrack * GetMatchedTrack(AliVCluster * cluster, AliVEvent * event, Int_t index = 0) const ;
248 void RecalculateClusterTrackMatching(AliVEvent * event, TObjArray* clusterArray = 0x0) ;
250 void GetMatchedResiduals(Int_t index, Float_t &dR, Float_t &dZ) {
251 if (fRecalculateMatching) fEMCALRecoUtils->GetMatchedResiduals(index,dR,dZ) ; }
253 //This could be used for PHOS ...
254 void SwitchOnRecalculateClusterTrackMatching() { fRecalculateMatching = kTRUE ; }
255 void SwitchOffRecalculateClusterTrackMatching() { fRecalculateMatching = kFALSE ; }
256 Bool_t IsRecalculationOfClusterTrackMatchingOn() const { return fRecalculateMatching ; }
258 Float_t GetCutZ() const { return fCutZ ; } // PHOS only
259 void SetCutZ(Float_t z) { fCutZ = z ; } // PHOS only
262 Float_t GetCutR() const { return fCutR ; } // PHOS and EMCAL
263 void SetCutR(Float_t r) { fCutR = r ; // PHOS and EMCA
264 fEMCALRecoUtils->SetCutR(r) ; }
266 Float_t GetCutEta() const { return fCutEta ; } // EMCAL only
267 void SetCutEta(Float_t e) { fCutEta = e ; // EMCAL only
268 fEMCALRecoUtils->SetCutEta(e) ; }
270 Float_t GetCutPhi() const { return fCutPhi ; } // EMCAL only
271 void SetCutPhi(Float_t p) { fCutPhi = p ; // EMCAL only
272 fEMCALRecoUtils->SetCutPhi(p) ; }
273 // OADB options settings
275 void AccessOADB(AliVEvent * event) ;
279 void SwitchOnEMCALOADB() { fOADBForEMCAL = kTRUE ; }
280 void SwitchOffEMCALOADB() { fOADBForEMCAL = kFALSE ; }
282 void SwitchOnPHOSOADB() { fOADBForPHOS = kTRUE ; }
283 void SwitchOffPHOSOADB() { fOADBForPHOS = kFALSE ; }
285 void SetEMCALOADBFilePath(TString path) { fOADBFilePathEMCAL = path ; }
286 void SetPHOSOADBFilePath (TString path) { fOADBFilePathPHOS = path ; }
288 void SetNumberOfSuperModulesUsed(Int_t nSM) { fNSuperModulesUsed = nSM ; }
289 Int_t GetNumberOfSuperModulesUsed() const { return fNSuperModulesUsed ; }
293 Int_t fDebug; // Debugging level
294 TString fEMCALGeoName; // Name of geometry to use for EMCAL.
295 TString fPHOSGeoName; // Name of geometry to use for PHOS.
296 AliEMCALGeometry * fEMCALGeo ; //! EMCAL geometry pointer
297 AliPHOSGeoUtils * fPHOSGeo ; //! PHOS geometry pointer
298 Bool_t fEMCALGeoMatrixSet; // Check if the transformation matrix is set for EMCAL
299 Bool_t fPHOSGeoMatrixSet ; // Check if the transformation matrix is set for PHOS
300 Bool_t fLoadEMCALMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
301 TGeoHMatrix * fEMCALMatrix[12]; // Geometry matrices with alignments
302 Bool_t fLoadPHOSMatrices; // Matrices set from configuration, not get from geometry.root or from ESDs/AODs
303 TGeoHMatrix * fPHOSMatrix[5]; // Geometry matrices with alignments
304 Bool_t fRemoveBadChannels; // Check the channel status provided and remove clusters with bad channels
305 TObjArray * fPHOSBadChannelMap; // Array of histograms with map of bad channels, PHOS
306 Int_t fNCellsFromPHOSBorder; // Number of cells from PHOS border the cell with maximum amplitude has to be.
307 Int_t fNMaskCellColumns; // Number of masked columns
308 Int_t* fMaskCellColumns; //[fNMaskCellColumns] list of masked cell collumn
309 Bool_t fRecalibration; // Switch on or off the recalibration
310 Bool_t fRunDependentCorrection;// Switch on or off the recalibration dependent on T
311 TObjArray * fPHOSRecalibrationFactors; // Array of histograms with map of recalibration factors, PHOS
312 AliEMCALRecoUtils* fEMCALRecoUtils; // EMCAL utils for cluster rereconstruction
313 Bool_t fRecalculatePosition; // Recalculate cluster position
314 Bool_t fCorrectELinearity ; // Correct cluster energy linearity
315 Bool_t fRecalculateMatching; // Recalculate cluster position
316 Float_t fCutR; // dR cut on matching (PHOS)
317 Float_t fCutZ; // dZ cut on matching (EMCAL/PHOS)
318 Float_t fCutEta; // dEta cut on matching (EMCAL)
319 Float_t fCutPhi; // dPhi cut on matching (EMCAL)
320 Float_t fLocMaxCutE; // Local maxima cut must have more than this energy
321 Float_t fLocMaxCutEDiff; // Local maxima cut, when aggregating cells, next can be a bit higher
322 Bool_t fPlotCluster; // Plot cluster in splitting method
323 Bool_t fOADBSet ; // AODB parameters already set
324 Bool_t fOADBForEMCAL ; // Get calibration from OADB for EMCAL
325 Bool_t fOADBForPHOS ; // Get calibration from OADB for PHOS
326 TString fOADBFilePathEMCAL ; // Default path $ALICE_ROOT/OADB/EMCAL, if needed change
327 TString fOADBFilePathPHOS ; // Default path $ALICE_ROOT/OADB/PHOS, if needed change
328 Bool_t fImportGeometryFromFile;// Import geometry settings in geometry.root file
329 TString fImportGeometryFilePath;// path fo geometry.root file
331 Int_t fNSuperModulesUsed; // Number of supermodules to be used in analysis, can be different than the real geo,
332 // to be used at initialization of histograms
335 AliCalorimeterUtils( const AliCalorimeterUtils & cu) ; // cpy ctor
336 AliCalorimeterUtils & operator = (const AliCalorimeterUtils & cu) ; // cpy assignment
338 ClassDef(AliCalorimeterUtils,16)
342 #endif //ALICALORIMETERUTILS_H