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
18 // IsInitialized() does the PID decision
21 // Markus Fasel <M.Fasel@gsi.de>
22 // Matus Kalisky <matus.kalisky@cern.ch> (contact)
29 #include "AliAODTrack.h"
30 #include "AliAODMCParticle.h"
31 #include "AliESDtrack.h"
33 #include "AliMCParticle.h"
35 #include "AliESDpid.h"
37 #include "AliHFEpidTOF.h"
38 #include "AliHFEpidBase.h"
41 ClassImp(AliHFEpidTOF)
43 //___________________________________________________________________
44 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
55 fESDpid = new AliESDpid;
58 //___________________________________________________________________
59 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
72 //___________________________________________________________________
73 AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){
75 // Assignment operator
84 //___________________________________________________________________
85 AliHFEpidTOF::~AliHFEpidTOF(){
90 if(fESDpid) delete fESDpid;
96 //___________________________________________________________________
97 void AliHFEpidTOF::Copy(TObject &ref) const {
99 // Performs the copying of the object
101 AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
104 target.fQAList = fQAList;
105 target.fESDpid = new AliESDpid(*fESDpid);
107 AliHFEpidBase::Copy(ref);
109 //___________________________________________________________________
110 Bool_t AliHFEpidTOF::InitializePID(){
112 // InitializePID: TOF experts have to implement code here
117 //___________________________________________________________________
118 Int_t AliHFEpidTOF::IsSelected(AliHFEpidObject *vtrack)
122 // as of 22/05/2006 :
123 // returns AliPID based on the ESD TOF PID decision
124 // the ESD PID will be checked and if necessary improved
125 // in the mean time. Best of luck
127 // returns 10 (== kUnknown)if PID can not be assigned for whatever reason
130 if(vtrack->fAnalysisType == AliHFEpidObject::kESDanalysis){
131 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack *>(vtrack->fRecTrack);
132 if(!esdTrack) return 0;
133 AliMCParticle *mcTrack = dynamic_cast<AliMCParticle *>(vtrack->fMCtrack);
134 return MakePIDesd(esdTrack, mcTrack);
136 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack *>(vtrack->fRecTrack);
137 if(!aodTrack) return 0;
138 AliAODMCParticle *aodmc = dynamic_cast<AliAODMCParticle *>(vtrack->fMCtrack);
139 return MakePIDaod(aodTrack, aodmc);
143 //___________________________________________________________________
144 Int_t AliHFEpidTOF::MakePIDesd(AliESDtrack *track, AliMCParticle * /*mcTrack*/){
146 // Does particle identification as discribed in IsSelected
149 status = track->GetStatus();
151 if(!(status & AliESDtrack::kTOFout)) return 0;
153 if(IsQAon())(dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(0.);
155 Double_t tItrackL = track->GetIntegratedLength();
156 Double_t tTOFsignal = track->GetTOFsignal();
160 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(1.);
163 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(2.);
167 if(tItrackL <=0 || tTOFsignal <=0) return 0;
170 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(3.);
171 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFsignal)))->Fill(tTOFsignal/1000.);
172 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFlength)))->Fill(tItrackL);
174 // get the TOF pid probabilities
175 Double_t tESDpid[5] = {0., 0., 0., 0., 0.};
176 Float_t tTOFpidSum = 0.;
177 // find the largest PID probability
178 track->GetTOFpid(tESDpid);
179 Double_t tMAXpid = 0.;
180 Int_t tMAXindex = -1;
181 for(Int_t i=0; i<5; ++i){
182 tTOFpidSum += tESDpid[i];
183 if(tESDpid[i] > tMAXpid){
184 tMAXpid = tESDpid[i];
192 case 0: pdg = 11; break;
193 case 1: pdg = 13; break;
194 case 2: pdg = 211; break;
195 case 3: pdg = 321; break;
196 case 4: pdg = 2212; break;
201 Double_t p = track->GetOuterParam()->P();
202 Double_t beta = (tItrackL/100.)/(TMath::C()*(tTOFsignal/1e12));
204 // sanity check, should not be necessary
205 if(TMath::Abs(tTOFpidSum - 1) > 0.01) return 0;
207 Double_t nSigmas = fESDpid->NumberOfSigmasTOF(track, (AliPID::EParticleType)tMAXindex, 0.);
208 if(TMath::Abs(nSigmas) > fNsigmaTOF) return 0;
211 // should be the same as AliPID flags
214 (dynamic_cast<TH2F *>(fQAList->At(kHistTOFpid0+tMAXindex)))->Fill(beta, p);
215 (dynamic_cast<TH2F *>(fQAList->At(kHistTOFpidBetavP)))->Fill(beta, p);
221 //___________________________________________________________________
222 Double_t AliHFEpidTOF::Likelihood(const AliESDtrack *track, Int_t species, Float_t rsig){
224 //gives probability for track to come from a certain particle species;
225 //no priors considered -> probabilities for equal abundances of all species!
226 //optional restriction to r-sigma bands of different particle species; default: rsig = 2. (see below)
228 //IMPORTANT: Tracks which are judged to be outliers get negative likelihoods -> unusable for combination with further detectors!
230 if(!track) return -1.;
231 Bool_t outlier = kTRUE;
232 // Check whether distance from the respective particle line is smaller than r sigma
233 for(Int_t hypo = 0; hypo < AliPID::kSPECIES; hypo++){
234 if(TMath::Abs(fESDpid->NumberOfSigmasTOF(track, (AliPID::EParticleType)hypo, 0.)) > rsig)
246 track->GetTOFpid(tofProb);
248 return tofProb[species];
250 //___________________________________________________________________
251 Int_t AliHFEpidTOF::MakePIDaod(AliAODTrack * /*aodTrack*/, AliAODMCParticle * /*mcTrack*/){
252 AliError("AOD PID not yet implemented");
256 //___________________________________________________________________
257 void AliHFEpidTOF::AddQAhistograms(TList *qaList){
259 // Create QA histograms for TOF PID
263 fQAList->SetName("fTOFqaHistos");
264 fQAList->AddAt(new TH1F("hTOF_flags", "TOF flags;flags (see code for info);counts", 10, -0.25, 4.75), kHistTOFpidFlags);
265 fQAList->AddAt(new TH2F("fTOFbeta_v_P_no","beta -v- P; beta;momentum [GeV/c]", 120, 0, 1.2, 200, 0, 20), kHistTOFpidBetavP);
266 fQAList->AddAt(new TH1F("hTOF_signal", "TOF signal; TOF signal [ns];counts", 1000, 12, 50), kHistTOFsignal);
267 fQAList->AddAt(new TH1F("hTOF_length", "TOF track length; length [cm];counts", 400, 300, 700), kHistTOFlength);
268 fQAList->AddAt(new TH2F("hTOFpid_electron", "TOF reco electron; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid0);
269 fQAList->AddAt(new TH2F("hTOFpid_muon", "TOF reco muon; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid1);
270 fQAList->AddAt(new TH2F("hTOFpid_pion", "TOF reco pion; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid2);
271 fQAList->AddAt(new TH2F("hTOFpid_kaon", "TOF reco kaon; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid3);
272 fQAList->AddAt(new TH2F("hTOFpid_proton", "TOF reco proton; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid4);
274 qaList->AddLast(fQAList);