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"
40 //________________________________________________
41 AliCaloPID::AliCaloPID() :
42 TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),
43 fEMCALElectronWeight(0.), fEMCALChargeWeight(0.),
44 fEMCALNeutralWeight(0.),
45 fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),
46 fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) ,
47 fPHOSNeutralWeight(0.), fPHOSWeightFormula(0),
48 fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
49 fDispCut(0.),fTOFCut(0.), fDebug(-1)
53 //Initialize parameters
57 //____________________________________________________________________________
58 AliCaloPID::AliCaloPID(const AliCaloPID & pid) :
59 TObject(pid), fEMCALPhotonWeight(pid.fEMCALPhotonWeight),
60 fEMCALPi0Weight(pid.fEMCALPi0Weight),
61 fEMCALElectronWeight(pid.fEMCALElectronWeight),
62 fEMCALChargeWeight(pid.fEMCALChargeWeight),
63 fEMCALNeutralWeight(pid.fEMCALNeutralWeight),
64 fPHOSPhotonWeight(pid.fPHOSPhotonWeight),
65 fPHOSPi0Weight(pid.fPHOSPi0Weight),
66 fPHOSElectronWeight(pid.fPHOSElectronWeight),
67 fPHOSChargeWeight(pid.fPHOSChargeWeight),
68 fPHOSNeutralWeight(pid.fPHOSNeutralWeight),
69 fPHOSWeightFormula(pid.fPHOSWeightFormula),
70 fPHOSPhotonWeightFormula(pid.fPHOSPhotonWeightFormula),
71 fPHOSPi0WeightFormula(pid.fPHOSPi0WeightFormula),
72 fDispCut(pid.fDispCut),fTOFCut(pid.fTOFCut),
79 //_________________________________________________________________________
80 AliCaloPID & AliCaloPID::operator = (const AliCaloPID & pid)
82 // assignment operator
84 if(&pid == this) return *this;
86 fEMCALPhotonWeight = pid. fEMCALPhotonWeight ;
87 fEMCALPi0Weight = pid.fEMCALPi0Weight ;
88 fEMCALElectronWeight = pid.fEMCALElectronWeight;
89 fEMCALChargeWeight = pid.fEMCALChargeWeight;
90 fEMCALNeutralWeight = pid.fEMCALNeutralWeight;
92 fPHOSPhotonWeight = pid.fPHOSPhotonWeight ;
93 fPHOSPi0Weight = pid.fPHOSPi0Weight ;
94 fPHOSElectronWeight = pid.fPHOSElectronWeight;
95 fPHOSChargeWeight = pid.fPHOSChargeWeight;
96 fPHOSNeutralWeight = pid.fPHOSNeutralWeight;
98 fPHOSWeightFormula = pid.fPHOSWeightFormula;
99 fPHOSPhotonWeightFormula = pid.fPHOSPhotonWeightFormula;
100 fPHOSPi0WeightFormula = pid.fPHOSPi0WeightFormula;
102 fDispCut = pid.fDispCut;
103 fTOFCut = pid.fTOFCut;
110 //_________________________________
111 AliCaloPID::~AliCaloPID() {
114 if(fPHOSPhotonWeightFormula) delete fPHOSPhotonWeightFormula ;
115 if(fPHOSPi0WeightFormula) delete fPHOSPi0WeightFormula ;
120 //_______________________________________________________________
121 void AliCaloPID::InitParameters()
123 //Initialize the parameters of the PID.
125 fEMCALPhotonWeight = 0.8 ;
126 fEMCALPi0Weight = 0.5 ;
127 fEMCALElectronWeight = 0.8 ;
128 fEMCALChargeWeight = 0.5 ;
129 fEMCALNeutralWeight = 0.5 ;
131 fPHOSPhotonWeight = 0.75 ;
132 fPHOSPi0Weight = 0.8 ;
133 fPHOSElectronWeight = 0.5 ;
134 fPHOSChargeWeight = 0.5 ;
135 fPHOSNeutralWeight = 0.5 ;
137 //Formula to set the PID weight threshold for photon or pi0
138 fPHOSWeightFormula = kTRUE;
139 fPHOSPhotonWeightFormula =
140 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))");
141 fPHOSPi0WeightFormula =
142 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))");
149 //_______________________________________________________________
150 Int_t AliCaloPID::GetPdg(const TString calo, const Double_t * pid, const Float_t energy) const {
151 //Return most probable identity of the particle.
153 if(!pid) AliFatal("pid pointer not initialized!!!");
155 Float_t wPh = fPHOSPhotonWeight ;
156 Float_t wPi0 = fPHOSPi0Weight ;
157 Float_t wE = fPHOSElectronWeight ;
158 Float_t wCh = fPHOSChargeWeight ;
159 Float_t wNe = fPHOSNeutralWeight ;
162 if(calo == "PHOS" && fPHOSWeightFormula){
163 wPh = fPHOSPhotonWeightFormula->Eval(energy) ;
164 wPi0 = fPHOSPi0WeightFormula->Eval(energy);
169 wPh = fEMCALPhotonWeight ;
170 wPi0 = fEMCALPi0Weight ;
171 wE = fEMCALElectronWeight ;
172 wCh = fEMCALChargeWeight ;
173 wNe = fEMCALNeutralWeight ;
177 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",
178 calo.Data(),pid[AliAODCluster::kPhoton], pid[AliAODCluster::kPi0],
179 pid[AliAODCluster::kElectron], pid[AliAODCluster::kEleCon],
180 pid[AliAODCluster::kPion], pid[AliAODCluster::kKaon], pid[AliAODCluster::kProton],
181 pid[AliAODCluster::kNeutron], pid[AliAODCluster::kKaon0]);
183 Int_t pdg = kNeutralUnknown ;
184 Float_t chargedHadronWeight = pid[AliAODCluster::kProton]+pid[AliAODCluster::kKaon]+
185 pid[AliAODCluster::kPion]+pid[AliAODCluster::kMuon];
186 Float_t neutralHadronWeight = pid[AliAODCluster::kNeutron]+pid[AliAODCluster::kKaon0];
187 Float_t allChargedWeight = pid[AliAODCluster::kElectron]+pid[AliAODCluster::kEleCon]+ chargedHadronWeight;
188 Float_t allNeutralWeight = pid[AliAODCluster::kPhoton]+pid[AliAODCluster::kPi0]+ neutralHadronWeight;
190 //Select most probable ID
192 if(pid[AliAODCluster::kPhoton] > wPh) pdg = kPhoton ;
193 else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ;
194 else if(pid[AliAODCluster::kElectron] > wE) pdg = kElectron ;
195 else if(pid[AliAODCluster::kEleCon] > wE) pdg = kEleCon ;
196 else if(chargedHadronWeight > wCh) pdg = kChargedHadron ;
197 else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ;
198 else if(allChargedWeight > allNeutralWeight)
199 pdg = kChargedUnknown ;
201 pdg = kNeutralUnknown ;
204 if(pid[AliAODCluster::kPhoton] > wPh) pdg = kPhoton ;
205 else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ;
206 else if(pid[AliAODCluster::kElectron] > wE) pdg = kElectron ;
207 else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ;
208 else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ;
209 else pdg = kNeutralUnknown ;
214 if(fDebug > 0)printf("AliCaloPID::GetPdg:Final Pdg: %d \n", pdg);
222 //_______________________________________________________________
223 Int_t AliCaloPID::GetPdg(const TString calo,const TLorentzVector mom, const AliAODCaloCluster * cluster) const {
224 //Recalculated PID with all parameters
225 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",
226 calo.Data(),mom.E(),cluster->GetM02(),cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(),
227 cluster->GetEmcCpvDistance(), cluster->GetDistToBadChannel(),cluster->GetNExMax());
229 if(calo == "EMCAL") {
230 if(cluster->GetM02()< 0.25) return kPhoton ;
231 else return kNeutralHadron ;
234 // if(calo == "PHOS") {
235 // if(cluster->GetM02()< 0.25) return kPhoton ;
236 // else return kNeutralHadron ;
239 return kNeutralHadron ;
243 //__________________________________________________
244 TString AliCaloPID::GetPIDParametersList() {
245 //Put data member values in string to keep in output container
247 TString parList ; //this will be list of parameters used for this analysis.
249 sprintf(onePar,"--- AliCaloPID ---\n") ;
251 sprintf(onePar,"fDispCut =%2.2f (Cut on dispersion, used in PID evaluation) \n",fDispCut) ;
253 sprintf(onePar,"fTOFCut =%e (Cut on TOF, used in PID evaluation) \n",fTOFCut) ;
255 sprintf(onePar,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)\n",fEMCALPhotonWeight) ;
257 sprintf(onePar,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)\n",fEMCALPi0Weight) ;
259 sprintf(onePar,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)\n",fEMCALElectronWeight) ;
261 sprintf(onePar,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)\n",fEMCALChargeWeight) ;
263 sprintf(onePar,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)\n",fEMCALNeutralWeight) ;
265 sprintf(onePar,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)\n",fPHOSPhotonWeight) ;
267 sprintf(onePar,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)\n",fPHOSPi0Weight) ;
269 sprintf(onePar,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)\n",fPHOSElectronWeight) ;
271 sprintf(onePar,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)\n",fPHOSChargeWeight) ;
273 sprintf(onePar,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)\n",fPHOSNeutralWeight) ;
276 if(fPHOSWeightFormula){
277 parList+="PHOS Photon Weight Formula: "+(fPHOSPhotonWeightFormula->GetExpFormula("p"));
278 parList+="PHOS Pi0 Weight Formula: "+(fPHOSPi0WeightFormula->GetExpFormula("p"));
285 //________________________________________________________________
286 void AliCaloPID::Print(const Option_t * opt) const
289 //Print some relevant parameters set for the analysis
293 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
295 printf("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n",
296 fPHOSPhotonWeight, fPHOSPi0Weight,
297 fPHOSElectronWeight, fPHOSChargeWeight, fPHOSNeutralWeight) ;
298 printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n",
299 fEMCALPhotonWeight, fEMCALPi0Weight,
300 fEMCALElectronWeight, fEMCALChargeWeight, fEMCALNeutralWeight) ;
302 printf("PHOS Parametrized weight on? = %d\n", fPHOSWeightFormula) ;
303 if(fPHOSWeightFormula){
304 printf("Photon weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
305 printf("Pi0 weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
308 printf("TOF cut = %e\n",fTOFCut);
309 printf("Dispersion cut = %2.2f\n",fDispCut);
310 printf("Debug level = %d\n",fDebug);
316 //_______________________________________________________________
317 void AliCaloPID::SetPIDBits(const TString calo, const AliAODCaloCluster * cluster, AliAODPWG4Particle * ph) {
318 //Set Bits for PID selection
321 Double_t disp=cluster->GetDispersion() ;
322 // Double_t m20=calo->GetM20() ;
323 // Double_t m02=calo->GetM02() ;
324 ph->SetDispBit(disp<fDispCut) ;
327 Double_t tof=cluster->GetTOF() ;
328 ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ;
331 // Double_t cpvR=calo->GetEmcCpvDistance() ;
332 Int_t ntr=cluster->GetNTracksMatched(); //number of track matched
333 ph->SetChargedBit(ntr>0) ; //Temporary cut, should we evaluate distance?
336 ph->SetPdg(GetPdg(calo,cluster->PID(),ph->E()));
339 printf("AliCaloPID::SetPIDBits: TOF %e, Dispersion %2.2f, NTracks %d\n",tof , disp, ntr);
340 printf("AliCaloPID::SetPIDBits: pdg %d, bits: TOF %d, Dispersion %d, Charge %d\n",
341 ph->GetPdg(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit());