1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliEMCALRecoUtils.cxx 33808 2009-07-15 09:48:08Z gconesab $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // Class AliEMCALRecoUtils
21 // Some utilities to recalculate the cluster position or energy linearity
24 // Author: Gustavo Conesa (LPSC- Grenoble)
25 // Track matching part: Rongrong Ma (Yale)
27 ///////////////////////////////////////////////////////////////////////////////
30 // standard C++ includes
31 //#include <Riostream.h>
34 #include <TGeoManager.h>
35 #include <TGeoMatrix.h>
40 #include <TObjArray.h>
43 #include "AliVCluster.h"
44 #include "AliVCaloCells.h"
45 #include "AliVEvent.h"
48 #include "AliESDEvent.h"
49 #include "AliAODEvent.h"
50 #include "AliESDtrack.h"
51 #include "AliAODTrack.h"
52 #include "AliExternalTrackParam.h"
53 #include "AliESDfriendTrack.h"
54 #include "AliTrackerBase.h"
57 #include "AliEMCALRecoUtils.h"
58 #include "AliEMCALGeometry.h"
59 #include "AliEMCALTrack.h"
60 #include "AliEMCALCalibTimeDepCorrection.h" // Run dependent
61 #include "AliEMCALPIDUtils.h"
63 ClassImp(AliEMCALRecoUtils)
65 //______________________________________________
66 AliEMCALRecoUtils::AliEMCALRecoUtils():
67 fParticleType(kPhoton), fPosAlgo(kUnchanged), fW0(4.),
68 fNonLinearityFunction(kNoCorrection), fNonLinearThreshold(30),
69 fSmearClusterEnergy(kFALSE), fRandom(),
70 fCellsRecalibrated(kFALSE), fRecalibration(kFALSE), fEMCALRecalibrationFactors(),
71 fTimeRecalibration(kFALSE), fEMCALTimeRecalibrationFactors(),
72 fUseRunCorrectionFactors(kFALSE), fRunCorrectionFactorsSet(kFALSE),
73 fRemoveBadChannels(kFALSE), fRecalDistToBadChannels(kFALSE), fEMCALBadChannelMap(),
74 fNCellsFromEMCALBorder(0), fNoEMCALBorderAtEta0(kTRUE),
75 fRejectExoticCluster(kFALSE), fPIDUtils(), fAODFilterMask(32),
76 fMatchedTrackIndex(0x0), fMatchedClusterIndex(0x0),
77 fResidualEta(0x0), fResidualPhi(0x0), fCutEtaPhiSum(kTRUE), fCutEtaPhiSeparate(kFALSE),
78 fCutR(0.1), fCutEta(0.025), fCutPhi(0.05),
79 fMass(0.139), fStep(10),
80 fTrackCutsType(kLooseCut), fCutMinTrackPt(0), fCutMinNClusterTPC(-1),
81 fCutMinNClusterITS(-1), fCutMaxChi2PerClusterTPC(1e10), fCutMaxChi2PerClusterITS(1e10),
82 fCutRequireTPCRefit(kFALSE), fCutRequireITSRefit(kFALSE), fCutAcceptKinkDaughters(kFALSE),
83 fCutMaxDCAToVertexXY(1e10), fCutMaxDCAToVertexZ(1e10), fCutDCAToVertex2D(kFALSE)
87 // Initialize all constant values which have to be used
88 // during Reco algorithm execution
91 //Misalignment matrices
92 for(Int_t i = 0; i < 15 ; i++) {
93 fMisalTransShift[i] = 0.;
94 fMisalRotShift[i] = 0.;
98 for(Int_t i = 0; i < 7 ; i++) fNonLinearityParams[i] = 0.;
100 //For kBeamTestCorrected case, but default is no correction
101 fNonLinearityParams[0] = 0.99078;
102 fNonLinearityParams[1] = 0.161499;
103 fNonLinearityParams[2] = 0.655166;
104 fNonLinearityParams[3] = 0.134101;
105 fNonLinearityParams[4] = 163.282;
106 fNonLinearityParams[5] = 23.6904;
107 fNonLinearityParams[6] = 0.978;
109 //For kPi0GammaGamma case
110 //fNonLinearityParams[0] = 0.1457/0.1349766/1.038;
111 //fNonLinearityParams[1] = -0.02024/0.1349766/1.038;
112 //fNonLinearityParams[2] = 1.046;
114 //Cluster energy smearing
115 fSmearClusterEnergy = kFALSE;
116 fSmearClusterParam[0] = 0.07; // * sqrt E term
117 fSmearClusterParam[1] = 0.00; // * E term
118 fSmearClusterParam[2] = 0.00; // constant
121 fMatchedTrackIndex = new TArrayI();
122 fMatchedClusterIndex = new TArrayI();
123 fResidualPhi = new TArrayF();
124 fResidualEta = new TArrayF();
125 fPIDUtils = new AliEMCALPIDUtils();
130 //______________________________________________________________________
131 AliEMCALRecoUtils::AliEMCALRecoUtils(const AliEMCALRecoUtils & reco)
133 fParticleType(reco.fParticleType), fPosAlgo(reco.fPosAlgo), fW0(reco.fW0),
134 fNonLinearityFunction(reco.fNonLinearityFunction), fNonLinearThreshold(reco.fNonLinearThreshold),
135 fSmearClusterEnergy(reco.fSmearClusterEnergy), fRandom(),
136 fCellsRecalibrated(reco.fCellsRecalibrated),
137 fRecalibration(reco.fRecalibration), fEMCALRecalibrationFactors(reco.fEMCALRecalibrationFactors),
138 fTimeRecalibration(reco.fTimeRecalibration), fEMCALTimeRecalibrationFactors(reco.fEMCALTimeRecalibrationFactors),
139 fUseRunCorrectionFactors(reco.fUseRunCorrectionFactors), fRunCorrectionFactorsSet(reco.fRunCorrectionFactorsSet),
140 fRemoveBadChannels(reco.fRemoveBadChannels), fRecalDistToBadChannels(reco.fRecalDistToBadChannels),
141 fEMCALBadChannelMap(reco.fEMCALBadChannelMap),
142 fNCellsFromEMCALBorder(reco.fNCellsFromEMCALBorder), fNoEMCALBorderAtEta0(reco.fNoEMCALBorderAtEta0),
143 fRejectExoticCluster(reco.fRejectExoticCluster), fPIDUtils(reco.fPIDUtils),
144 fAODFilterMask(reco.fAODFilterMask),
145 fMatchedTrackIndex( reco.fMatchedTrackIndex? new TArrayI(*reco.fMatchedTrackIndex):0x0),
146 fMatchedClusterIndex(reco.fMatchedClusterIndex?new TArrayI(*reco.fMatchedClusterIndex):0x0),
147 fResidualEta( reco.fResidualEta? new TArrayF(*reco.fResidualEta):0x0),
148 fResidualPhi( reco.fResidualPhi? new TArrayF(*reco.fResidualPhi):0x0),
149 fCutEtaPhiSum(reco.fCutEtaPhiSum), fCutEtaPhiSeparate(reco.fCutEtaPhiSeparate),
150 fCutR(reco.fCutR), fCutEta(reco.fCutEta), fCutPhi(reco.fCutPhi),
151 fMass(reco.fMass), fStep(reco.fStep),
152 fTrackCutsType(reco.fTrackCutsType), fCutMinTrackPt(reco.fCutMinTrackPt),
153 fCutMinNClusterTPC(reco.fCutMinNClusterTPC), fCutMinNClusterITS(reco.fCutMinNClusterITS),
154 fCutMaxChi2PerClusterTPC(reco.fCutMaxChi2PerClusterTPC), fCutMaxChi2PerClusterITS(reco.fCutMaxChi2PerClusterITS),
155 fCutRequireTPCRefit(reco.fCutRequireTPCRefit), fCutRequireITSRefit(reco.fCutRequireITSRefit),
156 fCutAcceptKinkDaughters(reco.fCutAcceptKinkDaughters), fCutMaxDCAToVertexXY(reco.fCutMaxDCAToVertexXY),
157 fCutMaxDCAToVertexZ(reco.fCutMaxDCAToVertexZ), fCutDCAToVertex2D(reco.fCutDCAToVertex2D)
161 for(Int_t i = 0; i < 15 ; i++) { fMisalRotShift[i] = reco.fMisalRotShift[i] ;
162 fMisalTransShift[i] = reco.fMisalTransShift[i] ; }
163 for(Int_t i = 0; i < 7 ; i++) { fNonLinearityParams[i] = reco.fNonLinearityParams[i] ; }
164 for(Int_t i = 0; i < 3 ; i++) { fSmearClusterParam[i] = reco.fSmearClusterParam[i] ; }
169 //______________________________________________________________________
170 AliEMCALRecoUtils & AliEMCALRecoUtils::operator = (const AliEMCALRecoUtils & reco)
172 //Assignment operator
174 if(this == &reco)return *this;
175 ((TNamed *)this)->operator=(reco);
177 for(Int_t i = 0; i < 15 ; i++) { fMisalTransShift[i] = reco.fMisalTransShift[i] ;
178 fMisalRotShift[i] = reco.fMisalRotShift[i] ; }
179 for(Int_t i = 0; i < 7 ; i++) { fNonLinearityParams[i] = reco.fNonLinearityParams[i] ; }
180 for(Int_t i = 0; i < 3 ; i++) { fSmearClusterParam[i] = reco.fSmearClusterParam[i] ; }
182 fParticleType = reco.fParticleType;
183 fPosAlgo = reco.fPosAlgo;
186 fNonLinearityFunction = reco.fNonLinearityFunction;
187 fNonLinearThreshold = reco.fNonLinearThreshold;
188 fSmearClusterEnergy = reco.fSmearClusterEnergy;
190 fCellsRecalibrated = reco.fCellsRecalibrated;
191 fRecalibration = reco.fRecalibration;
192 fEMCALRecalibrationFactors = reco.fEMCALRecalibrationFactors;
194 fTimeRecalibration = reco.fTimeRecalibration;
195 fEMCALTimeRecalibrationFactors = reco.fEMCALTimeRecalibrationFactors;
197 fUseRunCorrectionFactors = reco.fUseRunCorrectionFactors;
198 fRunCorrectionFactorsSet = reco.fRunCorrectionFactorsSet;
200 fRemoveBadChannels = reco.fRemoveBadChannels;
201 fRecalDistToBadChannels = reco.fRecalDistToBadChannels;
202 fEMCALBadChannelMap = reco.fEMCALBadChannelMap;
204 fNCellsFromEMCALBorder = reco.fNCellsFromEMCALBorder;
205 fNoEMCALBorderAtEta0 = reco.fNoEMCALBorderAtEta0;
206 fRejectExoticCluster = reco.fRejectExoticCluster;
208 fPIDUtils = reco.fPIDUtils;
210 fAODFilterMask = reco.fAODFilterMask;
212 fCutEtaPhiSum = reco.fCutEtaPhiSum;
213 fCutEtaPhiSeparate = reco.fCutEtaPhiSeparate;
215 fCutEta = reco.fCutEta;
216 fCutPhi = reco.fCutPhi;
219 fRejectExoticCluster = reco.fRejectExoticCluster;
221 fTrackCutsType = reco.fTrackCutsType;
222 fCutMinTrackPt = reco.fCutMinTrackPt;
223 fCutMinNClusterTPC = reco.fCutMinNClusterTPC;
224 fCutMinNClusterITS = reco.fCutMinNClusterITS;
225 fCutMaxChi2PerClusterTPC = reco.fCutMaxChi2PerClusterTPC;
226 fCutMaxChi2PerClusterITS = reco.fCutMaxChi2PerClusterITS;
227 fCutRequireTPCRefit = reco.fCutRequireTPCRefit;
228 fCutRequireITSRefit = reco.fCutRequireITSRefit;
229 fCutAcceptKinkDaughters = reco.fCutAcceptKinkDaughters;
230 fCutMaxDCAToVertexXY = reco.fCutMaxDCAToVertexXY;
231 fCutMaxDCAToVertexZ = reco.fCutMaxDCAToVertexZ;
232 fCutDCAToVertex2D = reco.fCutDCAToVertex2D;
234 if(reco.fResidualEta){
235 // assign or copy construct
237 *fResidualEta = *reco.fResidualEta;
239 else fResidualEta = new TArrayF(*reco.fResidualEta);
242 if(fResidualEta)delete fResidualEta;
246 if(reco.fResidualPhi){
247 // assign or copy construct
249 *fResidualPhi = *reco.fResidualPhi;
251 else fResidualPhi = new TArrayF(*reco.fResidualPhi);
254 if(fResidualPhi)delete fResidualPhi;
258 if(reco.fMatchedTrackIndex){
259 // assign or copy construct
260 if(fMatchedTrackIndex){
261 *fMatchedTrackIndex = *reco.fMatchedTrackIndex;
263 else fMatchedTrackIndex = new TArrayI(*reco.fMatchedTrackIndex);
266 if(fMatchedTrackIndex)delete fMatchedTrackIndex;
267 fMatchedTrackIndex = 0;
270 if(reco.fMatchedClusterIndex){
271 // assign or copy construct
272 if(fMatchedClusterIndex){
273 *fMatchedClusterIndex = *reco.fMatchedClusterIndex;
275 else fMatchedClusterIndex = new TArrayI(*reco.fMatchedClusterIndex);
278 if(fMatchedClusterIndex)delete fMatchedClusterIndex;
279 fMatchedClusterIndex = 0;
286 //__________________________________________________
287 AliEMCALRecoUtils::~AliEMCALRecoUtils()
291 if(fEMCALRecalibrationFactors) {
292 fEMCALRecalibrationFactors->Clear();
293 delete fEMCALRecalibrationFactors;
296 if(fEMCALTimeRecalibrationFactors) {
297 fEMCALTimeRecalibrationFactors->Clear();
298 delete fEMCALTimeRecalibrationFactors;
301 if(fEMCALBadChannelMap) {
302 fEMCALBadChannelMap->Clear();
303 delete fEMCALBadChannelMap;
306 delete fMatchedTrackIndex ;
307 delete fMatchedClusterIndex ;
308 delete fResidualEta ;
309 delete fResidualPhi ;
315 //_______________________________________________________________
316 Bool_t AliEMCALRecoUtils::CheckCellFiducialRegion(AliEMCALGeometry* geom, AliVCluster* cluster, AliVCaloCells* cells)
318 // Given the list of AbsId of the cluster, get the maximum cell and
319 // check if there are fNCellsFromBorder from the calorimeter border
322 AliInfo("Cluster pointer null!");
326 //If the distance to the border is 0 or negative just exit accept all clusters
327 if(cells->GetType()==AliVCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
329 Int_t absIdMax = -1, iSM =-1, ieta = -1, iphi = -1;
330 Bool_t shared = kFALSE;
331 GetMaxEnergyCell(geom, cells, cluster, absIdMax, iSM, ieta, iphi, shared);
333 AliDebug(2,Form("Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f, Ncells from border %d, EMCAL eta=0 %d\n",
334 absIdMax, cells->GetCellAmplitude(absIdMax), cluster->E(), fNCellsFromEMCALBorder, fNoEMCALBorderAtEta0));
336 if(absIdMax==-1) return kFALSE;
338 //Check if the cell is close to the borders:
339 Bool_t okrow = kFALSE;
340 Bool_t okcol = kFALSE;
342 if(iSM < 0 || iphi < 0 || ieta < 0 ) {
343 AliFatal(Form("Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name\n",
349 if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
352 if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
356 if(!fNoEMCALBorderAtEta0){
357 if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
361 if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
364 if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
368 AliDebug(2,Form("EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d: column? %d, row? %d\nq",
369 fNCellsFromEMCALBorder, ieta, iphi, iSM, okcol, okrow));
371 if (okcol && okrow) {
372 //printf("Accept\n");
376 //printf("Reject\n");
377 AliDebug(2,Form("Reject cluster in border, max cell : ieta %d, iphi %d, SM %d\n",ieta, iphi, iSM));
384 //_________________________________________________________________________________________________________
385 Bool_t AliEMCALRecoUtils::ClusterContainsBadChannel(AliEMCALGeometry* geom, UShort_t* cellList, const Int_t nCells){
386 // Check that in the cluster cells, there is no bad channel of those stored
387 // in fEMCALBadChannelMap or fPHOSBadChannelMap
389 if(!fRemoveBadChannels) return kFALSE;
390 if(!fEMCALBadChannelMap) return kFALSE;
395 for(Int_t iCell = 0; iCell<nCells; iCell++){
397 //Get the column and row
398 Int_t iTower = -1, iIphi = -1, iIeta = -1;
399 geom->GetCellIndex(cellList[iCell],imod,iTower,iIphi,iIeta);
400 if(fEMCALBadChannelMap->GetEntries() <= imod) continue;
401 geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
402 if(GetEMCALChannelStatus(imod, icol, irow)){
403 AliDebug(2,Form("Cluster with bad channel: SM %d, col %d, row %d\n",imod, icol, irow));
407 }// cell cluster loop
413 //_________________________________________________
414 Bool_t AliEMCALRecoUtils::IsExoticCluster(AliVCluster *cluster) const {
415 // Check if the cluster has high energy but small number of cells
416 // The criteria comes from Gustavo's study
420 AliInfo("Cluster pointer null!");
424 Int_t nc = cluster->GetNCells() ;
426 if ( nc > 8 ) return kFALSE ; // Good cluster, needed for 3x3 clusterizer
427 else if ( nc < 1 + cluster->E()/3. ) return kTRUE ; // Bad cluster
428 else return kFALSE ; // Good cluster
432 //__________________________________________________
433 Float_t AliEMCALRecoUtils::SmearClusterEnergy(AliVCluster* cluster) {
435 //In case of MC analysis, smear energy to match resolution/calibration in real data
438 AliInfo("Cluster pointer null!");
442 Float_t energy = cluster->E() ;
443 Float_t rdmEnergy = energy ;
444 if(fSmearClusterEnergy){
445 rdmEnergy = fRandom.Gaus(energy,fSmearClusterParam[0] * TMath::Sqrt(energy) +
446 fSmearClusterParam[1] * energy +
447 fSmearClusterParam[2] );
448 AliDebug(2, Form("Energy: original %f, smeared %f\n", energy, rdmEnergy));
455 //__________________________________________________
456 Float_t AliEMCALRecoUtils::CorrectClusterEnergyLinearity(AliVCluster* cluster){
457 // Correct cluster energy from non linearity functions
460 AliInfo("Cluster pointer null!");
464 Float_t energy = cluster->E();
466 switch (fNonLinearityFunction) {
470 //Non-Linearity correction (from MC with function ([0]*exp(-[1]/E))+(([2]/([3]*2.*TMath::Pi())*exp(-(E-[4])^2/(2.*[3]^2)))))
471 //Double_t fNonLinearityParams[0] = 1.014;
472 //Double_t fNonLinearityParams[1] = -0.03329;
473 //Double_t fNonLinearityParams[2] = -0.3853;
474 //Double_t fNonLinearityParams[3] = 0.5423;
475 //Double_t fNonLinearityParams[4] = -0.4335;
476 energy *= (fNonLinearityParams[0]*exp(-fNonLinearityParams[1]/energy))+
477 ((fNonLinearityParams[2]/(fNonLinearityParams[3]*2.*TMath::Pi())*
478 exp(-(energy-fNonLinearityParams[4])*(energy-fNonLinearityParams[4])/(2.*fNonLinearityParams[3]*fNonLinearityParams[3]))));
484 //Non-Linearity correction (from Olga Data with function p0+p1*exp(-p2*E))
485 //Double_t fNonLinearityParams[0] = 1.04;
486 //Double_t fNonLinearityParams[1] = -0.1445;
487 //Double_t fNonLinearityParams[2] = 1.046;
488 energy /= (fNonLinearityParams[0]+fNonLinearityParams[1]*exp(-fNonLinearityParams[2]*energy)); //Olga function
492 case kPi0GammaConversion:
494 //Non-Linearity correction (Nicolas from Dimitri Data with function C*[1-a*exp(-b*E)])
495 //fNonLinearityParams[0] = 0.139393/0.1349766;
496 //fNonLinearityParams[1] = 0.0566186;
497 //fNonLinearityParams[2] = 0.982133;
498 energy /= fNonLinearityParams[0]*(1-fNonLinearityParams[1]*exp(-fNonLinearityParams[2]*energy));
505 //From beam test, Alexei's results, for different ZS thresholds
506 // th=30 MeV; th = 45 MeV; th = 75 MeV
507 //fNonLinearityParams[0] = 1.007; 1.003; 1.002
508 //fNonLinearityParams[1] = 0.894; 0.719; 0.797
509 //fNonLinearityParams[2] = 0.246; 0.334; 0.358
510 //Rescale the param[0] with 1.03
511 energy /= fNonLinearityParams[0]/(1+fNonLinearityParams[1]*exp(-energy/fNonLinearityParams[2]));
516 case kBeamTestCorrected:
518 //From beam test, corrected for material between beam and EMCAL
519 //fNonLinearityParams[0] = 0.99078
520 //fNonLinearityParams[1] = 0.161499;
521 //fNonLinearityParams[2] = 0.655166;
522 //fNonLinearityParams[3] = 0.134101;
523 //fNonLinearityParams[4] = 163.282;
524 //fNonLinearityParams[5] = 23.6904;
525 //fNonLinearityParams[6] = 0.978;
526 energy *= fNonLinearityParams[6]/(fNonLinearityParams[0]*(1./(1.+fNonLinearityParams[1]*exp(-energy/fNonLinearityParams[2]))*1./(1.+fNonLinearityParams[3]*exp((energy-fNonLinearityParams[4])/fNonLinearityParams[5]))));
532 AliDebug(2,"No correction on the energy\n");
540 //__________________________________________________
541 void AliEMCALRecoUtils::InitNonLinearityParam()
543 //Initialising Non Linearity Parameters
545 if(fNonLinearityFunction == kPi0MC)
547 fNonLinearityParams[0] = 1.014;
548 fNonLinearityParams[1] = -0.03329;
549 fNonLinearityParams[2] = -0.3853;
550 fNonLinearityParams[3] = 0.5423;
551 fNonLinearityParams[4] = -0.4335;
554 if(fNonLinearityFunction == kPi0GammaGamma)
556 fNonLinearityParams[0] = 1.04;
557 fNonLinearityParams[1] = -0.1445;
558 fNonLinearityParams[2] = 1.046;
561 if(fNonLinearityFunction == kPi0GammaConversion)
563 fNonLinearityParams[0] = 0.139393;
564 fNonLinearityParams[1] = 0.0566186;
565 fNonLinearityParams[2] = 0.982133;
568 if(fNonLinearityFunction == kBeamTest)
570 if(fNonLinearThreshold == 30)
572 fNonLinearityParams[0] = 1.007;
573 fNonLinearityParams[1] = 0.894;
574 fNonLinearityParams[2] = 0.246;
576 if(fNonLinearThreshold == 45)
578 fNonLinearityParams[0] = 1.003;
579 fNonLinearityParams[1] = 0.719;
580 fNonLinearityParams[2] = 0.334;
582 if(fNonLinearThreshold == 75)
584 fNonLinearityParams[0] = 1.002;
585 fNonLinearityParams[1] = 0.797;
586 fNonLinearityParams[2] = 0.358;
590 if(fNonLinearityFunction == kBeamTestCorrected)
592 fNonLinearityParams[0] = 0.99078;
593 fNonLinearityParams[1] = 0.161499;
594 fNonLinearityParams[2] = 0.655166;
595 fNonLinearityParams[3] = 0.134101;
596 fNonLinearityParams[4] = 163.282;
597 fNonLinearityParams[5] = 23.6904;
598 fNonLinearityParams[6] = 0.978;
602 //__________________________________________________
603 Float_t AliEMCALRecoUtils::GetDepth(const Float_t energy, const Int_t iParticle, const Int_t iSM) const
605 //Calculate shower depth for a given cluster energy and particle type
615 depth = x0 * (TMath::Log(energy*1000/ ecr) + 0.5); //Multiply energy by 1000 to transform to MeV
619 depth = x0 * (TMath::Log(energy*1000/ ecr) - 0.5); //Multiply energy by 1000 to transform to MeV
626 gGeoManager->cd("ALIC_1/XEN1_1");
627 TGeoNode *geoXEn1 = gGeoManager->GetCurrentNode();
628 TGeoNodeMatrix *geoSM = dynamic_cast<TGeoNodeMatrix *>(geoXEn1->GetDaughter(iSM));
630 TGeoVolume *geoSMVol = geoSM->GetVolume();
631 TGeoShape *geoSMShape = geoSMVol->GetShape();
632 TGeoBBox *geoBox = dynamic_cast<TGeoBBox *>(geoSMShape);
633 if(geoBox) depth = 0.5 * geoBox->GetDX()*2 ;
634 else AliFatal("Null GEANT box");
635 }else AliFatal("NULL GEANT node matrix");
638 depth = x0 * (TMath::Log(energy*1000 / ecr) - 0.5); //Multiply energy by 1000 to transform to MeV
644 depth = x0 * (TMath::Log(energy*1000 / ecr) + 0.5); //Multiply energy by 1000 to transform to MeV
651 //__________________________________________________
652 void AliEMCALRecoUtils::GetMaxEnergyCell(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu,
653 Int_t & absId, Int_t& iSupMod, Int_t& ieta, Int_t& iphi, Bool_t &shared)
655 //For a given CaloCluster gets the absId of the cell
656 //with maximum energy deposit.
659 Double_t eCell = -1.;
660 Float_t fraction = 1.;
661 Float_t recalFactor = 1.;
662 Int_t cellAbsId = -1 ;
670 AliInfo("Cluster pointer null!");
671 absId=-1; iSupMod0=-1, ieta = -1; iphi = -1; shared = -1;
675 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
676 cellAbsId = clu->GetCellAbsId(iDig);
677 fraction = clu->GetCellAmplitudeFraction(iDig);
678 //printf("a Cell %d, id, %d, amp %f, fraction %f\n",iDig,cellAbsId,cells->GetCellAmplitude(cellAbsId),fraction);
679 if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
680 geom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
681 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
682 if(iDig==0) iSupMod0=iSupMod;
683 else if(iSupMod0!=iSupMod) {
685 //printf("AliEMCALRecoUtils::GetMaxEnergyCell() - SHARED CLUSTER\n");
687 if(IsRecalibrationOn()) {
688 recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
690 eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
691 //printf("b Cell %d, id, %d, amp %f, fraction %f\n",iDig,cellAbsId,eCell,fraction);
695 //printf("\t new max: cell %d, e %f, ecell %f\n",maxId, eMax,eCell);
699 //Get from the absid the supermodule, tower and eta/phi numbers
700 geom->GetCellIndex(absId,iSupMod,iTower,iIphi,iIeta);
701 //Gives SuperModule and Tower numbers
702 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
703 iIphi, iIeta,iphi,ieta);
704 //printf("Max id %d, iSM %d, col %d, row %d\n",absId,iSupMod,ieta,iphi);
705 //printf("Max end---\n");
709 //________________________________________________________________
710 void AliEMCALRecoUtils::InitEMCALRecalibrationFactors(){
711 //Init EMCAL recalibration factors
712 AliDebug(2,"AliCalorimeterUtils::InitEMCALRecalibrationFactors()");
713 //In order to avoid rewriting the same histograms
714 Bool_t oldStatus = TH1::AddDirectoryStatus();
715 TH1::AddDirectory(kFALSE);
717 fEMCALRecalibrationFactors = new TObjArray(10);
718 for (int i = 0; i < 10; i++) fEMCALRecalibrationFactors->Add(new TH2F(Form("EMCALRecalFactors_SM%d",i),Form("EMCALRecalFactors_SM%d",i), 48, 0, 48, 24, 0, 24));
719 //Init the histograms with 1
720 for (Int_t sm = 0; sm < 10; sm++) {
721 for (Int_t i = 0; i < 48; i++) {
722 for (Int_t j = 0; j < 24; j++) {
723 SetEMCALChannelRecalibrationFactor(sm,i,j,1.);
727 fEMCALRecalibrationFactors->SetOwner(kTRUE);
728 fEMCALRecalibrationFactors->Compress();
730 //In order to avoid rewriting the same histograms
731 TH1::AddDirectory(oldStatus);
734 //________________________________________________________________
735 void AliEMCALRecoUtils::InitEMCALTimeRecalibrationFactors(){
736 //Init EMCAL recalibration factors
737 AliDebug(2,"AliCalorimeterUtils::InitEMCALRecalibrationFactors()");
738 //In order to avoid rewriting the same histograms
739 Bool_t oldStatus = TH1::AddDirectoryStatus();
740 TH1::AddDirectory(kFALSE);
742 fEMCALTimeRecalibrationFactors = new TObjArray(4);
743 for (int i = 0; i < 4; i++)
744 fEMCALTimeRecalibrationFactors->Add(new TH1F(Form("hAllTimeAvBC%d",i),
745 Form("hAllTimeAvBC%d",i),
746 48*24*10,0.,48*24*10) );
747 //Init the histograms with 1
748 for (Int_t bc = 0; bc < 4; bc++) {
749 for (Int_t i = 0; i < 48*24*10; i++)
750 SetEMCALChannelTimeRecalibrationFactor(bc,i,0.);
753 fEMCALTimeRecalibrationFactors->SetOwner(kTRUE);
754 fEMCALTimeRecalibrationFactors->Compress();
756 //In order to avoid rewriting the same histograms
757 TH1::AddDirectory(oldStatus);
760 //________________________________________________________________
761 void AliEMCALRecoUtils::InitEMCALBadChannelStatusMap(){
762 //Init EMCAL bad channels map
763 AliDebug(2,"AliEMCALRecoUtils::InitEMCALBadChannelStatusMap()");
764 //In order to avoid rewriting the same histograms
765 Bool_t oldStatus = TH1::AddDirectoryStatus();
766 TH1::AddDirectory(kFALSE);
768 fEMCALBadChannelMap = new TObjArray(10);
769 //TH2F * hTemp = new TH2I("EMCALBadChannelMap","EMCAL SuperModule bad channel map", 48, 0, 48, 24, 0, 24);
770 for (int i = 0; i < 10; i++) {
771 fEMCALBadChannelMap->Add(new TH2I(Form("EMCALBadChannelMap_Mod%d",i),Form("EMCALBadChannelMap_Mod%d",i), 48, 0, 48, 24, 0, 24));
774 fEMCALBadChannelMap->SetOwner(kTRUE);
775 fEMCALBadChannelMap->Compress();
777 //In order to avoid rewriting the same histograms
778 TH1::AddDirectory(oldStatus);
781 //________________________________________________________________
782 void AliEMCALRecoUtils::RecalibrateClusterEnergy(AliEMCALGeometry* geom, AliVCluster * cluster, AliVCaloCells * cells, const Int_t bc){
783 // Recalibrate the cluster energy and Time, considering the recalibration map
784 // and the energy of the cells and time that compose the cluster.
785 // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
788 AliInfo("Cluster pointer null!");
792 //Get the cluster number of cells and list of absId, check what kind of cluster do we have.
793 UShort_t * index = cluster->GetCellsAbsId() ;
794 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
795 Int_t ncells = cluster->GetNCells();
797 //Initialize some used variables
800 Int_t icol =-1, irow =-1, imod=1;
801 Float_t factor = 1, frac = 0;
805 //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy
806 for(Int_t icell = 0; icell < ncells; icell++){
807 absId = index[icell];
808 frac = fraction[icell];
809 if(frac < 1e-5) frac = 1; //in case of EMCAL, this is set as 0 since unfolding is off
811 if(!fCellsRecalibrated && IsRecalibrationOn()){
814 Int_t iTower = -1, iIphi = -1, iIeta = -1;
815 geom->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
816 if(fEMCALRecalibrationFactors->GetEntries() <= imod) continue;
817 geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
818 factor = GetEMCALChannelRecalibrationFactor(imod,icol,irow);
820 AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - recalibrate cell: module %d, col %d, row %d, cell fraction %f,recalibration factor %f, cell energy %f\n",
821 imod,icol,irow,frac,factor,cells->GetCellAmplitude(absId)));
825 energy += cells->GetCellAmplitude(absId)*factor*frac;
827 if(emax < cells->GetCellAmplitude(absId)*factor*frac){
828 emax = cells->GetCellAmplitude(absId)*factor*frac;
834 cluster->SetE(energy);
836 AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - Energy before %f, after %f\n",cluster->E(),energy));
838 // Recalculate time of cluster only for ESDs
839 if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName()))){
842 Double_t weightedTime = 0;
844 Double_t weightTot = 0;
845 Double_t maxcellTime = 0;
846 for(Int_t icell = 0; icell < ncells; icell++){
847 absId = index[icell];
848 frac = fraction[icell];
849 if(frac < 1e-5) frac = 1; //in case of EMCAL, this is set as 0 since unfolding is off
851 Double_t celltime = cells->GetCellTime(absId);
852 RecalibrateCellTime(absId, bc, celltime);
853 if(absId == absIdMax) maxcellTime = celltime;
855 if(!fCellsRecalibrated){
857 Int_t iTower = -1, iIphi = -1, iIeta = -1;
858 geom->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
859 if(fEMCALRecalibrationFactors->GetEntries() <= imod) continue;
860 geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
861 factor = GetEMCALChannelRecalibrationFactor(imod,icol,irow);
863 AliDebug(2,Form("AliEMCALRecoUtils::RecalibrateClusterEnergy - recalibrate cell: module %d, col %d, row %d, cell fraction %f,recalibration factor %f, cell energy %f\n",
864 imod,icol,irow,frac,factor,cells->GetCellTime(absId)));
868 weight = GetCellWeight(cells->GetCellAmplitude(absId)*factor*frac , energy );
870 weightedTime += celltime * weight;
875 cluster->SetTOF(weightedTime/weightTot);
877 cluster->SetTOF(maxcellTime);
882 //________________________________________________________________
883 void AliEMCALRecoUtils::RecalibrateCells(AliEMCALGeometry* geom, AliVCaloCells * cells, Int_t bc){
884 // Recalibrate the cells time and energy, considering the recalibration map and the energy
885 // of the cells that compose the cluster.
886 // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
888 if(!IsRecalibrationOn() && !IsTimeRecalibrationOn()) return;
891 AliInfo("Cells pointer null!");
895 fCellsRecalibrated = kTRUE;
898 Int_t icol =-1, irow =-1, imod = 1;
899 Int_t iTower =-1, iIeta =-1, iIphi =-1;
901 Int_t nEMcell = cells->GetNumberOfCells() ;
903 for (Int_t iCell = 0; iCell < nEMcell; iCell++) {
905 absId = cells->GetCellNumber(iCell);
909 if(IsRecalibrationOn()){
910 geom->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
911 if(fEMCALRecalibrationFactors->GetEntries() <= imod) continue;
912 geom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
913 factor = GetEMCALChannelRecalibrationFactor(imod,icol,irow);
916 Float_t cellE = cells->GetAmplitude(iCell) * factor ;
919 Double_t celltime = cells->GetCellTime(absId);
920 RecalibrateCellTime(absId, bc, celltime);
923 cells->SetCell(iCell,cells->GetCellNumber(iCell),cellE, celltime);
929 //_________________________________________________________________________________________________
930 void AliEMCALRecoUtils::RecalibrateCellTime(const Int_t absId, const Int_t bc, Double_t & celltime)
932 // Recalibrate time of cell with absID considering the recalibration map
933 // bc= bunch crossing number returned by esdevent->GetBunchCrossNumber();
935 if(!fCellsRecalibrated && IsTimeRecalibrationOn()){
937 celltime -= GetEMCALChannelTimeRecalibrationFactor(bc%4,absId)*1.e-9; ;
943 //________________________________________________________________________________________________________________
944 void AliEMCALRecoUtils::RecalculateClusterPosition(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu)
946 //For a given CaloCluster recalculates the position for a given set of misalignment shifts and puts it again in the CaloCluster.
949 AliInfo("Cluster pointer null!");
953 if (fPosAlgo==kPosTowerGlobal) RecalculateClusterPositionFromTowerGlobal( geom, cells, clu);
954 else if(fPosAlgo==kPosTowerIndex) RecalculateClusterPositionFromTowerIndex ( geom, cells, clu);
955 else AliDebug(2,"Algorithm to recalculate position not selected, do nothing.");
959 //__________________________________________________
960 void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerGlobal(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu)
962 // For a given CaloCluster recalculates the position for a given set of misalignment shifts and puts it again in the CaloCluster.
963 // The algorithm is a copy of what is done in AliEMCALRecPoint
966 Float_t fraction = 1.;
967 Float_t recalFactor = 1.;
970 Int_t iTower = -1, iIphi = -1, iIeta = -1;
971 Int_t iSupModMax = -1, iSM=-1, iphi = -1, ieta = -1;
972 Float_t weight = 0., totalWeight=0.;
973 Float_t newPos[3] = {0,0,0};
974 Double_t pLocal[3], pGlobal[3];
975 Bool_t shared = kFALSE;
977 Float_t clEnergy = clu->E(); //Energy already recalibrated previously
978 GetMaxEnergyCell(geom, cells, clu, absId, iSupModMax, ieta, iphi,shared);
979 Double_t depth = GetDepth(clEnergy,fParticleType,iSupModMax) ;
981 //printf("** Cluster energy %f, ncells %d, depth %f\n",clEnergy,clu->GetNCells(),depth);
983 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
985 absId = clu->GetCellAbsId(iDig);
986 fraction = clu->GetCellAmplitudeFraction(iDig);
987 if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
989 if(!fCellsRecalibrated){
991 geom->GetCellIndex(absId,iSM,iTower,iIphi,iIeta);
992 geom->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
994 if(IsRecalibrationOn()) {
995 recalFactor = GetEMCALChannelRecalibrationFactor(iSM,ieta,iphi);
999 eCell = cells->GetCellAmplitude(absId)*fraction*recalFactor;
1001 weight = GetCellWeight(eCell,clEnergy);
1002 totalWeight += weight;
1004 geom->RelPosCellInSModule(absId,depth,pLocal[0],pLocal[1],pLocal[2]);
1005 //printf("pLocal (%f,%f,%f), SM %d, absId %d\n",pLocal[0],pLocal[1],pLocal[2],iSupModMax,absId);
1006 geom->GetGlobal(pLocal,pGlobal,iSupModMax);
1007 //printf("pLocal (%f,%f,%f)\n",pGlobal[0],pGlobal[1],pGlobal[2]);
1009 for(int i=0; i<3; i++ ) newPos[i] += (weight*pGlobal[i]);
1014 for(int i=0; i<3; i++ ) newPos[i] /= totalWeight;
1017 //Float_t pos[]={0,0,0};
1018 //clu->GetPosition(pos);
1019 //printf("OldPos : %2.3f,%2.3f,%2.3f\n",pos[0],pos[1],pos[2]);
1020 //printf("NewPos : %2.3f,%2.3f,%2.3f\n",newPos[0],newPos[1],newPos[2]);
1022 if(iSupModMax > 1) {//sector 1
1023 newPos[0] +=fMisalTransShift[3];//-=3.093;
1024 newPos[1] +=fMisalTransShift[4];//+=6.82;
1025 newPos[2] +=fMisalTransShift[5];//+=1.635;
1026 //printf(" + : %2.3f,%2.3f,%2.3f\n",fMisalTransShift[3],fMisalTransShift[4],fMisalTransShift[5]);
1030 newPos[0] +=fMisalTransShift[0];//+=1.134;
1031 newPos[1] +=fMisalTransShift[1];//+=8.2;
1032 newPos[2] +=fMisalTransShift[2];//+=1.197;
1033 //printf(" + : %2.3f,%2.3f,%2.3f\n",fMisalTransShift[0],fMisalTransShift[1],fMisalTransShift[2]);
1036 //printf("NewPos : %2.3f,%2.3f,%2.3f\n",newPos[0],newPos[1],newPos[2]);
1038 clu->SetPosition(newPos);
1042 //__________________________________________________
1043 void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerIndex(AliEMCALGeometry *geom, AliVCaloCells* cells, AliVCluster* clu)
1045 // For a given CaloCluster recalculates the position for a given set of misalignment shifts and puts it again in the CaloCluster.
1046 // The algorithm works with the tower indeces, averages the indeces and from them it calculates the global position
1048 Double_t eCell = 1.;
1049 Float_t fraction = 1.;
1050 Float_t recalFactor = 1.;
1054 Int_t iIphi = -1, iIeta = -1;
1055 Int_t iSupMod = -1, iSupModMax = -1;
1056 Int_t iphi = -1, ieta =-1;
1057 Bool_t shared = kFALSE;
1059 Float_t clEnergy = clu->E(); //Energy already recalibrated previously.
1060 GetMaxEnergyCell(geom, cells, clu, absId, iSupModMax, ieta, iphi,shared);
1061 Float_t depth = GetDepth(clEnergy,fParticleType,iSupMod) ;
1063 Float_t weight = 0., weightedCol = 0., weightedRow = 0., totalWeight=0.;
1064 Bool_t areInSameSM = kTRUE; //exclude clusters with cells in different SMs for now
1065 Int_t startingSM = -1;
1067 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
1068 absId = clu->GetCellAbsId(iDig);
1069 fraction = clu->GetCellAmplitudeFraction(iDig);
1070 if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
1072 if (iDig==0) startingSM = iSupMod;
1073 else if(iSupMod != startingSM) areInSameSM = kFALSE;
1075 eCell = cells->GetCellAmplitude(absId);
1077 geom->GetCellIndex(absId,iSupMod,iTower,iIphi,iIeta);
1078 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
1080 if(!fCellsRecalibrated){
1082 if(IsRecalibrationOn()) {
1084 recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
1089 eCell = cells->GetCellAmplitude(absId)*fraction*recalFactor;
1091 weight = GetCellWeight(eCell,clEnergy);
1092 if(weight < 0) weight = 0;
1093 totalWeight += weight;
1094 weightedCol += ieta*weight;
1095 weightedRow += iphi*weight;
1097 //printf("Max cell? cell %d, amplitude org %f, fraction %f, recalibration %f, amplitude new %f \n",cellAbsId, cells->GetCellAmplitude(cellAbsId), fraction, recalFactor, eCell) ;
1101 Float_t xyzNew[]={0.,0.,0.};
1102 if(areInSameSM == kTRUE) {
1103 //printf("In Same SM\n");
1104 weightedCol = weightedCol/totalWeight;
1105 weightedRow = weightedRow/totalWeight;
1106 geom->RecalculateTowerPosition(weightedRow, weightedCol, iSupModMax, depth, fMisalTransShift, fMisalRotShift, xyzNew);
1109 //printf("In Different SM\n");
1110 geom->RecalculateTowerPosition(iphi, ieta, iSupModMax, depth, fMisalTransShift, fMisalRotShift, xyzNew);
1113 clu->SetPosition(xyzNew);
1117 //____________________________________________________________________________
1118 void AliEMCALRecoUtils::RecalculateClusterDistanceToBadChannel(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster){
1120 //re-evaluate distance to bad channel with updated bad map
1122 if(!fRecalDistToBadChannels) return;
1125 AliInfo("Cluster pointer null!");
1129 //Get channels map of the supermodule where the cluster is.
1130 Int_t absIdMax = -1, iSupMod =-1, icolM = -1, irowM = -1;
1131 Bool_t shared = kFALSE;
1132 GetMaxEnergyCell(geom, cells, cluster, absIdMax, iSupMod, icolM, irowM, shared);
1133 TH2D* hMap = (TH2D*)fEMCALBadChannelMap->At(iSupMod);
1136 Float_t minDist = 10000.;
1139 //Loop on tower status map
1140 for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
1141 for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
1142 //Check if tower is bad.
1143 if(hMap->GetBinContent(icol,irow)==0) continue;
1144 //printf("AliEMCALRecoUtils::RecalculateDistanceToBadChannels() - \n \t Bad channel in SM %d, col %d, row %d, \n \t Cluster max in col %d, row %d\n",
1145 // iSupMod,icol, irow, icolM,irowM);
1147 dRrow=TMath::Abs(irowM-irow);
1148 dRcol=TMath::Abs(icolM-icol);
1149 dist=TMath::Sqrt(dRrow*dRrow+dRcol*dRcol);
1151 //printf("MIN DISTANCE TO BAD %2.2f\n",dist);
1158 //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module
1161 Int_t iSupMod2 = -1;
1163 //The only possible combinations are (0,1), (2,3) ... (8,9)
1164 if(iSupMod%2) iSupMod2 = iSupMod-1;
1165 else iSupMod2 = iSupMod+1;
1166 hMap2 = (TH2D*)fEMCALBadChannelMap->At(iSupMod2);
1168 //Loop on tower status map of second super module
1169 for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
1170 for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
1171 //Check if tower is bad.
1172 if(hMap2->GetBinContent(icol,irow)==0) continue;
1173 //printf("AliEMCALRecoUtils::RecalculateDistanceToBadChannels(shared) - \n \t Bad channel in SM %d, col %d, row %d \n \t Cluster max in SM %d, col %d, row %d\n",
1174 // iSupMod2,icol, irow,iSupMod,icolM,irowM);
1176 dRrow=TMath::Abs(irow-irowM);
1179 dRcol=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+icolM));
1182 dRcol=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-icolM);
1185 dist=TMath::Sqrt(dRrow*dRrow+dRcol*dRcol);
1186 if(dist < minDist) minDist = dist;
1191 }// shared cluster in 2 SuperModules
1193 AliDebug(2,Form("Max cluster cell (SM,col,row)=(%d %d %d) - Distance to Bad Channel %2.2f",iSupMod, icolM, irowM, minDist));
1194 cluster->SetDistanceToBadChannel(minDist);
1198 //____________________________________________________________________________
1199 void AliEMCALRecoUtils::RecalculateClusterPID(AliVCluster * cluster){
1201 //re-evaluate identification parameters with bayesian
1204 AliInfo("Cluster pointer null!");
1208 if ( cluster->GetM02() != 0)
1209 fPIDUtils->ComputePID(cluster->E(),cluster->GetM02());
1211 Float_t pidlist[AliPID::kSPECIESN+1];
1212 for(Int_t i = 0; i < AliPID::kSPECIESN+1; i++) pidlist[i] = fPIDUtils->GetPIDFinal(i);
1214 cluster->SetPID(pidlist);
1218 //____________________________________________________________________________
1219 void AliEMCALRecoUtils::RecalculateClusterShowerShapeParameters(AliEMCALGeometry * geom, AliVCaloCells* cells, AliVCluster * cluster)
1221 // Calculates new center of gravity in the local EMCAL-module coordinates
1222 // and tranfers into global ALICE coordinates
1223 // Calculates Dispersion and main axis
1226 AliInfo("Cluster pointer null!");
1232 Double_t eCell = 0.;
1233 Float_t fraction = 1.;
1234 Float_t recalFactor = 1.;
1242 Double_t etai = -1.;
1243 Double_t phii = -1.;
1250 Double_t xmean = 0.;
1251 Double_t zmean = 0.;
1254 for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++) {
1256 //Get from the absid the supermodule, tower and eta/phi numbers
1257 geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
1258 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1260 //Get the cell energy, if recalibration is on, apply factors
1261 fraction = cluster->GetCellAmplitudeFraction(iDigit);
1262 if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
1264 if(!fCellsRecalibrated){
1266 if(IsRecalibrationOn()) {
1267 recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
1272 eCell = cells->GetCellAmplitude(cluster->GetCellAbsId(iDigit))*fraction*recalFactor;
1274 if(cluster->E() > 0 && eCell > 0){
1276 w = GetCellWeight(eCell,cluster->E());
1278 etai=(Double_t)ieta;
1279 phii=(Double_t)iphi;
1284 dxx += w * etai * etai ;
1286 dzz += w * phii * phii ;
1288 dxz += w * etai * phii ;
1292 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, cluster->E()));
1295 //Normalize to the weight
1301 AliError(Form("Wrong weight %f\n", wtot));
1303 //Calculate dispersion
1304 for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++) {
1306 //Get from the absid the supermodule, tower and eta/phi numbers
1307 geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
1308 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1310 //Get the cell energy, if recalibration is on, apply factors
1311 fraction = cluster->GetCellAmplitudeFraction(iDigit);
1312 if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
1313 if(IsRecalibrationOn()) {
1314 recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
1316 eCell = cells->GetCellAmplitude(cluster->GetCellAbsId(iDigit))*fraction*recalFactor;
1318 if(cluster->E() > 0 && eCell > 0){
1320 w = GetCellWeight(eCell,cluster->E());
1322 etai=(Double_t)ieta;
1323 phii=(Double_t)iphi;
1324 if(w > 0.0) d += w*((etai-xmean)*(etai-xmean)+(phii-zmean)*(phii-zmean));
1327 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, cluster->E()));
1330 //Normalize to the weigth and set shower shape parameters
1331 if (wtot > 0 && nstat > 1) {
1336 dxx -= xmean * xmean ;
1337 dzz -= zmean * zmean ;
1338 dxz -= xmean * zmean ;
1339 cluster->SetM02(0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1340 cluster->SetM20(0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1344 cluster->SetM20(0.) ;
1345 cluster->SetM02(0.) ;
1349 cluster->SetDispersion(TMath::Sqrt(d)) ;
1351 cluster->SetDispersion(0) ;
1354 //____________________________________________________________________________
1355 void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr, AliEMCALGeometry *geom)
1357 //This function should be called before the cluster loop
1358 //Before call this function, please recalculate the cluster positions
1359 //Given the input event, loop over all the tracks, select the closest cluster as matched with fCutR
1360 //Store matched cluster indexes and residuals
1362 fMatchedTrackIndex->Reset();
1363 fMatchedClusterIndex->Reset();
1364 fResidualPhi->Reset();
1365 fResidualEta->Reset();
1367 fMatchedTrackIndex->Set(500);
1368 fMatchedClusterIndex->Set(500);
1369 fResidualPhi->Set(500);
1370 fResidualEta->Set(500);
1372 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event);
1373 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (event);
1377 for (Int_t i=0; i<21;i++) cv[i]=0;
1378 for(Int_t itr=0; itr<event->GetNumberOfTracks(); itr++)
1380 AliExternalTrackParam *trackParam = 0;
1382 //If the input event is ESD, the starting point for extrapolation is TPCOut, if available, or TPCInner
1385 AliESDtrack *esdTrack = esdevent->GetTrack(itr);
1386 if(!esdTrack || !IsAccepted(esdTrack)) continue;
1387 if(esdTrack->Pt()<fCutMinTrackPt) continue;
1388 trackParam = const_cast<AliExternalTrackParam*>(esdTrack->GetInnerParam());
1391 //If the input event is AOD, the starting point for extrapolation is at vertex
1392 //AOD tracks are selected according to its bit.
1395 AliAODTrack *aodTrack = aodevent->GetTrack(itr);
1396 if(!aodTrack) continue;
1397 if(!aodTrack->TestFilterMask(fAODFilterMask)) continue; //Select AOD tracks that fulfill GetStandardITSTPCTrackCuts2010()
1398 if(aodTrack->Pt()<fCutMinTrackPt) continue;
1399 Double_t pos[3],mom[3];
1400 aodTrack->GetXYZ(pos);
1401 aodTrack->GetPxPyPz(mom);
1402 AliDebug(5,Form("aod track: i=%d | pos=(%5.4f,%5.4f,%5.4f) | mom=(%5.4f,%5.4f,%5.4f) | charge=%d\n",itr,pos[0],pos[1],pos[2],mom[0],mom[1],mom[2],aodTrack->Charge()));
1403 trackParam= new AliExternalTrackParam(pos,mom,cv,aodTrack->Charge());
1406 //Return if the input data is not "AOD" or "ESD"
1409 printf("Wrong input data type! Should be \"AOD\" or \"ESD\"\n");
1413 if(!trackParam) continue;
1415 Float_t dRMax = fCutR, dEtaMax=fCutEta, dPhiMax=fCutPhi;
1417 if(!clusterArr){// get clusters from event
1418 for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++)
1420 AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
1421 if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;
1422 AliExternalTrackParam trkPamTmp(*trackParam);//Retrieve the starting point every time before the extrapolation
1423 Float_t tmpEta=-999, tmpPhi=-999;
1424 if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
1427 Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
1436 else if(fCutEtaPhiSeparate)
1438 if(TMath::Abs(tmpEta)<TMath::Abs(dEtaMax) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMax))
1447 printf("Error: please specify your cut criteria\n");
1448 printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
1449 printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
1450 if(aodevent && trackParam) delete trackParam;
1455 else { // external cluster array, not from ESD event
1456 for(Int_t icl=0; icl<clusterArr->GetEntriesFast(); icl++)
1458 AliVCluster *cluster = dynamic_cast<AliVCluster*> (clusterArr->At(icl)) ;
1460 AliInfo("Cluster not found!!!");
1463 if(!cluster->IsEMCAL()) continue;
1464 AliExternalTrackParam trkPamTmp (*trackParam);//Retrieve the starting point every time before the extrapolation
1465 Float_t tmpEta=-999, tmpPhi=-999;
1466 if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
1469 Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
1478 else if(fCutEtaPhiSeparate)
1480 if(TMath::Abs(tmpEta)<TMath::Abs(dEtaMax) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMax))
1489 printf("Error: please specify your cut criteria\n");
1490 printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
1491 printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
1492 if(aodevent && trackParam) delete trackParam;
1496 }// external list of clusters
1500 fMatchedTrackIndex ->AddAt(itr,matched);
1501 fMatchedClusterIndex->AddAt(index,matched);
1502 fResidualEta ->AddAt(dEtaMax,matched);
1503 fResidualPhi ->AddAt(dPhiMax,matched);
1506 if(aodevent && trackParam) delete trackParam;
1509 AliDebug(2,Form("Number of matched pairs = %d !\n",matched));
1511 fMatchedTrackIndex ->Set(matched);
1512 fMatchedClusterIndex->Set(matched);
1513 fResidualPhi ->Set(matched);
1514 fResidualEta ->Set(matched);
1517 //________________________________________________________________________________
1518 Int_t AliEMCALRecoUtils::FindMatchedCluster(AliESDtrack *track, AliVEvent *event, AliEMCALGeometry *geom)
1521 // This function returns the index of matched cluster to input track
1522 // Returns -1 if no match is found
1525 Float_t dRMax = fCutR, dEtaMax = fCutEta, dPhiMax = fCutPhi;
1528 AliExternalTrackParam *trackParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
1530 if(!trackParam) return index;
1531 for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++)
1533 AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
1534 if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;
1535 AliExternalTrackParam trkPamTmp (*trackParam);//Retrieve the starting point every time before the extrapolation
1536 Float_t tmpEta=-999, tmpPhi=-999;
1537 if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
1540 Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
1549 else if(fCutEtaPhiSeparate)
1551 if(TMath::Abs(tmpEta)<TMath::Abs(dEtaMax) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMax))
1560 printf("Error: please specify your cut criteria\n");
1561 printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
1562 printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
1569 //________________________________________________________________________________
1570 Bool_t AliEMCALRecoUtils::ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, AliVCluster *cluster, Float_t &tmpEta, Float_t &tmpPhi)
1573 //Return the residual by extrapolating a track to a cluster
1575 if(!trkParam || !cluster) return kFALSE;
1578 cluster->GetPosition(clsPos); //Has been recalculated
1579 TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);
1580 Double_t alpha = ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
1581 vec.RotateZ(-alpha); //Rotate the cluster to the local extrapolation coordinate system
1582 if(!AliTrackerBase::PropagateTrackToBxByBz(trkParam, vec.X(), fMass, fStep,kTRUE, 0.8, -1)) return kFALSE;
1583 trkParam->GetXYZ(trkPos); //Get the extrapolated global position
1585 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
1586 TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
1588 // track cluster matching
1589 tmpPhi = clsPosVec.DeltaPhi(trkPosVec); // tmpPhi is between -pi and pi
1590 tmpEta = clsPosVec.Eta()-trkPosVec.Eta(); // track cluster matching
1595 //________________________________________________________________________________
1596 void AliEMCALRecoUtils::GetMatchedResiduals(Int_t clsIndex, Float_t &dEta, Float_t &dPhi)
1598 //Given a cluster index as in AliESDEvent::GetCaloCluster(clsIndex)
1599 //Get the residuals dEta and dPhi for this cluster to the closest track
1600 //Works with ESDs and AODs
1602 if( FindMatchedPosForCluster(clsIndex) >= 999 )
1604 AliDebug(2,"No matched tracks found!\n");
1609 dEta = fResidualEta->At(FindMatchedPosForCluster(clsIndex));
1610 dPhi = fResidualPhi->At(FindMatchedPosForCluster(clsIndex));
1612 //________________________________________________________________________________
1613 void AliEMCALRecoUtils::GetMatchedClusterResiduals(Int_t trkIndex, Float_t &dEta, Float_t &dPhi)
1615 //Given a track index as in AliESDEvent::GetTrack(trkIndex)
1616 //Get the residuals dEta and dPhi for this track to the closest cluster
1617 //Works with ESDs and AODs
1619 if( FindMatchedPosForTrack(trkIndex) >= 999 )
1621 AliDebug(2,"No matched cluster found!\n");
1626 dEta = fResidualEta->At(FindMatchedPosForTrack(trkIndex));
1627 dPhi = fResidualPhi->At(FindMatchedPosForTrack(trkIndex));
1630 //__________________________________________________________
1631 Int_t AliEMCALRecoUtils::GetMatchedTrackIndex(Int_t clsIndex)
1633 //Given a cluster index as in AliESDEvent::GetCaloCluster(clsIndex)
1634 //Get the index of matched track to this cluster
1635 //Works with ESDs and AODs
1637 if(IsClusterMatched(clsIndex))
1638 return fMatchedTrackIndex->At(FindMatchedPosForCluster(clsIndex));
1643 //__________________________________________________________
1644 Int_t AliEMCALRecoUtils::GetMatchedClusterIndex(Int_t trkIndex)
1646 //Given a track index as in AliESDEvent::GetTrack(trkIndex)
1647 //Get the index of matched cluster to this track
1648 //Works with ESDs and AODs
1650 if(IsTrackMatched(trkIndex))
1651 return fMatchedClusterIndex->At(FindMatchedPosForTrack(trkIndex));
1656 //__________________________________________________
1657 Bool_t AliEMCALRecoUtils::IsClusterMatched(Int_t clsIndex) const
1659 //Given a cluster index as in AliESDEvent::GetCaloCluster(clsIndex)
1660 //Returns if the cluster has a match
1661 if(FindMatchedPosForCluster(clsIndex) < 999)
1667 //__________________________________________________
1668 Bool_t AliEMCALRecoUtils::IsTrackMatched(Int_t trkIndex) const
1670 //Given a track index as in AliESDEvent::GetTrack(trkIndex)
1671 //Returns if the track has a match
1672 if(FindMatchedPosForTrack(trkIndex) < 999)
1678 //__________________________________________________________
1679 UInt_t AliEMCALRecoUtils::FindMatchedPosForCluster(Int_t clsIndex) const
1681 //Given a cluster index as in AliESDEvent::GetCaloCluster(clsIndex)
1682 //Returns the position of the match in the fMatchedClusterIndex array
1683 Float_t tmpR = fCutR;
1686 for(Int_t i=0; i<fMatchedClusterIndex->GetSize(); i++)
1688 if(fMatchedClusterIndex->At(i)==clsIndex)
1690 Float_t r = TMath::Sqrt(fResidualEta->At(i)*fResidualEta->At(i) + fResidualPhi->At(i)*fResidualPhi->At(i));
1695 AliDebug(3,Form("Matched cluster index: index: %d, dEta: %2.4f, dPhi: %2.4f.\n",fMatchedClusterIndex->At(i),fResidualEta->At(i),fResidualPhi->At(i)));
1702 //__________________________________________________________
1703 UInt_t AliEMCALRecoUtils::FindMatchedPosForTrack(Int_t trkIndex) const
1705 //Given a track index as in AliESDEvent::GetTrack(trkIndex)
1706 //Returns the position of the match in the fMatchedTrackIndex array
1707 Float_t tmpR = fCutR;
1710 for(Int_t i=0; i<fMatchedTrackIndex->GetSize(); i++)
1712 if(fMatchedTrackIndex->At(i)==trkIndex)
1714 Float_t r = TMath::Sqrt(fResidualEta->At(i)*fResidualEta->At(i) + fResidualPhi->At(i)*fResidualPhi->At(i));
1719 AliDebug(3,Form("Matched track index: index: %d, dEta: %2.4f, dPhi: %2.4f.\n",fMatchedTrackIndex->At(i),fResidualEta->At(i),fResidualPhi->At(i)));
1726 //__________________________________________________________
1727 Bool_t AliEMCALRecoUtils::IsGoodCluster(AliVCluster *cluster, AliEMCALGeometry *geom, AliVCaloCells* cells)
1729 // check if the cluster survives some quality cut
1732 Bool_t isGood=kTRUE;
1733 if(!cluster || !cluster->IsEMCAL()) return kFALSE;
1734 if(ClusterContainsBadChannel(geom,cluster->GetCellsAbsId(),cluster->GetNCells())) return kFALSE;
1735 if(!CheckCellFiducialRegion(geom,cluster,cells)) return kFALSE;
1736 if(fRejectExoticCluster && IsExoticCluster(cluster)) return kFALSE;
1741 //__________________________________________________________
1742 Bool_t AliEMCALRecoUtils::IsAccepted(AliESDtrack *esdTrack)
1744 // Given a esd track, return whether the track survive all the cuts
1746 // The different quality parameter are first
1747 // retrieved from the track. then it is found out what cuts the
1748 // track did not survive and finally the cuts are imposed.
1750 UInt_t status = esdTrack->GetStatus();
1752 Int_t nClustersITS = esdTrack->GetITSclusters(0);
1753 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
1755 Float_t chi2PerClusterITS = -1;
1756 Float_t chi2PerClusterTPC = -1;
1757 if (nClustersITS!=0)
1758 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
1759 if (nClustersTPC!=0)
1760 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
1764 if(fTrackCutsType==kGlobalCut)
1766 Float_t maxDCAToVertexXYPtDep = 0.0182 + 0.0350/TMath::Power(esdTrack->Pt(),1.01); //This expression comes from AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()
1767 //AliDebug(3,Form("Track pT = %f, DCAtoVertexXY = %f",esdTrack->Pt(),MaxDCAToVertexXYPtDep));
1768 SetMaxDCAToVertexXY(maxDCAToVertexXYPtDep); //Set pT dependent DCA cut to vertex in x-y plane
1774 esdTrack->GetImpactParameters(b,bCov);
1775 if (bCov[0]<=0 || bCov[2]<=0) {
1776 AliDebug(1, "Estimated b resolution lower or equal zero!");
1777 bCov[0]=0; bCov[2]=0;
1780 Float_t dcaToVertexXY = b[0];
1781 Float_t dcaToVertexZ = b[1];
1782 Float_t dcaToVertex = -1;
1784 if (fCutDCAToVertex2D)
1785 dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY/fCutMaxDCAToVertexXY/fCutMaxDCAToVertexXY + dcaToVertexZ*dcaToVertexZ/fCutMaxDCAToVertexZ/fCutMaxDCAToVertexZ);
1787 dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY + dcaToVertexZ*dcaToVertexZ);
1791 Bool_t cuts[kNCuts];
1792 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
1794 // track quality cuts
1795 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
1797 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
1799 if (nClustersTPC<fCutMinNClusterTPC)
1801 if (nClustersITS<fCutMinNClusterITS)
1803 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
1805 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
1807 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
1809 if (fCutDCAToVertex2D && dcaToVertex > 1)
1811 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexXY) > fCutMaxDCAToVertexXY)
1813 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexZ) > fCutMaxDCAToVertexZ)
1816 if(fTrackCutsType==kGlobalCut)
1818 //Require at least one SPD point + anything else in ITS
1819 if( (esdTrack->HasPointOnITSLayer(0) || esdTrack->HasPointOnITSLayer(1)) == kFALSE)
1824 for (Int_t i=0; i<kNCuts; i++)
1825 if (cuts[i]) {cut = kTRUE;}
1835 //__________________________________________________
1836 void AliEMCALRecoUtils::InitTrackCuts()
1838 //Intilize the track cut criteria
1839 //By default these cuts are set according to AliESDtrackCuts::GetStandardTPCOnlyTrackCuts()
1840 //Also you can customize the cuts using the setters
1842 switch (fTrackCutsType)
1846 AliInfo(Form("Track cuts for matching: GetStandardTPCOnlyTrackCuts()"));
1848 SetMinNClustersTPC(70);
1849 SetMaxChi2PerClusterTPC(4);
1850 SetAcceptKinkDaughters(kFALSE);
1851 SetRequireTPCRefit(kFALSE);
1854 SetRequireITSRefit(kFALSE);
1855 SetMaxDCAToVertexZ(3.2);
1856 SetMaxDCAToVertexXY(2.4);
1857 SetDCAToVertex2D(kTRUE);
1864 AliInfo(Form("Track cuts for matching: GetStandardITSTPCTrackCuts2010(kTURE)"));
1866 SetMinNClustersTPC(70);
1867 SetMaxChi2PerClusterTPC(4);
1868 SetAcceptKinkDaughters(kFALSE);
1869 SetRequireTPCRefit(kTRUE);
1872 SetRequireITSRefit(kTRUE);
1873 SetMaxDCAToVertexZ(2);
1874 SetMaxDCAToVertexXY();
1875 SetDCAToVertex2D(kFALSE);
1882 AliInfo(Form("Track cuts for matching: Loose cut w/o DCA cut"));
1883 SetMinNClustersTPC(50);
1884 SetAcceptKinkDaughters(kTRUE);
1891 //___________________________________________________
1892 void AliEMCALRecoUtils::Print(const Option_t *) const
1896 printf("AliEMCALRecoUtils Settings: \n");
1897 printf("Misalignment shifts\n");
1898 for(Int_t i=0; i<5; i++) printf("\t sector %d, traslation (x,y,z)=(%f,%f,%f), rotation (x,y,z)=(%f,%f,%f)\n",i,
1899 fMisalTransShift[i*3],fMisalTransShift[i*3+1],fMisalTransShift[i*3+2],
1900 fMisalRotShift[i*3], fMisalRotShift[i*3+1], fMisalRotShift[i*3+2] );
1901 printf("Non linearity function %d, parameters:\n", fNonLinearityFunction);
1902 for(Int_t i=0; i<6; i++) printf("param[%d]=%f\n",i, fNonLinearityParams[i]);
1904 printf("Position Recalculation option %d, Particle Type %d, fW0 %2.2f, Recalibrate Data %d \n",fPosAlgo,fParticleType,fW0, fRecalibration);
1906 printf("Matching criteria: ");
1909 printf("sqrt(dEta^2+dPhi^2)<%2.2f\n",fCutR);
1911 else if(fCutEtaPhiSeparate)
1913 printf("dEta<%2.2f, dPhi<%2.2f\n",fCutEta,fCutPhi);
1918 printf("please specify your cut criteria\n");
1919 printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
1920 printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
1923 printf("Mass hypothesis = %2.3f [GeV/c^2], extrapolation step = %2.2f[cm]\n",fMass,fStep);
1925 printf("Track cuts: \n");
1926 printf("Minimum track pT: %1.2f\n",fCutMinTrackPt);
1927 printf("AOD track selection mask: %d\n",fAODFilterMask);
1928 printf("TPCRefit = %d, ITSRefit = %d\n",fCutRequireTPCRefit,fCutRequireITSRefit);
1929 printf("AcceptKinks = %d\n",fCutAcceptKinkDaughters);
1930 printf("MinNCulsterTPC = %d, MinNClusterITS = %d\n",fCutMinNClusterTPC,fCutMinNClusterITS);
1931 printf("MaxChi2TPC = %2.2f, MaxChi2ITS = %2.2f\n",fCutMaxChi2PerClusterTPC,fCutMaxChi2PerClusterITS);
1932 printf("DCSToVertex2D = %d, MaxDCAToVertexXY = %2.2f, MaxDCAToVertexZ = %2.2f\n",fCutDCAToVertex2D,fCutMaxDCAToVertexXY,fCutMaxDCAToVertexZ);
1936 //_____________________________________________________________________
1937 void AliEMCALRecoUtils::SetRunDependentCorrections(Int_t runnumber){
1938 //Get EMCAL time dependent corrections from file and put them in the recalibration histograms
1939 //Do it only once and only if it is requested
1941 if(!fUseRunCorrectionFactors) return;
1942 if(fRunCorrectionFactorsSet) return;
1944 AliInfo(Form("AliEMCALRecoUtils::GetRunDependentCorrections() - Get Correction Factors for Run number %d\n",runnumber));
1946 AliEMCALCalibTimeDepCorrection *corr = new AliEMCALCalibTimeDepCorrection();
1947 corr->ReadRootInfo(Form("CorrectionFiles/Run%d_Correction.root",runnumber));
1949 SwitchOnRecalibration();
1950 for(Int_t ism = 0; ism < 4; ism++){
1951 for(Int_t icol = 0; icol < 48; icol++){
1952 for(Int_t irow = 0; irow < 24; irow++){
1953 Float_t orgRecalFactor = GetEMCALChannelRecalibrationFactors(ism)->GetBinContent(icol,irow);
1954 Float_t newRecalFactor = orgRecalFactor*corr->GetCorrection(ism, icol,irow,0);
1955 GetEMCALChannelRecalibrationFactors(ism)->SetBinContent(icol,irow,newRecalFactor);
1956 //printf("ism %d, icol %d, irow %d, corrections : org %f, time dep %f, final %f (org*time %f)\n",ism, icol, irow,
1957 // orgRecalFactor, corr->GetCorrection(ism, icol,irow,0),
1958 // (GetEMCALChannelRecalibrationFactors(ism))->GetBinContent(icol,irow),newRecalFactor);
1962 fRunCorrectionFactorsSet = kTRUE;