]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALRecoUtils.h
BunchCrossing-based L1phase time offset correction added
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.h
CommitLineData
d9b3567c 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)
b540d03f 13// Track matching part: Rongrong Ma (Yale)
d9b3567c 14///////////////////////////////////////////////////////////////////////////////
15
16//Root includes
17#include "TNamed.h"
094786cc 18#include "TMath.h"
7cdec71f 19class TObjArray;
20class TArrayI;
21class TArrayF;
22#include "TH2I.h"
23class TH2F;
d9b3567c 24
25//AliRoot includes
26class AliVCluster;
27class AliVCaloCells;
bd8c7aef 28class AliVEvent;
b540d03f 29
30// EMCAL includes
094786cc 31class AliEMCALGeometry;
83bfd77a 32class AliEMCALPIDUtils;
bd8c7aef 33class AliESDtrack;
bb6f5f0b 34class AliExternalTrackParam;
d9b3567c 35
36class AliEMCALRecoUtils : public TNamed {
37
38public:
39
40 AliEMCALRecoUtils();
41 AliEMCALRecoUtils(const AliEMCALRecoUtils&);
42 AliEMCALRecoUtils& operator=(const AliEMCALRecoUtils&);
b540d03f 43 virtual ~AliEMCALRecoUtils() ;
44 void Print(const Option_t*) const;
45
46 //enums
4b58ac4f 47 enum NonlinearityFunctions{kPi0MC=0,kPi0GammaGamma=1,kPi0GammaConversion=2,kNoCorrection=3,kBeamTest=4,kBeamTestCorrected=5};
fd6df01c 48 enum PositionAlgorithms{kUnchanged=-1,kPosTowerIndex=0, kPosTowerGlobal=1};
094786cc 49 enum ParticleType{kPhoton=0, kElectron=1,kHadron =2, kUnknown=-1};
b540d03f 50 enum { kNCuts = 11 }; //track matching
5f7714ad 51 enum TrackCutsType{kTPCOnlyCut=0, kGlobalCut=1};
b540d03f 52
53 //-----------------------------------------------------
d9b3567c 54 //Position recalculation
b540d03f 55 //-----------------------------------------------------
56
094786cc 57 void RecalculateClusterPosition(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
58 void RecalculateClusterPositionFromTowerIndex (AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
59 void RecalculateClusterPositionFromTowerGlobal(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu);
60
61 Float_t GetCellWeight(const Float_t eCell, const Float_t eCluster) const { return TMath::Max( 0., fW0 + TMath::Log( eCell / eCluster ));}
62
63 Float_t GetDepth(const Float_t eCluster, const Int_t iParticle, const Int_t iSM) const ;
64
65 void GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu,
cb231979 66 Int_t & absId, Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared);
d9b3567c 67
2a71e873 68 Float_t GetMisalTransShift(const Int_t i) const {
69 if(i < 15 ){return fMisalTransShift[i]; }
d9b3567c 70 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)); return 0.;}
71 }
094786cc 72 Float_t* GetMisalTransShiftArray() {return fMisalTransShift; }
d9b3567c 73
2a71e873 74 void SetMisalTransShift(const Int_t i, const Float_t shift) {
75 if(i < 15 ){fMisalTransShift[i] = shift; }
d9b3567c 76 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i));}
77 }
2a71e873 78 void SetMisalTransShiftArray(Float_t * misal)
79 { for(Int_t i = 0; i < 15; i++)fMisalTransShift[i] = misal[i]; }
d9b3567c 80
2a71e873 81 Float_t GetMisalRotShift(const Int_t i) const {
82 if(i < 15 ){return fMisalRotShift[i]; }
83 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i)); return 0.;}
84 }
094786cc 85 Float_t* GetMisalRotShiftArray() {return fMisalRotShift; }
2a71e873 86
87 void SetMisalRotShift(const Int_t i, const Float_t shift) {
88 if(i < 15 ){fMisalRotShift[i] = shift; }
89 else { AliInfo(Form("Index %d larger than 15, do nothing\n",i));}
90 }
91 void SetMisalRotShiftArray(Float_t * misal)
92 { for(Int_t i = 0; i < 15; i++)fMisalRotShift[i] = misal[i]; }
93
96957075 94 Int_t GetParticleType() const { return fParticleType ;}
95 void SetParticleType(Int_t particle) { fParticleType = particle ;}
2a71e873 96
96957075 97 Int_t GetPositionAlgorithm() const { return fPosAlgo ;}
98 void SetPositionAlgorithm(Int_t alg) { fPosAlgo = alg ;}
2a71e873 99
96957075 100 Float_t GetW0() const { return fW0 ;}
101 void SetW0(Float_t w0) { fW0 = w0 ;}
094786cc 102
b540d03f 103 //-----------------------------------------------------
d9b3567c 104 //Non Linearity
b540d03f 105 //-----------------------------------------------------
106
d9b3567c 107 Float_t CorrectClusterEnergyLinearity(AliVCluster* clu);
108
109 Float_t GetNonLinearityParam(const Int_t i) const {
dff9e2e3 110 if(i < 7 ){return fNonLinearityParams[i]; }
111 else { AliInfo(Form("Index %d larger than 7, do nothing\n",i)); return 0.;}
d9b3567c 112 }
113 void SetNonLinearityParam(const Int_t i, const Float_t param) {
dff9e2e3 114 if(i < 7 ){fNonLinearityParams[i] = param; }
115 else { AliInfo(Form("Index %d larger than 7, do nothing\n",i));}
d9b3567c 116 }
7e0ecb89 117 void InitNonLinearityParam();
118
119 Int_t GetNonLinearityFunction() const { return fNonLinearityFunction ; }
120 void SetNonLinearityFunction(Int_t fun) { fNonLinearityFunction = fun ; InitNonLinearityParam() ; }
121
122 void SetNonLinearityThreshold(Int_t threshold) {fNonLinearThreshold = threshold ;} //only for Alexie's non linearity correction
123 Int_t GetNonLinearityThreshold() const {return fNonLinearThreshold ;}
124
b540d03f 125
126 //-----------------------------------------------------
094786cc 127 //Recalibration
b540d03f 128 //-----------------------------------------------------
129
094786cc 130 void RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells);
131
b540d03f 132 Bool_t IsRecalibrationOn() const { return fRecalibration ; }
133 void SwitchOnRecalibration() { fRecalibration = kTRUE ; if(!fEMCALRecalibrationFactors)InitEMCALRecalibrationFactors();}
134 void SwitchOffRecalibration() { fRecalibration = kFALSE ; }
135 void InitEMCALRecalibrationFactors() ;
96957075 136
137 //Recalibrate channels with time dependent corrections
b540d03f 138 void SwitchOnTimeDepCorrection() { fUseTimeCorrectionFactors = kTRUE ; SwitchOnRecalibration();}
139 void SwitchOffTimeDepCorrection() { fUseTimeCorrectionFactors = kFALSE;}
96957075 140 void SetTimeDependentCorrections(Int_t runnumber);
141
094786cc 142 Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const {
143 if(fEMCALRecalibrationFactors) return (Float_t) ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->GetBinContent(iCol,iRow);
144 else return 1;}
145
146 void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
147 if(!fEMCALRecalibrationFactors) InitEMCALRecalibrationFactors();
148 ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c);}
149
96957075 150 TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const { return (TH2F*)fEMCALRecalibrationFactors->At(iSM) ;}
151 void SetEMCALChannelRecalibrationFactors(TObjArray *map) { fEMCALRecalibrationFactors = map ;}
152 void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) { fEMCALRecalibrationFactors->AddAt(h,iSM) ;}
094786cc 153
b540d03f 154 //-----------------------------------------------------
fd6df01c 155 //Modules fiducial region, remove clusters in borders
b540d03f 156 //-----------------------------------------------------
157
fd6df01c 158 Bool_t CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells) ;
96957075 159 void SetNumberOfCellsFromEMCALBorder(Int_t n) { fNCellsFromEMCALBorder = n ;}
160 Int_t GetNumberOfCellsFromEMCALBorder() const { return fNCellsFromEMCALBorder ;}
fd6df01c 161
96957075 162 void SwitchOnNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kTRUE ;}
163 void SwitchOffNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kFALSE ;}
7cdec71f 164 Bool_t IsEMCALNoBorderAtEta0() const { return fNoEMCALBorderAtEta0 ;}
fd6df01c 165
b540d03f 166 //-----------------------------------------------------
fd6df01c 167 // Bad channels
b540d03f 168 //-----------------------------------------------------
169
170 Bool_t IsBadChannelsRemovalSwitchedOn() const { return fRemoveBadChannels ;}
171 void SwitchOnBadChannelsRemoval () { fRemoveBadChannels = kTRUE ; if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap();}
172 void SwitchOffBadChannelsRemoval() { fRemoveBadChannels = kFALSE ;}
fd6df01c 173
b540d03f 174 Bool_t IsDistanceToBadChannelRecalculated() const { return fRecalDistToBadChannels ;}
175 void SwitchOnDistToBadChannelRecalculation() { fRecalDistToBadChannels = kTRUE ; if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap();}
176 void SwitchOffDistToBadChannelRecalculation() { fRecalDistToBadChannels = kFALSE ;}
78467229 177
fd6df01c 178 void InitEMCALBadChannelStatusMap() ;
179
180 Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const {
181 if(fEMCALBadChannelMap) return (Int_t) ((TH2I*)fEMCALBadChannelMap->At(iSM))->GetBinContent(iCol,iRow);
182 else return 0;}//Channel is ok by default
183
184 void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
185 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ;
186 ((TH2I*)fEMCALBadChannelMap->At(iSM))->SetBinContent(iCol,iRow,c);}
187
188 TH2I * GetEMCALChannelStatusMap(Int_t iSM) const {return (TH2I*)fEMCALBadChannelMap->At(iSM);}
189 void SetEMCALChannelStatusMap(TObjArray *map) {fEMCALBadChannelMap = map;}
6fe0e6d0 190 void SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) {fEMCALBadChannelMap->AddAt(h,iSM);}
191
7cdec71f 192 Bool_t ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, const Int_t nCells);
fd6df01c 193
b540d03f 194 //-----------------------------------------------------
195 // Recalculate other cluster parameters
196 //-----------------------------------------------------
197
cb231979 198 void RecalculateClusterDistanceToBadChannel(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
83bfd77a 199 void RecalculateClusterPID(AliVCluster * cluster);
cb231979 200
83bfd77a 201 AliEMCALPIDUtils * GetPIDUtils() { return fPIDUtils;}
202
203 void RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
204
b540d03f 205 //----------------------------------------------------
206 // Track matching
207 //----------------------------------------------------
bd8c7aef 208
9741c6a0 209 void FindMatches(AliVEvent *event, TObjArray * clusterArr=0x0, AliEMCALGeometry *geom=0x0);
210 Int_t FindMatchedCluster(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom);
fa4287a2 211 Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, AliVCluster *cluster, Float_t &tmpEta, Float_t &tmpPhi);
212 void GetMatchedResiduals(Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
213 void GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
bb6f5f0b 214 Int_t GetMatchedTrackIndex(Int_t clsIndex);
215 Int_t GetMatchedClusterIndex(Int_t trkIndex);
7cdec71f 216 Bool_t IsClusterMatched(Int_t clsIndex) const;
217 Bool_t IsTrackMatched(Int_t trkIndex) const;
bb6f5f0b 218 UInt_t FindMatchedPosForCluster(Int_t clsIndex) const;
7cdec71f 219 UInt_t FindMatchedPosForTrack(Int_t trkIndex) const;
bb6f5f0b 220
fa4287a2 221 void SwitchOnCutEtaPhiSum() {fCutEtaPhiSum=kTRUE;fCutEtaPhiSeparate=kFALSE;}
222 void SwitchOnCutEtaPhiSeparate() {fCutEtaPhiSeparate=kTRUE;fCutEtaPhiSum=kFALSE;}
223
224 Float_t GetCutR() const { return fCutR ;}
225 Float_t GetCutEta() const { return fCutEta ;}
226 Float_t GetCutPhi() const { return fCutPhi ;}
227 void SetCutR(Float_t cutR) { fCutR=cutR ;}
228 void SetCutEta(Float_t cutEta) { fCutEta=cutEta ;}
229 void SetCutPhi(Float_t cutPhi) { fCutPhi=cutPhi ;}
230 void SetCutZ(Float_t cutZ) {printf("Obsolete fucntion of cutZ=%1.1f\n",cutZ);} //Obsolete
bb6f5f0b 231
232 Double_t GetMass() const { return fMass ;}
233 Double_t GetStep() const { return fStep ;}
234 void SetMass(Double_t mass){ fMass=mass ;}
235 void SetStep(Double_t step){ fStep=step ;}
236
9741c6a0 237 //Cluster cut
238 Bool_t IsGoodCluster(AliVCluster *cluster, AliEMCALGeometry *geom, AliVCaloCells* cells);
7cdec71f 239 Bool_t IsExoticCluster(AliVCluster *cluster) const ;
9741c6a0 240
7cdec71f 241 void SwitchOnRejectExoticCluster() { fRejectExoticCluster=kTRUE ;}
242 void SwitchOffRejectExoticCluster() { fRejectExoticCluster=kFALSE ;}
243 Bool_t IsRejectExoticCluster() const { return fRejectExoticCluster ;}
9741c6a0 244
bd8c7aef 245
246 //Track Cuts
b540d03f 247 Bool_t IsAccepted(AliESDtrack *track);
248 void InitTrackCuts();
5f7714ad 249 void SetTrackCutsType(Int_t type) { fTrackCutsType = type; InitTrackCuts(); }
250 Int_t GetTrackCutsType() const { return fTrackCutsType; }
bd8c7aef 251
252 // track quality cut setters
fa4287a2 253 void SetMinTrackPt(Double_t pt=0) { fCutMinTrackPt = pt ;}
b540d03f 254 void SetMinNClustersTPC(Int_t min=-1) { fCutMinNClusterTPC = min ;}
255 void SetMinNClustersITS(Int_t min=-1) { fCutMinNClusterITS = min ;}
256 void SetMaxChi2PerClusterTPC(Float_t max=1e10) { fCutMaxChi2PerClusterTPC = max ;}
257 void SetMaxChi2PerClusterITS(Float_t max=1e10) { fCutMaxChi2PerClusterITS = max ;}
258 void SetRequireTPCRefit(Bool_t b=kFALSE) { fCutRequireTPCRefit = b ;}
259 void SetRequireITSRefit(Bool_t b=kFALSE) { fCutRequireITSRefit = b ;}
260 void SetAcceptKinkDaughters(Bool_t b=kTRUE) { fCutAcceptKinkDaughters = b ;}
261 void SetMaxDCAToVertexXY(Float_t dist=1e10) { fCutMaxDCAToVertexXY = dist ;}
262 void SetMaxDCAToVertexZ(Float_t dist=1e10) { fCutMaxDCAToVertexZ = dist ;}
263 void SetDCAToVertex2D(Bool_t b=kFALSE) { fCutDCAToVertex2D = b ;}
bd8c7aef 264
fa4287a2 265 // getters
266 Double_t GetMinTrackPt() const { return fCutMinTrackPt ;}
b540d03f 267 Int_t GetMinNClusterTPC() const { return fCutMinNClusterTPC ;}
268 Int_t GetMinNClustersITS() const { return fCutMinNClusterITS ;}
269 Float_t GetMaxChi2PerClusterTPC() const { return fCutMaxChi2PerClusterTPC ;}
270 Float_t GetMaxChi2PerClusterITS() const { return fCutMaxChi2PerClusterITS ;}
271 Bool_t GetRequireTPCRefit() const { return fCutRequireTPCRefit ;}
272 Bool_t GetRequireITSRefit() const { return fCutRequireITSRefit ;}
273 Bool_t GetAcceptKinkDaughters() const { return fCutAcceptKinkDaughters ;}
274 Float_t GetMaxDCAToVertexXY() const { return fCutMaxDCAToVertexXY ;}
275 Float_t GetMaxDCAToVertexZ() const { return fCutMaxDCAToVertexZ ;}
276 Bool_t GetDCAToVertex2D() const { return fCutDCAToVertex2D ;}
bd8c7aef 277
fd6df01c 278
d9b3567c 279private:
280
b540d03f 281 //Position recalculation
96957075 282 Float_t fMisalTransShift[15]; // Shift parameters
283 Float_t fMisalRotShift[15]; // Shift parameters
284 Int_t fNonLinearityFunction; // Non linearity function choice
dff9e2e3 285 Float_t fNonLinearityParams[7]; // Parameters for the non linearity function
96957075 286 Int_t fParticleType; // Particle type for depth calculation
287 Int_t fPosAlgo; // Position recalculation algorithm
288 Float_t fW0; // Weight0
7e0ecb89 289 Int_t fNonLinearThreshold; // Non linearity threshold value for kBeamTesh non linearity function
fd6df01c 290
b540d03f 291 // Recalibration
fd6df01c 292 Bool_t fRecalibration; // Switch on or off the recalibration
293 TObjArray* fEMCALRecalibrationFactors; // Array of histograms with map of recalibration factors, EMCAL
b540d03f 294
295 // Bad Channels
fd6df01c 296 Bool_t fRemoveBadChannels; // Check the channel status provided and remove clusters with bad channels
78467229 297 Bool_t fRecalDistToBadChannels; // Calculate distance from highest energy tower of cluster to closes bad channel
fd6df01c 298 TObjArray* fEMCALBadChannelMap; // Array of histograms with map of bad channels, EMCAL
b540d03f 299
300 // Border cells
fd6df01c 301 Int_t fNCellsFromEMCALBorder; // Number of cells from EMCAL border the cell with maximum amplitude has to be.
302 Bool_t fNoEMCALBorderAtEta0; // Do fiducial cut in EMCAL region eta = 0?
b540d03f 303
bb6f5f0b 304 //Track matching
305 UInt_t fAODFilterMask; // Filter mask to select AOD tracks. Refer to $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C
b540d03f 306 TArrayI * fMatchedTrackIndex; // Array that stores indexes of matched tracks
96957075 307 TArrayI * fMatchedClusterIndex; // Array that stores indexes of matched clusters
fa4287a2 308 TArrayF * fResidualEta; // Array that stores the residual eta
309 TArrayF * fResidualPhi; // Array that stores the residual phi
310 Bool_t fCutEtaPhiSum; // Place cut on sqrt(dEta^2+dPhi^2)
311 Bool_t fCutEtaPhiSeparate; // Cut on dEta and dPhi separately
312 Float_t fCutR; // sqrt(dEta^2+dPhi^2) cut on matching
313 Float_t fCutEta; // dEta cut on matching
314 Float_t fCutPhi; // dPhi cut on matching
bb6f5f0b 315 Double_t fMass; // Mass hypothesis of the track
316 Double_t fStep; // Length of each step used in extrapolation in the unit of cm.
9741c6a0 317
318 // Cluster cuts
319 Bool_t fRejectExoticCluster; // Switch on or off exotic cluster rejection
320
321 // Track cuts
5f7714ad 322 Int_t fTrackCutsType; // Esd track cuts type for matching
fa4287a2 323 Double_t fCutMinTrackPt; // Cut on track pT
96957075 324 Int_t fCutMinNClusterTPC; // Min number of tpc clusters
325 Int_t fCutMinNClusterITS; // Min number of its clusters
326 Float_t fCutMaxChi2PerClusterTPC; // Max tpc fit chi2 per tpc cluster
327 Float_t fCutMaxChi2PerClusterITS; // Max its fit chi2 per its cluster
328 Bool_t fCutRequireTPCRefit; // Require TPC refit
329 Bool_t fCutRequireITSRefit; // Require ITS refit
330 Bool_t fCutAcceptKinkDaughters; // Accepting kink daughters?
331 Float_t fCutMaxDCAToVertexXY; // Track-to-vertex cut in max absolute distance in xy-plane
332 Float_t fCutMaxDCAToVertexZ; // Track-to-vertex cut in max absolute distance in z-plane
333 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
bd8c7aef 334
b540d03f 335 //PID
96957075 336 AliEMCALPIDUtils * fPIDUtils; // Recalculate PID parameters
337
338 //Time Correction
339 Bool_t fUseTimeCorrectionFactors; // Use Time Dependent Correction
340 Bool_t fTimeCorrectionFactorsSet; // Time Correction set at leat once
83bfd77a 341
fa4287a2 342 ClassDef(AliEMCALRecoUtils, 12)
d9b3567c 343
344};
345
346#endif // ALIEMCALRECOUTILS_H
347
348