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};
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 //-----------------------------------------------------
133 //-----------------------------------------------------
135 void RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells * cells) ;
137 Bool_t IsRecalibrationOn() const { return fRecalibration ; }
138 void SwitchOffRecalibration() { fRecalibration = kFALSE ; }
139 void SwitchOnRecalibration() { fRecalibration = kTRUE ;
140 if(!fEMCALRecalibrationFactors)InitEMCALRecalibrationFactors() ; }
141 void InitEMCALRecalibrationFactors() ;
143 //Recalibrate channels with time dependent corrections
144 void SwitchOffTimeDepCorrection() { fUseTimeCorrectionFactors = kFALSE ; }
145 void SwitchOnTimeDepCorrection() { fUseTimeCorrectionFactors = kTRUE ;
146 SwitchOnRecalibration() ; }
147 void SetTimeDependentCorrections(Int_t runnumber);
149 Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow) const {
150 if(fEMCALRecalibrationFactors)
151 return (Float_t) ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->GetBinContent(iCol,iRow);
154 void SetEMCALChannelRecalibrationFactor(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
155 if(!fEMCALRecalibrationFactors) InitEMCALRecalibrationFactors() ;
156 ((TH2F*)fEMCALRecalibrationFactors->At(iSM))->SetBinContent(iCol,iRow,c) ; }
158 TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const { return (TH2F*)fEMCALRecalibrationFactors->At(iSM) ; }
159 void SetEMCALChannelRecalibrationFactors(TObjArray *map) { fEMCALRecalibrationFactors = map ; }
160 void SetEMCALChannelRecalibrationFactors(Int_t iSM , TH2F* h) { fEMCALRecalibrationFactors->AddAt(h,iSM) ; }
162 //-----------------------------------------------------
163 //Modules fiducial region, remove clusters in borders
164 //-----------------------------------------------------
166 Bool_t CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells) ;
167 void SetNumberOfCellsFromEMCALBorder(Int_t n) { fNCellsFromEMCALBorder = n ; }
168 Int_t GetNumberOfCellsFromEMCALBorder() const { return fNCellsFromEMCALBorder ; }
170 void SwitchOnNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kTRUE ; }
171 void SwitchOffNoFiducialBorderInEMCALEta0() { fNoEMCALBorderAtEta0 = kFALSE ; }
172 Bool_t IsEMCALNoBorderAtEta0() const { return fNoEMCALBorderAtEta0 ; }
174 //-----------------------------------------------------
176 //-----------------------------------------------------
178 Bool_t IsBadChannelsRemovalSwitchedOn() const { return fRemoveBadChannels ; }
179 void SwitchOffBadChannelsRemoval() { fRemoveBadChannels = kFALSE ; }
180 void SwitchOnBadChannelsRemoval () { fRemoveBadChannels = kTRUE ;
181 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ; }
183 Bool_t IsDistanceToBadChannelRecalculated() const { return fRecalDistToBadChannels ; }
184 void SwitchOffDistToBadChannelRecalculation() { fRecalDistToBadChannels = kFALSE ; }
185 void SwitchOnDistToBadChannelRecalculation() { fRecalDistToBadChannels = kTRUE ;
186 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ; }
188 void InitEMCALBadChannelStatusMap() ;
190 Int_t GetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow) const {
191 if(fEMCALBadChannelMap) return (Int_t) ((TH2I*)fEMCALBadChannelMap->At(iSM))->GetBinContent(iCol,iRow);
192 else return 0;}//Channel is ok by default
194 void SetEMCALChannelStatus(Int_t iSM , Int_t iCol, Int_t iRow, Double_t c = 1) {
195 if(!fEMCALBadChannelMap)InitEMCALBadChannelStatusMap() ;
196 ((TH2I*)fEMCALBadChannelMap->At(iSM))->SetBinContent(iCol,iRow,c) ; }
198 TH2I * GetEMCALChannelStatusMap(Int_t iSM) const { return (TH2I*)fEMCALBadChannelMap->At(iSM) ; }
199 void SetEMCALChannelStatusMap(TObjArray *map) { fEMCALBadChannelMap = map ; }
200 void SetEMCALChannelStatusMap(Int_t iSM , TH2I* h) { fEMCALBadChannelMap->AddAt(h,iSM) ; }
202 Bool_t ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, const Int_t nCells);
204 //-----------------------------------------------------
205 // Recalculate other cluster parameters
206 //-----------------------------------------------------
208 void RecalculateClusterDistanceToBadChannel (AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
209 void RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster);
210 void RecalculateClusterPID(AliVCluster * cluster);
212 AliEMCALPIDUtils * GetPIDUtils() { return fPIDUtils;}
215 //----------------------------------------------------
217 //----------------------------------------------------
219 Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, AliVCluster *cluster, Float_t &tmpEta, Float_t &tmpPhi);
221 void FindMatches(AliVEvent *event, TObjArray * clusterArr=0x0, AliEMCALGeometry *geom=0x0);
222 Int_t FindMatchedCluster(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom);
223 UInt_t FindMatchedPosForCluster(Int_t clsIndex) const;
224 UInt_t FindMatchedPosForTrack(Int_t trkIndex) const;
226 void GetMatchedResiduals(Int_t clsIndex, Float_t &dEta, Float_t &dPhi);
227 void GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi);
228 Int_t GetMatchedTrackIndex(Int_t clsIndex);
229 Int_t GetMatchedClusterIndex(Int_t trkIndex);
231 Bool_t IsClusterMatched(Int_t clsIndex) const;
232 Bool_t IsTrackMatched(Int_t trkIndex) const;
235 void SwitchOnCutEtaPhiSum() { fCutEtaPhiSum = kTRUE ;
236 fCutEtaPhiSeparate = kFALSE ; }
237 void SwitchOnCutEtaPhiSeparate() { fCutEtaPhiSeparate = kTRUE ;
238 fCutEtaPhiSum = kFALSE ; }
240 Float_t GetCutR() const { return fCutR ; }
241 Float_t GetCutEta() const { return fCutEta ; }
242 Float_t GetCutPhi() const { return fCutPhi ; }
243 void SetCutR(Float_t cutR) { fCutR = cutR ; }
244 void SetCutEta(Float_t cutEta) { fCutEta = cutEta ; }
245 void SetCutPhi(Float_t cutPhi) { fCutPhi = cutPhi ; }
246 void SetCutZ(Float_t cutZ) { printf("Obsolete fucntion of cutZ=%1.1f\n",cutZ) ; } //Obsolete
248 Double_t GetMass() const { return fMass ; }
249 Double_t GetStep() const { return fStep ; }
250 void SetMass(Double_t mass) { fMass = mass ; }
251 void SetStep(Double_t step) { fStep = step ; }
254 Bool_t IsGoodCluster(AliVCluster *cluster, AliEMCALGeometry *geom, AliVCaloCells* cells);
255 Bool_t IsExoticCluster(AliVCluster *cluster) const ;
257 void SwitchOnRejectExoticCluster() { fRejectExoticCluster=kTRUE ; }
258 void SwitchOffRejectExoticCluster() { fRejectExoticCluster=kFALSE ; }
259 Bool_t IsRejectExoticCluster() const { return fRejectExoticCluster ; }
263 Bool_t IsAccepted(AliESDtrack *track);
264 void InitTrackCuts();
265 void SetTrackCutsType(Int_t type) { fTrackCutsType = type ;
267 Int_t GetTrackCutsType() const { return fTrackCutsType; }
269 // track quality cut setters
270 void SetMinTrackPt(Double_t pt=0) { fCutMinTrackPt = pt ; }
271 void SetMinNClustersTPC(Int_t min=-1) { fCutMinNClusterTPC = min ; }
272 void SetMinNClustersITS(Int_t min=-1) { fCutMinNClusterITS = min ; }
273 void SetMaxChi2PerClusterTPC(Float_t max=1e10) { fCutMaxChi2PerClusterTPC = max ; }
274 void SetMaxChi2PerClusterITS(Float_t max=1e10) { fCutMaxChi2PerClusterITS = max ; }
275 void SetRequireTPCRefit(Bool_t b=kFALSE) { fCutRequireTPCRefit = b ; }
276 void SetRequireITSRefit(Bool_t b=kFALSE) { fCutRequireITSRefit = b ; }
277 void SetAcceptKinkDaughters(Bool_t b=kTRUE) { fCutAcceptKinkDaughters = b ; }
278 void SetMaxDCAToVertexXY(Float_t dist=1e10) { fCutMaxDCAToVertexXY = dist ; }
279 void SetMaxDCAToVertexZ(Float_t dist=1e10) { fCutMaxDCAToVertexZ = dist ; }
280 void SetDCAToVertex2D(Bool_t b=kFALSE) { fCutDCAToVertex2D = b ; }
283 Double_t GetMinTrackPt() const { return fCutMinTrackPt ; }
284 Int_t GetMinNClusterTPC() const { return fCutMinNClusterTPC ; }
285 Int_t GetMinNClustersITS() const { return fCutMinNClusterITS ; }
286 Float_t GetMaxChi2PerClusterTPC() const { return fCutMaxChi2PerClusterTPC ; }
287 Float_t GetMaxChi2PerClusterITS() const { return fCutMaxChi2PerClusterITS ; }
288 Bool_t GetRequireTPCRefit() const { return fCutRequireTPCRefit ; }
289 Bool_t GetRequireITSRefit() const { return fCutRequireITSRefit ; }
290 Bool_t GetAcceptKinkDaughters() const { return fCutAcceptKinkDaughters ; }
291 Float_t GetMaxDCAToVertexXY() const { return fCutMaxDCAToVertexXY ; }
292 Float_t GetMaxDCAToVertexZ() const { return fCutMaxDCAToVertexZ ; }
293 Bool_t GetDCAToVertex2D() const { return fCutDCAToVertex2D ; }
298 //Position recalculation
299 Float_t fMisalTransShift[15]; // Shift parameters
300 Float_t fMisalRotShift[15]; // Shift parameters
301 Int_t fParticleType; // Particle type for depth calculation
302 Int_t fPosAlgo; // Position recalculation algorithm
303 Float_t fW0; // Weight0
306 Int_t fNonLinearityFunction; // Non linearity function choice
307 Float_t fNonLinearityParams[7]; // Parameters for the non linearity function
308 Int_t fNonLinearThreshold; // Non linearity threshold value for kBeamTesh non linearity function
310 // Energy smearing for MC
311 Bool_t fSmearClusterEnergy; // Smear cluster energy, to be done only for simulated data to match real data
312 Float_t fSmearClusterParam[3]; // Smearing parameters
313 TRandom3 fRandom; // Random generator
316 Bool_t fRecalibration; // Switch on or off the recalibration
317 TObjArray* fEMCALRecalibrationFactors; // Array of histograms with map of recalibration factors, EMCAL
319 // Recalibrate with run dependent corrections
320 Bool_t fUseTimeCorrectionFactors; // Use Time Dependent Correction
321 Bool_t fTimeCorrectionFactorsSet; // Time Correction set at leat once
324 Bool_t fRemoveBadChannels; // Check the channel status provided and remove clusters with bad channels
325 Bool_t fRecalDistToBadChannels; // Calculate distance from highest energy tower of cluster to closes bad channel
326 TObjArray* fEMCALBadChannelMap; // Array of histograms with map of bad channels, EMCAL
329 Int_t fNCellsFromEMCALBorder; // Number of cells from EMCAL border the cell with maximum amplitude has to be.
330 Bool_t fNoEMCALBorderAtEta0; // Do fiducial cut in EMCAL region eta = 0?
333 Bool_t fRejectExoticCluster; // Switch on or off exotic cluster rejection
336 AliEMCALPIDUtils * fPIDUtils; // Recalculate PID parameters
339 UInt_t fAODFilterMask; // Filter mask to select AOD tracks. Refer to $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C
340 TArrayI * fMatchedTrackIndex; // Array that stores indexes of matched tracks
341 TArrayI * fMatchedClusterIndex; // Array that stores indexes of matched clusters
342 TArrayF * fResidualEta; // Array that stores the residual eta
343 TArrayF * fResidualPhi; // Array that stores the residual phi
344 Bool_t fCutEtaPhiSum; // Place cut on sqrt(dEta^2+dPhi^2)
345 Bool_t fCutEtaPhiSeparate; // Cut on dEta and dPhi separately
346 Float_t fCutR; // sqrt(dEta^2+dPhi^2) cut on matching
347 Float_t fCutEta; // dEta cut on matching
348 Float_t fCutPhi; // dPhi cut on matching
349 Double_t fMass; // Mass hypothesis of the track
350 Double_t fStep; // Length of each step used in extrapolation in the unit of cm.
353 Int_t fTrackCutsType; // Esd track cuts type for matching
354 Double_t fCutMinTrackPt; // Cut on track pT
355 Int_t fCutMinNClusterTPC; // Min number of tpc clusters
356 Int_t fCutMinNClusterITS; // Min number of its clusters
357 Float_t fCutMaxChi2PerClusterTPC; // Max tpc fit chi2 per tpc cluster
358 Float_t fCutMaxChi2PerClusterITS; // Max its fit chi2 per its cluster
359 Bool_t fCutRequireTPCRefit; // Require TPC refit
360 Bool_t fCutRequireITSRefit; // Require ITS refit
361 Bool_t fCutAcceptKinkDaughters; // Accepting kink daughters?
362 Float_t fCutMaxDCAToVertexXY; // Track-to-vertex cut in max absolute distance in xy-plane
363 Float_t fCutMaxDCAToVertexZ; // Track-to-vertex cut in max absolute distance in z-plane
364 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
366 ClassDef(AliEMCALRecoUtils, 13)
370 #endif // ALIEMCALRECOUTILS_H