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 **************************************************************************/
17 // Implements the abstract base class AliHFEpidBase
19 // Class contains TPC specific cuts and QA histograms
20 // Two selection strategies are offered: Selection of certain value
21 // regions in the TPC dE/dx (by IsSelected), and likelihoods
25 // Markus Fasel <M.Fasel@gsi.de>
26 // Markus Heide <mheide@uni-muenster.de>
31 #include "AliAODpidUtil.h"
32 #include "AliAODPid.h"
33 #include "AliAODTrack.h"
34 #include "AliAODMCParticle.h"
35 #include "AliESDtrack.h"
36 #include "AliExternalTrackParam.h"
38 #include "AliMCParticle.h"
40 #include "AliESDpid.h"
42 #include "AliHFEpidTPC.h"
43 #include "AliHFEpidQAmanager.h"
45 ClassImp(AliHFEpidTPC)
47 //___________________________________________________________________
48 AliHFEpidTPC::AliHFEpidTPC() :
51 , fLineCrossingsEnabled(0)
52 , fUpperSigmaCut(NULL)
53 , fLowerSigmaCut(NULL)
54 , fElectronMeanCorrection(NULL)
56 , fRejectionEnabled(0)
60 // default constructor
62 memset(fRejection, 0, sizeof(Float_t) * 4 * AliPID::kSPECIES);
63 memset(fLineCrossingSigma, 0, sizeof(Double_t) * AliPID::kSPECIES);
64 memset(fPAsigCut, 0, sizeof(Float_t) * 2);
65 memset(fNAsigmaTPC, 0, sizeof(Float_t) * 2);
69 //___________________________________________________________________
70 AliHFEpidTPC::AliHFEpidTPC(const char* name) :
73 , fLineCrossingsEnabled(0)
74 , fUpperSigmaCut(NULL)
75 , fLowerSigmaCut(NULL)
76 , fElectronMeanCorrection(NULL)
78 , fRejectionEnabled(0)
82 // default constructor
85 memset(fRejection, 0, sizeof(Float_t) * 4 * AliPID::kSPECIES);
86 memset(fLineCrossingSigma, 0, sizeof(Double_t) * AliPID::kSPECIES);
87 memset(fPAsigCut, 0, sizeof(Float_t) * 2);
88 memset(fNAsigmaTPC, 0, sizeof(Float_t) * 2);
92 //___________________________________________________________________
93 AliHFEpidTPC::AliHFEpidTPC(const AliHFEpidTPC &ref) :
95 , fLineCrossingsEnabled(0)
96 , fUpperSigmaCut(NULL)
97 , fLowerSigmaCut(NULL)
98 , fElectronMeanCorrection(NULL)
100 , fRejectionEnabled(0)
109 //___________________________________________________________________
110 AliHFEpidTPC &AliHFEpidTPC::operator=(const AliHFEpidTPC &ref){
112 // Assignment operator
119 //___________________________________________________________________
120 void AliHFEpidTPC::Copy(TObject &o) const{
123 // called in copy constructor and assigment operator
125 AliHFEpidTPC &target = dynamic_cast<AliHFEpidTPC &>(o);
127 target.fLineCrossingsEnabled = fLineCrossingsEnabled;
128 target.fUpperSigmaCut = fUpperSigmaCut;
129 target.fLowerSigmaCut = fLowerSigmaCut;
130 target.fElectronMeanCorrection = fElectronMeanCorrection;
131 target.fNsigmaTPC = fNsigmaTPC;
132 target.fRejectionEnabled = fRejectionEnabled;
133 target.fPID = new AliPID(*fPID);
134 memcpy(target.fLineCrossingSigma, fLineCrossingSigma, sizeof(Double_t) * AliPID::kSPECIES);
135 memcpy(target.fPAsigCut, fPAsigCut, sizeof(Float_t) * 2);
136 memcpy(target.fNAsigmaTPC, fNAsigmaTPC, sizeof(Float_t) * 2);
138 AliHFEpidBase::Copy(target);
141 //___________________________________________________________________
142 AliHFEpidTPC::~AliHFEpidTPC(){
146 if(fPID) delete fPID;
149 //___________________________________________________________________
150 Bool_t AliHFEpidTPC::InitializePID(){
152 // Add TPC dE/dx Line crossings
154 //AddTPCdEdxLineCrossing(AliPID::kKaon, 0.3, 0.018);
155 //AddTPCdEdxLineCrossing(AliPID::kProton, 0.9, 0.054);
159 //___________________________________________________________________
160 Int_t AliHFEpidTPC::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const
163 // For the TPC pid we use the 2-sigma band around the bethe bloch curve
165 // exclusion of the crossing points
168 if((!fESDpid && track->IsESDanalysis()) || (!fAODpid && track->IsAODanalysis())) return 0;
170 // QA before selection
171 if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTPCpid, AliHFEdetPIDqa::kBeforePID);
172 AliDebug(1, "Doing TPC PID based on n-Sigma cut approach");
173 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
174 Float_t nsigma = NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype);
175 AliDebug(1, Form("TPC NSigma: %f", nsigma));
176 // exclude crossing points:
177 // Determine the bethe values for each particle species
178 Bool_t isLineCrossing = kFALSE;
179 for(Int_t ispecies = 0; ispecies < AliPID::kSPECIES; ispecies++){
180 if(ispecies == AliPID::kElectron) continue;
181 if(!(fLineCrossingsEnabled & 1 << ispecies)) continue;
182 if(TMath::Abs(NumberOfSigmas(track->GetRecTrack(), (AliPID::EParticleType)ispecies, anatype)) < fLineCrossingSigma[ispecies] && TMath::Abs(nsigma) < fNsigmaTPC){
183 // Point in a line crossing region, no PID possible, but !PID still possible ;-)
184 isLineCrossing = kTRUE;
188 if(isLineCrossing) return 0;
190 // Check particle rejection
191 if(HasParticleRejection()){
192 Int_t reject = Reject(track->GetRecTrack(), anatype);
193 if(reject != 0) return reject;
196 // Check if we have an asymmetric sigma model set
198 if(fUpperSigmaCut || fLowerSigmaCut){
199 pdg = CutSigmaModel(track->GetRecTrack(), anatype) ? 11 : 0;
201 // Perform Asymmetric n-sigma cut if required, else perform symmetric TPC sigma cut
203 if(HasAsymmetricSigmaCut() && (p = track->GetRecTrack()->P()) >= fPAsigCut[0] && p <= fPAsigCut[1]){
204 if(nsigma >= fNAsigmaTPC[0] && nsigma <= fNAsigmaTPC[1]) pdg = 11;
206 if(TMath::Abs(nsigma) < fNsigmaTPC ) pdg = 11;
209 if(pidqa && pdg != 0) pidqa->ProcessTrack(track, AliHFEpid::kTPCpid, AliHFEdetPIDqa::kAfterPID);
214 //___________________________________________________________________
215 Bool_t AliHFEpidTPC::CutSigmaModel(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anaType) const {
217 // N SigmaCut using parametrization of the cuts
219 Bool_t isSelected = kTRUE;
220 Float_t nsigma = NumberOfSigmas(track, AliPID::kElectron, anaType);
221 Double_t p = GetP(track, anaType);
222 if(fUpperSigmaCut && nsigma > fUpperSigmaCut->Eval(p)) isSelected = kFALSE;
223 if(fLowerSigmaCut && nsigma < fLowerSigmaCut->Eval(p)) isSelected = kFALSE;
227 //___________________________________________________________________
228 Int_t AliHFEpidTPC::Reject(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anaType) const{
230 // reject particles based on asymmetric sigma cut
232 Int_t pdc[AliPID::kSPECIES] = {11,13,211,321,2212};
233 Double_t p = GetP(track, anaType);
234 for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++){
235 if(!TESTBIT(fRejectionEnabled, ispec)) continue;
236 // Particle rejection enabled
237 if(p < fRejection[4*ispec] || p > fRejection[4*ispec+2]) continue;
238 Double_t sigma = NumberOfSigmas(track, static_cast<AliPID::EParticleType>(ispec), anaType);
239 if(sigma >= fRejection[4*ispec+1] && sigma <= fRejection[4*ispec+3]) return pdc[ispec] * track->Charge();
244 //___________________________________________________________________
245 void AliHFEpidTPC::AddTPCdEdxLineCrossing(Int_t species, Double_t sigma){
247 // Add exclusion point for the TPC PID where a dEdx line crosses the electron line
248 // Stores line center and line sigma
250 if(species >= AliPID::kSPECIES){
251 AliError("Species doesn't exist");
254 fLineCrossingsEnabled |= 1 << species;
255 fLineCrossingSigma[species] = sigma;
258 //___________________________________________________________________
259 Double_t AliHFEpidTPC::NumberOfSigmas(const AliVParticle *track, AliPID::EParticleType species, AliHFEpidObject::AnalysisType_t anaType) const {
261 // Get the number of sigmas
263 Double_t nSigmas = 100;
264 if(anaType == AliHFEpidObject::kESDanalysis){
266 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
267 if(esdtrack && fESDpid) nSigmas = fESDpid->NumberOfSigmasTPC(esdtrack, species);
269 const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
270 if(aodtrack && fAODpid) nSigmas = fAODpid->NumberOfSigmasTPC(aodtrack, species);
272 // Correct for the mean o
273 if(fElectronMeanCorrection)
274 nSigmas -= fElectronMeanCorrection->Eval(GetP(track, anaType));
278 //___________________________________________________________________
279 Double_t AliHFEpidTPC::GetP(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype) const {
281 // Get the momentum at the inner wall of the TPC
284 if(anatype == AliHFEpidObject::kESDanalysis){
285 // ESD analysis: Use Inner Params for the momentum estimate
286 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
287 if(esdtrack) p = esdtrack->GetInnerParam() ? esdtrack->GetInnerParam()->GetP() : esdtrack->P();
289 // AOD analysis: Use TPC momentum stored in the AliAODpid object
290 const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
291 if(aodtrack) p = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTPCmomentum() : aodtrack->P();