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