]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEpidTOF.cxx
Commit modifications done to take care of the problems
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEpidTOF.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 //
16 // Class for TOF PID
17 // Implements the abstract base class AliHFEpidBase
18 // IsInitialized() does the PID decision
19 // 
20 // Authors:
21 //   Markus Fasel  <M.Fasel@gsi.de>
22 //   Matus Kalisky <matus.kalisky@cern.ch>  (contact)
23 //
24
25 #include <TMath.h>
26
27 #include "AliAODpidUtil.h"
28 #include "AliAODTrack.h"
29 #include "AliESDpid.h"
30 #include "AliESDtrack.h"
31 #include "AliPID.h"
32
33 #include "AliHFEdetPIDqa.h"
34 #include "AliHFEpidTOF.h"
35 #include "AliHFEpidQAmanager.h"
36
37
38 ClassImp(AliHFEpidTOF)
39
40 //___________________________________________________________________
41 AliHFEpidTOF::AliHFEpidTOF():
42   AliHFEpidBase()
43   , fPID(NULL)
44   , fNsigmaTOF(3)
45 {
46   //
47   // Constructor
48   //
49
50
51 //___________________________________________________________________
52 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
53   AliHFEpidBase(name)
54   , fPID(NULL)
55   , fNsigmaTOF(3)
56 {
57   //
58   // Constructor
59   //
60 }
61
62 //___________________________________________________________________
63 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
64   AliHFEpidBase("")
65   , fPID(NULL)
66   , fNsigmaTOF(3)
67 {  
68   // 
69   // Copy operator
70   //
71
72   c.Copy(*this);
73 }
74 //___________________________________________________________________
75 AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){
76   //
77   // Assignment operator
78   //
79
80   if(this != &ref){
81     ref.Copy(*this);
82   }
83
84   return *this;
85 }
86 //___________________________________________________________________
87 AliHFEpidTOF::~AliHFEpidTOF(){
88   //
89   // Destructor
90   //
91   if(fPID) delete fPID;
92 }
93 //___________________________________________________________________
94 void AliHFEpidTOF::Copy(TObject &ref) const {
95   //
96   // Performs the copying of the object
97   //
98   AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
99
100   target.fPID = fPID;          
101   target.fNsigmaTOF = fNsigmaTOF;
102
103   AliHFEpidBase::Copy(ref);
104 }
105 //___________________________________________________________________
106 Bool_t AliHFEpidTOF::InitializePID(){
107   //
108   // InitializePID: TOF experts have to implement code here
109   //
110   return kTRUE;
111 }
112
113 //___________________________________________________________________
114 Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const
115 {
116   //
117   // TOF PID based on n-Sigma cut
118   // Selects Protons and Kaons via n-sigma cut up to 3 GeV/c
119   // In addition histos for n-sigma before (all species) and after (only closest species) are filled
120   //
121   if((!fESDpid && track->IsESDanalysis()) || (!fAODpid && track->IsAODanalysis())) return 0;
122   AliDebug(2, "PID object available");
123
124   AliHFEpidObject::AnalysisType_t anaType = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
125   const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
126   if(!(vtrack && vtrack->GetStatus() & AliESDtrack::kTOFpid)) return 0;
127   AliDebug(2, "Track Has TOF PID");
128
129   if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
130
131   // Fill before selection
132   Double_t sigEle = NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anaType);
133   AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle));
134   Int_t pdg = 0;
135   if(TMath::Abs(sigEle) < fNsigmaTOF){
136     pdg = 11;
137     if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID);
138   }
139  
140   return pdg;
141 }
142
143 /////////////////////////////////////////////////////////
144 //
145 // Wrappers for functions which are not virtual but
146 // only available for ESD and AOD case separately
147 //
148 /////////////////////////////////////////////////////////
149
150 //___________________________________________________________________
151 Double_t AliHFEpidTOF::NumberOfSigmas(const AliVParticle *track, AliPID::EParticleType species, AliHFEpidObject::AnalysisType_t anaType) const {
152   //    
153   // Get the number of sigmas
154   //
155   Double_t nSigmas = 100;
156   if(anaType == AliHFEpidObject::kESDanalysis){
157     // ESD analysis
158     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
159     if(esdtrack && fESDpid) nSigmas = fESDpid->NumberOfSigmasTOF(esdtrack, species, fESDpid->GetTOFResponse().GetStartTime(track->P()));
160   } else {
161     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
162     if(aodtrack && fAODpid) nSigmas = fAODpid->NumberOfSigmasTOF(aodtrack, species);
163   }
164   return nSigmas;
165 }
166
167 //___________________________________________________________________
168 Double_t AliHFEpidTOF::GetTOFsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype) const{
169   //
170   // Get the TOF signal
171   //
172   Double_t tofSignal = 0.;
173   if(anatype == AliHFEpidObject::kESDanalysis){
174     // ESD analysis
175     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
176     if(esdtrack) tofSignal = esdtrack->GetTOFsignal();
177   } else {
178     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
179     if(aodtrack) tofSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTOFsignal() : 0.;
180   }
181   return tofSignal;
182 }
183
184 //___________________________________________________________________
185 Double_t AliHFEpidTOF::GetTime0(AliHFEpidObject::AnalysisType_t anatype) const{
186   //
187   // Get Time0
188   //
189   Double_t time0 = 0.;
190   if(anatype == AliHFEpidObject::kESDanalysis){
191     time0 = fESDpid->GetTOFResponse().GetTimeZero();
192   }else {
193     time0 = fAODpid->GetTOFResponse().GetTimeZero();
194   }
195   return time0;
196 }
197
198 //___________________________________________________________________
199 void AliHFEpidTOF::GetIntegratedTimes(const AliVParticle *track, Double_t *times, AliHFEpidObject::AnalysisType_t anatype) const{
200   //
201   // Return integrated times
202   //
203   if(anatype == AliHFEpidObject::kESDanalysis){
204     // ESD analysis
205     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
206     if(esdtrack) esdtrack->GetIntegratedTimes(times);
207   } else {
208     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
209     if(aodtrack) aodtrack->GetDetPid()->GetIntegratedTimes(times);
210   }
211
212 }
213