AliPhysics  ff1d528 (ff1d528)
 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 fEMCALFuncTrackPtDepDEtaParam (0) , fEMCALFuncTrackPtDepDPhiParam (0),
63 fTOFCut(0.),
64 fPHOSDispersionCut(1000), fPHOSRCut(1000),
65 //Split
66 fUseSimpleMassCut(kFALSE),
67 fUseSimpleM02Cut(kFALSE),
68 fUseSplitAsyCut(kFALSE),
69 fUseSplitSSCut(kTRUE),
70 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
71 fMassEtaMin(0), fMassEtaMax(0),
72 fMassPi0Min(0), fMassPi0Max(0),
73 fMassPhoMin(0), fMassPhoMax(0),
74 fM02MaxParamShiftNLMN(0),
75 fSplitWidthSigma(0), fMassShiftHighECell(0)
76 {
78 }
79 
80 //________________________________________
85 //________________________________________
87 TObject(), fDebug(-1), fParticleFlux(flux),
88 //Bayesian
89 fEMCALPIDUtils(), fUseBayesianWeights(kFALSE), fRecalculateBayesian(kFALSE),
90 fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
91 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), fEMCALNeutralWeight(0.),
92 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
93 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , fPHOSNeutralWeight(0.),
94 fPHOSWeightFormula(0), fPHOSPhotonWeightFormula(0), fPHOSPi0WeightFormula(0),
95 fPHOSPhotonWeightFormulaExpression(""),
96 fPHOSPi0WeightFormulaExpression(""),
97 //PID calculation
98 fEMCALL0CutMax(100.), fEMCALL0CutMin(0),
99 fEMCALDEtaCut(2000.), fEMCALDPhiCut(2000.),
100 fEMCALUseTrackPtDepMatchingCut(0),
101 fEMCALFuncTrackPtDepDEta(0), fEMCALFuncTrackPtDepDPhi(0),
102 fEMCALFuncTrackPtDepDEtaString(""), fEMCALFuncTrackPtDepDPhiString(""),
103 fEMCALFuncTrackPtDepDEtaNParam(0) , fEMCALFuncTrackPtDepDPhiNParam(0),
104 fEMCALFuncTrackPtDepDEtaParam (0) , fEMCALFuncTrackPtDepDPhiParam (0),
105 fTOFCut(0.),
106 fPHOSDispersionCut(1000), fPHOSRCut(1000),
107 //Split
108 fUseSimpleMassCut(kFALSE),
109 fUseSimpleM02Cut(kFALSE),
110 fUseSplitAsyCut(kFALSE),
111 fUseSplitSSCut(kTRUE),
112 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
113 fMassEtaMin(0), fMassEtaMax(0),
114 fMassPi0Min(0), fMassPi0Max(0),
115 fMassPhoMin(0), fMassPhoMax(0),
116 fM02MaxParamShiftNLMN(0),
117 fSplitWidthSigma(0), fMassShiftHighECell(0)
118 {
119  InitParameters();
120 }
121 
122 //_______________________________________________
127 //_______________________________________________
128 AliCaloPID::AliCaloPID(const TNamed * emcalpid) :
129 TObject(), fDebug(-1), fParticleFlux(kLow),
130 //Bayesian
131 fEMCALPIDUtils((AliEMCALPIDUtils*)emcalpid),
132 fUseBayesianWeights(kFALSE), fRecalculateBayesian(kFALSE),
133 fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
134 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), fEMCALNeutralWeight(0.),
135 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
136 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , fPHOSNeutralWeight(0.),
137 fPHOSWeightFormula(0), fPHOSPhotonWeightFormula(0), fPHOSPi0WeightFormula(0),
138 fPHOSPhotonWeightFormulaExpression(""),
139 fPHOSPi0WeightFormulaExpression(""),
140 //PID calculation
141 fEMCALL0CutMax(100.), fEMCALL0CutMin(0),
142 fEMCALDEtaCut(2000.), fEMCALDPhiCut(2000.),
143 fEMCALUseTrackPtDepMatchingCut(0),
144 fEMCALFuncTrackPtDepDEta(0), fEMCALFuncTrackPtDepDPhi(0),
145 fEMCALFuncTrackPtDepDEtaString(""), fEMCALFuncTrackPtDepDPhiString(""),
146 fEMCALFuncTrackPtDepDEtaNParam(0) , fEMCALFuncTrackPtDepDPhiNParam(0),
147 fEMCALFuncTrackPtDepDEtaParam (0) , fEMCALFuncTrackPtDepDPhiParam (0),
148 fTOFCut(0.),
149 fPHOSDispersionCut(1000), fPHOSRCut(1000),
150 //Split
151 fUseSimpleMassCut(kFALSE),
152 fUseSimpleM02Cut(kFALSE),
153 fUseSplitAsyCut(kFALSE),
154 fUseSplitSSCut(kTRUE),
155 fSplitM02MaxCut(0), fSplitM02MinCut(0), fSplitMinNCells(0),
156 fMassEtaMin(0), fMassEtaMax(0),
157 fMassPi0Min(0), fMassPi0Max(0),
158 fMassPhoMin(0), fMassPhoMax(0),
159 fM02MaxParamShiftNLMN(0),
160 fSplitWidthSigma(0), fMassShiftHighECell(0)
161 {
162  InitParameters();
163 }
164 
165 //_______________________
166 // Destructor.
167 //_______________________
169 {
170  delete fPHOSPhotonWeightFormula ;
171  delete fPHOSPi0WeightFormula ;
172  delete fEMCALPIDUtils ;
177 }
178 
179 //_______________________________
180 // Initialize the parameters of the PID.
181 //_______________________________
183 {
184  // Bayesian
185  fEMCALPhotonWeight = 0.6 ;
186  fEMCALPi0Weight = 0.6 ;
187  fEMCALElectronWeight = 0.6 ;
188  fEMCALChargeWeight = 0.6 ;
189  fEMCALNeutralWeight = 0.6 ;
190 
191  fPHOSPhotonWeight = 0.6 ;
192  fPHOSPi0Weight = 0.6 ;
193  fPHOSElectronWeight = 0.6 ;
194  fPHOSChargeWeight = 0.6 ;
195  fPHOSNeutralWeight = 0.6 ;
196 
197  //Formula to set the PID weight threshold for photon or pi0
198  fPHOSWeightFormula = kFALSE;
199  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))";
200  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))" ;
201 
203  {
204  if(fParticleFlux == kLow)
205  {
206  AliInfo("SetLOWFluxParam");
207  fEMCALPIDUtils->SetLowFluxParam() ;
208  }
209  else if (fParticleFlux == kHigh)
210  {
211  AliInfo("SetHighFluxParam");
212  fEMCALPIDUtils->SetHighFluxParam() ;
213  }
214  }
215 
216  //PID recalculation, not bayesian
217 
218  //EMCAL
219  fEMCALL0CutMax = 0.3 ;
220  fEMCALL0CutMin = 0.01;
221 
222  // Fix Track Matching
223  fEMCALDPhiCut = 0.05; // Same cut as in AliEMCALRecoUtils
224  fEMCALDEtaCut = 0.025;// Same cut as in AliEMCALRecoUtils
225 
226  // Pt dependent track matching
227  // In case we change the default setting to true
230 
231  // PHOS / EMCAL, not used
232  fTOFCut = 1.e-6;
233 
234  //PHOS
235  fPHOSRCut = 2. ;
236  fPHOSDispersionCut = 2.5;
237 
238  // Cluster splitting
239 
240  fSplitM02MinCut = 0.3 ;
241  fSplitM02MaxCut = 5 ;
242  fSplitMinNCells = 4 ;
243 
244  fMassEtaMin = 0.4;
245  fMassEtaMax = 0.6;
246 
247  fMassPi0Min = 0.11;
248  fMassPi0Max = 0.18;
249 
250  fMassPhoMin = 0.0;
251  fMassPhoMax = 0.08;
252 
253  fMassPi0Param[0][0] = 0 ; // Constant term on mass dependence
254  fMassPi0Param[0][1] = 0 ; // slope term on mass dependence
255  fMassPi0Param[0][2] = 0 ; // E function change
256  fMassPi0Param[0][3] = 0.044 ; // constant term on mass dependence
257  fMassPi0Param[0][4] = 0.0049; // slope term on mass dependence
258  fMassPi0Param[0][5] = 0.070 ; // Absolute low mass cut
259 
260  fMassPi0Param[1][0] = 0.115 ; // Constant term below 21 GeV
261  fMassPi0Param[1][1] = 0.00096; // slope term below 21 GeV
262  fMassPi0Param[1][2] = 21 ; // E function change
263  fMassPi0Param[1][3] = 0.10 ; // constant term on mass dependence
264  fMassPi0Param[1][4] = 0.0017; // slope term on mass dependence
265  fMassPi0Param[1][5] = 0.070 ; // Absolute low mass cut
266 
267  fWidthPi0Param[0][0] = 0.012 ; // Constant term on width dependence
268  fWidthPi0Param[0][1] = 0.0 ; // Slope term on width dependence
269  fWidthPi0Param[0][2] = 19 ; // E function change
270  fWidthPi0Param[0][3] = 0.0012; // Constant term on width dependence
271  fWidthPi0Param[0][4] = 0.0006; // Slope term on width dependence
272  fWidthPi0Param[0][5] = 0.0 ; // xx term
273 
274  fWidthPi0Param[1][0] = 0.009 ; // Constant term on width dependence
275  fWidthPi0Param[1][1] = 0.000 ; // Slope term on width dependence
276  fWidthPi0Param[1][2] = 10 ; // E function change
277  fWidthPi0Param[1][3] = 0.0023 ; // Constant term on width dependence
278  fWidthPi0Param[1][4] = 0.00067; // Slope term on width dependence
279  fWidthPi0Param[1][5] = 0.000 ;// xx term
280 
281  fMassShiftHighECell = 0; // Shift of cuts in case of higher energy threshold in cells, 5 MeV when Ecell>150 MeV
282 
283  //TF1 *lM02MinNLM1 = new TF1("M02MinNLM1","exp(2.135-0.245*x)",6,13.6);
284  fM02MinParam[0][0] = 2.135 ;
285  fM02MinParam[0][1] =-0.245 ;
286  fM02MinParam[0][2] = 0.0 ;
287  fM02MinParam[0][3] = 0.0 ;
288  fM02MinParam[0][4] = 0.0 ;
289 
290  // Same as NLM=1 for NLM=2
291  fM02MinParam[1][0] = 2.135 ;
292  fM02MinParam[1][1] =-0.245 ;
293  fM02MinParam[1][2] = 0.0 ;
294  fM02MinParam[1][3] = 0.0 ;
295  fM02MinParam[1][4] = 0.0 ;
296 
297  //TF1 *lM02MaxNLM1 = new TF1("M02MaxNLM1","exp(0.0662-0.0201*x)-0.0955+0.00186*x[0]+9.91/x[0]",6,100);
298  fM02MaxParam[0][0] = 0.0662 ;
299  fM02MaxParam[0][1] =-0.0201 ;
300  fM02MaxParam[0][2] =-0.0955 ;
301  fM02MaxParam[0][3] = 0.00186;
302  fM02MaxParam[0][4] = 9.91 ;
303 
304  //TF1 *lM02MaxNLM2 = new TF1("M02MaxNLM2","exp(0.353-0.0264*x)-0.524+0.00559*x[0]+21.9/x[0]",6,100);
305  fM02MaxParam[1][0] = 0.353 ;
306  fM02MaxParam[1][1] =-0.0264 ;
307  fM02MaxParam[1][2] =-0.524 ;
308  fM02MaxParam[1][3] = 0.00559;
309  fM02MaxParam[1][4] = 21.9 ;
310 
311  fM02MaxParamShiftNLMN = 0.75;
312 
313  //TF1 *lAsyNLM1 = new TF1("lAsyNLM1","0.96-879/(x*x*x)",5,100);
314  fAsyMinParam[0][0] = 0.96 ;
315  fAsyMinParam[0][1] = 0 ;
316  fAsyMinParam[0][2] =-879 ;
317  fAsyMinParam[0][3] = 0.96 ; // Absolute max
318 
319  //TF1 *lAsyNLM2 = new TF1("lAsyNLM2","0.95+0.0015*x-233/(x*x*x)",5,100);
320  fAsyMinParam[1][0] = 0.95 ;
321  fAsyMinParam[1][1] = 0.0015;
322  fAsyMinParam[1][2] =-233 ;
323  fAsyMinParam[1][3] = 1.0 ; // Absolute max
324 
325  fSplitEFracMin[0] = 0.0 ; // 0.96
326  fSplitEFracMin[1] = 0.0 ; // 0.96
327  fSplitEFracMin[2] = 0.0 ; // 0.7
328 
329  fSubClusterEMin[0] = 0.0; // 3 GeV
330  fSubClusterEMin[1] = 0.0; // 1 GeV
331  fSubClusterEMin[2] = 0.0; // 1 GeV
332 
333  fSplitWidthSigma = 3. ;
334 }
335 
336 
337 //_______________________________
344 //_______________________________
346 {
347  AliInfo("Init track matching residual pt dependent cuts;"
348  " careful if another initialization is done before this call!");
349 
350  fEMCALFuncTrackPtDepDEtaString = "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])" ;
351  fEMCALFuncTrackPtDepDPhiString = "[1] + 1 / pow(x + pow(1 / ([0] - [1]), 1 / [2]), [2])" ;
352 
355 
358 
361 
368 }
369 
370 //_________________________________________________________________________________________
376 //_________________________________________________________________________________________
378 {
379  if(!fUseSplitAsyCut) return kTRUE ;
380 
381  Float_t abasy = TMath::Abs(asy);
382 
383  Int_t inlm = nlm-1;
384  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
385 
386  // Get the parametrized min cut of asymmetry for NLM=2 up to 11 GeV
387 
388  Float_t cut = fAsyMinParam[inlm][0] + fAsyMinParam[inlm][1]*energy + fAsyMinParam[inlm][2]/energy/energy/energy ;
389 
390  // In any case and beyond validity energy range of the function,
391  // the parameter cannot be smaller than 1
392  if( cut > fAsyMinParam[inlm][3] ) cut = fAsyMinParam[inlm][3];
393 
394  //printf("energy %2.2f - nlm: %d (%d)- p0 %f, p1 %f, p2 %f, p3 %f ; cut: %2.2f\n",energy,nlm,inlm,
395  // fAsyMinParam[inlm][0],fAsyMinParam[inlm][1],fAsyMinParam[inlm][2],fAsyMinParam[inlm][3],cut);
396 
397  if(abasy < cut) return kTRUE;
398  else return kFALSE;
399 }
400 
401 //______________________________________________________________________________________
407 //______________________________________________________________________________________
409 {
411  {
412  if(mass < fMassPi0Max && mass > fMassPi0Min) return kTRUE;
413  else return kFALSE;
414  }
415 
416  // Get the selected mean value as reference for the mass
417  Int_t inlm = nlm-1;
418  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
419 
420  Float_t meanMass = energy * fMassPi0Param[inlm][1] + fMassPi0Param[inlm][0];
421  if(energy > fMassPi0Param[inlm][2]) meanMass = energy * fMassPi0Param[inlm][4] + fMassPi0Param[inlm][3];
422 
423  // In case of higher energy cell cut than 50 MeV, smaller mean mass 0-5 MeV, not really necessary
424  meanMass -= fMassShiftHighECell;
425 
426  // Get the parametrized width of the mass
427  Float_t width = 0.009;
428  if (energy > 8 && energy < fWidthPi0Param[inlm][2])
429  width = energy * fWidthPi0Param[inlm][1] + fWidthPi0Param[inlm][0];
430  else if( energy > fWidthPi0Param[inlm][2])
431  width = energy * energy * fWidthPi0Param[inlm][5] + energy * fWidthPi0Param[inlm][4] + fWidthPi0Param[inlm][3];
432 
433  // Calculate the 2 sigma cut
434  Float_t minMass = meanMass-fSplitWidthSigma*width;
435  Float_t maxMass = meanMass+fSplitWidthSigma*width;
436 
437  // In case of low energy, hard cut to avoid conversions
438  if(energy < 10 && minMass < fMassPi0Param[inlm][5] ) minMass = fMassPi0Param[inlm][5];
439 
440  //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 ",
441  // energy,mass *1000, inlm, fSplitWidthSigma, width*1000, meanMass*1000,minMass*1000,maxMass*1000);
442 
443  if(mass < maxMass && mass > minMass) return kTRUE;
444  else return kFALSE;
445 }
446 
447 //________________________________________________
451 //________________________________________________
453 {
454  Float_t minCut = fSplitM02MinCut;
455  Float_t maxCut = fSplitM02MaxCut;
456 
457  if(m02 < maxCut && m02 > minCut) return kTRUE;
458  else return kFALSE;
459 }
460 
461 //_______________________________________________________________________________
467 //_______________________________________________________________________________
469 {
470  if(!fUseSplitSSCut) return kTRUE ;
471 
472  //First check the absolute minimum and maximum
473  if(!IsInM02Range(m02)) return kFALSE ;
474 
475  //If requested, check the E dependent cuts
476  else if(!fUseSimpleM02Cut)
477  {
478  Int_t inlm = nlm-1;
479  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
480 
481  Float_t minCut = fSplitM02MinCut;
482  Float_t maxCut = fSplitM02MaxCut;
483 
484  //e^{a+bx} + c + dx + e/x
485  if(energy > 1) minCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*energy ) +
486  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*energy + fM02MinParam[inlm][4]/energy;
487 
488  if(energy > 1) maxCut = TMath::Exp( fM02MaxParam[inlm][0] + fM02MaxParam[inlm][1]*energy ) +
489  fM02MaxParam[inlm][2] + fM02MaxParam[inlm][3]*energy + fM02MaxParam[inlm][4]/energy;
490 
491  // In any case and beyond validity energy range of the function,
492  // the parameter cannot be smaller than 0.3 or larger than 4-5
493  if( minCut < fSplitM02MinCut) minCut = fSplitM02MinCut;
494  if( maxCut > fSplitM02MaxCut) maxCut = fSplitM02MaxCut;
495  if( nlm > 2 ) maxCut+=fM02MaxParamShiftNLMN;
496 
497  //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);
498 
499  if(m02 < maxCut && m02 > minCut) return kTRUE;
500  else return kFALSE;
501 
502  }
503 
504  else return kTRUE;
505 }
506 
507 
508 //______________________________________________________________________________
509 // Select the appropriate shower shape range in splitting method to select eta's
510 // Use same parametrization as pi0, just shift the distributions (to be tuned)
515 //______________________________________________________________________________
517 {
518  if(!fUseSplitSSCut) return kTRUE ;
519 
520  //First check the absolute minimum and maximum
521  if(!IsInM02Range(m02)) return kFALSE ;
522 
523  //DO NOT USE, study parametrization
524 
525  //If requested, check the E dependent cuts
526  else if(!fUseSimpleM02Cut)
527  {
528  Int_t inlm = nlm-1;
529  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
530 
531  Float_t minCut = fSplitM02MinCut;
532  Float_t maxCut = fSplitM02MaxCut;
533 
534  Float_t shiftE = energy-20; // to be tuned
535  if(nlm==1) shiftE=energy-28;
536 
537  //e^{a+bx} + c + dx + e/x
538  if(shiftE > 1) minCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*shiftE ) +
539  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*shiftE + fM02MinParam[inlm][4]/shiftE;
540 
541  // In any case the parameter cannot be smaller than 0.3
542  if( minCut < fSplitM02MinCut) minCut = fSplitM02MinCut;
543 
544  shiftE = energy+20; // to be tuned
545 
546  if(shiftE > 1) maxCut = 1 + TMath::Exp( fM02MaxParam[inlm][0] + fM02MaxParam[inlm][1]*shiftE ) +
547  fM02MaxParam[inlm][2] + fM02MaxParam[inlm][3]*shiftE + fM02MaxParam[inlm][4]/shiftE;
548 
549  // In any case the parameter cannot be smaller than 4-5
550  if( maxCut > fSplitM02MaxCut) maxCut = fSplitM02MaxCut;
551  if( nlm > 2 ) maxCut+=fM02MaxParamShiftNLMN;
552 
553  //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);
554 
555  if(m02 < maxCut && m02 > minCut) return kTRUE;
556  else return kFALSE;
557 
558  }
559 
560  else return kTRUE;
561 }
562 
563 //______________________________________________________________________________
570 //______________________________________________________________________________
572 {
573  if(!fUseSplitSSCut) return kTRUE ;
574 
575  Float_t minCut = 0.1;
576  Float_t maxCut = fSplitM02MinCut;
577 
578  if(!fUseSimpleM02Cut)
579  {
580  Int_t inlm = nlm-1;
581  if(nlm > 2) inlm=1; // only 2 cases defined nlm=1 and nlm>=2
582 
583  //e^{a+bx} + c + dx + e/x
584  if(energy > 1) maxCut = TMath::Exp( fM02MinParam[inlm][0] + fM02MinParam[inlm][1]*energy ) +
585  fM02MinParam[inlm][2] + fM02MinParam[inlm][3]*energy + fM02MinParam[inlm][4]/energy;
586 
587  if( maxCut < fSplitM02MinCut) maxCut = fSplitM02MinCut;
588  }
589 
590  if(m02 < maxCut && m02 > minCut) return kTRUE;
591  else return kFALSE;
592 
593 }
594 
595 //______________________________________________
597 //______________________________________________
598 AliEMCALPIDUtils *AliCaloPID::GetEMCALPIDUtils()
599 {
600  if(!fEMCALPIDUtils) fEMCALPIDUtils = new AliEMCALPIDUtils ;
601 
602  return fEMCALPIDUtils ;
603 }
604 
605 
606 //________________________________________________________________
609 //________________________________________________________________
611 {
612  Float_t energy = cluster->E();
613  Float_t lambda0 = cluster->GetM02();
614  Float_t lambda1 = cluster->GetM20();
615 
616  // ---------------------
617  // Use bayesian approach
618  // ---------------------
619 
621  {
622  Double_t weights[AliPID::kSPECIESCN];
623 
624  if(cluster->IsEMCAL() && fRecalculateBayesian)
625  {
626  fEMCALPIDUtils->ComputePID(energy, lambda0);
627  for(Int_t i = 0; i < AliPID::kSPECIESCN; i++) weights[i] = fEMCALPIDUtils->GetPIDFinal(i);
628  }
629  else
630  {
631  for(Int_t i = 0; i < AliPID::kSPECIESCN; i++) weights[i] = cluster->GetPID()[i];
632  }
633 
634  if(fDebug > 0) PrintClusterPIDWeights(weights);
635 
636  return GetIdentifiedParticleTypeFromBayesWeights(cluster->IsEMCAL(), weights, energy);
637  }
638 
639  // -------------------------------------------------------
640  // Calculate PID SS from data, do not use bayesian weights
641  // -------------------------------------------------------
642 
643  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",
644  cluster->IsEMCAL(),energy,lambda0,cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(),
645  cluster->GetEmcCpvDistance(), cluster->GetDistanceToBadChannel(),cluster->GetNExMax()));
646 
647  if(cluster->IsEMCAL())
648  {
649  AliDebug(1,Form("EMCAL SS %f <%f < %f?",fEMCALL0CutMin, lambda0, fEMCALL0CutMax));
650 
651  if(lambda0 < fEMCALL0CutMax && lambda0 > fEMCALL0CutMin) return kPhoton ;
652  else return kNeutralUnknown ;
653  } // EMCAL
654  else // PHOS
655  {
656  if(TestPHOSDispersion(energy,lambda0,lambda1) < fPHOSDispersionCut) return kPhoton;
657  else return kNeutralUnknown;
658  }
659 }
660 
661 //_________________________________________________________________________________________________________
666 //_________________________________________________________________________________________________________
668 {
669  if(!pid)
670  {
671  AliFatal("pid pointer not initialized!!!");
672  return kNeutralUnknown; // not needed, added to content coverity
673  }
674 
675  Float_t wPh = fPHOSPhotonWeight ;
676  Float_t wPi0 = fPHOSPi0Weight ;
678  Float_t wCh = fPHOSChargeWeight ;
680 
681  if(!isEMCAL && fPHOSWeightFormula){
682  wPh = GetPHOSPhotonWeightFormula()->Eval(energy) ;
683  wPi0 = GetPHOSPi0WeightFormula() ->Eval(energy);
684  }
685  else
686  {
687  wPh = fEMCALPhotonWeight ;
688  wPi0 = fEMCALPi0Weight ;
689  wE = fEMCALElectronWeight ;
690  wCh = fEMCALChargeWeight ;
691  wNe = fEMCALNeutralWeight ;
692  }
693 
694  if(fDebug > 0) PrintClusterPIDWeights(pid);
695 
697  Float_t chargedHadronWeight = pid[AliVCluster::kProton]+pid[AliVCluster::kKaon]+
698  pid[AliVCluster::kPion]+pid[AliVCluster::kMuon];
699  Float_t neutralHadronWeight = pid[AliVCluster::kNeutron]+pid[AliVCluster::kKaon0];
700  Float_t allChargedWeight = pid[AliVCluster::kElectron]+pid[AliVCluster::kEleCon]+ chargedHadronWeight;
701  Float_t allNeutralWeight = pid[AliVCluster::kPhoton]+pid[AliVCluster::kPi0]+ neutralHadronWeight;
702 
703  //Select most probable ID
704  if(!isEMCAL) // PHOS
705  {
706  if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ;
707  else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ;
708  else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ;
709  else if(pid[AliVCluster::kEleCon] > wE) pdg = kEleCon ;
710  else if(chargedHadronWeight > wCh) pdg = kChargedHadron ;
711  else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ;
712  else if(allChargedWeight > allNeutralWeight)
713  pdg = kChargedUnknown ;
714  else
715  pdg = kNeutralUnknown ;
716  }
717  else //EMCAL
718  {
719  if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ;
720  else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ;
721  else if(pid[AliVCluster::kPhoton]+pid[AliVCluster::kElectron] > wPh) pdg = kPhoton ; //temporal sollution until track matching for electrons is considered
722  else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ;
723  else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ;
724  else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ;
725  else pdg = kNeutralUnknown ;
726  }
727 
728  AliDebug(1,Form("Final Pdg: %d, cluster energy %2.2f", pdg,energy));
729 
730  return pdg ;
731 
732 }
733 
734 //____________________________________________________________________________________________________________
753 //____________________________________________________________________________________________________________
755  AliVCaloCells* cells,
756  AliCalorimeterUtils * caloutils,
757  Double_t vertex[3],
758  Int_t & nMax,
759  Double_t & mass, Double_t & angle,
760  TLorentzVector & l1, TLorentzVector & l2,
761  Int_t & absId1, Int_t & absId2,
762  Float_t & distbad1, Float_t & distbad2,
763  Bool_t & fidcut1, Bool_t & fidcut2 ) const
764 {
765  Float_t eClus = cluster->E();
766  Float_t m02 = cluster->GetM02();
767  const Int_t nc = cluster->GetNCells();
768  Int_t absIdList[nc];
769  Float_t maxEList [nc];
770 
771  mass = -1.;
772  angle = -1.;
773 
774  //If too low number of cells, skip it
775  if ( nc < fSplitMinNCells) return kNeutralUnknown ;
776 
777  AliDebug(2,"\t pass nCells cut");
778 
779  // Get Number of local maxima
780  nMax = caloutils->GetNumberOfLocalMaxima(cluster, cells, absIdList, maxEList) ;
781 
782  AliDebug(1,Form("Cluster : E %1.1f, M02 %1.2f, NLM %d, N Cells %d",eClus,m02,nMax,nc));
783 
784  //---------------------------------------------------------------------
785  // Get the 2 max indeces and do inv mass
786  //---------------------------------------------------------------------
787 
789  if(cluster->IsPHOS()) calorimeter = AliFiducialCut::kPHOS;
790 
791  if ( nMax == 2 )
792  {
793  absId1 = absIdList[0];
794  absId2 = absIdList[1];
795 
796  //Order in energy
797  Float_t en1 = cells->GetCellAmplitude(absId1);
798  caloutils->RecalibrateCellAmplitude(en1,calorimeter,absId1);
799  Float_t en2 = cells->GetCellAmplitude(absId2);
800  caloutils->RecalibrateCellAmplitude(en2,calorimeter,absId2);
801  if(en1 < en2)
802  {
803  absId2 = absIdList[0];
804  absId1 = absIdList[1];
805  }
806  }
807  else if( nMax == 1 )
808  {
809 
810  absId1 = absIdList[0];
811 
812  //Find second highest energy cell
813 
814  Float_t enmax = 0 ;
815  for(Int_t iDigit = 0 ; iDigit < cluster->GetNCells() ; iDigit++)
816  {
817  Int_t absId = cluster->GetCellsAbsId()[iDigit];
818  if( absId == absId1 ) continue ;
819  Float_t endig = cells->GetCellAmplitude(absId);
820  caloutils->RecalibrateCellAmplitude(endig,calorimeter,absId);
821  if(endig > enmax)
822  {
823  enmax = endig ;
824  absId2 = absId ;
825  }
826  }// cell loop
827  }// 1 maxima
828  else
829  { // n max > 2
830  // loop on maxima, find 2 highest
831 
832  // First max
833  Float_t enmax = 0 ;
834  for(Int_t iDigit = 0 ; iDigit < nMax ; iDigit++)
835  {
836  Float_t endig = maxEList[iDigit];
837  if(endig > enmax)
838  {
839  enmax = endig ;
840  absId1 = absIdList[iDigit];
841  }
842  }// first maxima loop
843 
844  // Second max
845  Float_t enmax2 = 0;
846  for(Int_t iDigit = 0 ; iDigit < nMax ; iDigit++)
847  {
848  if(absIdList[iDigit]==absId1) continue;
849  Float_t endig = maxEList[iDigit];
850  if(endig > enmax2)
851  {
852  enmax2 = endig ;
853  absId2 = absIdList[iDigit];
854  }
855  }// second maxima loop
856 
857  } // n local maxima > 2
858 
859  if(absId2<0 || absId1<0)
860  {
861  AliDebug(1,Form("Bad index for local maxima : N max %d, i1 %d, i2 %d, cluster E %2.2f, ncells %d, m02 %2.2f",
862  nMax,absId1,absId2,eClus,nc,m02));
863  return kNeutralUnknown ;
864  }
865 
866  //---------------------------------------------------------------------
867  // Split the cluster energy in 2, around the highest 2 local maxima
868  //---------------------------------------------------------------------
869 
870  AliAODCaloCluster cluster1(0, 0,NULL,0.,NULL,NULL,1,0);
871  AliAODCaloCluster cluster2(1, 0,NULL,0.,NULL,NULL,1,0);
872 
873  caloutils->SplitEnergy(absId1,absId2,cluster, cells, &cluster1, &cluster2,nMax); /*absIdList, maxEList,*/
874 
875  fidcut1 = caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), &cluster1,cells);
876  fidcut2 = caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), &cluster2,cells);
877 
878  caloutils->GetEMCALRecoUtils()->RecalculateClusterDistanceToBadChannel(caloutils->GetEMCALGeometry(),cells,&cluster1);
879  caloutils->GetEMCALRecoUtils()->RecalculateClusterDistanceToBadChannel(caloutils->GetEMCALGeometry(),cells,&cluster2);
880 
881  distbad1 = cluster1.GetDistanceToBadChannel();
882  distbad2 = cluster2.GetDistanceToBadChannel();
883 // if(!fidcut2 || !fidcut1 || distbad1 < 2 || distbad2 < 2)
884 // printf("*** Dist to bad channel cl %f, cl1 %f, cl2 %f; fid cut cl %d, cl1 %d, cl2 %d \n",
885 // cluster->GetDistanceToBadChannel(),distbad1,distbad2,
886 // caloutils->GetEMCALRecoUtils()->CheckCellFiducialRegion(caloutils->GetEMCALGeometry(), cluster,cells),fidcut1,fidcut2);
887 
888  cluster1.GetMomentum(l1,vertex);
889  cluster2.GetMomentum(l2,vertex);
890 
891  mass = (l1+l2).M();
892  angle = l2.Angle(l1.Vect());
893  Float_t e1 = cluster1.E();
894  Float_t e2 = cluster2.E();
895 
896  // Consider clusters with splitted energy not too different to original cluster energy
897  Float_t splitFracCut = 0;
898  if(nMax < 3) splitFracCut = fSplitEFracMin[nMax-1];
899  else splitFracCut = fSplitEFracMin[2];
900  if((e1+e2)/eClus < splitFracCut) return kNeutralUnknown ;
901 
902  AliDebug(2,"\t pass Split E frac cut");
903 
904  // Consider sub-clusters with minimum energy
905  Float_t minECut = fSubClusterEMin[2];
906  if (nMax == 2) minECut = fSubClusterEMin[1];
907  else if(nMax == 1) minECut = fSubClusterEMin[0];
908  if(e1 < minECut || e2 < minECut)
909  {
910  //printf("Reject: e1 %2.1f, e2 %2.1f, cut %2.1f\n",e1,e2,minECut);
911  return kNeutralUnknown ;
912  }
913 
914  AliDebug(2,"\t pass min sub-cluster E cut");
915 
916  // Asymmetry of cluster
917  Float_t asy =-10;
918  if(e1+e2 > 0) asy = (e1-e2) / (e1+e2);
919 
920  if( !IsInPi0SplitAsymmetryRange(eClus,asy,nMax) ) return kNeutralUnknown ;
921 
922 
923  AliDebug(2,"\t pass asymmetry cut");
924 
925  Bool_t pi0OK = kFALSE;
926  Bool_t etaOK = kFALSE;
927  Bool_t conOK = kFALSE;
928 
929  //If too small or big M02, skip it
930  if (IsInPi0M02Range(eClus,m02,nMax)) pi0OK = kTRUE;
931  else if(IsInEtaM02Range(eClus,m02,nMax)) etaOK = kTRUE;
932  else if(IsInConM02Range(eClus,m02,nMax)) conOK = kTRUE;
933 
934  Float_t energy = eClus;
935  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.
936 
937  // Check the mass, and set an ID to the splitted cluster
938  if ( conOK && mass < fMassPhoMax && mass > fMassPhoMin ) { AliDebug(2,"\t Split Conv"); return kPhoton ; }
939  else if( etaOK && mass < fMassEtaMax && mass > fMassEtaMin ) { AliDebug(2,"\t Split Eta" ); return kEta ; }
940  else if( pi0OK && IsInPi0SplitMassRange(energy,mass,nMax) ) { AliDebug(2,"\t Split Pi0" ); return kPi0 ; }
941  else return kNeutralUnknown ;
942 
943 }
944 
945 //_________________________________________
947 //_________________________________________
949 {
950  TString parList ; //this will be list of parameters used for this analysis.
951  const Int_t buffersize = 255;
952  char onePar[buffersize] ;
953  snprintf(onePar,buffersize,"--- AliCaloPID ---") ;
954  parList+=onePar ;
956  {
957  snprintf(onePar,buffersize,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)",fEMCALPhotonWeight) ;
958  parList+=onePar ;
959  snprintf(onePar,buffersize,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)",fEMCALPi0Weight) ;
960  parList+=onePar ;
961  snprintf(onePar,buffersize,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)",fEMCALElectronWeight) ;
962  parList+=onePar ;
963  snprintf(onePar,buffersize,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)",fEMCALChargeWeight) ;
964  parList+=onePar ;
965  snprintf(onePar,buffersize,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)",fEMCALNeutralWeight) ;
966  parList+=onePar ;
967  snprintf(onePar,buffersize,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)",fPHOSPhotonWeight) ;
968  parList+=onePar ;
969  snprintf(onePar,buffersize,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)",fPHOSPi0Weight) ;
970  parList+=onePar ;
971  snprintf(onePar,buffersize,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)",fPHOSElectronWeight) ;
972  parList+=onePar ;
973  snprintf(onePar,buffersize,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)",fPHOSChargeWeight) ;
974  parList+=onePar ;
975  snprintf(onePar,buffersize,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)",fPHOSNeutralWeight) ;
976  parList+=onePar ;
977 
979  {
980  snprintf(onePar,buffersize,"PHOS Photon Weight Formula: %s",fPHOSPhotonWeightFormulaExpression.Data() ) ;
981  parList+=onePar;
982  snprintf(onePar,buffersize,"PHOS Pi0 Weight Formula: %s",fPHOSPi0WeightFormulaExpression.Data() ) ;
983  parList+=onePar;
984  }
985  }
986  else
987  {
988  snprintf(onePar,buffersize,"EMCAL: fEMCALL0CutMin =%2.2f, fEMCALL0CutMax =%2.2f (Cut on Shower Shape)",fEMCALL0CutMin, fEMCALL0CutMax) ;
989  parList+=onePar ;
990  snprintf(onePar,buffersize,"EMCAL: fEMCALDEtaCut =%2.2f, fEMCALDPhiCut =%2.2f (Cut on track matching)",fEMCALDEtaCut, fEMCALDPhiCut) ;
991  parList+=onePar ;
992  snprintf(onePar,buffersize,"fTOFCut =%e (Cut on TOF, used in PID evaluation)",fTOFCut) ;
993  parList+=onePar ;
994  snprintf(onePar,buffersize,"fPHOSRCut =%2.2f, fPHOSDispersionCut =%2.2f (Cut on Shower Shape and CPV)",fPHOSRCut,fPHOSDispersionCut) ;
995  parList+=onePar ;
996 
997  }
998 
999  if(fUseSimpleM02Cut)
1000  {
1001  snprintf(onePar,buffersize,"%2.2f< M02 < %2.2f", fSplitM02MinCut, fSplitM02MaxCut) ;
1002  parList+=onePar ;
1003  }
1004  snprintf(onePar,buffersize,"fMinNCells =%d", fSplitMinNCells) ;
1005  parList+=onePar ;
1006  if(fUseSimpleMassCut)
1007  {
1008  snprintf(onePar,buffersize,"pi0 : %2.1f < m <%2.1f", fMassPi0Min,fMassPi0Max);
1009  parList+=onePar ;
1010  }
1011  snprintf(onePar,buffersize,"eta : %2.1f < m <%2.1f", fMassEtaMin,fMassEtaMax);
1012  parList+=onePar ;
1013  snprintf(onePar,buffersize,"conv: %2.1f < m <%2.1f", fMassPhoMin,fMassPhoMax);
1014  parList+=onePar ;
1015 
1016 
1017  return parList;
1018 }
1019 
1020 //________________________________________________
1022 //________________________________________________
1023 void AliCaloPID::Print(const Option_t * opt) const
1024 {
1025  if(! opt)
1026  return;
1027 
1028  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1029 
1031  {
1032  printf("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n",
1035  printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n",
1038 
1039  printf("PHOS Parametrized weight on? = %d\n", fPHOSWeightFormula) ;
1040  if(fPHOSWeightFormula)
1041  {
1042  printf("Photon weight formula = %s\n", fPHOSPhotonWeightFormulaExpression.Data());
1043  printf("Pi0 weight formula = %s\n", fPHOSPi0WeightFormulaExpression .Data());
1044  }
1045  if(fRecalculateBayesian) printf(" Recalculate bayesian with Particle Flux? = %d\n",fParticleFlux);
1046  }
1047  else
1048  {
1049  printf("TOF cut = %e\n", fTOFCut);
1050  printf("EMCAL Lambda0 cut min = %2.2f; max = %2.2f\n", fEMCALL0CutMin,fEMCALL0CutMax);
1051  printf("EMCAL cluster-track dEta < %2.3f; dPhi < %2.3f\n", fEMCALDEtaCut, fEMCALDPhiCut);
1052  printf("PHOS Treac matching cut =%2.2f, Dispersion Cut =%2.2f \n",fPHOSRCut, fPHOSDispersionCut) ;
1053 
1054  }
1055 
1056  printf("Min. N Cells =%d \n", fSplitMinNCells) ;
1057  if(fUseSimpleM02Cut) printf("%2.2f < lambda_0^2 <%2.2f \n",fSplitM02MinCut,fSplitM02MaxCut);
1058  if(fUseSimpleMassCut)printf("pi0 : %2.2f<m<%2.2f \n", fMassPi0Min,fMassPi0Max);
1059  printf("eta : %2.2f<m<%2.2f \n", fMassEtaMin,fMassEtaMax);
1060  printf("phot: %2.2f<m<%2.2f \n", fMassPhoMin,fMassPhoMax);
1061 
1062  printf(" \n");
1063 }
1064 
1065 //_________________________________________________________________
1066 // Print PID of cluster, (AliVCluster*)cluster->GetPID()
1067 //_________________________________________________________________
1069 {
1070  printf("AliCaloPID::PrintClusterPIDWeights() \n \t ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f, \n \t \
1071  pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n",
1072  pid[AliVCluster::kPhoton], pid[AliVCluster::kPi0],
1073  pid[AliVCluster::kElectron], pid[AliVCluster::kEleCon],
1074  pid[AliVCluster::kPion], pid[AliVCluster::kKaon],
1075  pid[AliVCluster::kProton],
1076  pid[AliVCluster::kNeutron], pid[AliVCluster::kKaon0]);
1077 }
1078 
1079 //___________________________________________________________________________
1081 //___________________________________________________________________________
1082 void AliCaloPID::SetPIDBits(AliVCluster * cluster,
1083  AliAODPWG4Particle * ph, AliCalorimeterUtils* cu,
1084  AliVEvent* event)
1085 {
1086  // Dispersion/lambdas
1087  //Double_t disp= cluster->GetDispersion() ;
1088  Double_t l1 = cluster->GetM20() ;
1089  Double_t l0 = cluster->GetM02() ;
1090  Bool_t isDispOK = kTRUE ;
1091  if(cluster->IsPHOS()){
1092  if(TestPHOSDispersion(ph->Pt(),l0,l1) < fPHOSDispersionCut) isDispOK = kTRUE;
1093  else isDispOK = kFALSE;
1094  }
1095  else{//EMCAL
1096 
1097  if(l0 > fEMCALL0CutMin && l0 < fEMCALL0CutMax) isDispOK = kTRUE;
1098 
1099  }
1100 
1101  ph->SetDispBit(isDispOK) ;
1102 
1103  //TOF
1104  Double_t tof=cluster->GetTOF() ;
1105  ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ;
1106 
1107  //Charged
1108  Bool_t isNeutral = IsTrackMatched(cluster,cu,event);
1109 
1110  ph->SetChargedBit(isNeutral);
1111 
1112  //Set PID pdg
1113  ph->SetIdentifiedParticleType(GetIdentifiedParticleType(cluster));
1114 
1115  AliDebug(1,Form("TOF %e, Lambda0 %2.2f, Lambda1 %2.2f",tof , l0, l1));
1116  AliDebug(1,Form("pdg %d, bits: TOF %d, Dispersion %d, Charge %d",
1117  ph->GetIdentifiedParticleType(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit()));
1118 }
1119 
1120 //_________________________________________________________
1127 //_________________________________________________________
1129 {
1130  if( !fEMCALFuncTrackPtDepDEta )
1131  {
1133 
1134  for(Int_t iparam = 0; iparam < fEMCALFuncTrackPtDepDEtaNParam; iparam++)
1135  fEMCALFuncTrackPtDepDEta->SetParameter(iparam,fEMCALFuncTrackPtDepDEtaParam[iparam]);
1136  }
1137 
1138  return fEMCALFuncTrackPtDepDEta ;
1139 }
1140 
1141 //_________________________________________________________
1148 //_________________________________________________________
1150 {
1151  if ( !fEMCALFuncTrackPtDepDPhi )
1152  {
1154 
1155  for(Int_t iparam = 0; iparam < fEMCALFuncTrackPtDepDPhiNParam; iparam++)
1156  fEMCALFuncTrackPtDepDPhi->SetParameter(iparam,fEMCALFuncTrackPtDepDPhiParam[iparam]);
1157  }
1158 
1159  return fEMCALFuncTrackPtDepDPhi;
1160 }
1161 
1162 //_________________________________________________________
1168 //_________________________________________________________
1169 Bool_t AliCaloPID::IsTrackMatched(AliVCluster* cluster,
1170  AliCalorimeterUtils * cu,
1171  AliVEvent* event)
1172 {
1173  Int_t nMatches = cluster->GetNTracksMatched();
1174  AliVTrack * track = 0;
1175 
1176  // At least one match
1177  //
1178  if(nMatches <= 0) return kFALSE;
1179 
1180  // Select the track, depending on ESD or AODs
1181  //
1182  //In case of ESDs,
1183  //by default without match one entry with negative index, no match, reject.
1184  //
1185  if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
1186  {
1187  Int_t iESDtrack = ((AliESDCaloCluster*)cluster)->GetTracksMatched()->At(0); //cluster->GetTrackMatchedIndex();
1188 
1189  if(iESDtrack >= 0) track = dynamic_cast<AliVTrack*> (event->GetTrack(iESDtrack));
1190  else return kFALSE;
1191 
1192  if (!track)
1193  {
1194  AliWarning(Form("Null matched track in ESD for index %d",iESDtrack));
1195  return kFALSE;
1196  }
1197  } // ESDs
1198  else
1199  { // AODs
1200  track = dynamic_cast<AliVTrack*> (cluster->GetTrackMatched(0));
1201  if (!track)
1202  {
1203  AliWarning("Null matched track in AOD!");
1204  return kFALSE;
1205  }
1206  } // AODs
1207 
1208  Float_t dEta = cluster->GetTrackDz();
1209  Float_t dPhi = cluster->GetTrackDx();
1210 
1211  // Comment out, new value already set in AliCalorimeterUtils::RecalculateClusterTrackMatching()
1212  // when executed in the reader.
1213  // // if track matching was recalculated
1214  // if(cluster->IsEMCAL() && cu && cu->IsRecalculationOfClusterTrackMatchingOn())
1215  // {
1216  // dR = 2000., dZ = 2000.;
1217  // cu->GetEMCALRecoUtils()->GetMatchedResiduals(cluster->GetID(),dZ,dR);
1218  // //AliDebug(2,"Residuals, (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n", cluster->GetTrackDz(),dZ,cluster->GetTrackDx(),dR));
1219  // }
1220 
1221  if(cluster->IsPHOS())
1222  {
1223  Int_t charge = track->Charge();
1224  Double_t mf = event->GetMagneticField();
1225  if(TestPHOSChargedVeto(dPhi, dEta, track->Pt(), charge, mf ) < fPHOSRCut)
1226  return kTRUE;
1227  else
1228  return kFALSE;
1229 
1230  } // PHOS
1231  else // EMCAL
1232  {
1233  AliDebug(1,Form("EMCAL dPhi %f < %f, dEta %f < %f ",dPhi, fEMCALDPhiCut, dEta, fEMCALDEtaCut));
1234 
1236  {
1237  if(TMath::Abs(dPhi) < fEMCALDPhiCut &&
1238  TMath::Abs(dEta) < fEMCALDEtaCut) return kTRUE;
1239  else return kFALSE;
1240  }
1241  else
1242  {
1243  Float_t trackPt = track->Pt();
1244 
1245  Bool_t matchDEta = kFALSE;
1246  if( TMath::Abs(dEta) < GetEMCALFuncTrackPtDepDEta()->Eval(trackPt))
1247  matchDEta = kTRUE;
1248  else
1249  matchDEta = kFALSE;
1250 
1251  Bool_t matchDPhi = kFALSE;
1252  if( TMath::Abs(dPhi) < GetEMCALFuncTrackPtDepDPhi()->Eval(trackPt))
1253  matchDPhi = kTRUE;
1254  else
1255  matchDPhi = kFALSE;
1256 
1257 // 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",
1258 // cluster->E(),trackPt,dEta,dPhi,
1259 // GetEMCALFuncTrackPtDepDEta()->Eval(trackPt), GetEMCALFuncTrackPtDepDPhi()->Eval(trackPt),
1260 // matchDEta, matchDPhi);
1261 
1262  if(matchDPhi && matchDEta) return kTRUE ;
1263  else return kFALSE;
1264 
1265  }
1266  }// EMCAL cluster
1267 }
1268 
1269 //___________________________________________________________________________________________________
1277 //___________________________________________________________________________________________________
1279 {
1280  Double_t l2Mean = 1.53126+9.50835e+06/(1.+1.08728e+07*pt+1.73420e+06*pt*pt) ;
1281  Double_t l1Mean = 1.12365+0.123770*TMath::Exp(-pt*0.246551)+5.30000e-03*pt ;
1282  Double_t l2Sigma = 6.48260e-02+7.60261e+10/(1.+1.53012e+11*pt+5.01265e+05*pt*pt)+9.00000e-03*pt;
1283  Double_t l1Sigma = 4.44719e-04+6.99839e-01/(1.+1.22497e+00*pt+6.78604e-07*pt*pt)+9.00000e-03*pt;
1284  Double_t c =-0.35-0.550*TMath::Exp(-0.390730*pt) ;
1285  Double_t r2 = 0.5* (l1-l1Mean)*(l1-l1Mean)/l1Sigma/l1Sigma +
1286  0.5* (l2-l2Mean)*(l2-l2Mean)/l2Sigma/l2Sigma +
1287  0.5*c*(l1-l1Mean)*(l2-l2Mean)/l1Sigma/l2Sigma ;
1288 
1289  AliDebug(1,Form("PHOS SS R %f < %f?", TMath::Sqrt(r2), fPHOSDispersionCut));
1290 
1291  return TMath::Sqrt(r2) ;
1292 }
1293 
1294 //_______________________________________________________________________________________________
1309 //_______________________________________________________________________________________________
1311  Int_t charge, Double_t mf) const
1312 {
1313  Double_t meanX = 0.;
1314  Double_t meanZ = 0.;
1315  Double_t sx = TMath::Min(5.4,2.59719e+02*TMath::Exp(-pt/1.02053e-01)+
1316  6.58365e-01*5.91917e-01*5.91917e-01/((pt-9.61306e-01)*(pt-9.61306e-01)+5.91917e-01*5.91917e-01)+
1317  1.59219);
1318  Double_t sz = TMath::Min(2.75,4.90341e+02*1.91456e-02*1.91456e-02/(pt*pt+1.91456e-02*1.91456e-02)+
1319  1.60) ;
1320 
1321  if(mf<0.){ //field --
1322  meanZ = -0.468318 ;
1323  if(charge>0)
1324  meanX = TMath::Min(7.3, 3.89994*1.20679 *1.20679 /(pt*pt+1.20679*1.20679)+
1325  0.249029+2.49088e+07*TMath::Exp(-pt*3.33650e+01)) ;
1326  else
1327  meanX =-TMath::Min(7.7, 3.86040*0.912499*0.912499/(pt*pt+0.912499*0.912499)+
1328  1.23114 +4.48277e+05*TMath::Exp(-pt*2.57070e+01)) ;
1329  }
1330  else{ //Field ++
1331  meanZ = -0.468318;
1332  if(charge>0)
1333  meanX =-TMath::Min(8.0,3.86040*1.31357*1.31357/(pt*pt+1.31357*1.31357)+
1334  0.880579+7.56199e+06*TMath::Exp(-pt*3.08451e+01)) ;
1335  else
1336  meanX = TMath::Min(6.85, 3.89994*1.16240*1.16240/(pt*pt+1.16240*1.16240)-
1337  0.120787+2.20275e+05*TMath::Exp(-pt*2.40913e+01)) ;
1338  }
1339 
1340  Double_t rz = (dz-meanZ)/sz ;
1341  Double_t rx = (dx-meanX)/sx ;
1342 
1343  AliDebug(1,Form("PHOS Matching R %f < %f",TMath::Sqrt(rx*rx+rz*rz), fPHOSRCut));
1344 
1345  return TMath::Sqrt(rx*rx+rz*rz) ;
1346 }
1347 
Int_t charge
void InitParamTrackMatchPtDependent()
Definition: AliCaloPID.cxx:345
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:516
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:377
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:168
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:948
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:468
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:610
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:408
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:754
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:571
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:667
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:598
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:182
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:452
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