2 // Class AliRsnCutPIDTOF
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
10 // authors: Martin Vala (martin.vala@cern.ch)
11 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
14 #include "AliAnalysisManager.h"
15 #include "AliESDInputHandler.h"
16 #include "AliESDtrack.h"
17 #include "AliESDpid.h"
18 #include "AliAODTrack.h"
19 #include "AliAODpidUtil.h"
21 #include "AliRsnCutPIDTOF.h"
23 ClassImp(AliRsnCutPIDTOF)
25 //_________________________________________________________________________________________________
26 AliRsnCutPIDTOF::AliRsnCutPIDTOF
27 (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) :
28 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
29 fRejectUnmatched(rejectUnmatched),
30 fRefType(AliPID::kUnknown),
36 // Default constructor.
37 // To set the reference PID type, calls the SetRefType method,
38 // which sets the mass accordingly and coherently.
44 //_________________________________________________________________________________________________
45 AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF ©) :
47 fRejectUnmatched(copy.fRejectUnmatched),
48 fRefType(AliPID::kUnknown),
50 fESDpid(copy.fESDpid),
55 // To set the reference PID type, calls the SetRefType method,
56 // which sets the mass accordingly and coherently.
59 SetRefType(copy.fRefType);
62 //_________________________________________________________________________________________________
63 AliRsnCutPIDTOF &AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF ©)
66 // Assignment operator.
67 // To set the reference PID type, calls the SetRefType method,
68 // which sets the mass accordingly and coherently.
73 fRejectUnmatched = copy.fRejectUnmatched;
74 fESDpid = copy.fESDpid;
75 fAODpid = copy.fAODpid;
77 SetRefType(copy.fRefType);
82 //_________________________________________________________________________________________________
83 Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
90 if (!TargetOK(object)) return kFALSE;
92 // reject always non-track objects
93 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
95 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
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");
106 if (fRejectUnmatched) return kFALSE;
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];
113 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
114 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
116 // cut check depends on the object type
118 // setup the ESD PID object
119 AliESDEvent *esd = 0x0;
120 if (fEvent) esd = fEvent->GetRefESD();
122 AliError("Processing an ESD track, but target is not an ESD event");
125 if (!fESDpid) fESDpid = new AliESDpid;
126 fESDpid->SetTOFResponse(esd, AliESDpid::kTOF_T0);
128 // get time of flight, reference times and sigma
129 esdTrack->GetIntegratedTimes(times);
130 tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid->GetTOFResponse().GetStartTime(esdTrack->P()));
131 sigma = (Double_t)fESDpid->GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass);
133 // port values to standard AliRsnCut checker
134 fCutValueD = (tof - ref) / sigma;
136 } else if (aodTrack) {
137 // for AOD tracks, all operations are done by the AOD PID utility
138 if (!fAODpid) fAODpid = new AliAODpidUtil;
139 fCutValueD = (Double_t)fAODpid->NumberOfSigmasTOF(aodTrack, fRefType);
142 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
147 //_________________________________________________________________________________________________
148 void AliRsnCutPIDTOF::Print(const Option_t *) const
151 // Print information on this cut
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")));