]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPIDTOF.cxx
add possibility to smear cluster energy, only for MC, some stetic changes in header...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDTOF.cxx
CommitLineData
35e49ca5 1//
2// Class AliRsnCutPIDTOF
3//
80e49c8b 4// Implements the PID check with TOF detector,
5// computed as a compatibility within a given range
6// expressed in number of sigmas w.r. to expected time.
7// Uses the default cut checking facilities of AliRsnCut
8// to check this.
35e49ca5 9//
10// authors: Martin Vala (martin.vala@cern.ch)
11// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
12//
13
223b8750 14#include "AliAnalysisManager.h"
15#include "AliESDInputHandler.h"
16
35e49ca5 17#include "AliRsnCutPIDTOF.h"
18
19ClassImp(AliRsnCutPIDTOF)
20
35e49ca5 21//_________________________________________________________________________________________________
80e49c8b 22AliRsnCutPIDTOF::AliRsnCutPIDTOF
23(const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) :
35e49ca5 24 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
223b8750 25 fInitialized(kFALSE),
80e49c8b 26 fRejectUnmatched(rejectUnmatched),
27 fRefType(AliPID::kUnknown),
28 fRefMass(0.0),
35e49ca5 29 fESDpid(),
30 fAODpid()
31{
32//
33// Default constructor.
80e49c8b 34// To set the reference PID type, calls the SetRefType method,
35// which sets the mass accordingly and coherently.
35e49ca5 36//
80e49c8b 37
38 SetRefType(ref);
35e49ca5 39}
40
41//_________________________________________________________________________________________________
42AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) :
43 AliRsnCut(copy),
223b8750 44 fInitialized(kFALSE),
80e49c8b 45 fRejectUnmatched(copy.fRejectUnmatched),
46 fRefType(AliPID::kUnknown),
47 fRefMass(0.0),
35e49ca5 48 fESDpid(copy.fESDpid),
49 fAODpid(copy.fAODpid)
50{
51//
80e49c8b 52// Copy constructor.
53// To set the reference PID type, calls the SetRefType method,
54// which sets the mass accordingly and coherently.
35e49ca5 55//
80e49c8b 56
57 SetRefType(copy.fRefType);
35e49ca5 58}
59
60//_________________________________________________________________________________________________
61AliRsnCutPIDTOF& AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF& copy)
62{
63//
80e49c8b 64// Assignment operator.
65// To set the reference PID type, calls the SetRefType method,
66// which sets the mass accordingly and coherently.
35e49ca5 67//
68
223b8750 69 fInitialized = kFALSE;
80e49c8b 70 fRejectUnmatched = copy.fRejectUnmatched;
223b8750 71 fESDpid = copy.fESDpid;
72 fAODpid = copy.fAODpid;
80e49c8b 73
74 SetRefType(copy.fRefType);
35e49ca5 75
76 return (*this);
77}
78
79//_________________________________________________________________________________________________
80Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
81{
82//
83// Cut checker.
84//
85
223b8750 86 // initialize if needed
87 if (!fInitialized) Initialize();
88
35e49ca5 89 // coherence check
90 if (!TargetOK(object)) return kFALSE;
91
659ef4f0 92 // reject always non-track objects
35e49ca5 93 AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
94 if (!vtrack)
95 {
80e49c8b 96 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
35e49ca5 97 return kFALSE;
98 }
659ef4f0 99
80e49c8b 100 // checks that track is matched in TOF:
101 // if not, the track is accepted or rejected
102 // depending on the 'fRejectUnmatched' data member:
103 // -- kTRUE --> all unmatched tracks are rejected
104 // -- kFALSE --> all unmatched tracks are accepted (it is assumed that other PIDs are done)
105 if (!IsMatched(vtrack))
35e49ca5 106 {
107 AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF");
80e49c8b 108 return (!fRejectUnmatched);
35e49ca5 109 }
110
80e49c8b 111 // retrieve real object type and
112 // prepare some useful variables
113 Double_t tof, sigma, times[5];
114 Double_t &ref = times[(Int_t)fRefType];
35e49ca5 115 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
116 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
80e49c8b 117
118 // cut check depends on the object type
35e49ca5 119 if (esdTrack)
120 {
80e49c8b 121 // setup the ESD PID object
122 AliESDEvent *esd = AliRsnTarget::GetCurrentEvent()->GetRefESD();
123 if (!esd)
124 {
125 AliError("Processing an ESD track, but target is not an ESD event");
126 return kFALSE;
127 }
128 fESDpid.SetTOFResponse(esd, AliESDpid::kTOF_T0);
129
130 // get time of flight, reference times and sigma
131 esdTrack->GetIntegratedTimes(times);
132 tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid.GetTOFResponse().GetStartTime(esdTrack->P()));
133 sigma = (Double_t)fESDpid.GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass);
134
135 // port values to standard AliRsnCut checker
136 fCutValueD = (tof - ref) / sigma;
137 return OkRangeD();
35e49ca5 138 }
139 else if (aodTrack)
140 {
80e49c8b 141 // for AOD tracks, all operations are done by the AOD PID utility
142 fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(aodTrack, fRefType);
143 return OkRangeD();
35e49ca5 144 }
145 else
146 {
80e49c8b 147 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
35e49ca5 148 return kFALSE;
149 }
150}
151
a909ffad 152//_________________________________________________________________________________________________
153void AliRsnCutPIDTOF::Print(const Option_t *) const
154{
155//
156// Print information on this cut
157//
158
159 AliInfo(Form("Cut name, type : %s %s", GetName(), ClassName()));
160 AliInfo(Form("TOF PID cut range (sigmas): %.3f %.3f", fMinD, fMaxD));
80e49c8b 161 AliInfo(Form("Unmatched tracks are : %s", (fRejectUnmatched ? "rejected" : "accepted")));
a909ffad 162}
223b8750 163
164//_________________________________________________________________________________________________
165void AliRsnCutPIDTOF::Initialize()
166{
167//
168// Initialize ESD pid object from global one
169//
170
171 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
172 AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
173 if (handler)
174 {
175 AliESDpid *pid = handler->GetESDpid();
176 fESDpid = (*pid);
177 }
178
179 fInitialized = kTRUE;
180}