]>
Commit | Line | Data |
---|---|---|
1c5acb87 | 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 | /* $Id: AliCaloPID.cxx 21839 2007-10-29 13:49:42Z gustavo $ */ | |
16 | ||
17 | //_________________________________________________________________________ | |
bdd2a262 | 18 | // Class for PID selection with calorimeters |
19 | // The Output of the 2 main methods GetPdg is a PDG number identifying the cluster, | |
20 | // being kPhoton, kElectron, kPi0 ... as defined in the header file | |
21 | // - GetPdg(const TString calo, const Double_t * pid, const Float_t energy) | |
22 | // Reads the PID weights array of the ESDs and depending on its magnitude identifies the particle | |
0ae57829 | 23 | // - GetPdg(const TString calo,const TLorentzVector mom, const AliVCluster * cluster) |
bdd2a262 | 24 | // Recalcultes PID, the bayesian or any new one to be implemented in the future |
25 | // Right now only the possibility to recalculate EMCAL with bayesian and simple PID. | |
26 | // In order to recalculate Bayesian, it is necessary to load the EMCALUtils library | |
27 | // and do SwitchOnBayesianRecalculation(). | |
28 | // To change the PID parameters from Low to High like the ones by default, use the constructor | |
29 | // AliCaloPID(flux) | |
30 | // where flux is AliCaloPID::kLow or AliCaloPID::kHigh | |
31 | // If it is necessary to change the parameters use the constructor | |
32 | // AliCaloPID(AliEMCALPIDUtils *utils) and set the parameters before. | |
33 | // - SetPIDBits: Simple PID, depending on the thresholds fDispCut fTOFCut and even the | |
34 | // result of the PID bayesian a different PID bit is set. | |
35 | // | |
36 | // All these methods can be called in the analysis you are interested. | |
37 | // | |
1c5acb87 | 38 | //*-- Author: Gustavo Conesa (LNF-INFN) |
39 | ////////////////////////////////////////////////////////////////////////////// | |
40 | ||
41 | ||
42 | // --- ROOT system --- | |
43 | #include <TMath.h> | |
1c5acb87 | 44 | #include <TString.h> |
a33b76ed | 45 | //#include <TFormula.h> |
1c5acb87 | 46 | |
47 | //---- ANALYSIS system ---- | |
1c5acb87 | 48 | #include "AliCaloPID.h" |
0ae57829 | 49 | #include "AliVCluster.h" |
1c5acb87 | 50 | #include "AliAODPWG4Particle.h" |
bdd2a262 | 51 | #include "AliEMCALPIDUtils.h" |
1c5acb87 | 52 | ClassImp(AliCaloPID) |
53 | ||
54 | ||
55 | //________________________________________________ | |
56 | AliCaloPID::AliCaloPID() : | |
57 | TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.), | |
58 | fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), | |
59 | fEMCALNeutralWeight(0.), | |
60 | fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.), | |
61 | fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , | |
a33b76ed | 62 | fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), |
63 | //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0), | |
bdd2a262 | 64 | fDispCut(0.),fTOFCut(0.), fDebug(-1), |
e5dbdaf0 | 65 | fRecalculateBayesian(kFALSE), fParticleFlux(kLow), fEMCALPIDUtils(new AliEMCALPIDUtils) |
1c5acb87 | 66 | { |
477d6cee | 67 | //Ctor |
68 | ||
69 | //Initialize parameters | |
70 | InitParameters(); | |
1c5acb87 | 71 | } |
72 | ||
bdd2a262 | 73 | //________________________________________________ |
74 | AliCaloPID::AliCaloPID(const Int_t flux) : | |
75 | TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.), | |
76 | fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), | |
77 | fEMCALNeutralWeight(0.), | |
78 | fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.), | |
79 | fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , | |
a33b76ed | 80 | fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), |
81 | //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0), | |
bdd2a262 | 82 | fDispCut(0.),fTOFCut(0.), fDebug(-1), |
e5dbdaf0 | 83 | fRecalculateBayesian(kTRUE), fParticleFlux(flux), fEMCALPIDUtils(new AliEMCALPIDUtils) |
bdd2a262 | 84 | { |
85 | //Ctor | |
86 | ||
87 | //Initialize parameters | |
88 | InitParameters(); | |
89 | } | |
90 | ||
91 | //________________________________________________ | |
92 | AliCaloPID::AliCaloPID(const TTask * emcalpid) : | |
93 | TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.), | |
94 | fEMCALElectronWeight(0.), fEMCALChargeWeight(0.), | |
95 | fEMCALNeutralWeight(0.), | |
96 | fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.), | |
97 | fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , | |
a33b76ed | 98 | fPHOSNeutralWeight(0.), //fPHOSWeightFormula(0), |
99 | //fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0), | |
bdd2a262 | 100 | fDispCut(0.),fTOFCut(0.), fDebug(-1), |
e5dbdaf0 | 101 | fRecalculateBayesian(kTRUE), fParticleFlux(-1), fEMCALPIDUtils( (AliEMCALPIDUtils*) emcalpid) |
bdd2a262 | 102 | { |
103 | //Ctor | |
104 | ||
105 | //Initialize parameters | |
106 | InitParameters(); | |
107 | } | |
108 | ||
1c5acb87 | 109 | //____________________________________________________________________________ |
110 | AliCaloPID::AliCaloPID(const AliCaloPID & pid) : | |
111 | TObject(pid), fEMCALPhotonWeight(pid.fEMCALPhotonWeight), | |
112 | fEMCALPi0Weight(pid.fEMCALPi0Weight), | |
113 | fEMCALElectronWeight(pid.fEMCALElectronWeight), | |
114 | fEMCALChargeWeight(pid.fEMCALChargeWeight), | |
115 | fEMCALNeutralWeight(pid.fEMCALNeutralWeight), | |
116 | fPHOSPhotonWeight(pid.fPHOSPhotonWeight), | |
117 | fPHOSPi0Weight(pid.fPHOSPi0Weight), | |
118 | fPHOSElectronWeight(pid.fPHOSElectronWeight), | |
119 | fPHOSChargeWeight(pid.fPHOSChargeWeight), | |
120 | fPHOSNeutralWeight(pid.fPHOSNeutralWeight), | |
a33b76ed | 121 | //fPHOSWeightFormula(pid.fPHOSWeightFormula), |
122 | //fPHOSPhotonWeightFormula(new TFormula(*pid.fPHOSPhotonWeightFormula)), | |
123 | //fPHOSPi0WeightFormula (new TFormula(*pid.fPHOSPi0WeightFormula)), | |
1c5acb87 | 124 | fDispCut(pid.fDispCut),fTOFCut(pid.fTOFCut), |
bdd2a262 | 125 | fDebug(pid.fDebug), fRecalculateBayesian(pid.fRecalculateBayesian), |
fb9841b8 | 126 | fParticleFlux(pid.fParticleFlux), |
127 | fEMCALPIDUtils(new AliEMCALPIDUtils(*pid.fEMCALPIDUtils)) | |
1c5acb87 | 128 | { |
477d6cee | 129 | // cpy ctor |
1c5acb87 | 130 | |
131 | } | |
132 | ||
133 | //_________________________________________________________________________ | |
614701c6 | 134 | //AliCaloPID & AliCaloPID::operator = (const AliCaloPID & pid) |
135 | //{ | |
136 | // // assignment operator | |
137 | // | |
138 | // if(&pid == this) return *this; | |
139 | // | |
140 | // fEMCALPhotonWeight = pid. fEMCALPhotonWeight ; | |
141 | // fEMCALPi0Weight = pid.fEMCALPi0Weight ; | |
142 | // fEMCALElectronWeight = pid.fEMCALElectronWeight; | |
143 | // fEMCALChargeWeight = pid.fEMCALChargeWeight; | |
144 | // fEMCALNeutralWeight = pid.fEMCALNeutralWeight; | |
145 | // | |
146 | // fPHOSPhotonWeight = pid.fPHOSPhotonWeight ; | |
147 | // fPHOSPi0Weight = pid.fPHOSPi0Weight ; | |
148 | // fPHOSElectronWeight = pid.fPHOSElectronWeight; | |
149 | // fPHOSChargeWeight = pid.fPHOSChargeWeight; | |
150 | // fPHOSNeutralWeight = pid.fPHOSNeutralWeight; | |
151 | // | |
152 | // fPHOSWeightFormula = pid.fPHOSWeightFormula; | |
153 | // delete fPHOSPhotonWeightFormula; fPHOSPhotonWeightFormula = new TFormula(*pid.fPHOSPhotonWeightFormula); | |
154 | // delete fPHOSPi0WeightFormula; fPHOSPi0WeightFormula = new TFormula(*pid.fPHOSPi0WeightFormula); | |
155 | // | |
156 | // fDispCut = pid.fDispCut; | |
157 | // fTOFCut = pid.fTOFCut; | |
158 | // fDebug = pid.fDebug; | |
159 | // | |
160 | // fRecalculateBayesian = pid.fRecalculateBayesian; | |
161 | // fParticleFlux = pid.fParticleFlux; | |
162 | // | |
163 | // delete fEMCALPIDUtils; fEMCALPIDUtils = new AliEMCALPIDUtils(*pid.fEMCALPIDUtils); | |
164 | // | |
165 | // return *this; | |
166 | // | |
167 | //} | |
1c5acb87 | 168 | |
169 | //_________________________________ | |
170 | AliCaloPID::~AliCaloPID() { | |
477d6cee | 171 | //Dtor |
172 | ||
a33b76ed | 173 | // if(fPHOSPhotonWeightFormula) delete fPHOSPhotonWeightFormula ; |
174 | // if(fPHOSPi0WeightFormula) delete fPHOSPi0WeightFormula ; | |
fb9841b8 | 175 | if(fEMCALPIDUtils) delete fEMCALPIDUtils ; |
1c5acb87 | 176 | } |
177 | ||
178 | ||
1c5acb87 | 179 | //_______________________________________________________________ |
180 | void AliCaloPID::InitParameters() | |
181 | { | |
477d6cee | 182 | //Initialize the parameters of the PID. |
183 | ||
691c43c9 | 184 | fEMCALPhotonWeight = 0.5 ; |
477d6cee | 185 | fEMCALPi0Weight = 0.5 ; |
691c43c9 | 186 | fEMCALElectronWeight = 0.5 ; |
477d6cee | 187 | fEMCALChargeWeight = 0.5 ; |
188 | fEMCALNeutralWeight = 0.5 ; | |
189 | ||
691c43c9 | 190 | fPHOSPhotonWeight = 0.5 ; |
191 | fPHOSPi0Weight = 0.5 ; | |
477d6cee | 192 | fPHOSElectronWeight = 0.5 ; |
193 | fPHOSChargeWeight = 0.5 ; | |
194 | fPHOSNeutralWeight = 0.5 ; | |
195 | ||
196 | //Formula to set the PID weight threshold for photon or pi0 | |
a33b76ed | 197 | //fPHOSWeightFormula = kTRUE; |
198 | //if(fPHOSPhotonWeightFormula) delete fPHOSPhotonWeightFormula; | |
199 | //if(fPHOSPi0WeightFormula) delete fPHOSPi0WeightFormula; | |
200 | //fPHOSPhotonWeightFormula = | |
201 | //new TFormula("photonWeight","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))"); | |
202 | //fPHOSPi0WeightFormula = | |
203 | //new TFormula("pi0Weight","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))"); | |
477d6cee | 204 | |
5ae09196 | 205 | fDispCut = 0.25; |
477d6cee | 206 | fTOFCut = 5.e-9; |
207 | fDebug = -1; | |
bdd2a262 | 208 | |
209 | if(fRecalculateBayesian){ | |
bdd2a262 | 210 | if(fParticleFlux == kLow){ |
211 | printf("AliCaloPID::Init() - SetLOWFluxParam\n"); | |
212 | fEMCALPIDUtils->SetLowFluxParam() ; | |
213 | } | |
214 | else if (fParticleFlux == kHigh){ | |
215 | printf("AliCaloPID::Init() - SetHIGHFluxParam\n"); | |
216 | fEMCALPIDUtils->SetHighFluxParam() ; | |
217 | } | |
bdd2a262 | 218 | } |
1c5acb87 | 219 | } |
220 | ||
221 | //_______________________________________________________________ | |
222 | Int_t AliCaloPID::GetPdg(const TString calo, const Double_t * pid, const Float_t energy) const { | |
477d6cee | 223 | //Return most probable identity of the particle. |
224 | ||
225 | if(!pid){ | |
226 | printf("AliCaloPID::GetPdg() - pid pointer not initialized!!!\n"); | |
227 | abort(); | |
228 | } | |
229 | ||
15800db4 | 230 | Float_t wPh = fPHOSPhotonWeight ; |
477d6cee | 231 | Float_t wPi0 = fPHOSPi0Weight ; |
15800db4 | 232 | Float_t wE = fPHOSElectronWeight ; |
233 | Float_t wCh = fPHOSChargeWeight ; | |
234 | Float_t wNe = fPHOSNeutralWeight ; | |
477d6cee | 235 | |
236 | ||
a33b76ed | 237 | // if(calo == "PHOS" && fPHOSWeightFormula){ |
238 | // wPh = fPHOSPhotonWeightFormula->Eval(energy) ; | |
239 | // wPi0 = fPHOSPi0WeightFormula->Eval(energy); | |
240 | // } | |
477d6cee | 241 | |
242 | if(calo == "EMCAL"){ | |
243 | ||
244 | wPh = fEMCALPhotonWeight ; | |
245 | wPi0 = fEMCALPi0Weight ; | |
246 | wE = fEMCALElectronWeight ; | |
247 | wCh = fEMCALChargeWeight ; | |
248 | wNe = fEMCALNeutralWeight ; | |
249 | ||
250 | } | |
251 | ||
252 | if(fDebug > 0) printf("AliCaloPID::GetPdg: calo %s, ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f, hadrons: pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n", | |
c8fe2783 | 253 | calo.Data(),pid[AliVCluster::kPhoton], pid[AliVCluster::kPi0], |
254 | pid[AliVCluster::kElectron], pid[AliVCluster::kEleCon], | |
255 | pid[AliVCluster::kPion], pid[AliVCluster::kKaon], pid[AliVCluster::kProton], | |
256 | pid[AliVCluster::kNeutron], pid[AliVCluster::kKaon0]); | |
477d6cee | 257 | |
258 | Int_t pdg = kNeutralUnknown ; | |
c8fe2783 | 259 | Float_t chargedHadronWeight = pid[AliVCluster::kProton]+pid[AliVCluster::kKaon]+ |
260 | pid[AliVCluster::kPion]+pid[AliVCluster::kMuon]; | |
261 | Float_t neutralHadronWeight = pid[AliVCluster::kNeutron]+pid[AliVCluster::kKaon0]; | |
262 | Float_t allChargedWeight = pid[AliVCluster::kElectron]+pid[AliVCluster::kEleCon]+ chargedHadronWeight; | |
263 | Float_t allNeutralWeight = pid[AliVCluster::kPhoton]+pid[AliVCluster::kPi0]+ neutralHadronWeight; | |
477d6cee | 264 | |
265 | //Select most probable ID | |
266 | if(calo=="PHOS"){ | |
c8fe2783 | 267 | if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ; |
268 | else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ; | |
269 | else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ; | |
270 | else if(pid[AliVCluster::kEleCon] > wE) pdg = kEleCon ; | |
477d6cee | 271 | else if(chargedHadronWeight > wCh) pdg = kChargedHadron ; |
272 | else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ; | |
273 | else if(allChargedWeight > allNeutralWeight) | |
274 | pdg = kChargedUnknown ; | |
275 | else | |
276 | pdg = kNeutralUnknown ; | |
277 | } | |
278 | else{//EMCAL | |
bdd2a262 | 279 | |
c8fe2783 | 280 | if(pid[AliVCluster::kPhoton]+pid[AliVCluster::kElectron] > wPh) pdg = kPhoton ; //temporal sollution until track matching for electrons is considered |
281 | //if(pid[AliVCluster::kPhoton] > wPh) pdg = kPhoton ; | |
282 | else if(pid[AliVCluster::kPi0] > wPi0) pdg = kPi0 ; | |
283 | //else if(pid[AliVCluster::kElectron] > wE) pdg = kElectron ; | |
477d6cee | 284 | else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ; |
285 | else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ; | |
286 | else pdg = kNeutralUnknown ; | |
287 | ||
288 | } | |
289 | ||
ebc881ec | 290 | if(fDebug > 0)printf("AliCaloPID::GetPdg:Final Pdg: %d, cluster energy %2.2f \n", pdg,energy); |
477d6cee | 291 | |
292 | return pdg ; | |
293 | ||
1c5acb87 | 294 | } |
295 | ||
296 | //_______________________________________________________________ | |
0ae57829 | 297 | Int_t AliCaloPID::GetPdg(const TString calo,const TLorentzVector mom, const AliVCluster * cluster) const { |
477d6cee | 298 | //Recalculated PID with all parameters |
bdd2a262 | 299 | Float_t lambda0 = cluster->GetM02(); |
300 | Float_t energy = mom.E(); | |
301 | ||
302 | if(fDebug > 0) printf("AliCaloPID::GetPdg: Calorimeter %s, E %3.2f, l0 %3.2f, l1 %3.2f, disp %3.2f, tof %1.11f, distCPV %3.2f, distToBC %1.1f, NMax %d\n", | |
303 | calo.Data(),energy,lambda0,cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(), | |
c8fe2783 | 304 | cluster->GetEmcCpvDistance(), cluster->GetDistanceToBadChannel(),cluster->GetNExMax()); |
bdd2a262 | 305 | |
477d6cee | 306 | if(calo == "EMCAL") { |
bdd2a262 | 307 | //Recalculate Bayesian |
308 | if(fRecalculateBayesian){ | |
bdd2a262 | 309 | if(fDebug > 0) { |
c8fe2783 | 310 | const Double_t *pid0 = cluster->GetPID(); |
bdd2a262 | 311 | printf("AliCaloPID::GetPdg: BEFORE calo %s, ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f, hadrons: pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n", |
c8fe2783 | 312 | calo.Data(),pid0[AliVCluster::kPhoton], pid0[AliVCluster::kPi0], |
313 | pid0[AliVCluster::kElectron], pid0[AliVCluster::kEleCon], | |
314 | pid0[AliVCluster::kPion], pid0[AliVCluster::kKaon], pid0[AliVCluster::kProton], | |
315 | pid0[AliVCluster::kNeutron], pid0[AliVCluster::kKaon0]); | |
bdd2a262 | 316 | } |
317 | ||
318 | fEMCALPIDUtils->ComputePID(energy, lambda0); | |
319 | Double_t pid[AliPID::kSPECIESN]; | |
320 | for(Int_t i = 0; i < AliPID::kSPECIESN; i++) pid[i] = fEMCALPIDUtils->GetPIDFinal(i); | |
321 | return GetPdg(calo, pid, energy); | |
322 | ||
bdd2a262 | 323 | |
324 | } | |
325 | ||
c8fe2783 | 326 | // If no use of bayesian, simple PID |
327 | if(lambda0 < 0.25) return kPhoton ; | |
328 | //else return kNeutralHadron ; | |
329 | else return kPi0 ; | |
477d6cee | 330 | } |
331 | ||
332 | // if(calo == "PHOS") { | |
333 | // if(cluster->GetM02()< 0.25) return kPhoton ; | |
334 | // else return kNeutralHadron ; | |
335 | // } | |
336 | ||
337 | return kNeutralHadron ; | |
338 | ||
1c5acb87 | 339 | } |
340 | ||
341 | //__________________________________________________ | |
342 | TString AliCaloPID::GetPIDParametersList() { | |
477d6cee | 343 | //Put data member values in string to keep in output container |
344 | ||
345 | TString parList ; //this will be list of parameters used for this analysis. | |
5ae09196 | 346 | const Int_t buffersize = 255; |
347 | char onePar[buffersize] ; | |
348 | snprintf(onePar,buffersize,"--- AliCaloPID ---\n") ; | |
477d6cee | 349 | parList+=onePar ; |
5ae09196 | 350 | snprintf(onePar,buffersize,"fDispCut =%2.2f (Cut on dispersion, used in PID evaluation) \n",fDispCut) ; |
477d6cee | 351 | parList+=onePar ; |
5ae09196 | 352 | snprintf(onePar,buffersize,"fTOFCut =%e (Cut on TOF, used in PID evaluation) \n",fTOFCut) ; |
477d6cee | 353 | parList+=onePar ; |
5ae09196 | 354 | snprintf(onePar,buffersize,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)\n",fEMCALPhotonWeight) ; |
477d6cee | 355 | parList+=onePar ; |
5ae09196 | 356 | snprintf(onePar,buffersize,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)\n",fEMCALPi0Weight) ; |
477d6cee | 357 | parList+=onePar ; |
5ae09196 | 358 | snprintf(onePar,buffersize,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)\n",fEMCALElectronWeight) ; |
477d6cee | 359 | parList+=onePar ; |
5ae09196 | 360 | snprintf(onePar,buffersize,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)\n",fEMCALChargeWeight) ; |
477d6cee | 361 | parList+=onePar ; |
5ae09196 | 362 | snprintf(onePar,buffersize,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)\n",fEMCALNeutralWeight) ; |
477d6cee | 363 | parList+=onePar ; |
5ae09196 | 364 | snprintf(onePar,buffersize,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)\n",fPHOSPhotonWeight) ; |
477d6cee | 365 | parList+=onePar ; |
5ae09196 | 366 | snprintf(onePar,buffersize,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)\n",fPHOSPi0Weight) ; |
477d6cee | 367 | parList+=onePar ; |
5ae09196 | 368 | snprintf(onePar,buffersize,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)\n",fPHOSElectronWeight) ; |
477d6cee | 369 | parList+=onePar ; |
5ae09196 | 370 | snprintf(onePar,buffersize,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)\n",fPHOSChargeWeight) ; |
477d6cee | 371 | parList+=onePar ; |
5ae09196 | 372 | snprintf(onePar,buffersize,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)\n",fPHOSNeutralWeight) ; |
477d6cee | 373 | parList+=onePar ; |
374 | ||
a33b76ed | 375 | // if(fPHOSWeightFormula){ |
5ae09196 | 376 | // sprintf(onePar,buffersize,"PHOS Photon Weight Formula: %s\n",(fPHOSPhotonWeightFormula->GetExpFormula("p")).Data()) ; |
a33b76ed | 377 | // parList+=onePar; |
5ae09196 | 378 | // sprintf(onePar,buffersize,"PHOS Pi0 Weight Formula: %s\n",(fPHOSPi0WeightFormula->GetExpFormula("p")).Data()) ; |
a33b76ed | 379 | // parList+=onePar; |
380 | // } | |
477d6cee | 381 | |
382 | return parList; | |
383 | ||
1c5acb87 | 384 | } |
385 | ||
386 | //________________________________________________________________ | |
387 | void AliCaloPID::Print(const Option_t * opt) const | |
388 | { | |
477d6cee | 389 | |
390 | //Print some relevant parameters set for the analysis | |
391 | if(! opt) | |
392 | return; | |
393 | ||
394 | printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ; | |
395 | ||
396 | printf("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n", | |
397 | fPHOSPhotonWeight, fPHOSPi0Weight, | |
398 | fPHOSElectronWeight, fPHOSChargeWeight, fPHOSNeutralWeight) ; | |
399 | printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n", | |
400 | fEMCALPhotonWeight, fEMCALPi0Weight, | |
401 | fEMCALElectronWeight, fEMCALChargeWeight, fEMCALNeutralWeight) ; | |
402 | ||
a33b76ed | 403 | // printf("PHOS Parametrized weight on? = %d\n", fPHOSWeightFormula) ; |
404 | // if(fPHOSWeightFormula){ | |
405 | // printf("Photon weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data()); | |
406 | // printf("Pi0 weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data()); | |
407 | // } | |
477d6cee | 408 | |
409 | printf("TOF cut = %e\n",fTOFCut); | |
410 | printf("Dispersion cut = %2.2f\n",fDispCut); | |
411 | printf("Debug level = %d\n",fDebug); | |
bdd2a262 | 412 | printf("Recalculate Bayesian? = %d\n",fRecalculateBayesian); |
413 | if(fRecalculateBayesian) printf("Particle Flux? = %d\n",fParticleFlux); | |
477d6cee | 414 | printf(" \n"); |
415 | ||
1c5acb87 | 416 | } |
417 | ||
418 | //_______________________________________________________________ | |
0ae57829 | 419 | void AliCaloPID::SetPIDBits(const TString calo, const AliVCluster * cluster, AliAODPWG4Particle * ph) { |
477d6cee | 420 | //Set Bits for PID selection |
421 | ||
422 | //Dispersion/lambdas | |
5ae09196 | 423 | //Double_t disp= cluster->GetDispersion() ; |
424 | Double_t l1 = cluster->GetM20() ; | |
425 | Double_t l0 = cluster->GetM02() ; | |
426 | Bool_t isDispOK = kTRUE ; | |
427 | if(cluster->IsPHOS()){ | |
428 | ||
429 | if(l1>= 0 && l0>= 0 && l1 < 0.1 && l0 < 0.1) isDispOK=kFALSE ; | |
430 | if(l1>= 0 && l0 > 0.5 && l1 < 0.1 && l0 < 1.5) isDispOK=kTRUE ; | |
431 | if(l1>= 0 && l0 > 2.0 && l1 < 0.1 && l0 < 2.7) isDispOK=kFALSE ; | |
432 | if(l1>= 0 && l0 > 2.7 && l1 < 0.1 && l0 < 4.0) isDispOK=kFALSE ; | |
433 | if(l1 > 0.1 && l1 < 0.7 && l0 > 0.7 && l0 < 2.1) isDispOK=kTRUE ; | |
434 | if(l1 > 0.1 && l1 < 0.3 && l0 > 3.0 && l0 < 5.0) isDispOK=kFALSE ; | |
435 | if(l1 > 0.3 && l1 < 0.7 && l0 > 2.5 && l0 < 4.0) isDispOK=kFALSE ; | |
436 | if(l1 > 0.7 && l1 < 1.3 && l0 > 1.0 && l0 < 1.6) isDispOK=kTRUE ; | |
437 | if(l1 > 0.7 && l1 < 1.3 && l0 > 1.6 && l0 < 3.5) isDispOK=kTRUE ; | |
438 | if(l1 > 1.3 && l1 < 3.5 && l0 > 1.3 && l0 < 3.5) isDispOK=kTRUE ; | |
439 | ||
440 | } | |
441 | else{//EMCAL | |
442 | ||
443 | if(l0 > fDispCut || l0 < 0.) isDispOK = kFALSE; | |
444 | ||
445 | } | |
446 | ||
447 | ph->SetDispBit(isDispOK) ; | |
477d6cee | 448 | |
449 | //TOF | |
450 | Double_t tof=cluster->GetTOF() ; | |
451 | ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ; | |
452 | ||
5ae09196 | 453 | //Charged veto |
454 | //Bool_t isNeutral = kTRUE ; | |
455 | //if(cluster->IsPHOS()) isNeutral = cluster->GetEmcCpvDistance() > 5. ; | |
456 | //else | |
457 | Bool_t isNeutral = IsTrackMatched(cluster); | |
458 | ||
459 | ph->SetChargedBit(isNeutral); | |
477d6cee | 460 | |
461 | //Set PID pdg | |
c8fe2783 | 462 | ph->SetPdg(GetPdg(calo,cluster->GetPID(),ph->E())); |
477d6cee | 463 | |
464 | if(fDebug > 0){ | |
5ae09196 | 465 | printf("AliCaloPID::SetPIDBits: TOF %e, Lambda0 %2.2f, Lambda1 %2.2f\n",tof , l0, l1); |
477d6cee | 466 | printf("AliCaloPID::SetPIDBits: pdg %d, bits: TOF %d, Dispersion %d, Charge %d\n", |
6639984f | 467 | ph->GetPdg(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit()); |
477d6cee | 468 | } |
1c5acb87 | 469 | } |
470 | ||
5ae09196 | 471 | //__________________________________________________________________________ |
472 | Bool_t AliCaloPID::IsTrackMatched(const AliVCluster* cluster) const { | |
473 | //Check if there is any track attached to this cluster | |
474 | ||
475 | Int_t nMatches = cluster->GetNTracksMatched(); | |
476 | ||
477 | // printf("N matches %d, first match %d\n",nMatches,cluster->GetTrackMatchedIndex()); | |
478 | // if (cluster->GetTrackMatched(0)) printf("\t matched track id %d\n",((AliVTrack*)cluster->GetTrackMatched(0))->GetID()) ; | |
479 | // else if(cluster->GetTrackMatchedIndex()>=0) printf("\t matched track id %d\n",((AliVTrack*) GetReader()->GetInputEvent()->GetTrack(cluster->GetTrackMatchedIndex()))->GetID()) ; | |
480 | ||
481 | if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName()))) | |
482 | { | |
483 | if (nMatches > 0) { | |
484 | if (nMatches == 1 ) { | |
485 | Int_t iESDtrack = cluster->GetTrackMatchedIndex(); | |
486 | //printf("Track Matched index %d\n",iESDtrack); | |
487 | if(iESDtrack==-1) return kFALSE ;// Default value of array, there is no match | |
488 | else return kTRUE; | |
489 | }//Just one, check | |
490 | else return kTRUE ;//More than one, there is a match. | |
491 | }// > 0 | |
492 | else return kFALSE; //It does not happen, but in case | |
493 | ||
494 | }//ESDs | |
495 | else | |
496 | { | |
497 | //AODs | |
498 | if(nMatches > 0) return kTRUE; //There is at least one match. | |
499 | else return kFALSE; | |
500 | ||
501 | }//AODs or MC (copy into AOD) | |
502 | ||
503 | return kFALSE; | |
504 | ||
505 | } | |
506 | ||
1c5acb87 | 507 |