]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutPIDTOF.cxx
Recovered charge and phi values in AliRsnValueDaughter (overwritten by wrong commit)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPIDTOF.cxx
1 //
2 // Class AliRsnCutPIDTOF
3 //
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.
9 //
10 // authors: Martin Vala (martin.vala@cern.ch)
11 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
12 //
13
14 #include "AliAnalysisManager.h"
15 #include "AliESDInputHandler.h"
16 #include "AliESDtrack.h"
17 #include "AliESDpid.h"
18 #include "AliAODTrack.h"
19 #include "AliAODpidUtil.h"
20
21 #include "AliRsnCutPIDTOF.h"
22
23 ClassImp(AliRsnCutPIDTOF)
24
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),
31    fRefMass(0.0),
32    fESDpid(0x0),
33    fAODpid(0x0)
34 {
35 //
36 // Default constructor.
37 // To set the reference PID type, calls the SetRefType method,
38 // which sets the mass accordingly and coherently.
39 //
40
41    SetRefType(ref);
42 }
43
44 //_________________________________________________________________________________________________
45 AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF &copy) :
46    AliRsnCut(copy),
47    fRejectUnmatched(copy.fRejectUnmatched),
48    fRefType(AliPID::kUnknown),
49    fRefMass(0.0),
50    fESDpid(copy.fESDpid),
51    fAODpid(copy.fAODpid)
52 {
53 //
54 // Copy constructor.
55 // To set the reference PID type, calls the SetRefType method,
56 // which sets the mass accordingly and coherently.
57 //
58
59    SetRefType(copy.fRefType);
60 }
61
62 //_________________________________________________________________________________________________
63 AliRsnCutPIDTOF &AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF &copy)
64 {
65 //
66 // Assignment operator.
67 // To set the reference PID type, calls the SetRefType method,
68 // which sets the mass accordingly and coherently.
69 //
70    if (this == &copy)
71       return *this;
72
73    fRejectUnmatched = copy.fRejectUnmatched;
74    fESDpid          = copy.fESDpid;
75    fAODpid          = copy.fAODpid;
76
77    SetRefType(copy.fRefType);
78
79    return (*this);
80 }
81
82 //_________________________________________________________________________________________________
83 Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
84 {
85 //
86 // Cut checker.
87 //
88
89    // coherence check
90    if (!TargetOK(object)) return kFALSE;
91
92    // reject always non-track objects
93    AliVTrack *vtrack = fDaughter->Ref2Vtrack();
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()));
96       return kFALSE;
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");
106       if (fRejectUnmatched) return kFALSE;
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];
113    AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
114    AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
115
116    // cut check depends on the object type
117    if (esdTrack) {
118       // setup the ESD PID object
119       AliESDEvent *esd = 0x0;
120       if (fEvent) esd = fEvent->GetRefESD();
121       if (!esd) {
122          AliError("Processing an ESD track, but target is not an ESD event");
123          return kFALSE;
124       }
125       if (!fESDpid) fESDpid = new AliESDpid;
126       fESDpid->SetTOFResponse(esd, AliESDpid::kTOF_T0);
127
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);
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
138       if (!fAODpid) fAODpid = new AliAODpidUtil;
139       fCutValueD = (Double_t)fAODpid->NumberOfSigmasTOF(aodTrack, fRefType);
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    }
145 }
146
147 //_________________________________________________________________________________________________
148 void AliRsnCutPIDTOF::Print(const Option_t *) const
149 {
150 //
151 // Print information on this cut
152 //
153
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")));
157 }
158