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 Float_t timeZeroTOF = 0; // Need to get TimeZero first!
153 if(!(status & AliESDtrack::kTOFout)) return 0;
155 if(IsQAon())(dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(0.);
157 Double_t tItrackL = track->GetIntegratedLength();
158 Double_t tTOFsignal = track->GetTOFsignal();
162 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(1.);
165 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(2.);
169 if(tItrackL <=0 || tTOFsignal <=0) return 0;
172 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFpidFlags)))->Fill(3.);
173 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFsignal)))->Fill(tTOFsignal/1000.);
174 (dynamic_cast<TH1F *>(fQAList->At(kHistTOFlength)))->Fill(tItrackL);
176 // get the TOF pid probabilities
177 Double_t tESDpid[5] = {0., 0., 0., 0., 0.};
178 Float_t tTOFpidSum = 0.;
179 // find the largest PID probability
180 track->GetTOFpid(tESDpid);
181 Double_t tMAXpid = 0.;
182 Int_t tMAXindex = -1;
183 for(Int_t i=0; i<5; ++i){
184 tTOFpidSum += tESDpid[i];
185 if(tESDpid[i] > tMAXpid){
186 tMAXpid = tESDpid[i];
194 case 0: pdg = 11; break;
195 case 1: pdg = 13; break;
196 case 2: pdg = 211; break;
197 case 3: pdg = 321; break;
198 case 4: pdg = 2212; break;
203 Double_t p = track->GetOuterParam()->P();
204 Double_t beta = (tItrackL/100.)/(TMath::C()*(tTOFsignal/1e12));
206 // sanity check, should not be necessary
207 if(TMath::Abs(tTOFpidSum - 1) > 0.01) return 0;
209 Double_t nSigmas = fESDpid->NumberOfSigmasTOF(track, (AliPID::EParticleType)tMAXindex,timeZeroTOF);
210 if(TMath::Abs(nSigmas) > fNsigmaTOF) return 0;
213 // should be the same as AliPID flags
216 (dynamic_cast<TH2F *>(fQAList->At(kHistTOFpid0+tMAXindex)))->Fill(beta, p);
217 (dynamic_cast<TH2F *>(fQAList->At(kHistTOFpidBetavP)))->Fill(beta, p);
223 //___________________________________________________________________
224 Double_t AliHFEpidTOF::Likelihood(const AliESDtrack *track, Int_t species, Float_t rsig){
226 //gives probability for track to come from a certain particle species;
227 //no priors considered -> probabilities for equal abundances of all species!
228 //optional restriction to r-sigma bands of different particle species; default: rsig = 2. (see below)
230 //IMPORTANT: Tracks which are judged to be outliers get negative likelihoods -> unusable for combination with further detectors!
232 Float_t timeZeroTOF = 0; // Need to get timeZero first !
233 if(!track) return -1.;
234 Bool_t outlier = kTRUE;
235 // Check whether distance from the respective particle line is smaller than r sigma
236 for(Int_t hypo = 0; hypo < AliPID::kSPECIES; hypo++){
237 if(TMath::Abs(fESDpid->NumberOfSigmasTOF(track, (AliPID::EParticleType)hypo, timeZeroTOF)) > rsig)
249 track->GetTOFpid(tofProb);
251 return tofProb[species];
253 //___________________________________________________________________
254 Int_t AliHFEpidTOF::MakePIDaod(AliAODTrack * /*aodTrack*/, AliAODMCParticle * /*mcTrack*/){
255 AliError("AOD PID not yet implemented");
259 //___________________________________________________________________
260 void AliHFEpidTOF::AddQAhistograms(TList *qaList){
262 // Create QA histograms for TOF PID
266 fQAList->SetName("fTOFqaHistos");
267 fQAList->AddAt(new TH1F("hTOF_flags", "TOF flags;flags (see code for info);counts", 10, -0.25, 4.75), kHistTOFpidFlags);
268 fQAList->AddAt(new TH2F("fTOFbeta_v_P_no","beta -v- P; beta;momentum [GeV/c]", 120, 0, 1.2, 200, 0, 20), kHistTOFpidBetavP);
269 fQAList->AddAt(new TH1F("hTOF_signal", "TOF signal; TOF signal [ns];counts", 1000, 12, 50), kHistTOFsignal);
270 fQAList->AddAt(new TH1F("hTOF_length", "TOF track length; length [cm];counts", 400, 300, 700), kHistTOFlength);
271 fQAList->AddAt(new TH2F("hTOFpid_electron", "TOF reco electron; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid0);
272 fQAList->AddAt(new TH2F("hTOFpid_muon", "TOF reco muon; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid1);
273 fQAList->AddAt(new TH2F("hTOFpid_pion", "TOF reco pion; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid2);
274 fQAList->AddAt(new TH2F("hTOFpid_kaon", "TOF reco kaon; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid3);
275 fQAList->AddAt(new TH2F("hTOFpid_proton", "TOF reco proton; beta ; momentum [GeV/c]", 120, 0, 1.2, 200, 0, 5), kHistTOFpid4);
277 qaList->AddLast(fQAList);