]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | ClassImp(AliRsnCutPIDTOF) | |
20 | ||
35e49ca5 | 21 | //_________________________________________________________________________________________________ |
80e49c8b | 22 | AliRsnCutPIDTOF::AliRsnCutPIDTOF |
23 | (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) : | |
2a1c7696 | 24 | AliRsnCut(name, AliRsnCut::kDaughter, min, max), |
25 | fInitialized(kFALSE), | |
26 | fRejectUnmatched(rejectUnmatched), | |
27 | fRefType(AliPID::kUnknown), | |
28 | fRefMass(0.0), | |
29 | fESDpid(), | |
30 | fAODpid() | |
35e49ca5 | 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 | |
2a1c7696 | 38 | SetRefType(ref); |
35e49ca5 | 39 | } |
40 | ||
41 | //_________________________________________________________________________________________________ | |
42 | AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) : | |
2a1c7696 | 43 | AliRsnCut(copy), |
44 | fInitialized(kFALSE), | |
45 | fRejectUnmatched(copy.fRejectUnmatched), | |
46 | fRefType(AliPID::kUnknown), | |
47 | fRefMass(0.0), | |
48 | fESDpid(copy.fESDpid), | |
49 | fAODpid(copy.fAODpid) | |
35e49ca5 | 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 | |
2a1c7696 | 57 | SetRefType(copy.fRefType); |
35e49ca5 | 58 | } |
59 | ||
60 | //_________________________________________________________________________________________________ | |
61 | AliRsnCutPIDTOF& 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 | ||
2a1c7696 | 69 | fInitialized = kFALSE; |
70 | fRejectUnmatched = copy.fRejectUnmatched; | |
71 | fESDpid = copy.fESDpid; | |
72 | fAODpid = copy.fAODpid; | |
80e49c8b | 73 | |
2a1c7696 | 74 | SetRefType(copy.fRefType); |
75 | ||
76 | return (*this); | |
35e49ca5 | 77 | } |
78 | ||
79 | //_________________________________________________________________________________________________ | |
80 | Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object) | |
81 | { | |
82 | // | |
83 | // Cut checker. | |
84 | // | |
85 | ||
2a1c7696 | 86 | // initialize if needed |
87 | if (!fInitialized) Initialize(); | |
88 | ||
89 | // coherence check | |
90 | if (!TargetOK(object)) return kFALSE; | |
91 | ||
92 | // reject always non-track objects | |
93 | AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef()); | |
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"); | |
106 | return (!fRejectUnmatched); | |
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->GetRefESDtrack(); | |
114 | AliAODTrack *aodTrack = fDaughter->GetRefAODtrack(); | |
115 | ||
116 | // cut check depends on the object type | |
117 | if (esdTrack) { | |
118 | // setup the ESD PID object | |
119 | AliESDEvent *esd = AliRsnTarget::GetCurrentEvent()->GetRefESD(); | |
120 | if (!esd) { | |
121 | AliError("Processing an ESD track, but target is not an ESD event"); | |
122 | return kFALSE; | |
123 | } | |
124 | fESDpid.SetTOFResponse(esd, AliESDpid::kTOF_T0); | |
125 | ||
126 | // get time of flight, reference times and sigma | |
127 | esdTrack->GetIntegratedTimes(times); | |
128 | tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid.GetTOFResponse().GetStartTime(esdTrack->P())); | |
129 | sigma = (Double_t)fESDpid.GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass); | |
130 | ||
131 | // port values to standard AliRsnCut checker | |
132 | fCutValueD = (tof - ref) / sigma; | |
133 | return OkRangeD(); | |
134 | } else if (aodTrack) { | |
135 | // for AOD tracks, all operations are done by the AOD PID utility | |
136 | fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(aodTrack, fRefType); | |
137 | return OkRangeD(); | |
138 | } else { | |
139 | AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName())); | |
140 | return kFALSE; | |
141 | } | |
35e49ca5 | 142 | } |
143 | ||
a909ffad | 144 | //_________________________________________________________________________________________________ |
145 | void AliRsnCutPIDTOF::Print(const Option_t *) const | |
146 | { | |
147 | // | |
148 | // Print information on this cut | |
149 | // | |
150 | ||
2a1c7696 | 151 | AliInfo(Form("Cut name, type : %s %s", GetName(), ClassName())); |
152 | AliInfo(Form("TOF PID cut range (sigmas): %.3f %.3f", fMinD, fMaxD)); | |
153 | AliInfo(Form("Unmatched tracks are : %s", (fRejectUnmatched ? "rejected" : "accepted"))); | |
a909ffad | 154 | } |
223b8750 | 155 | |
156 | //_________________________________________________________________________________________________ | |
157 | void AliRsnCutPIDTOF::Initialize() | |
158 | { | |
159 | // | |
160 | // Initialize ESD pid object from global one | |
161 | // | |
162 | ||
2a1c7696 | 163 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); |
164 | AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler()); | |
165 | if (handler) { | |
166 | AliESDpid *pid = handler->GetESDpid(); | |
167 | fESDpid = (*pid); | |
168 | } | |
169 | ||
170 | fInitialized = kTRUE; | |
223b8750 | 171 | } |