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