]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliHFEpidTOF.cxx
Various updates, including corrections for code rule violations
[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   if(!((dynamic_cast<const AliVTrack *>(track->GetRecTrack()))->GetStatus() & AliESDtrack::kTOFpid)) return 0;
126   AliDebug(2, "Track Has TOF PID");
127
128   if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
129
130   // Fill before selection
131   Double_t sigEle = NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anaType);
132   AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle));
133   Int_t pdg = 0;
134   if(TMath::Abs(sigEle) < fNsigmaTOF){
135     pdg = 11;
136     if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID);
137   }
138  
139   return pdg;
140 }
141
142 /////////////////////////////////////////////////////////
143 //
144 // Wrappers for functions which are not virtual but
145 // only available for ESD and AOD case separately
146 //
147 /////////////////////////////////////////////////////////
148
149 //___________________________________________________________________
150 Double_t AliHFEpidTOF::NumberOfSigmas(const AliVParticle *track, AliPID::EParticleType species, AliHFEpidObject::AnalysisType_t anaType) const {
151   //    
152   // Get the number of sigmas
153   //
154   Double_t nSigmas = 100;
155   if(anaType == AliHFEpidObject::kESDanalysis){
156     // ESD analysis
157     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
158     if(esdtrack && fESDpid) nSigmas = fESDpid->NumberOfSigmasTOF(esdtrack, species, fESDpid->GetTOFResponse().GetTimeZero());
159   } else {
160     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
161     if(aodtrack && fAODpid) nSigmas = fAODpid->NumberOfSigmasTOF(aodtrack, species);
162   }
163   return nSigmas;
164 }
165
166 //___________________________________________________________________
167 Double_t AliHFEpidTOF::GetTOFsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype) const{
168   //
169   // Get the TOF signal
170   //
171   Double_t tofSignal = 0.;
172   if(anatype == AliHFEpidObject::kESDanalysis){
173     // ESD analysis
174     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
175     tofSignal = esdtrack->GetTOFsignal();
176   } else {
177     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
178     tofSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTOFsignal() : 0.;
179   }
180   return tofSignal;
181 }
182
183 //___________________________________________________________________
184 Double_t AliHFEpidTOF::GetTime0(AliHFEpidObject::AnalysisType_t anatype) const{
185   //
186   // Get Time0
187   //
188   Double_t time0 = 0.;
189   if(anatype == AliHFEpidObject::kESDanalysis){
190     time0 = fESDpid->GetTOFResponse().GetTimeZero();
191   }else {
192     time0 = fAODpid->GetTOFResponse().GetTimeZero();
193   }
194   return time0;
195 }
196
197 //___________________________________________________________________
198 void AliHFEpidTOF::GetIntegratedTimes(const AliVParticle *track, Double_t *times, AliHFEpidObject::AnalysisType_t anatype) const{
199   //
200   // Return integrated times
201   //
202   if(anatype == AliHFEpidObject::kESDanalysis){
203     // ESD analysis
204     const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
205     esdtrack->GetIntegratedTimes(times);
206   } else {
207     const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
208     aodtrack->GetDetPid()->GetIntegratedTimes(times);
209   }
210
211 }
212