1 #ifndef ALIEMCALRECOUTILS_H
2 #define ALIEMCALRECOUTILS_H
4 /* $Id: AliEMCALRecoUtils.h 33808 2009-07-15 09:48:08Z gconesab $ */
6 ///////////////////////////////////////////////////////////////////////////////
8 // Class AliEMCALRecoUtils
9 // Some utilities to recalculate the cluster position or energy linearity
12 // Author: Gustavo Conesa (LPSC- Grenoble)
13 // Track matching part: Rongrong Ma (Yale)
14 ///////////////////////////////////////////////////////////////////////////////
32 class AliEMCALGeometry;
33 class AliEMCALPIDUtils;
35 class AliExternalTrackParam;
37 class AliEMCALRecoUtils : public TNamed {
42 AliEMCALRecoUtils(const AliEMCALRecoUtils&);
43 AliEMCALRecoUtils& operator=(const AliEMCALRecoUtils&);
44 virtual ~AliEMCALRecoUtils() ;
45 void Print(const Option_t*) const;
48 enum NonlinearityFunctions{kPi0MC=0,kPi0GammaGamma=1,kPi0GammaConversion=2,kNoCorrection=3,kBeamTest=4,kBeamTestCorrected=5};
49 enum PositionAlgorithms{kUnchanged=-1,kPosTowerIndex=0, kPosTowerGlobal=1};
50 enum ParticleType{kPhoton=0, kElectron=1,kHadron =2, kUnknown=-1};
51 enum { kNCuts = 11 }; //track matching
52 enum TrackCutsType{kTPCOnlyCut=0, kGlobalCut=1, kLooseCut=2};
54 //-----------------------------------------------------
55 //Position recalculation
56 //-----------------------------------------------------
58 void RecalculateClusterPosition (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
59 void RecalculateClusterPositionFromTowerIndex (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
60 void RecalculateClusterPositionFromTowerGlobal(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
62 Float_t GetCellWeight(const Float_t eCell, const Float_t eCluster) const { return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster )) ; }
64 Float_t GetDepth(const Float_t eCluster, const Int_t iParticle, const Int_t iSM) const ;
66 void GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu,
67 Int_t & absId, Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared);
69 Float_t GetMisalTransShift(const Int_t i) const { if(i < 15 ) { return fMisalTransShift[i] ; }
70 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ;
72 Float_t* GetMisalTransShiftArray() { return fMisalTransShift ; }
74 void SetMisalTransShift(const Int_t i, const Float_t shift) {
75 if(i < 15 ) { fMisalTransShift[i] = shift ; }
76 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; } }
77 void SetMisalTransShiftArray(Float_t * misal) { for(Int_t i = 0; i < 15; i++) fMisalTransShift[i] = misal[i] ; }
79 Float_t GetMisalRotShift(const Int_t i) const { if(i < 15 ) { return fMisalRotShift[i] ; }
80 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ;
83 Float_t* GetMisalRotShiftArray() { return fMisalRotShift ; }
85 void SetMisalRotShift(const Int_t i, const Float_t shift) {
86 if(i < 15 ) { fMisalRotShift[i] = shift ; }
87 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)) ; } }
89 void SetMisalRotShiftArray(Float_t * misal) { for(Int_t i = 0; i < 15; i++)fMisalRotShift[i] = misal[i] ; }
91 Int_t GetParticleType() const { return fParticleType ; }
92 void SetParticleType(Int_t particle) { fParticleType = particle ; }
94 Int_t GetPositionAlgorithm() const { return fPosAlgo ; }
95 void SetPositionAlgorithm(Int_t alg) { fPosAlgo = alg ; }
97 Float_t GetW0() const { return fW0 ; }
98 void SetW0(Float_t w0) { fW0 = w0 ; }
100 //-----------------------------------------------------
102 //-----------------------------------------------------
104 Float_t CorrectClusterEnergyLinearity(AliVCluster* clu) ;
106 Float_t GetNonLinearityParam(const Int_t i) const { if(i < 7 ){ return fNonLinearityParams[i] ; }
107 else { AliInfo(Form("Index %d larger than 7, do nothing\n",i)) ;
109 void SetNonLinearityParam(const Int_t i, const Float_t param) {
110 if(i < 7 ){fNonLinearityParams[i] = param ; }
111 else { AliInfo(Form("Index %d larger than 7, do nothing\n",i)) ; } }
112 void InitNonLinearityParam();
114 Int_t GetNonLinearityFunction() const { return fNonLinearityFunction ; }
115 void SetNonLinearityFunction(Int_t fun) { fNonLinearityFunction = fun ; InitNonLinearityParam() ; }
117 void SetNonLinearityThreshold(Int_t threshold) { fNonLinearThreshold = threshold ; } //only for Alexie's non linearity correction
118 Int_t GetNonLinearityThreshold() const { return fNonLinearThreshold ; }
120 //-----------------------------------------------------
121 // MC clusters energy smearing
122 //-----------------------------------------------------
124 Float_t SmearClusterEnergy(AliVCluster* clu) ;
125 void SwitchOnClusterEnergySmearing() { fSmearClusterEnergy = kTRUE ; }
126 void SwitchOffClusterEnergySmearing() { fSmearClusterEnergy = kFALSE ; }
127 Bool_t IsClusterEnergySmeared() const { return fSmearClusterEnergy ; }
128 void SetSmearingParameters(Int_t i, Float_t param) { if(i < 3){ fSmearClusterParam[i] = param ; }
129 else { AliInfo(Form("Index %d larger than 2, do nothing\n",i)) ; } }
131 //-----------------------------------------------------
132 // Energy Recalibration
133 //-----------------------------------------------------
135 void RecalibrateCells(AliEMCALGeometry* geom, AliVCaloCells * cells, Int_t bc) ; // Energy and Time
136 void RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells, const Int_t bc=0) ; // Energy and time
138 Bool_t IsRecalibrationOn() const { return fRecalibration ; }
139 void SwitchOffRecalibration() { fRecalibration = kFALSE ; }
140 void SwitchOnRecalibration() { fRecalibration = kTRUE ;
141 if(!fEMCALRecalibrationFactors)InitEMCALRecalibrationFactors() ; }
142 void InitEMCALRecalibrationFactors() ;
144 TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const { return (TH2F*)fEMCALRecalibrationFactors->At(iSM) ; }
145 void SetEMCALChannelRecalibrationFactors(TObjArray *map) { fEMCALRecalibrationFactors = map ; }
146 void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) { fEMCALRecalibrationFactors->AddAt(h,iSM) ; }
148 Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const {
149 if(fEMCALRecalibrationFactors)
150 return (Float_t) ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->GetBinContent(iCol,iRow);
153 void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
154 if(!fEMCALRecalibrationFactors) InitEMCALRecalibrationFactors() ;
155 ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c) ; }
157 //Recalibrate channels energy with run dependent corrections
158 void SwitchOffRunDepCorrection() { fUseRunCorrectionFactors = kFALSE ; }
159 void SwitchOnRunDepCorrection() { fUseRunCorrectionFactors = kTRUE ;
160 SwitchOnRecalibration() ; }
161 void SetRunDependentCorrections(Int_t runnumber);
163 //-----------------------------------------------------
164 // Time Recalibration
165 //-----------------------------------------------------
167 void RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & time);
169 Bool_t IsTimeRecalibrationOn() const { return fTimeRecalibration ; }
170 void SwitchOffTimeRecalibration() { fTimeRecalibration = kFALSE ; }
171 void SwitchOnTimeRecalibration() { fTimeRecalibration = kTRUE ;
172 if(!fEMCALTimeRecalibrationFactors)InitEMCALTimeRecalibrationFactors() ; }
173 void InitEMCALTimeRecalibrationFactors() ;
175 Float_t GetEMCALChannelTimeRecalibrationFactor(Int_t bc, Int_t absID) const {
176 if(fEMCALTimeRecalibrationFactors)
177 return (Float_t) ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->GetBinContent(absID);
180 void SetEMCALChannelTimeRecalibrationFactor(Int_t bc,Int_t absID, Double_t c = 1) {
181 if(!fEMCALTimeRecalibrationFactors) InitEMCALTimeRecalibrationFactors() ;
182 ((TH1F*)fEMCALTimeRecalibrationFactors->At(bc))->SetBinContent(absID,c) ; }
184 TH1F * GetEMCALChannelTimeRecalibrationFactors(Int_t bc) const { return (TH1F*)fEMCALTimeRecalibrationFactors->At(bc) ; }
185 void SetEMCALChannelTimeRecalibrationFactors(TObjArray *map) { fEMCALTimeRecalibrationFactors = map ; }
186 void SetEMCALChannelTimeRecalibrationFactors(Int_t bc , TH1F* h) { fEMCALTimeRecalibrationFactors->AddAt(h,bc) ; }
188 //-----------------------------------------------------
189 // Modules fiducial region, remove clusters in borders
190 //-----------------------------------------------------
192 Bool_t CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells) ;
193 void SetNumberOfCellsFromEMCALBorder(Int_t n) { fNCellsFromEMCALBorder = n ; }
194 Int_t GetNumberOfCellsFromEMCALBorder() const { return fNCellsFromEMCALBorder ; }
196 void SwitchOnNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kTRUE ; }
197 void SwitchOffNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kFALSE ; }
198 Bool_t IsEMCALNoBorderAtEta0() const { return fNoEMCALBorderAtEta0 ; }
200 //-----------------------------------------------------
202 //-----------------------------------------------------
204 Bool_t IsBadChannelsRemovalSwitchedOn() const { return fRemoveBadChannels ; }
205 void SwitchOffBadChannelsRemoval() { fRemoveBadChannels = kFALSE ; }
206 void SwitchOnBadChannelsRemoval () { fRemoveBadChannels = kTRUE ;
207 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ; }
209 Bool_t IsDistanceToBadChannelRecalculated() const { return fRecalDistToBadChannels ; }
210 void SwitchOffDistToBadChannelRecalculation() { fRecalDistToBadChannels = kFALSE ; }
211 void SwitchOnDistToBadChannelRecalculation() { fRecalDistToBadChannels = kTRUE ;
212 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ; }
214 void InitEMCALBadChannelStatusMap() ;
216 Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const {
217 if(fEMCALBadChannelMap) return (Int_t) ((TH2I*)fEMCALBadChannelMap->At(iSM))->GetBinContent(iCol,iRow);
218 else return 0;}//Channel is ok by default
220 void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
221 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ;
222 ((TH2I*)fEMCALBadChannelMap->At(iSM))->SetBinContent(iCol,iRow,c) ; }
224 TH2I * GetEMCALChannelStatusMap(Int_t iSM) const { return (TH2I*)fEMCALBadChannelMap->At(iSM) ; }
225 void SetEMCALChannelStatusMap(TObjArray *map) { fEMCALBadChannelMap = map ; }
226 void SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALBadChannelMap->AddAt(h,iSM) ; }
228 Bool_t ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, const Int_t nCells);
230 //-----------------------------------------------------
231 // Recalculate other cluster parameters
232 //-----------------------------------------------------
234 void RecalculateClusterDistanceToBadChannel (AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
235 void RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
236 void RecalculateClusterPID(AliVCluster * cluster);
238 AliEMCALPIDUtils * GetPIDUtils() { return fPIDUtils;}
241 //----------------------------------------------------
243 //----------------------------------------------------
245 Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, AliVCluster *cluster, Float_t &tmpEta, Float_t &tmpPhi);
247 void FindMatches(AliVEvent *event, TObjArray * clusterArr=0x0, AliEMCALGeometry *geom=0x0);
248 Int_t FindMatchedCluster(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom);
249 UInt_t FindMatchedPosForCluster(Int_t clsIndex) const;
250 UInt_t FindMatchedPosForTrack(Int_t trkIndex) const;
252 void GetMatchedResiduals(Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
253 void GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
254 Int_t GetMatchedTrackIndex(Int_t clsIndex);
255 Int_t GetMatchedClusterIndex(Int_t trkIndex);
257 Bool_t IsClusterMatched(Int_t clsIndex) const;
258 Bool_t IsTrackMatched(Int_t trkIndex) const;
261 void SwitchOnCutEtaPhiSum() { fCutEtaPhiSum = kTRUE ;
262 fCutEtaPhiSeparate = kFALSE ; }
263 void SwitchOnCutEtaPhiSeparate() { fCutEtaPhiSeparate = kTRUE ;
264 fCutEtaPhiSum = kFALSE ; }
266 Float_t GetCutR() const { return fCutR ; }
267 Float_t GetCutEta() const { return fCutEta ; }
268 Float_t GetCutPhi() const { return fCutPhi ; }
269 void SetCutR(Float_t cutR) { fCutR = cutR ; }
270 void SetCutEta(Float_t cutEta) { fCutEta = cutEta ; }
271 void SetCutPhi(Float_t cutPhi) { fCutPhi = cutPhi ; }
272 void SetCutZ(Float_t cutZ) { printf("Obsolete fucntion of cutZ=%1.1f\n",cutZ) ; } //Obsolete
274 Double_t GetMass() const { return fMass ; }
275 Double_t GetStep() const { return fStep ; }
276 void SetMass(Double_t mass) { fMass = mass ; }
277 void SetStep(Double_t step) { fStep = step ; }
280 Bool_t IsGoodCluster(AliVCluster *cluster, AliEMCALGeometry *geom, AliVCaloCells* cells);
281 Bool_t IsExoticCluster(AliVCluster *cluster) const ;
283 void SwitchOnRejectExoticCluster() { fRejectExoticCluster=kTRUE ; }
284 void SwitchOffRejectExoticCluster() { fRejectExoticCluster=kFALSE ; }
285 Bool_t IsRejectExoticCluster() const { return fRejectExoticCluster ; }
289 Bool_t IsAccepted(AliESDtrack *track);
290 void InitTrackCuts();
291 void SetTrackCutsType(Int_t type) { fTrackCutsType = type ;
293 Int_t GetTrackCutsType() const { return fTrackCutsType; }
295 // track quality cut setters
296 void SetMinTrackPt(Double_t pt=0) { fCutMinTrackPt = pt ; }
297 void SetMinNClustersTPC(Int_t min=-1) { fCutMinNClusterTPC = min ; }
298 void SetMinNClustersITS(Int_t min=-1) { fCutMinNClusterITS = min ; }
299 void SetMaxChi2PerClusterTPC(Float_t max=1e10) { fCutMaxChi2PerClusterTPC = max ; }
300 void SetMaxChi2PerClusterITS(Float_t max=1e10) { fCutMaxChi2PerClusterITS = max ; }
301 void SetRequireTPCRefit(Bool_t b=kFALSE) { fCutRequireTPCRefit = b ; }
302 void SetRequireITSRefit(Bool_t b=kFALSE) { fCutRequireITSRefit = b ; }
303 void SetAcceptKinkDaughters(Bool_t b=kTRUE) { fCutAcceptKinkDaughters = b ; }
304 void SetMaxDCAToVertexXY(Float_t dist=1e10) { fCutMaxDCAToVertexXY = dist ; }
305 void SetMaxDCAToVertexZ(Float_t dist=1e10) { fCutMaxDCAToVertexZ = dist ; }
306 void SetDCAToVertex2D(Bool_t b=kFALSE) { fCutDCAToVertex2D = b ; }
309 Double_t GetMinTrackPt() const { return fCutMinTrackPt ; }
310 Int_t GetMinNClusterTPC() const { return fCutMinNClusterTPC ; }
311 Int_t GetMinNClustersITS() const { return fCutMinNClusterITS ; }
312 Float_t GetMaxChi2PerClusterTPC() const { return fCutMaxChi2PerClusterTPC ; }
313 Float_t GetMaxChi2PerClusterITS() const { return fCutMaxChi2PerClusterITS ; }
314 Bool_t GetRequireTPCRefit() const { return fCutRequireTPCRefit ; }
315 Bool_t GetRequireITSRefit() const { return fCutRequireITSRefit ; }
316 Bool_t GetAcceptKinkDaughters() const { return fCutAcceptKinkDaughters ; }
317 Float_t GetMaxDCAToVertexXY() const { return fCutMaxDCAToVertexXY ; }
318 Float_t GetMaxDCAToVertexZ() const { return fCutMaxDCAToVertexZ ; }
319 Bool_t GetDCAToVertex2D() const { return fCutDCAToVertex2D ; }
324 //Position recalculation
325 Float_t fMisalTransShift[15]; // Shift parameters
326 Float_t fMisalRotShift[15]; // Shift parameters
327 Int_t fParticleType; // Particle type for depth calculation
328 Int_t fPosAlgo; // Position recalculation algorithm
329 Float_t fW0; // Weight0
332 Int_t fNonLinearityFunction; // Non linearity function choice
333 Float_t fNonLinearityParams[7]; // Parameters for the non linearity function
334 Int_t fNonLinearThreshold; // Non linearity threshold value for kBeamTesh non linearity function
336 // Energy smearing for MC
337 Bool_t fSmearClusterEnergy; // Smear cluster energy, to be done only for simulated data to match real data
338 Float_t fSmearClusterParam[3]; // Smearing parameters
339 TRandom3 fRandom; // Random generator
341 // Energy Recalibration
342 Bool_t fCellsRecalibrated; // Internal bool to check if cells (time/energy) where recalibrated and not recalibrate them when recalculating different things
343 Bool_t fRecalibration; // Switch on or off the recalibration
344 TObjArray* fEMCALRecalibrationFactors; // Array of histograms with map of recalibration factors, EMCAL
346 // Time Recalibration
347 Bool_t fTimeRecalibration; // Switch on or off the time recalibration
348 TObjArray* fEMCALTimeRecalibrationFactors; // Array of histograms with map of time recalibration factors, EMCAL
350 // Recalibrate with run dependent corrections, energy
351 Bool_t fUseRunCorrectionFactors; // Use Run Dependent Correction
352 Bool_t fRunCorrectionFactorsSet; // Run Correction set at leat once
355 Bool_t fRemoveBadChannels; // Check the channel status provided and remove clusters with bad channels
356 Bool_t fRecalDistToBadChannels; // Calculate distance from highest energy tower of cluster to closes bad channel
357 TObjArray* fEMCALBadChannelMap; // Array of histograms with map of bad channels, EMCAL
360 Int_t fNCellsFromEMCALBorder; // Number of cells from EMCAL border the cell with maximum amplitude has to be.
361 Bool_t fNoEMCALBorderAtEta0; // Do fiducial cut in EMCAL region eta = 0?
364 Bool_t fRejectExoticCluster; // Switch on or off exotic cluster rejection
367 AliEMCALPIDUtils * fPIDUtils; // Recalculate PID parameters
370 UInt_t fAODFilterMask; // Filter mask to select AOD tracks. Refer to $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C
371 TArrayI * fMatchedTrackIndex; // Array that stores indexes of matched tracks
372 TArrayI * fMatchedClusterIndex; // Array that stores indexes of matched clusters
373 TArrayF * fResidualEta; // Array that stores the residual eta
374 TArrayF * fResidualPhi; // Array that stores the residual phi
375 Bool_t fCutEtaPhiSum; // Place cut on sqrt(dEta^2+dPhi^2)
376 Bool_t fCutEtaPhiSeparate; // Cut on dEta and dPhi separately
377 Float_t fCutR; // sqrt(dEta^2+dPhi^2) cut on matching
378 Float_t fCutEta; // dEta cut on matching
379 Float_t fCutPhi; // dPhi cut on matching
380 Double_t fMass; // Mass hypothesis of the track
381 Double_t fStep; // Length of each step used in extrapolation in the unit of cm.
384 Int_t fTrackCutsType; // Esd track cuts type for matching
385 Double_t fCutMinTrackPt; // Cut on track pT
386 Int_t fCutMinNClusterTPC; // Min number of tpc clusters
387 Int_t fCutMinNClusterITS; // Min number of its clusters
388 Float_t fCutMaxChi2PerClusterTPC; // Max tpc fit chi2 per tpc cluster
389 Float_t fCutMaxChi2PerClusterITS; // Max its fit chi2 per its cluster
390 Bool_t fCutRequireTPCRefit; // Require TPC refit
391 Bool_t fCutRequireITSRefit; // Require ITS refit
392 Bool_t fCutAcceptKinkDaughters; // Accepting kink daughters?
393 Float_t fCutMaxDCAToVertexXY; // Track-to-vertex cut in max absolute distance in xy-plane
394 Float_t fCutMaxDCAToVertexZ; // Track-to-vertex cut in max absolute distance in z-plane
395 Bool_t fCutDCAToVertex2D; // If true a 2D DCA cut is made. Tracks are accepted if sqrt((DCAXY / fCutMaxDCAToVertexXY)^2 + (DCAZ / fCutMaxDCAToVertexZ)^2) < 1 AND sqrt((DCAXY / fCutMinDCAToVertexXY)^2 + (DCAZ / fCutMinDCAToVertexZ)^2) > 1
397 ClassDef(AliEMCALRecoUtils, 14)
401 #endif // ALIEMCALRECOUTILS_H