1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 /* $Id: AliCaloPID.cxx 21839 2007-10-29 13:49:42Z gustavo $ */
17 //_________________________________________________________________________
18 // Class for track/cluster acceptance selection
19 // Selection in Central barrel, EMCAL and PHOS
21 //*-- Author: Gustavo Conesa (LNF-INFN)
22 //////////////////////////////////////////////////////////////////////////////
25 // --- ROOT system ---
27 #include <TLorentzVector.h>
31 //---- ANALYSIS system ----
33 #include "AliCaloPID.h"
34 #include "AliAODCaloCluster.h"
35 #include "AliAODPWG4Particle.h"
37 #include "TParticle.h"
42 //________________________________________________
43 AliCaloPID::AliCaloPID() :
44 TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
45 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.),
46 fEMCALNeutralWeight(0.),
47 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
48 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) ,
49 fPHOSNeutralWeight(0.), fPHOSWeightFormula(0),
50 fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
51 fDispCut(0.),fTOFCut(0.), fDebug(-1)
55 //Initialize parameters
59 //____________________________________________________________________________
60 AliCaloPID::AliCaloPID(const AliCaloPID & pid) :
61 TObject(pid), fEMCALPhotonWeight(pid.fEMCALPhotonWeight),
62 fEMCALPi0Weight(pid.fEMCALPi0Weight),
63 fEMCALElectronWeight(pid.fEMCALElectronWeight),
64 fEMCALChargeWeight(pid.fEMCALChargeWeight),
65 fEMCALNeutralWeight(pid.fEMCALNeutralWeight),
66 fPHOSPhotonWeight(pid.fPHOSPhotonWeight),
67 fPHOSPi0Weight(pid.fPHOSPi0Weight),
68 fPHOSElectronWeight(pid.fPHOSElectronWeight),
69 fPHOSChargeWeight(pid.fPHOSChargeWeight),
70 fPHOSNeutralWeight(pid.fPHOSNeutralWeight),
71 fPHOSWeightFormula(pid.fPHOSWeightFormula),
72 fPHOSPhotonWeightFormula(pid.fPHOSPhotonWeightFormula),
73 fPHOSPi0WeightFormula(pid.fPHOSPi0WeightFormula),
74 fDispCut(pid.fDispCut),fTOFCut(pid.fTOFCut),
81 //_________________________________________________________________________
82 AliCaloPID & AliCaloPID::operator = (const AliCaloPID & pid)
84 // assignment operator
86 if(&pid == this) return *this;
88 fEMCALPhotonWeight = pid. fEMCALPhotonWeight ;
89 fEMCALPi0Weight = pid.fEMCALPi0Weight ;
90 fEMCALElectronWeight = pid.fEMCALElectronWeight;
91 fEMCALChargeWeight = pid.fEMCALChargeWeight;
92 fEMCALNeutralWeight = pid.fEMCALNeutralWeight;
94 fPHOSPhotonWeight = pid.fPHOSPhotonWeight ;
95 fPHOSPi0Weight = pid.fPHOSPi0Weight ;
96 fPHOSElectronWeight = pid.fPHOSElectronWeight;
97 fPHOSChargeWeight = pid.fPHOSChargeWeight;
98 fPHOSNeutralWeight = pid.fPHOSNeutralWeight;
100 fPHOSWeightFormula = pid.fPHOSWeightFormula;
101 fPHOSPhotonWeightFormula = pid.fPHOSPhotonWeightFormula;
102 fPHOSPi0WeightFormula = pid.fPHOSPi0WeightFormula;
104 fDispCut = pid.fDispCut;
105 fTOFCut = pid.fTOFCut;
112 //_________________________________
113 AliCaloPID::~AliCaloPID() {
116 if(fPHOSPhotonWeightFormula) delete fPHOSPhotonWeightFormula ;
117 if(fPHOSPi0WeightFormula) delete fPHOSPi0WeightFormula ;
122 //_________________________________________________________________________
123 Int_t AliCaloPID::CheckOrigin(const Int_t label, AliStack * stack) const {
124 //Play with the MC stack if available
125 //Check origin of the candidates, good for PYTHIA
127 if(!stack) AliFatal("Stack is not available, check analysis settings in configuration file, STOP!!");
129 if(label >= 0 && label < stack->GetNtrack()){
131 TParticle * mom = stack->Particle(label);
132 Int_t mPdg = TMath::Abs(mom->GetPdgCode());
133 Int_t mStatus = mom->GetStatusCode() ;
134 Int_t iParent = mom->GetFirstMother() ;
135 if(fDebug > 0 && label < 8 ) printf("AliCaloPID::CheckOrigin: Mother is parton %d\n",iParent);
138 TParticle * parent = new TParticle ;
142 parent = stack->Particle(iParent);
143 pPdg = TMath::Abs(parent->GetPdgCode());
144 pStatus = parent->GetStatusCode();
146 else if(fDebug > 0 ) printf("AliCaloPID::CheckOrigin: Parent with label %d\n",iParent);
152 if(pPdg == 22) return kMCPrompt;
153 else return kMCFragmentation;
155 else if(pStatus == 11){
156 if(pPdg == 111) return kMCPi0Decay ;
157 else if (pPdg == 321) return kMCEtaDecay ;
158 else return kMCOtherDecay ;
160 }//Status 1 : Pythia generated
161 else if(mStatus == 0){
162 if(pPdg ==22 || pPdg ==11) return kMCConversion ;
163 if(pPdg == 111) return kMCPi0Decay ;
164 else if (pPdg == 221) return kMCEtaDecay ;
165 else return kMCOtherDecay ;
166 }//status 0 : geant generated
168 else if(mPdg == 111) return kMCPi0 ;
169 else if(mPdg == 221) return kMCEta ;
171 if(mStatus == 0) return kMCConversion ;
172 else return kMCElectron ;
174 else return kMCUnknown;
177 if(label < 0 ) printf("AliCaloPID::CheckOrigin: *** bad label or no stack ***: label %d \n", label);
178 if(label >= stack->GetNtrack()) printf("AliCaloPID::CheckOrigin: *** large label ***: label %d, n tracks %d \n", label, stack->GetNtrack());
186 //_______________________________________________________________
187 void AliCaloPID::InitParameters()
189 //Initialize the parameters of the PID.
191 fEMCALPhotonWeight = 0.8 ;
192 fEMCALPi0Weight = 0.5 ;
193 fEMCALElectronWeight = 0.8 ;
194 fEMCALChargeWeight = 0.5 ;
195 fEMCALNeutralWeight = 0.5 ;
197 fPHOSPhotonWeight = 0.75 ;
198 fPHOSPi0Weight = 0.8 ;
199 fPHOSElectronWeight = 0.5 ;
200 fPHOSChargeWeight = 0.5 ;
201 fPHOSNeutralWeight = 0.5 ;
203 //Formula to set the PID weight threshold for photon or pi0
204 fPHOSWeightFormula = kTRUE;
205 fPHOSPhotonWeightFormula =
206 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))");
207 fPHOSPi0WeightFormula =
208 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))");
215 //_______________________________________________________________
216 Int_t AliCaloPID::GetPdg(const TString calo, const Double_t * pid, const Float_t energy) const {
217 //Return most probable identity of the particle.
219 if(!pid) AliFatal("pid pointer not initialized!!!");
221 Float_t wPh = fPHOSPhotonWeight ;
222 Float_t wPi0 = fPHOSPi0Weight ;
223 Float_t wE = fPHOSElectronWeight ;
224 Float_t wCh = fPHOSChargeWeight ;
225 Float_t wNe = fPHOSNeutralWeight ;
228 if(calo == "PHOS" && fPHOSWeightFormula){
229 wPh = fPHOSPhotonWeightFormula->Eval(energy) ;
230 wPi0 = fPHOSPi0WeightFormula->Eval(energy);
235 wPh = fEMCALPhotonWeight ;
236 wPi0 = fEMCALPi0Weight ;
237 wE = fEMCALElectronWeight ;
238 wCh = fEMCALChargeWeight ;
239 wNe = fEMCALNeutralWeight ;
243 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",
244 calo.Data(),pid[AliAODCluster::kPhoton], pid[AliAODCluster::kPi0],
245 pid[AliAODCluster::kElectron], pid[AliAODCluster::kEleCon],
246 pid[AliAODCluster::kPion], pid[AliAODCluster::kKaon], pid[AliAODCluster::kProton],
247 pid[AliAODCluster::kNeutron], pid[AliAODCluster::kKaon0]);
249 Int_t pdg = kNeutralUnknown ;
250 Float_t chargedHadronWeight = pid[AliAODCluster::kProton]+pid[AliAODCluster::kKaon]+
251 pid[AliAODCluster::kPion]+pid[AliAODCluster::kMuon];
252 Float_t neutralHadronWeight = pid[AliAODCluster::kNeutron]+pid[AliAODCluster::kKaon0];
253 Float_t allChargedWeight = pid[AliAODCluster::kElectron]+pid[AliAODCluster::kEleCon]+ chargedHadronWeight;
254 Float_t allNeutralWeight = pid[AliAODCluster::kPhoton]+pid[AliAODCluster::kPi0]+ neutralHadronWeight;
256 //Select most probable ID
258 if(pid[AliAODCluster::kPhoton] > wPh) pdg = kPhoton ;
259 else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ;
260 else if(pid[AliAODCluster::kElectron] > wE) pdg = kElectron ;
261 else if(pid[AliAODCluster::kEleCon] > wE) pdg = kEleCon ;
262 else if(chargedHadronWeight > wCh) pdg = kChargedHadron ;
263 else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ;
264 else if(allChargedWeight > allNeutralWeight)
265 pdg = kChargedUnknown ;
267 pdg = kNeutralUnknown ;
270 //Temporal solution, electrons and photons not differenciated
271 if(pid[AliAODCluster::kPhoton] + pid[AliAODCluster::kElectron] > wPh) pdg = kPhoton ;
272 else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ;
273 else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ;
274 else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ;
275 else pdg = kNeutralUnknown ;
280 if(fDebug > 0)printf("AliCaloPID::GetPdg:Final Pdg: %d \n", pdg);
288 //_______________________________________________________________
289 Int_t AliCaloPID::GetPdg(const TString calo,const TLorentzVector mom, const AliAODCaloCluster * cluster) const {
290 //Recalculated PID with all parameters
291 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",
292 calo.Data(),mom.E(),cluster->GetM02(),cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(),
293 cluster->GetEmcCpvDistance(), cluster->GetDistToBadChannel(),cluster->GetNExMax());
295 if(calo == "EMCAL") {
296 if(cluster->GetM02()< 0.25) return kPhoton ;
297 else return kNeutralHadron ;
300 // if(calo == "PHOS") {
301 // if(cluster->GetM02()< 0.25) return kPhoton ;
302 // else return kNeutralHadron ;
305 return kNeutralHadron ;
309 //__________________________________________________
310 TString AliCaloPID::GetPIDParametersList() {
311 //Put data member values in string to keep in output container
313 TString parList ; //this will be list of parameters used for this analysis.
315 sprintf(onePar,"--- AliCaloPID ---\n") ;
317 sprintf(onePar,"fDispCut =%2.2f (Cut on dispersion, used in PID evaluation) \n",fDispCut) ;
319 sprintf(onePar,"fTOFCut =%e (Cut on TOF, used in PID evaluation) \n",fTOFCut) ;
321 sprintf(onePar,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)\n",fEMCALPhotonWeight) ;
323 sprintf(onePar,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)\n",fEMCALPi0Weight) ;
325 sprintf(onePar,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)\n",fEMCALElectronWeight) ;
327 sprintf(onePar,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)\n",fEMCALChargeWeight) ;
329 sprintf(onePar,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)\n",fEMCALNeutralWeight) ;
331 sprintf(onePar,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)\n",fPHOSPhotonWeight) ;
333 sprintf(onePar,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)\n",fPHOSPi0Weight) ;
335 sprintf(onePar,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)\n",fPHOSElectronWeight) ;
337 sprintf(onePar,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)\n",fPHOSChargeWeight) ;
339 sprintf(onePar,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)\n",fPHOSNeutralWeight) ;
342 if(fPHOSWeightFormula){
343 parList+="PHOS Photon Weight Formula: "+(fPHOSPhotonWeightFormula->GetExpFormula("p"));
344 parList+="PHOS Pi0 Weight Formula: "+(fPHOSPi0WeightFormula->GetExpFormula("p"));
351 //________________________________________________________________
352 void AliCaloPID::Print(const Option_t * opt) const
355 //Print some relevant parameters set for the analysis
359 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
361 printf("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n",
362 fPHOSPhotonWeight, fPHOSPi0Weight,
363 fPHOSElectronWeight, fPHOSChargeWeight, fPHOSNeutralWeight) ;
364 printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n",
365 fEMCALPhotonWeight, fEMCALPi0Weight,
366 fEMCALElectronWeight, fEMCALChargeWeight, fEMCALNeutralWeight) ;
368 printf("PHOS Parametrized weight on? = %d\n", fPHOSWeightFormula) ;
369 if(fPHOSWeightFormula){
370 printf("Photon weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
371 printf("Pi0 weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
374 printf("TOF cut = %e\n",fTOFCut);
375 printf("Dispersion cut = %2.2f\n",fDispCut);
376 printf("Debug level = %d\n",fDebug);
382 //_______________________________________________________________
383 void AliCaloPID::SetPIDBits(const TString calo, const AliAODCaloCluster * cluster, AliAODPWG4Particle * ph) {
384 //Set Bits for PID selection
387 Double_t disp=cluster->GetDispersion() ;
388 // Double_t m20=calo->GetM20() ;
389 // Double_t m02=calo->GetM02() ;
390 ph->SetDispBit(disp<fDispCut) ;
393 Double_t tof=cluster->GetTOF() ;
394 ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ;
397 // Double_t cpvR=calo->GetEmcCpvDistance() ;
398 Int_t ntr=cluster->GetNTracksMatched(); //number of track matched
399 ph->SetChargedBit(ntr>0) ; //Temporary cut, should we evaluate distance?
402 ph->SetPdg(GetPdg(calo,cluster->PID(),ph->E()));
405 printf("AliCaloPID::SetPIDBits: TOF %e, Dispersion %2.2f, NTracks %d\n",tof , disp, ntr);
406 printf("AliCaloPID::SetPIDBits: pdg %d, bits: TOF %d, Dispersion %d, Charge %d\n",
407 ph->GetPdg(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit());