AliPhysics  ec7afe5 (ec7afe5)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliCaloPID.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 // --- ROOT system ---
17 #include <TMath.h>
18 #include <TString.h>
19 #include <TList.h>
20 
21 // ---- ANALYSIS system ----
22 #include "AliCaloPID.h"
23 #include "AliAODCaloCluster.h"
24 #include "AliESDCaloCluster.h"
25 #include "AliVCaloCells.h"
26 #include "AliVTrack.h"
27 #include "AliAODPWG4Particle.h"
28 #include "AliCalorimeterUtils.h"
29 #include "AliFiducialCut.h" // detector enum definition
30 #include "AliVEvent.h"
31 #include "AliLog.h"
32 
33 // ---- Detector ----
34 #include "AliEMCALPIDUtils.h"
35 
39 
40 //________________________
43 //________________________
45 TObject(), fDebug(-1), fParticleFlux(kLow),
46 //Bayesian
47 fEMCALPIDUtils(), fUseBayesianWeights(kFALSE), fRecalculateBayesian(kFALSE),
48 fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
49 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), fEMCALNeutralWeight(0.),
50 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
51 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , fPHOSNeutralWeight(0.),
52 fPHOSWeightFormula(0), fPHOSPhotonWeightFormula(0), fPHOSPi0WeightFormula(0),
53 fPHOSPhotonWeightFormulaExpression(""),
54 fPHOSPi0WeightFormulaExpression(""),
55 //PID calculation
56 fEMCALL0CutMax(100.), fEMCALL0CutMin(0),
57 fEMCALDEtaCut(2000.), fEMCALDPhiCut(2000.),
58 fEMCALUseTrackPtDepMatchingCut(0),
59 fEMCALFuncTrackPtDepDEta(0), fEMCALFuncTrackPtDepDPhi(0),
60 fEMCALFuncTrackPtDepDEtaString(""), fEMCALFuncTrackPtDepDPhiString(""),
61 fEMCALFuncTrackPtDepDEtaNParam(0) , fEMCALFuncTrackPtDepDPhiNParam(0),
62 fTOFCut(0.),
63 fPHOSDispersionCut(1000), fPHOSRCut(1000),
64 //Split
65 fUseSimpleMassCut(kFALSE),
66 fUseSimpleM02Cut(kFALSE),
67 fUseSplitAsyCut(kFALSE),
68 fUseSplitSSCut(kTRUE),
69 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
70 fMassEtaMin(0), fMassEtaMax(0),
71 fMassPi0Min(0), fMassPi0Max(0),
72 fMassPhoMin(0), fMassPhoMax(0),
73 fM02MaxParamShiftNLMN(0),
74 fSplitWidthSigma(0), fMassShiftHighECell(0)
75 {
77 }
78 
79 //________________________________________
84 //________________________________________
86 TObject(), fDebug(-1), fParticleFlux(flux),
87 //Bayesian
88 fEMCALPIDUtils(), fUseBayesianWeights(kFALSE), fRecalculateBayesian(kFALSE),
89 fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
90 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), fEMCALNeutralWeight(0.),
91 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
92 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , fPHOSNeutralWeight(0.),
93 fPHOSWeightFormula(0), fPHOSPhotonWeightFormula(0), fPHOSPi0WeightFormula(0),
94 fPHOSPhotonWeightFormulaExpression(""),
95 fPHOSPi0WeightFormulaExpression(""),
96 //PID calculation
97 fEMCALL0CutMax(100.), fEMCALL0CutMin(0),
98 fEMCALDEtaCut(2000.), fEMCALDPhiCut(2000.),
99 fEMCALUseTrackPtDepMatchingCut(0),
100 fEMCALFuncTrackPtDepDEta(0), fEMCALFuncTrackPtDepDPhi(0),
101 fEMCALFuncTrackPtDepDEtaString(""), fEMCALFuncTrackPtDepDPhiString(""),
102 fTOFCut(0.),
103 fPHOSDispersionCut(1000), fPHOSRCut(1000),
104 //Split
105 fUseSimpleMassCut(kFALSE),
106 fUseSimpleM02Cut(kFALSE),
107 fUseSplitAsyCut(kFALSE),
108 fUseSplitSSCut(kTRUE),
109 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
110 fMassEtaMin(0), fMassEtaMax(0),
111 fMassPi0Min(0), fMassPi0Max(0),
112 fMassPhoMin(0), fMassPhoMax(0),
113 fM02MaxParamShiftNLMN(0),
114 fSplitWidthSigma(0), fMassShiftHighECell(0)
115 {
116  InitParameters();
117 }
118 
119 //_______________________________________________
124 //_______________________________________________
125 AliCaloPID::AliCaloPID(const TNamed * emcalpid) :
126 TObject(), fDebug(-1), fParticleFlux(kLow),
127 //Bayesian
128 fEMCALPIDUtils((AliEMCALPIDUtils*)emcalpid),
129 fUseBayesianWeights(kFALSE), fRecalculateBayesian(kFALSE),
130 fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
131 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), fEMCALNeutralWeight(0.),
132 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
133 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , fPHOSNeutralWeight(0.),
134 fPHOSWeightFormula(0), fPHOSPhotonWeightFormula(0), fPHOSPi0WeightFormula(0),
135 fPHOSPhotonWeightFormulaExpression(""),
136 fPHOSPi0WeightFormulaExpression(""),
137 //PID calculation
138 fEMCALL0CutMax(100.), fEMCALL0CutMin(0),
139 fEMCALDEtaCut(2000.), fEMCALDPhiCut(2000.),
140 fEMCALUseTrackPtDepMatchingCut(0),
141 fEMCALFuncTrackPtDepDEta(0), fEMCALFuncTrackPtDepDPhi(0),
142 fEMCALFuncTrackPtDepDEtaString(""), fEMCALFuncTrackPtDepDPhiString(""),
143 fTOFCut(0.),
144 fPHOSDispersionCut(1000), fPHOSRCut(1000),
145 //Split
146 fUseSimpleMassCut(kFALSE),
147 fUseSimpleM02Cut(kFALSE),
148 fUseSplitAsyCut(kFALSE),
149 fUseSplitSSCut(kTRUE),
150 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
151 fMassEtaMin(0), fMassEtaMax(0),
152 fMassPi0Min(0), fMassPi0Max(0),
153 fMassPhoMin(0), fMassPhoMax(0),
154 fM02MaxParamShiftNLMN(0),
155 fSplitWidthSigma(0), fMassShiftHighECell(0)
156 {
157  InitParameters();
158 }
159 
160 //_______________________
161 // Destructor.
162 //_______________________
164 {
165  delete fPHOSPhotonWeightFormula ;
166  delete fPHOSPi0WeightFormula ;
167  delete fEMCALPIDUtils ;
172 }
173 
174 //_______________________________
175 // Initialize the parameters of the PID.
176 //_______________________________
178 {
179  // Bayesian
180  fEMCALPhotonWeight = 0.6 ;
181  fEMCALPi0Weight = 0.6 ;
182  fEMCALElectronWeight = 0.6 ;
183  fEMCALChargeWeight = 0.6 ;
184  fEMCALNeutralWeight = 0.6 ;
185 
186  fPHOSPhotonWeight = 0.6 ;
187  fPHOSPi0Weight = 0.6 ;
188  fPHOSElectronWeight = 0.6 ;
189  fPHOSChargeWeight = 0.6 ;
190  fPHOSNeutralWeight = 0.6 ;
191 
192  //Formula to set the PID weight threshold for photon or pi0
193  fPHOSWeightFormula = kFALSE;
194  fPHOSPhotonWeightFormulaExpression = "0.98*(x<40)+ 0.68*(x>=100)+(x>=40 && x<100)*(0.98+x*(6e-3)-x*x*(2e-04)+x*x*x*(1.1e-06))";
195  fPHOSPi0WeightFormulaExpression = "0.98*(x<65)+ 0.915*(x>=100)+(x>=65 && x-x*(1.95e-3)-x*x*(4.31e-05)+x*x*x*(3.61e-07))" ;
196 
198  {
199  if(fParticleFlux == kLow)
200  {
201  AliInfo("SetLOWFluxParam");
202  fEMCALPIDUtils->SetLowFluxParam() ;
203  }
204  else if (fParticleFlux == kHigh)
205  {
206  AliInfo("SetHighFluxParam");
207  fEMCALPIDUtils->SetHighFluxParam() ;
208  }
209  }
210 
211  //PID recalculation, not bayesian
212 
213  //EMCAL
214  fEMCALL0CutMax = 0.3 ;
215  fEMCALL0CutMin = 0.01;
216 
217  // Fix Track Matching
218  fEMCALDPhiCut = 0.05; // Same cut as in AliEMCALRecoUtils
219  fEMCALDEtaCut = 0.025;// Same cut as in AliEMCALRecoUtils
220 
221  // Pt dependent track matching
222  // In case we change the default setting to true
225 
226  // PHOS / EMCAL, not used
227  fTOFCut = 1.e-6;
228 
229  //PHOS
230  fPHOSRCut = 2. ;
231  fPHOSDispersionCut = 2.5;
232 
233  // Cluster splitting
234 
235  fSplitM02MinCut = 0.3 ;
236  fSplitM02MaxCut = 5 ;
237  fSplitMinNCells = 4 ;
238 
239  fMassEtaMin = 0.4;
240  fMassEtaMax = 0.6;
241 
242  fMassPi0Min = 0.11;
243  fMassPi0Max = 0.18;
244 
245  fMassPhoMin = 0.0;
246  fMassPhoMax = 0.08;
247 
248  fMassPi0Param[0][0] = 0 ; // Constant term on mass dependence
249  fMassPi0Param[0][1] = 0 ; // slope term on mass dependence
250  fMassPi0Param[0][2] = 0 ; // E function change
251  fMassPi0Param[0][3] = 0.044 ; // constant term on mass dependence
252  fMassPi0Param[0][4] = 0.0049; // slope term on mass dependence
253  fMassPi0Param[0][5] = 0.070 ; // Absolute low mass cut
254 
255  fMassPi0Param[1][0] = 0.115 ; // Constant term below 21 GeV
256  fMassPi0Param[1][1] = 0.00096; // slope term below 21 GeV
257  fMassPi0Param[1][2] = 21 ; // E function change
258  fMassPi0Param[1][3] = 0.10 ; // constant term on mass dependence
259  fMassPi0Param[1][4] = 0.0017; // slope term on mass dependence
260  fMassPi0Param[1][5] = 0.070 ; // Absolute low mass cut
261 
262  fWidthPi0Param[0][0] = 0.012 ; // Constant term on width dependence
263  fWidthPi0Param[0][1] = 0.0 ; // Slope term on width dependence
264  fWidthPi0Param[0][2] = 19 ; // E function change
265  fWidthPi0Param[0][3] = 0.0012; // Constant term on width dependence
266  fWidthPi0Param[0][4] = 0.0006; // Slope term on width dependence
267  fWidthPi0Param[0][5] = 0.0 ; // xx term
268 
269  fWidthPi0Param[1][0] = 0.009 ; // Constant term on width dependence
270  fWidthPi0Param[1][1] = 0.000 ; // Slope term on width dependence
271  fWidthPi0Param[1][2] = 10 ; // E function change
272  fWidthPi0Param[1][3] = 0.0023 ; // Constant term on width dependence
273  fWidthPi0Param[1][4] = 0.00067; // Slope term on width dependence
274  fWidthPi0Param[1][5] = 0.000 ;// xx term
275 
276  fMassShiftHighECell = 0; // Shift of cuts in case of higher energy threshold in cells, 5 MeV when Ecell>150 MeV
277 
278  //TF1 *lM02MinNLM1 = new TF1("M02MinNLM1","exp(2.135-0.245*x)",6,13.6);
279  fM02MinParam[0][0] = 2.135 ;
280  fM02MinParam[0][1] =-0.245 ;
281  fM02MinParam[0][2] = 0.0 ;
282  fM02MinParam[0][3] = 0.0 ;
283  fM02MinParam[0][4] = 0.0 ;
284 
285  // Same as NLM=1 for NLM=2
286  fM02MinParam[1][0] = 2.135 ;
287  fM02MinParam[1][1] =-0.245 ;
288  fM02MinParam[1][2] = 0.0 ;
289  fM02MinParam[1][3] = 0.0 ;
290  fM02MinParam[1][4] = 0.0 ;
291 
292  //TF1 *lM02MaxNLM1 = new TF1("M02MaxNLM1","exp(0.0662-0.0201*x)-0.0955+0.00186*x[0]+9.91/x[0]",6,100);
293  fM02MaxParam[0][0] = 0.0662 ;
294  fM02MaxParam[0][1] =-0.0201 ;
295  fM02MaxParam[0][2] =-0.0955 ;
296  fM02MaxParam[0][3] = 0.00186;
297  fM02MaxParam[0][4] = 9.91 ;
298 
299  //TF1 *lM02MaxNLM2 = new TF1("M02MaxNLM2","exp(0.353-0.0264*x)-0.524+0.00559*x[0]+21.9/x[0]",6,100);
300  fM02MaxParam[1][0] = 0.353 ;
301  fM02MaxParam[1][1] =-0.0264 ;
302  fM02MaxParam[1][2] =-0.524 ;
303  fM02MaxParam[1][3] = 0.00559;
304  fM02MaxParam[1][4] = 21.9 ;
305 
306  fM02MaxParamShiftNLMN = 0.75;
307 
308  //TF1 *lAsyNLM1 = new TF1("lAsyNLM1","0.96-879/(x*x*x)",5,100);
309  fAsyMinParam[0][0] = 0.96 ;
310  fAsyMinParam[0][1] = 0 ;
311  fAsyMinParam[0][2] =-879 ;
312  fAsyMinParam[0][3] = 0.96 ; // Absolute max
313 
314  //TF1 *lAsyNLM2 = new TF1("lAsyNLM2","0.95+0.0015*x-233/(x*x*x)",5,100);
315  fAsyMinParam[1][0] = 0.95 ;
316  fAsyMinParam[1][1] = 0.0015;
317  fAsyMinParam[1][2] =-233 ;
318  fAsyMinParam[1][3] = 1.0 ; // Absolute max
319 
320  fSplitEFracMin[0] = 0.0 ; // 0.96
321  fSplitEFracMin[1] = 0.0 ; // 0.96
322  fSplitEFracMin[2] = 0.0 ; // 0.7
323 
324  fSubClusterEMin[0] = 0.0; // 3 GeV
325  fSubClusterEMin[1] = 0.0; // 1 GeV
326  fSubClusterEMin[2] = 0.0; // 1 GeV
327 
328  fSplitWidthSigma = 3. ;
329 }
330 
331 
332 //_______________________________
339 //_______________________________
341 {
342  fEMCALFuncTrackPtDepDEtaString = "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])" ;
343  fEMCALFuncTrackPtDepDPhiString = "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])" ;
344 
347 
350 
357 }
358 
359 //_________________________________________________________________________________________
365 //_________________________________________________________________________________________
367 {
368  if(!fUseSplitAsyCut) return kTRUE ;
369 
370  Float_t abasy = TMath::Abs(asy);
371 
372  Int_t inlm = nlm-1;
373  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
374 
375  // Get the parametrized min cut of asymmetry for NLM=2 up to 11 GeV
376 
377  Float_t cut = fAsyMinParam[inlm][0] + fAsyMinParam[inlm][1]*energy + fAsyMinParam[inlm][2]/energy/energy/energy ;
378 
379  // In any case and beyond validity energy range of the function,
380  // the parameter cannot be smaller than 1
381  if( cut > fAsyMinParam[inlm][3] ) cut = fAsyMinParam[inlm][3];
382 
383  //printf("energy %2.2f - nlm: %d (%d)- p0 %f, p1 %f, p2 %f, p3 %f ; cut: %2.2f\n",energy,nlm,inlm,
384  // fAsyMinParam[inlm][0],fAsyMinParam[inlm][1],fAsyMinParam[inlm][2],fAsyMinParam[inlm][3],cut);
385 
386  if(abasy < cut) return kTRUE;
387  else return kFALSE;
388 }
389 
390 //______________________________________________________________________________________
396 //______________________________________________________________________________________
398 {
400  {
401  if(mass < fMassPi0Max && mass > fMassPi0Min) return kTRUE;
402  else return kFALSE;
403  }
404 
405  // Get the selected mean value as reference for the mass
406  Int_t inlm = nlm-1;
407  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
408 
409  Float_t meanMass = energy * fMassPi0Param[inlm][1] + fMassPi0Param[inlm][0];
410  if(energy > fMassPi0Param[inlm][2]) meanMass = energy * fMassPi0Param[inlm][4] + fMassPi0Param[inlm][3];
411 
412  // In case of higher energy cell cut than 50 MeV, smaller mean mass 0-5 MeV, not really necessary
413  meanMass -= fMassShiftHighECell;
414 
415  // Get the parametrized width of the mass
416  Float_t width = 0.009;
417  if (energy > 8 && energy < fWidthPi0Param[inlm][2])
418  width = energy * fWidthPi0Param[inlm][1] + fWidthPi0Param[inlm][0];
419  else if( energy > fWidthPi0Param[inlm][2])
420  width = energy * energy * fWidthPi0Param[inlm][5] + energy * fWidthPi0Param[inlm][4] + fWidthPi0Param[inlm][3];
421 
422  // Calculate the 2 sigma cut
423  Float_t minMass = meanMass-fSplitWidthSigma*width;
424  Float_t maxMass = meanMass+fSplitWidthSigma*width;
425 
426  // In case of low energy, hard cut to avoid conversions
427  if(energy < 10 && minMass < fMassPi0Param[inlm][5] ) minMass = fMassPi0Param[inlm][5];
428 
429  //printf("E %2.2f, mass %1.1f, nlm %d: sigma %1.1f width %3.1f, mean Mass %3.0f, minMass %3.0f, maxMass %3.0f\n ",
430  // energy,mass *1000, inlm, fSplitWidthSigma, width*1000, meanMass*1000,minMass*1000,maxMass*1000);
431 
432  if(mass < maxMass && mass > minMass) return kTRUE;
433  else return kFALSE;
434 }
435 
436 //________________________________________________
440 //________________________________________________
442 {
443  Float_t minCut = fSplitM02MinCut;
444  Float_t maxCut = fSplitM02MaxCut;
445 
446  if(m02 < maxCut && m02 > minCut) return kTRUE;
447  else return kFALSE;
448 }
449 
450 //_______________________________________________________________________________
456 //_______________________________________________________________________________
458 {
459  if(!fUseSplitSSCut) return kTRUE ;
460 
461  //First check the absolute minimum and maximum
462  if(!IsInM02Range(m02)) return kFALSE ;
463 
464  //If requested, check the E dependent cuts
465  else if(!fUseSimpleM02Cut)
466  {
467  Int_t inlm = nlm-1;
468  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
469 
470  Float_t minCut = fSplitM02MinCut;
471  Float_t maxCut = fSplitM02MaxCut;
472 
473  //e^{a+bx} + c + dx + e/x
474  if(energy > 1) minCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*energy ) +
475  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*energy + fM02MinParam[inlm][4]/energy;
476 
477  if(energy > 1) maxCut = TMath::Exp( fM02MaxParam[inlm][0] + fM02MaxParam[inlm][1]*energy ) +
478  fM02MaxParam[inlm][2] + fM02MaxParam[inlm][3]*energy + fM02MaxParam[inlm][4]/energy;
479 
480  // In any case and beyond validity energy range of the function,
481  // the parameter cannot be smaller than 0.3 or larger than 4-5
482  if( minCut < fSplitM02MinCut) minCut = fSplitM02MinCut;
483  if( maxCut > fSplitM02MaxCut) maxCut = fSplitM02MaxCut;
484  if( nlm > 2 ) maxCut+=fM02MaxParamShiftNLMN;
485 
486  //if(energy > 7) printf("\t \t E %2.2f, nlm %d, m02 %2.2f, minM02 %2.2f, maxM02 %2.2f\n",energy, nlm, m02,minCut,maxCut);
487 
488  if(m02 < maxCut && m02 > minCut) return kTRUE;
489  else return kFALSE;
490 
491  }
492 
493  else return kTRUE;
494 }
495 
496 
497 //______________________________________________________________________________
498 // Select the appropriate shower shape range in splitting method to select eta's
499 // Use same parametrization as pi0, just shift the distributions (to be tuned)
504 //______________________________________________________________________________
506 {
507  if(!fUseSplitSSCut) return kTRUE ;
508 
509  //First check the absolute minimum and maximum
510  if(!IsInM02Range(m02)) return kFALSE ;
511 
512  //DO NOT USE, study parametrization
513 
514  //If requested, check the E dependent cuts
515  else if(!fUseSimpleM02Cut)
516  {
517  Int_t inlm = nlm-1;
518  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
519 
520  Float_t minCut = fSplitM02MinCut;
521  Float_t maxCut = fSplitM02MaxCut;
522 
523  Float_t shiftE = energy-20; // to be tuned
524  if(nlm==1) shiftE=energy-28;
525 
526  //e^{a+bx} + c + dx + e/x
527  if(shiftE > 1) minCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*shiftE ) +
528  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*shiftE + fM02MinParam[inlm][4]/shiftE;
529 
530  // In any case the parameter cannot be smaller than 0.3
531  if( minCut < fSplitM02MinCut) minCut = fSplitM02MinCut;
532 
533  shiftE = energy+20; // to be tuned
534 
535  if(shiftE > 1) maxCut = 1 + TMath::Exp( fM02MaxParam[inlm][0] + fM02MaxParam[inlm][1]*shiftE ) +
536  fM02MaxParam[inlm][2] + fM02MaxParam[inlm][3]*shiftE + fM02MaxParam[inlm][4]/shiftE;
537 
538  // In any case the parameter cannot be smaller than 4-5
539  if( maxCut > fSplitM02MaxCut) maxCut = fSplitM02MaxCut;
540  if( nlm > 2 ) maxCut+=fM02MaxParamShiftNLMN;
541 
542  //if(energy>6)printf("\t \t E %2.2f, nlm %d, m02 %2.2f, minM02 %2.2f, maxM02 %2.2f\n",energy, nlm, m02,minCut,maxCut);
543 
544  if(m02 < maxCut && m02 > minCut) return kTRUE;
545  else return kFALSE;
546 
547  }
548 
549  else return kTRUE;
550 }
551 
552 //______________________________________________________________________________
559 //______________________________________________________________________________
561 {
562  if(!fUseSplitSSCut) return kTRUE ;
563 
564  Float_t minCut = 0.1;
565  Float_t maxCut = fSplitM02MinCut;
566 
567  if(!fUseSimpleM02Cut)
568  {
569  Int_t inlm = nlm-1;
570  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
571 
572  //e^{a+bx} + c + dx + e/x
573  if(energy > 1) maxCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*energy ) +
574  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*energy + fM02MinParam[inlm][4]/energy;
575 
576  if( maxCut < fSplitM02MinCut) maxCut = fSplitM02MinCut;
577  }
578 
579  if(m02 < maxCut && m02 > minCut) return kTRUE;
580  else return kFALSE;
581 
582 }
583 
584 //______________________________________________
586 //______________________________________________
587 AliEMCALPIDUtils *AliCaloPID::GetEMCALPIDUtils()
588 {
589  if(!fEMCALPIDUtils) fEMCALPIDUtils = new AliEMCALPIDUtils ;
590 
591  return fEMCALPIDUtils ;
592 }
593 
594 
595 //________________________________________________________________
598 //________________________________________________________________
600 {
601  Float_t energy = cluster->E();
602  Float_t lambda0 = cluster->GetM02();
603  Float_t lambda1 = cluster->GetM20();
604 
605  // ---------------------
606  // Use bayesian approach
607  // ---------------------
608 
610  {
611  Double_t weights[AliPID::kSPECIESCN];
612 
613  if(cluster->IsEMCAL() && fRecalculateBayesian)
614  {
615  fEMCALPIDUtils->ComputePID(energy, lambda0);
616  for(Int_t i = 0; i < AliPID::kSPECIESCN; i++) weights[i] = fEMCALPIDUtils->GetPIDFinal(i);
617  }
618  else
619  {
620  for(Int_t i = 0; i < AliPID::kSPECIESCN; i++) weights[i] = cluster->GetPID()[i];
621  }
622 
623  if(fDebug > 0) PrintClusterPIDWeights(weights);
624 
625  return GetIdentifiedParticleTypeFromBayesWeights(cluster->IsEMCAL(), weights, energy);
626  }
627 
628  // -------------------------------------------------------
629  // Calculate PID SS from data, do not use bayesian weights
630  // -------------------------------------------------------
631 
632  AliDebug(1,Form("EMCAL %d?, E %3.2f, l0 %3.2f, l1 %3.2f, disp %3.2f, tof %1.11f, distCPV %3.2f, distToBC %1.1f, NMax %d",
633  cluster->IsEMCAL(),energy,lambda0,cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(),
634  cluster->GetEmcCpvDistance(), cluster->GetDistanceToBadChannel(),cluster->GetNExMax()));
635 
636  if(cluster->IsEMCAL())
637  {
638  AliDebug(1,Form("EMCAL SS %f <%f < %f?",fEMCALL0CutMin, lambda0, fEMCALL0CutMax));
639 
640  if(lambda0 < fEMCALL0CutMax && lambda0 > fEMCALL0CutMin) return kPhoton ;
641  else return kNeutralUnknown ;
642  } // EMCAL
643  else // PHOS
644  {
645  if(TestPHOSDispersion(energy,lambda0,lambda1) < fPHOSDispersionCut) return kPhoton;
646  else return kNeutralUnknown;
647  }
648 }
649 
650 //_________________________________________________________________________________________________________
655 //_________________________________________________________________________________________________________
657 {
658  if(!pid)
659  {
660  AliFatal("pid pointer not initialized!!!");
661  return kNeutralUnknown; // not needed, added to content coverity
662  }
663 
664  Float_t wPh = fPHOSPhotonWeight ;
665  Float_t wPi0 = fPHOSPi0Weight ;
667  Float_t wCh = fPHOSChargeWeight ;
669 
670  if(!isEMCAL && fPHOSWeightFormula){
671  wPh = GetPHOSPhotonWeightFormula()->Eval(energy) ;
672  wPi0 = GetPHOSPi0WeightFormula() ->Eval(energy);
673  }
674  else
675  {
676  wPh = fEMCALPhotonWeight ;
677  wPi0 = fEMCALPi0Weight ;
678  wE = fEMCALElectronWeight ;
679  wCh = fEMCALChargeWeight ;
680  wNe = fEMCALNeutralWeight ;
681  }
682 
683  if(fDebug > 0) PrintClusterPIDWeights(pid);
684 
686  Float_t chargedHadronWeight = pid[AliVCluster::kProton]+pid[AliVCluster::kKaon]+
687  pid[AliVCluster::kPion]+pid[AliVCluster::kMuon];
688  Float_t neutralHadronWeight = pid[AliVCluster::kNeutron]+pid[AliVCluster::kKaon0];
689  Float_t allChargedWeight = pid[AliVCluster::kElectron]+pid[AliVCluster::kEleCon]+ chargedHadronWeight;
690  Float_t allNeutralWeight = pid[AliVCluster::kPhoton]+pid[AliVCluster::kPi0]+ neutralHadronWeight;
691 
692  //Select most probable ID
693  if(!isEMCAL) // PHOS
694  {
695  if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ;
696  else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ;
697  else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ;
698  else if(pid[AliVCluster::kEleCon] > wE) pdg = kEleCon ;
699  else if(chargedHadronWeight > wCh) pdg = kChargedHadron ;
700  else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ;
701  else if(allChargedWeight > allNeutralWeight)
702  pdg = kChargedUnknown ;
703  else
704  pdg = kNeutralUnknown ;
705  }
706  else //EMCAL
707  {
708  if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ;
709  else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ;
710  else if(pid[AliVCluster::kPhoton]+pid[AliVCluster::kElectron] > wPh) pdg = kPhoton ; //temporal sollution until track matching for electrons is considered
711  else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ;
712  else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ;
713  else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ;
714  else pdg = kNeutralUnknown ;
715  }
716 
717  AliDebug(1,Form("Final Pdg: %d, cluster energy %2.2f", pdg,energy));
718 
719  return pdg ;
720 
721 }
722 
723 //____________________________________________________________________________________________________________
742 //____________________________________________________________________________________________________________
744  AliVCaloCells* cells,
745  AliCalorimeterUtils * caloutils,
746  Double_t vertex[3],
747  Int_t & nMax,
748  Double_t & mass, Double_t & angle,
749  TLorentzVector & l1, TLorentzVector & l2,
750  Int_t & absId1, Int_t & absId2,
751  Float_t & distbad1, Float_t & distbad2,
752  Bool_t & fidcut1, Bool_t & fidcut2 ) const
753 {
754  Float_t eClus = cluster->E();
755  Float_t m02 = cluster->GetM02();
756  const Int_t nc = cluster->GetNCells();
757  Int_t absIdList[nc];
758  Float_t maxEList [nc];
759 
760  mass = -1.;
761  angle = -1.;
762 
763  //If too low number of cells, skip it
764  if ( nc < fSplitMinNCells) return kNeutralUnknown ;
765 
766  AliDebug(2,"\t pass nCells cut");
767 
768  // Get Number of local maxima
769  nMax = caloutils->GetNumberOfLocalMaxima(cluster, cells, absIdList, maxEList) ;
770 
771  AliDebug(1,Form("Cluster : E %1.1f, M02 %1.2f, NLM %d, N Cells %d",eClus,m02,nMax,nc));
772 
773  //---------------------------------------------------------------------
774  // Get the 2 max indeces and do inv mass
775  //---------------------------------------------------------------------
776 
778  if(cluster->IsPHOS()) calorimeter = AliFiducialCut::kPHOS;
779 
780  if ( nMax == 2 )
781  {
782  absId1 = absIdList[0];
783  absId2 = absIdList[1];
784 
785  //Order in energy
786  Float_t en1 = cells->GetCellAmplitude(absId1);
787  caloutils->RecalibrateCellAmplitude(en1,calorimeter,absId1);
788  Float_t en2 = cells->GetCellAmplitude(absId2);
789  caloutils->RecalibrateCellAmplitude(en2,calorimeter,absId2);
790  if(en1 < en2)
791  {
792  absId2 = absIdList[0];
793  absId1 = absIdList[1];
794  }
795  }
796  else if( nMax == 1 )
797  {
798 
799  absId1 = absIdList[0];
800 
801  //Find second highest energy cell
802 
803  Float_t enmax = 0 ;
804  for(Int_t iDigit = 0 ; iDigit < cluster->GetNCells() ; iDigit++)
805  {
806  Int_t absId = cluster->GetCellsAbsId()[iDigit];
807  if( absId == absId1 ) continue ;
808  Float_t endig = cells->GetCellAmplitude(absId);
809  caloutils->RecalibrateCellAmplitude(endig,calorimeter,absId);
810  if(endig > enmax)
811  {
812  enmax = endig ;
813  absId2 = absId ;
814  }
815  }// cell loop
816  }// 1 maxima
817  else
818  { // n max > 2
819  // loop on maxima, find 2 highest
820 
821  // First max
822  Float_t enmax = 0 ;
823  for(Int_t iDigit = 0 ; iDigit < nMax ; iDigit++)
824  {
825  Float_t endig = maxEList[iDigit];
826  if(endig > enmax)
827  {
828  enmax = endig ;
829  absId1 = absIdList[iDigit];
830  }
831  }// first maxima loop
832 
833  // Second max
834  Float_t enmax2 = 0;
835  for(Int_t iDigit = 0 ; iDigit < nMax ; iDigit++)
836  {
837  if(absIdList[iDigit]==absId1) continue;
838  Float_t endig = maxEList[iDigit];
839  if(endig > enmax2)
840  {
841  enmax2 = endig ;
842  absId2 = absIdList[iDigit];
843  }
844  }// second maxima loop
845 
846  } // n local maxima > 2
847 
848  if(absId2<0 || absId1<0)
849  {
850  AliDebug(1,Form("Bad index for local maxima : N max %d, i1 %d, i2 %d, cluster E %2.2f, ncells %d, m02 %2.2f",
851  nMax,absId1,absId2,eClus,nc,m02));
852  return kNeutralUnknown ;
853  }
854 
855  //---------------------------------------------------------------------
856  // Split the cluster energy in 2, around the highest 2 local maxima
857  //---------------------------------------------------------------------
858 
859  AliAODCaloCluster cluster1(0, 0,NULL,0.,NULL,NULL,1,0);
860  AliAODCaloCluster cluster2(1, 0,NULL,0.,NULL,NULL,1,0);
861 
862  caloutils->SplitEnergy(absId1,absId2,cluster, cells, &cluster1, &cluster2,nMax); /*absIdList, maxEList,*/
863 
864  fidcut1 = caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), &cluster1,cells);
865  fidcut2 = caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), &cluster2,cells);
866 
867  caloutils->GetEMCALRecoUtils()->RecalculateClusterDistanceToBadChannel(caloutils->GetEMCALGeometry(),cells,&cluster1);
868  caloutils->GetEMCALRecoUtils()->RecalculateClusterDistanceToBadChannel(caloutils->GetEMCALGeometry(),cells,&cluster2);
869 
870  distbad1 = cluster1.GetDistanceToBadChannel();
871  distbad2 = cluster2.GetDistanceToBadChannel();
872 // if(!fidcut2 || !fidcut1 || distbad1 < 2 || distbad2 < 2)
873 // printf("*** Dist to bad channel cl %f, cl1 %f, cl2 %f; fid cut cl %d, cl1 %d, cl2 %d \n",
874 // cluster->GetDistanceToBadChannel(),distbad1,distbad2,
875 // caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), cluster,cells),fidcut1,fidcut2);
876 
877  cluster1.GetMomentum(l1,vertex);
878  cluster2.GetMomentum(l2,vertex);
879 
880  mass = (l1+l2).M();
881  angle = l2.Angle(l1.Vect());
882  Float_t e1 = cluster1.E();
883  Float_t e2 = cluster2.E();
884 
885  // Consider clusters with splitted energy not too different to original cluster energy
886  Float_t splitFracCut = 0;
887  if(nMax < 3) splitFracCut = fSplitEFracMin[nMax-1];
888  else splitFracCut = fSplitEFracMin[2];
889  if((e1+e2)/eClus < splitFracCut) return kNeutralUnknown ;
890 
891  AliDebug(2,"\t pass Split E frac cut");
892 
893  // Consider sub-clusters with minimum energy
894  Float_t minECut = fSubClusterEMin[2];
895  if (nMax == 2) minECut = fSubClusterEMin[1];
896  else if(nMax == 1) minECut = fSubClusterEMin[0];
897  if(e1 < minECut || e2 < minECut)
898  {
899  //printf("Reject: e1 %2.1f, e2 %2.1f, cut %2.1f\n",e1,e2,minECut);
900  return kNeutralUnknown ;
901  }
902 
903  AliDebug(2,"\t pass min sub-cluster E cut");
904 
905  // Asymmetry of cluster
906  Float_t asy =-10;
907  if(e1+e2 > 0) asy = (e1-e2) / (e1+e2);
908 
909  if( !IsInPi0SplitAsymmetryRange(eClus,asy,nMax) ) return kNeutralUnknown ;
910 
911 
912  AliDebug(2,"\t pass asymmetry cut");
913 
914  Bool_t pi0OK = kFALSE;
915  Bool_t etaOK = kFALSE;
916  Bool_t conOK = kFALSE;
917 
918  //If too small or big M02, skip it
919  if (IsInPi0M02Range(eClus,m02,nMax)) pi0OK = kTRUE;
920  else if(IsInEtaM02Range(eClus,m02,nMax)) etaOK = kTRUE;
921  else if(IsInConM02Range(eClus,m02,nMax)) conOK = kTRUE;
922 
923  Float_t energy = eClus;
924  if(nMax > 2) energy = e1+e2; // In case of NLM>2 use mass cut for NLM=2 but for the split sum not the cluster energy that is not the pi0 E.
925 
926  // Check the mass, and set an ID to the splitted cluster
927  if ( conOK && mass < fMassPhoMax && mass > fMassPhoMin ) { AliDebug(2,"\t Split Conv"); return kPhoton ; }
928  else if( etaOK && mass < fMassEtaMax && mass > fMassEtaMin ) { AliDebug(2,"\t Split Eta" ); return kEta ; }
929  else if( pi0OK && IsInPi0SplitMassRange(energy,mass,nMax) ) { AliDebug(2,"\t Split Pi0" ); return kPi0 ; }
930  else return kNeutralUnknown ;
931 
932 }
933 
934 //_________________________________________
936 //_________________________________________
938 {
939  TString parList ; //this will be list of parameters used for this analysis.
940  const Int_t buffersize = 255;
941  char onePar[buffersize] ;
942  snprintf(onePar,buffersize,"--- AliCaloPID ---") ;
943  parList+=onePar ;
945  {
946  snprintf(onePar,buffersize,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)",fEMCALPhotonWeight) ;
947  parList+=onePar ;
948  snprintf(onePar,buffersize,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)",fEMCALPi0Weight) ;
949  parList+=onePar ;
950  snprintf(onePar,buffersize,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)",fEMCALElectronWeight) ;
951  parList+=onePar ;
952  snprintf(onePar,buffersize,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)",fEMCALChargeWeight) ;
953  parList+=onePar ;
954  snprintf(onePar,buffersize,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)",fEMCALNeutralWeight) ;
955  parList+=onePar ;
956  snprintf(onePar,buffersize,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)",fPHOSPhotonWeight) ;
957  parList+=onePar ;
958  snprintf(onePar,buffersize,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)",fPHOSPi0Weight) ;
959  parList+=onePar ;
960  snprintf(onePar,buffersize,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)",fPHOSElectronWeight) ;
961  parList+=onePar ;
962  snprintf(onePar,buffersize,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)",fPHOSChargeWeight) ;
963  parList+=onePar ;
964  snprintf(onePar,buffersize,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)",fPHOSNeutralWeight) ;
965  parList+=onePar ;
966 
968  {
969  snprintf(onePar,buffersize,"PHOS Photon Weight Formula: %s",fPHOSPhotonWeightFormulaExpression.Data() ) ;
970  parList+=onePar;
971  snprintf(onePar,buffersize,"PHOS Pi0 Weight Formula: %s",fPHOSPi0WeightFormulaExpression.Data() ) ;
972  parList+=onePar;
973  }
974  }
975  else
976  {
977  snprintf(onePar,buffersize,"EMCAL: fEMCALL0CutMin =%2.2f, fEMCALL0CutMax =%2.2f (Cut on Shower Shape)",fEMCALL0CutMin, fEMCALL0CutMax) ;
978  parList+=onePar ;
979  snprintf(onePar,buffersize,"EMCAL: fEMCALDEtaCut =%2.2f, fEMCALDPhiCut =%2.2f (Cut on track matching)",fEMCALDEtaCut, fEMCALDPhiCut) ;
980  parList+=onePar ;
981  snprintf(onePar,buffersize,"fTOFCut =%e (Cut on TOF, used in PID evaluation)",fTOFCut) ;
982  parList+=onePar ;
983  snprintf(onePar,buffersize,"fPHOSRCut =%2.2f, fPHOSDispersionCut =%2.2f (Cut on Shower Shape and CPV)",fPHOSRCut,fPHOSDispersionCut) ;
984  parList+=onePar ;
985 
986  }
987 
988  if(fUseSimpleM02Cut)
989  {
990  snprintf(onePar,buffersize,"%2.2f< M02 < %2.2f", fSplitM02MinCut, fSplitM02MaxCut) ;
991  parList+=onePar ;
992  }
993  snprintf(onePar,buffersize,"fMinNCells =%d", fSplitMinNCells) ;
994  parList+=onePar ;
996  {
997  snprintf(onePar,buffersize,"pi0 : %2.1f < m <%2.1f", fMassPi0Min,fMassPi0Max);
998  parList+=onePar ;
999  }
1000  snprintf(onePar,buffersize,"eta : %2.1f < m <%2.1f", fMassEtaMin,fMassEtaMax);
1001  parList+=onePar ;
1002  snprintf(onePar,buffersize,"conv: %2.1f < m <%2.1f", fMassPhoMin,fMassPhoMax);
1003  parList+=onePar ;
1004 
1005 
1006  return parList;
1007 }
1008 
1009 //________________________________________________
1011 //________________________________________________
1012 void AliCaloPID::Print(const Option_t * opt) const
1013 {
1014  if(! opt)
1015  return;
1016 
1017  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1018 
1020  {
1021  printf("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n",
1024  printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n",
1027 
1028  printf("PHOS Parametrized weight on? = %d\n", fPHOSWeightFormula) ;
1029  if(fPHOSWeightFormula)
1030  {
1031  printf("Photon weight formula = %s\n", fPHOSPhotonWeightFormulaExpression.Data());
1032  printf("Pi0 weight formula = %s\n", fPHOSPi0WeightFormulaExpression .Data());
1033  }
1034  if(fRecalculateBayesian) printf(" Recalculate bayesian with Particle Flux? = %d\n",fParticleFlux);
1035  }
1036  else
1037  {
1038  printf("TOF cut = %e\n", fTOFCut);
1039  printf("EMCAL Lambda0 cut min = %2.2f; max = %2.2f\n", fEMCALL0CutMin,fEMCALL0CutMax);
1040  printf("EMCAL cluster-track dEta < %2.3f; dPhi < %2.3f\n", fEMCALDEtaCut, fEMCALDPhiCut);
1041  printf("PHOS Treac matching cut =%2.2f, Dispersion Cut =%2.2f \n",fPHOSRCut, fPHOSDispersionCut) ;
1042 
1043  }
1044 
1045  printf("Min. N Cells =%d \n", fSplitMinNCells) ;
1046  if(fUseSimpleM02Cut) printf("%2.2f < lambda_0^2 <%2.2f \n",fSplitM02MinCut,fSplitM02MaxCut);
1047  if(fUseSimpleMassCut)printf("pi0 : %2.2f<m<%2.2f \n", fMassPi0Min,fMassPi0Max);
1048  printf("eta : %2.2f<m<%2.2f \n", fMassEtaMin,fMassEtaMax);
1049  printf("phot: %2.2f<m<%2.2f \n", fMassPhoMin,fMassPhoMax);
1050 
1051  printf(" \n");
1052 }
1053 
1054 //_________________________________________________________________
1055 // Print PID of cluster, (AliVCluster*)cluster->GetPID()
1056 //_________________________________________________________________
1058 {
1059  printf("AliCaloPID::PrintClusterPIDWeights() \n \t ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f, \n \t \
1060  pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n",
1061  pid[AliVCluster::kPhoton], pid[AliVCluster::kPi0],
1062  pid[AliVCluster::kElectron], pid[AliVCluster::kEleCon],
1063  pid[AliVCluster::kPion], pid[AliVCluster::kKaon],
1064  pid[AliVCluster::kProton],
1065  pid[AliVCluster::kNeutron], pid[AliVCluster::kKaon0]);
1066 }
1067 
1068 //___________________________________________________________________________
1070 //___________________________________________________________________________
1071 void AliCaloPID::SetPIDBits(AliVCluster * cluster,
1072  AliAODPWG4Particle * ph, AliCalorimeterUtils* cu,
1073  AliVEvent* event)
1074 {
1075  // Dispersion/lambdas
1076  //Double_t disp= cluster->GetDispersion() ;
1077  Double_t l1 = cluster->GetM20() ;
1078  Double_t l0 = cluster->GetM02() ;
1079  Bool_t isDispOK = kTRUE ;
1080  if(cluster->IsPHOS()){
1081  if(TestPHOSDispersion(ph->Pt(),l0,l1) < fPHOSDispersionCut) isDispOK = kTRUE;
1082  else isDispOK = kFALSE;
1083  }
1084  else{//EMCAL
1085 
1086  if(l0 > fEMCALL0CutMin && l0 < fEMCALL0CutMax) isDispOK = kTRUE;
1087 
1088  }
1089 
1090  ph->SetDispBit(isDispOK) ;
1091 
1092  //TOF
1093  Double_t tof=cluster->GetTOF() ;
1094  ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ;
1095 
1096  //Charged
1097  Bool_t isNeutral = IsTrackMatched(cluster,cu,event);
1098 
1099  ph->SetChargedBit(isNeutral);
1100 
1101  //Set PID pdg
1102  ph->SetIdentifiedParticleType(GetIdentifiedParticleType(cluster));
1103 
1104  AliDebug(1,Form("TOF %e, Lambda0 %2.2f, Lambda1 %2.2f",tof , l0, l1));
1105  AliDebug(1,Form("pdg %d, bits: TOF %d, Dispersion %d, Charge %d",
1106  ph->GetIdentifiedParticleType(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit()));
1107 }
1108 
1109 //_________________________________________________________
1116 //_________________________________________________________
1118 {
1119  if( !fEMCALFuncTrackPtDepDEta )
1120  {
1122 
1123  for(Int_t iparam = 0; iparam < fEMCALFuncTrackPtDepDEtaNParam; iparam++)
1124  fEMCALFuncTrackPtDepDEta->SetParameter(iparam,fEMCALFuncTrackPtDepDEtaParam[iparam]);
1125  }
1126 
1127  return fEMCALFuncTrackPtDepDEta ;
1128 }
1129 
1130 //_________________________________________________________
1137 //_________________________________________________________
1139 {
1140  if ( !fEMCALFuncTrackPtDepDPhi )
1141  {
1143 
1144  for(Int_t iparam = 0; iparam < fEMCALFuncTrackPtDepDPhiNParam; iparam++)
1145  fEMCALFuncTrackPtDepDPhi->SetParameter(iparam,fEMCALFuncTrackPtDepDPhiParam[iparam]);
1146  }
1147 
1148  return fEMCALFuncTrackPtDepDPhi;
1149 }
1150 
1151 //_________________________________________________________
1157 //_________________________________________________________
1158 Bool_t AliCaloPID::IsTrackMatched(AliVCluster* cluster,
1159  AliCalorimeterUtils * cu,
1160  AliVEvent* event)
1161 {
1162  Int_t nMatches = cluster->GetNTracksMatched();
1163  AliVTrack * track = 0;
1164 
1165  // At least one match
1166  //
1167  if(nMatches <= 0) return kFALSE;
1168 
1169  // Select the track, depending on ESD or AODs
1170  //
1171  //In case of ESDs,
1172  //by default without match one entry with negative index, no match, reject.
1173  //
1174  if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
1175  {
1176  Int_t iESDtrack = ((AliESDCaloCluster*)cluster)->GetTracksMatched()->At(0); //cluster->GetTrackMatchedIndex();
1177 
1178  if(iESDtrack >= 0) track = dynamic_cast<AliVTrack*> (event->GetTrack(iESDtrack));
1179  else return kFALSE;
1180 
1181  if (!track)
1182  {
1183  AliWarning(Form("Null matched track in ESD for index %d",iESDtrack));
1184  return kFALSE;
1185  }
1186  } // ESDs
1187  else
1188  { // AODs
1189  track = dynamic_cast<AliVTrack*> (cluster->GetTrackMatched(0));
1190  if (!track)
1191  {
1192  AliWarning("Null matched track in AOD!");
1193  return kFALSE;
1194  }
1195  } // AODs
1196 
1197  Float_t dEta = cluster->GetTrackDz();
1198  Float_t dPhi = cluster->GetTrackDx();
1199 
1200  // Comment out, new value already set in AliCalorimeterUtils::RecalculateClusterTrackMatching()
1201  // when executed in the reader.
1202  // // if track matching was recalculated
1203  // if(cluster->IsEMCAL() && cu && cu->IsRecalculationOfClusterTrackMatchingOn())
1204  // {
1205  // dR = 2000., dZ = 2000.;
1206  // cu->GetEMCALRecoUtils()->GetMatchedResiduals(cluster->GetID(),dZ,dR);
1207  // //AliDebug(2,"Residuals, (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n", cluster->GetTrackDz(),dZ,cluster->GetTrackDx(),dR));
1208  // }
1209 
1210  if(cluster->IsPHOS())
1211  {
1212  Int_t charge = track->Charge();
1213  Double_t mf = event->GetMagneticField();
1214  if(TestPHOSChargedVeto(dPhi, dEta, track->Pt(), charge, mf ) < fPHOSRCut)
1215  return kTRUE;
1216  else
1217  return kFALSE;
1218 
1219  } // PHOS
1220  else // EMCAL
1221  {
1222  AliDebug(1,Form("EMCAL dPhi %f < %f, dEta %f < %f ",dPhi, fEMCALDPhiCut, dEta, fEMCALDEtaCut));
1223 
1225  {
1226  if(TMath::Abs(dPhi) < fEMCALDPhiCut &&
1227  TMath::Abs(dEta) < fEMCALDEtaCut) return kTRUE;
1228  else return kFALSE;
1229  }
1230  else
1231  {
1232  Float_t trackPt = track->Pt();
1233 
1234  Bool_t matchDEta = kFALSE;
1235  if( TMath::Abs(dEta) < GetEMCALFuncTrackPtDepDEta()->Eval(trackPt))
1236  matchDEta = kTRUE;
1237  else
1238  matchDEta = kFALSE;
1239 
1240  Bool_t matchDPhi = kFALSE;
1241  if( TMath::Abs(dPhi) < GetEMCALFuncTrackPtDepDPhi()->Eval(trackPt))
1242  matchDPhi = kTRUE;
1243  else
1244  matchDPhi = kFALSE;
1245 
1246 // printf("Cluster E %2.2f, track pT %2.2f, dEta %2.2f, dPhi %2.2f, cut eta %2.2f, cut phi %2.2f, match eta %d, match phi %d\n",
1247 // cluster->E(),trackPt,dEta,dPhi,
1248 // GetEMCALFuncTrackPtDepDEta()->Eval(trackPt), GetEMCALFuncTrackPtDepDPhi()->Eval(trackPt),
1249 // matchDEta, matchDPhi);
1250 
1251  if(matchDPhi && matchDEta) return kTRUE ;
1252  else return kFALSE;
1253 
1254  }
1255  }// EMCAL cluster
1256 }
1257 
1258 //___________________________________________________________________________________________________
1266 //___________________________________________________________________________________________________
1268 {
1269  Double_t l2Mean = 1.53126+9.50835e+06/(1.+1.08728e+07*pt+1.73420e+06*pt*pt) ;
1270  Double_t l1Mean = 1.12365+0.123770*TMath::Exp(-pt*0.246551)+5.30000e-03*pt ;
1271  Double_t l2Sigma = 6.48260e-02+7.60261e+10/(1.+1.53012e+11*pt+5.01265e+05*pt*pt)+9.00000e-03*pt;
1272  Double_t l1Sigma = 4.44719e-04+6.99839e-01/(1.+1.22497e+00*pt+6.78604e-07*pt*pt)+9.00000e-03*pt;
1273  Double_t c =-0.35-0.550*TMath::Exp(-0.390730*pt) ;
1274  Double_t r2 = 0.5* (l1-l1Mean)*(l1-l1Mean)/l1Sigma/l1Sigma +
1275  0.5* (l2-l2Mean)*(l2-l2Mean)/l2Sigma/l2Sigma +
1276  0.5*c*(l1-l1Mean)*(l2-l2Mean)/l1Sigma/l2Sigma ;
1277 
1278  AliDebug(1,Form("PHOS SS R %f < %f?", TMath::Sqrt(r2), fPHOSDispersionCut));
1279 
1280  return TMath::Sqrt(r2) ;
1281 }
1282 
1283 //_______________________________________________________________________________________________
1298 //_______________________________________________________________________________________________
1300  Int_t charge, Double_t mf) const
1301 {
1302  Double_t meanX = 0.;
1303  Double_t meanZ = 0.;
1304  Double_t sx = TMath::Min(5.4,2.59719e+02*TMath::Exp(-pt/1.02053e-01)+
1305  6.58365e-01*5.91917e-01*5.91917e-01/((pt-9.61306e-01)*(pt-9.61306e-01)+5.91917e-01*5.91917e-01)+
1306  1.59219);
1307  Double_t sz = TMath::Min(2.75,4.90341e+02*1.91456e-02*1.91456e-02/(pt*pt+1.91456e-02*1.91456e-02)+
1308  1.60) ;
1309 
1310  if(mf<0.){ //field --
1311  meanZ = -0.468318 ;
1312  if(charge>0)
1313  meanX = TMath::Min(7.3, 3.89994*1.20679 *1.20679 /(pt*pt+1.20679*1.20679)+
1314  0.249029+2.49088e+07*TMath::Exp(-pt*3.33650e+01)) ;
1315  else
1316  meanX =-TMath::Min(7.7, 3.86040*0.912499*0.912499/(pt*pt+0.912499*0.912499)+
1317  1.23114 +4.48277e+05*TMath::Exp(-pt*2.57070e+01)) ;
1318  }
1319  else{ //Field ++
1320  meanZ = -0.468318;
1321  if(charge>0)
1322  meanX =-TMath::Min(8.0,3.86040*1.31357*1.31357/(pt*pt+1.31357*1.31357)+
1323  0.880579+7.56199e+06*TMath::Exp(-pt*3.08451e+01)) ;
1324  else
1325  meanX = TMath::Min(6.85, 3.89994*1.16240*1.16240/(pt*pt+1.16240*1.16240)-
1326  0.120787+2.20275e+05*TMath::Exp(-pt*2.40913e+01)) ;
1327  }
1328 
1329  Double_t rz = (dz-meanZ)/sz ;
1330  Double_t rx = (dx-meanX)/sx ;
1331 
1332  AliDebug(1,Form("PHOS Matching R %f < %f",TMath::Sqrt(rx*rx+rz*rz), fPHOSRCut));
1333 
1334  return TMath::Sqrt(rx*rx+rz*rz) ;
1335 }
1336 
Int_t charge
void InitParamTrackMatchPtDependent()
Definition: AliCaloPID.cxx:340
Int_t pdg
TString fPHOSPhotonWeightFormulaExpression
Photon weight formula in string.
Definition: AliCaloPID.h:331
Bool_t IsInEtaM02Range(Float_t energy, Float_t m02, Int_t nlm) const
Definition: AliCaloPID.cxx:505
Float_t fTOFCut
Cut on TOF, used in PID evaluation.
Definition: AliCaloPID.h:356
Float_t fMassPhoMin
Min Photon mass.
Definition: AliCaloPID.h:374
TFormula * GetPHOSPi0WeightFormula()
Definition: AliCaloPID.h:167
double Double_t
Definition: External.C:58
Int_t fEMCALFuncTrackPtDepDEtaNParam
number of formula parameters for matching eta residual pT track dependent
Definition: AliCaloPID.h:346
Float_t fPHOSNeutralWeight
Bayesian PID weight for neutral hadrons in PHOS.
Definition: AliCaloPID.h:326
Bool_t fUseBayesianWeights
Select clusters based on weights calculated in reconstruction.
Definition: AliCaloPID.h:314
Bool_t IsInPi0SplitAsymmetryRange(Float_t energy, Float_t asy, Int_t nlm) const
Definition: AliCaloPID.cxx:366
Float_t fMassPhoMax
Min Photon mass.
Definition: AliCaloPID.h:375
Float_t fMassPi0Max
Min Pi0 mass, simple cut case.
Definition: AliCaloPID.h:373
Float_t fEMCALElectronWeight
Bayesian PID weight for electrons in EMCAL.
Definition: AliCaloPID.h:319
virtual ~AliCaloPID()
Definition: AliCaloPID.cxx:163
AliEMCALRecoUtils * GetEMCALRecoUtils() const
Float_t fPHOSPhotonWeight
Bayesian PID weight for photons in PHOS.
Definition: AliCaloPID.h:322
Float_t fSplitEFracMin[3]
Definition: AliCaloPID.h:382
Float_t fM02MaxParamShiftNLMN
shift of max M02 for NLM>2.
Definition: AliCaloPID.h:380
Float_t fWidthPi0Param[2][6]
Width param, 2 regions in energy.
Definition: AliCaloPID.h:377
Double_t mass
energy
Definition: HFPtSpectrum.C:44
Bool_t fUseSplitAsyCut
Remove splitted clusters with too large asymmetry.
Definition: AliCaloPID.h:365
TF1 * fEMCALFuncTrackPtDepDEta
TF1 for track pT dependent cut in matching eta residual.
Definition: AliCaloPID.h:342
Float_t fEMCALPi0Weight
Bayesian PID weight for pi0 in EMCAL.
Definition: AliCaloPID.h:318
Float_t fEMCALPhotonWeight
Bayesian PID weight for photons in EMCAL.
Definition: AliCaloPID.h:317
Float_t fSubClusterEMin[3]
Do not use sub-clusters with too low energy depeding on NLM.
Definition: AliCaloPID.h:384
Bool_t IsTrackMatched(AliVCluster *cluster, AliCalorimeterUtils *cu, AliVEvent *event)
Float_t fMassEtaMax
Max Eta mass.
Definition: AliCaloPID.h:371
TCanvas * c
Definition: TestFitELoss.C:172
TString fEMCALFuncTrackPtDepDPhiString
TF1 for track pT dependent cut in matching phi residual, formula string.
Definition: AliCaloPID.h:345
TString fPHOSPi0WeightFormulaExpression
Pi0 weight formula in string.
Definition: AliCaloPID.h:332
TFormula * GetPHOSPhotonWeightFormula()
Definition: AliCaloPID.h:161
Float_t fEMCALDEtaCut
Track matching fixed cut on eta residual.
Definition: AliCaloPID.h:338
const TString calorimeter
Definition: anaM.C:36
Float_t fMassPi0Min
Min Pi0 mass, simple cut case.
Definition: AliCaloPID.h:372
Float_t fPHOSChargeWeight
Bayesian PID weight for charged hadrons in PHOS.
Definition: AliCaloPID.h:325
Float_t fMassPi0Param[2][6]
Mean mass param, 2 regions in energy.
Definition: AliCaloPID.h:376
TString GetPIDParametersList()
Put data member values in string to keep in output container.
Definition: AliCaloPID.cxx:937
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Float_t fM02MaxParam[2][5]
5 param for expo + pol fit on M02 maximum for pi0 selection.
Definition: AliCaloPID.h:379
Bool_t fRecalculateBayesian
Recalculate PID bayesian or use simple PID?
Definition: AliCaloPID.h:315
TF1 * GetEMCALFuncTrackPtDepDEta()
AliEMCALGeometry * GetEMCALGeometry() const
int Int_t
Definition: External.C:63
Float_t fSplitWidthSigma
Cut on mass+-width*fSplitWidthSigma.
Definition: AliCaloPID.h:385
Int_t fDebug
Debug level.
Definition: AliCaloPID.h:308
float Float_t
Definition: External.C:68
Bool_t IsInPi0M02Range(Float_t energy, Float_t m02, Int_t nlm) const
Definition: AliCaloPID.cxx:457
Int_t fEMCALFuncTrackPtDepDPhiNParam
number of formula parameters for matching eta residual pT track dependent
Definition: AliCaloPID.h:347
Float_t fSplitM02MaxCut
Study clusters with l0 smaller than cut.
Definition: AliCaloPID.h:367
Float_t * fEMCALFuncTrackPtDepDPhiParam
Formula parameters for track matching eta residual pT track dependent.
Definition: AliCaloPID.h:353
Float_t TestPHOSDispersion(Double_t pt, Double_t m20, Double_t m02) const
Bool_t fPHOSWeightFormula
Use parametrized weight threshold, function of energy.
Definition: AliCaloPID.h:328
Float_t TestPHOSChargedVeto(Double_t dx, Double_t dz, Double_t ptTrack, Int_t chargeTrack, Double_t mf) const
void SetPIDBits(AliVCluster *cluster, AliAODPWG4Particle *aodph, AliCalorimeterUtils *cu, AliVEvent *event)
Set Bits for PID selection.
Float_t fEMCALNeutralWeight
Bayesian PID weight for neutral hadrons in EMCAL.
Definition: AliCaloPID.h:321
Int_t GetNumberOfLocalMaxima(AliVCluster *cluster, AliVCaloCells *cells)
Find the number of local maxima in cluster.
Float_t fPHOSRCut
Track-Cluster distance cut for track matching in PHOS.
Definition: AliCaloPID.h:359
Int_t GetIdentifiedParticleType(AliVCluster *cluster)
Definition: AliCaloPID.cxx:599
TF1 * GetEMCALFuncTrackPtDepDPhi()
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TString fEMCALFuncTrackPtDepDEtaString
TF1 for track pT dependent cut in matching eta residual, formula string.
Definition: AliCaloPID.h:344
Bool_t fUseSplitSSCut
Remove splitted clusters out of shower shape band.
Definition: AliCaloPID.h:366
Bool_t fEMCALUseTrackPtDepMatchingCut
Activate the matching selection, pT dependent.
Definition: AliCaloPID.h:341
Float_t fMassShiftHighECell
Shift cuts 5 MeV for Ecell > 150 MeV, default Ecell > 50 MeV.
Definition: AliCaloPID.h:386
Bool_t IsInPi0SplitMassRange(Float_t energy, Float_t mass, Int_t nlm) const
Definition: AliCaloPID.cxx:397
Float_t fPHOSElectronWeight
Bayesian PID weight for electrons in PHOS.
Definition: AliCaloPID.h:324
Float_t fEMCALDPhiCut
Track matching fixed cut on phi residual.
Definition: AliCaloPID.h:339
Float_t fEMCALL0CutMax
Max Cut on shower shape lambda0, used in PID evaluation, only EMCAL.
Definition: AliCaloPID.h:336
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Int_t GetIdentifiedParticleTypeFromClusterSplitting(AliVCluster *cluster, AliVCaloCells *cells, AliCalorimeterUtils *caloutils, Double_t vertex[3], Int_t &nLocMax, Double_t &mass, Double_t &angle, TLorentzVector &l1, TLorentzVector &l2, Int_t &absId1, Int_t &absId2, Float_t &distbad1, Float_t &distbad2, Bool_t &fidcut1, Bool_t &fidcut2) const
Definition: AliCaloPID.cxx:743
Float_t * fEMCALFuncTrackPtDepDEtaParam
Formula parameters for track matching eta residual pT track dependent.
Definition: AliCaloPID.h:350
TFormula * fPHOSPhotonWeightFormula
Formula for photon weight.
Definition: AliCaloPID.h:329
Double_t minMass
Bool_t IsInConM02Range(Float_t energy, Float_t m02, Int_t nlm) const
Definition: AliCaloPID.cxx:560
Float_t fPHOSDispersionCut
Shower shape elipse radious cut.
Definition: AliCaloPID.h:358
Int_t GetIdentifiedParticleTypeFromBayesWeights(Bool_t isEMCAL, Double_t *pid, Float_t energy)
Definition: AliCaloPID.cxx:656
void RecalibrateCellAmplitude(Float_t &amp, Int_t calo, Int_t absId) const
Recalculate cell energy if recalibration factor.
const char Option_t
Definition: External.C:48
Bool_t fUseSimpleM02Cut
Use simple min-max M02 cut.
Definition: AliCaloPID.h:364
Class for PID selection with calorimeters.
Definition: AliCaloPID.h:53
Float_t fEMCALL0CutMin
Min Cut on shower shape lambda0, used in PID evaluation, only EMCAL.
Definition: AliCaloPID.h:337
AliEMCALPIDUtils * GetEMCALPIDUtils()
Definition: AliCaloPID.cxx:587
Double_t maxMass
Float_t fMassEtaMin
Min Eta mass.
Definition: AliCaloPID.h:370
bool Bool_t
Definition: External.C:53
Class with utils specific to calorimeter clusters/cells.
Float_t fEMCALChargeWeight
Bayesian PID weight for charged hadrons in EMCAL.
Definition: AliCaloPID.h:320
AliEMCALPIDUtils * fEMCALPIDUtils
Pointer to EMCALPID to redo the PID Bayesian calculation.
Definition: AliCaloPID.h:313
void InitParameters()
Definition: AliCaloPID.cxx:177
Int_t fParticleFlux
Particle flux for setting PID parameters.
Definition: AliCaloPID.h:309
Float_t fM02MinParam[2][5]
5 param for expo + pol fit on M02 minimum for pi0 selection (maximum for conversions).
Definition: AliCaloPID.h:378
void PrintClusterPIDWeights(const Double_t *pid) const
Bool_t fUseSimpleMassCut
Use simple min-max pi0 mass cut.
Definition: AliCaloPID.h:363
Float_t fPHOSPi0Weight
Bayesian PID weight for pi0 in PHOS.
Definition: AliCaloPID.h:323
TFormula * fPHOSPi0WeightFormula
Formula for pi0 weight.
Definition: AliCaloPID.h:330
Bool_t IsInM02Range(Float_t m02) const
Definition: AliCaloPID.cxx:441
Int_t fSplitMinNCells
Study clusters with ncells larger than cut.
Definition: AliCaloPID.h:369
void SplitEnergy(Int_t absId1, Int_t absId2, AliVCluster *cluster, AliVCaloCells *cells, AliAODCaloCluster *cluster1, AliAODCaloCluster *cluster2, Int_t nMax, Int_t eventNumber=0)
Float_t fSplitM02MinCut
Study clusters with l0 larger than cut, simple case.
Definition: AliCaloPID.h:368
Float_t fAsyMinParam[2][4]
4 param for fit on asymmetry minimum, for 2 cases, NLM=1 and NLM>=2.
Definition: AliCaloPID.h:381
TF1 * fEMCALFuncTrackPtDepDPhi
TF1 for track pT dependent cut in matching phi residual.
Definition: AliCaloPID.h:343