updated macros for Sigma* analysis (M- Venaruzzo)
[u/mrichter/AliRoot.git] / PWGLF / 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"
c865cb1d 16#include "AliESDtrack.h"
17#include "AliESDpid.h"
18#include "AliAODTrack.h"
19#include "AliAODpidUtil.h"
223b8750 20
35e49ca5 21#include "AliRsnCutPIDTOF.h"
22
23ClassImp(AliRsnCutPIDTOF)
24
35e49ca5 25//_________________________________________________________________________________________________
80e49c8b 26AliRsnCutPIDTOF::AliRsnCutPIDTOF
27(const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) :
2a1c7696 28 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
2a1c7696 29 fRejectUnmatched(rejectUnmatched),
30 fRefType(AliPID::kUnknown),
31 fRefMass(0.0),
c865cb1d 32 fESDpid(0x0),
33 fAODpid(0x0)
35e49ca5 34{
35//
36// Default constructor.
80e49c8b 37// To set the reference PID type, calls the SetRefType method,
38// which sets the mass accordingly and coherently.
35e49ca5 39//
80e49c8b 40
2a1c7696 41 SetRefType(ref);
35e49ca5 42}
43
44//_________________________________________________________________________________________________
61f275d1 45AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF &copy) :
2a1c7696 46 AliRsnCut(copy),
2a1c7696 47 fRejectUnmatched(copy.fRejectUnmatched),
48 fRefType(AliPID::kUnknown),
49 fRefMass(0.0),
50 fESDpid(copy.fESDpid),
51 fAODpid(copy.fAODpid)
35e49ca5 52{
53//
80e49c8b 54// Copy constructor.
55// To set the reference PID type, calls the SetRefType method,
56// which sets the mass accordingly and coherently.
35e49ca5 57//
80e49c8b 58
2a1c7696 59 SetRefType(copy.fRefType);
35e49ca5 60}
61
62//_________________________________________________________________________________________________
61f275d1 63AliRsnCutPIDTOF &AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF &copy)
35e49ca5 64{
65//
80e49c8b 66// Assignment operator.
67// To set the reference PID type, calls the SetRefType method,
68// which sets the mass accordingly and coherently.
35e49ca5 69//
61f275d1 70 if (this == &copy)
71 return *this;
35e49ca5 72
2a1c7696 73 fRejectUnmatched = copy.fRejectUnmatched;
74 fESDpid = copy.fESDpid;
75 fAODpid = copy.fAODpid;
80e49c8b 76
2a1c7696 77 SetRefType(copy.fRefType);
78
79 return (*this);
35e49ca5 80}
81
82//_________________________________________________________________________________________________
83Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
84{
85//
86// Cut checker.
87//
88
2a1c7696 89 // coherence check
90 if (!TargetOK(object)) return kFALSE;
91
92 // reject always non-track objects
f34f960b 93 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
2a1c7696 94 if (!vtrack) {
95 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
80e49c8b 96 return kFALSE;
2a1c7696 97 }
98
99 // checks that track is matched in TOF:
100 // if not, the track is accepted or rejected
101 // depending on the 'fRejectUnmatched' data member:
102 // -- kTRUE --> all unmatched tracks are rejected
103 // -- kFALSE --> all unmatched tracks are accepted (it is assumed that other PIDs are done)
104 if (!IsMatched(vtrack)) {
105 AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF");
c865cb1d 106 if (fRejectUnmatched) return kFALSE;
2a1c7696 107 }
108
109 // retrieve real object type and
110 // prepare some useful variables
111 Double_t tof, sigma, times[5];
112 Double_t &ref = times[(Int_t)fRefType];
f34f960b 113 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
114 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
2a1c7696 115
116 // cut check depends on the object type
117 if (esdTrack) {
118 // setup the ESD PID object
d7712d44 119 AliESDEvent *esd = 0x0;
c865cb1d 120 if (fEvent) esd = fEvent->GetRefESD();
121 if (!esd) {
122 AliError("Processing an ESD track, but target is not an ESD event");
2a1c7696 123 return kFALSE;
124 }
c865cb1d 125 if (!fESDpid) fESDpid = new AliESDpid;
126 fESDpid->SetTOFResponse(esd, AliESDpid::kTOF_T0);
2a1c7696 127
128 // get time of flight, reference times and sigma
129 esdTrack->GetIntegratedTimes(times);
c865cb1d 130 tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid->GetTOFResponse().GetStartTime(esdTrack->P()));
131 sigma = (Double_t)fESDpid->GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass);
2a1c7696 132
133 // port values to standard AliRsnCut checker
134 fCutValueD = (tof - ref) / sigma;
135 return OkRangeD();
136 } else if (aodTrack) {
137 // for AOD tracks, all operations are done by the AOD PID utility
c865cb1d 138 if (!fAODpid) fAODpid = new AliAODpidUtil;
139 fCutValueD = (Double_t)fAODpid->NumberOfSigmasTOF(aodTrack, fRefType);
2a1c7696 140 return OkRangeD();
141 } else {
142 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
143 return kFALSE;
144 }
35e49ca5 145}
146
147//_________________________________________________________________________________________________
a909ffad 148void AliRsnCutPIDTOF::Print(const Option_t *) const
149{
150//
151// Print information on this cut
152//
153
2a1c7696 154 AliInfo(Form("Cut name, type : %s %s", GetName(), ClassName()));
155 AliInfo(Form("TOF PID cut range (sigmas): %.3f %.3f", fMinD, fMaxD));
156 AliInfo(Form("Unmatched tracks are : %s", (fRejectUnmatched ? "rejected" : "accepted")));
a909ffad 157}
223b8750 158