2 // Class AliRsnCutTrackQuality
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval [--> IsBetween() ]
6 // - a value equal to a given reference [--> MatchesValue()]
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
15 // authors: Martin Vala (martin.vala@cern.ch)
16 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
19 #include <Riostream.h>
24 #include "AliESDtrack.h"
25 #include "AliAODTrack.h"
26 #include "AliESDtrackCuts.h"
28 #include "AliRsnEvent.h"
29 #include "AliRsnDaughter.h"
30 #include "AliRsnCutTrackQuality.h"
32 ClassImp(AliRsnCutTrackQuality)
34 //_________________________________________________________________________________________________
35 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const char *name) :
36 AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
39 fRejectKinkDaughters(kTRUE),
48 fITSmaxChi2(fgkVeryBig),
50 fTPCmaxChi2(fgkVeryBig)
53 // Default constructor.
54 // Initializes all cuts in such a way that all of them are disabled.
57 SetPtRange(0.0, fgkVeryBig);
58 SetEtaRange(-fgkVeryBig, fgkVeryBig);
61 //_________________________________________________________________________________________________
62 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const AliRsnCutTrackQuality ©) :
64 fFlagsOn(copy.fFlagsOn),
65 fFlagsOff(copy.fFlagsOff),
66 fRejectKinkDaughters(copy.fRejectKinkDaughters),
67 fDCARfixed(copy.fDCARfixed),
68 fDCARptFormula(copy.fDCARptFormula),
69 fDCARmax(copy.fDCARmax),
70 fDCAZfixed(copy.fDCAZfixed),
71 fDCAZptFormula(copy.fDCAZptFormula),
72 fDCAZmax(copy.fDCAZmax),
73 fSPDminNClusters(copy.fSPDminNClusters),
74 fITSminNClusters(copy.fITSminNClusters),
75 fITSmaxChi2(copy.fITSmaxChi2),
76 fTPCminNClusters(copy.fTPCminNClusters),
77 fTPCmaxChi2(copy.fTPCmaxChi2)
81 // Just copy all data member values.
84 SetPtRange(copy.fPt[0], copy.fPt[1]);
85 SetEtaRange(copy.fEta[0], copy.fEta[1]);
88 //_________________________________________________________________________________________________
89 AliRsnCutTrackQuality& AliRsnCutTrackQuality::operator=(const AliRsnCutTrackQuality ©)
92 // Assignment operator.
93 // Just copy all data member values.
97 fFlagsOn = copy.fFlagsOn;
98 fFlagsOff = copy.fFlagsOff;
99 fRejectKinkDaughters = copy.fRejectKinkDaughters;
100 fDCARfixed = copy.fDCARfixed;
101 fDCARptFormula = copy.fDCARptFormula;
102 fDCARmax = copy.fDCARmax;
103 fDCAZfixed = copy.fDCAZfixed;
104 fDCAZptFormula = copy.fDCAZptFormula;
105 fDCAZmax = copy.fDCAZmax;
106 fSPDminNClusters = copy.fSPDminNClusters;
107 fITSminNClusters = copy.fITSminNClusters;
108 fITSmaxChi2 = copy.fITSmaxChi2;
109 fTPCminNClusters = copy.fTPCminNClusters;
110 fTPCmaxChi2 = copy.fTPCmaxChi2;
112 SetPtRange(copy.fPt[0], copy.fPt[1]);
113 SetEtaRange(copy.fEta[0], copy.fEta[1]);
118 //_________________________________________________________________________________________________
119 void AliRsnCutTrackQuality::DisableAll()
127 fRejectKinkDaughters = kFALSE;
130 fDCARmax = fgkVeryBig;
133 fDCAZmax = fgkVeryBig;
134 fSPDminNClusters = 0;
135 fITSminNClusters = 0;
136 fITSmaxChi2 = fgkVeryBig;
137 fTPCminNClusters = 0;
138 fTPCmaxChi2 = fgkVeryBig;
140 SetPtRange(0.0, fgkVeryBig);
141 SetEtaRange(-fgkVeryBig, fgkVeryBig);
144 //_________________________________________________________________________________________________
145 Bool_t AliRsnCutTrackQuality::IsSelected(TObject *object)
149 // Checks the type of object being evaluated
150 // and then calls the appropriate sub-function (for ESD or AOD)
154 if (!TargetOK(object)) return kFALSE;
156 // status is checked in the same way for all tracks, using AliVTrack
157 // as a convention, if a the collection of 'on' flags is '0x0', it
158 // is assumed that no flags are required, and this check is skipped;
159 // for the collection of 'off' flags this is not needed
160 AliVTrack *vtrack = fDaughter->GetRefVtrack();
162 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
165 ULong_t status = (ULong_t)vtrack->GetStatus();
166 ULong_t checkOn = status & fFlagsOn;
167 ULong_t checkOff = status & fFlagsOff;
168 if (fFlagsOn != 0x0 && checkOn != fFlagsOn) {
169 AliDebug(AliLog::kDebug + 2, Form("Not all required flags are present: required %lx, track has %lx", fFlagsOn, status));
173 AliDebug(AliLog::kDebug + 2, Form("Some forbidden flags are present: required %lx, track has %lx", fFlagsOff, status));
177 // retrieve real object type
178 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
179 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
181 AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
182 return CheckESD(esdTrack);
183 } else if (aodTrack) {
184 AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
185 return CheckAOD(aodTrack);
187 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
192 //_________________________________________________________________________________________________
193 Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
196 // Check an ESD track.
197 // This is done using the default track checker for ESD.
198 // It is declared static, not to recreate it every time.
201 static AliESDtrackCuts cuts;
203 // general acceptance/pt cuts
204 cuts.SetPtRange(fPt[0], fPt[1]);
205 cuts.SetEtaRange(fEta[0], fEta[1]);
207 // transverse DCA cuts
209 cuts.SetMaxDCAToVertexXY(fDCARmax);
211 cuts.SetMaxDCAToVertexXYPtDep(fDCARptFormula.Data());
213 // longitudinal DCA cuts
215 cuts.SetMaxDCAToVertexZ(fDCAZmax);
217 cuts.SetMaxDCAToVertexZPtDep(fDCAZptFormula.Data());
219 // these options are always disabled in current version
220 cuts.SetDCAToVertex2D(kFALSE);
221 cuts.SetRequireSigmaToVertex(kFALSE);
223 // TPC related cuts for TPC+ITS tracks
224 cuts.SetMinNClustersTPC(fTPCminNClusters);
225 cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
226 cuts.SetAcceptKinkDaughters(!fRejectKinkDaughters);
228 // ITS related cuts for TPC+ITS tracks
229 if (fSPDminNClusters > 0)
230 cuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
232 // now that all is initialized, do the check
233 return cuts.IsSelected(track);
236 //_________________________________________________________________________________________________
237 Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
240 // Check an AOD track.
241 // This is done doing directly all checks, since there is not
242 // an equivalend checker for AOD tracks
245 // step #0: check SPD and ITS clusters
247 nSPD = TESTBIT(track->GetITSClusterMap(), 0);
248 nSPD += TESTBIT(track->GetITSClusterMap(), 1);
249 if (nSPD < fSPDminNClusters) {
250 AliDebug(AliLog::kDebug + 2, "Not enough SPD clusters in this track. Rejected");
254 // step #1: check number of clusters in TPC
255 if (track->GetTPCNcls() < fTPCminNClusters) {
256 AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
259 if (track->GetITSNcls() < fITSminNClusters) {
260 AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
264 // step #2: check chi square
265 if (track->Chi2perNDF() > fTPCmaxChi2) {
266 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
269 if (track->Chi2perNDF() > fITSmaxChi2) {
270 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
274 // step #3: reject kink daughters
275 AliAODVertex *vertex = track->GetProdVertex();
276 if (vertex && fRejectKinkDaughters) {
277 if (vertex->GetType() == AliAODVertex::kKink) {
278 AliDebug(AliLog::kDebug + 2, "Kink daughter. Rejected");
283 // step #4: DCA cut (transverse)
284 Double_t b[2], cov[3];
285 vertex = AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetPrimaryVertex();
287 AliDebug(AliLog::kDebug + 2, "NULL vertex");
290 if (!track->PropagateToDCA(vertex, AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetMagneticField(), kVeryBig, b, cov)) {
291 AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
294 // if the DCA cut is not fixed, compute current value
296 static TString str(fDCARptFormula);
297 str.ReplaceAll("pt", "x");
298 static const TFormula dcaXY(Form("%s_dcaXY", GetName()), str.Data());
299 fDCARmax = dcaXY.Eval(track->Pt());
302 if (TMath::Abs(b[0]) > fDCARmax) {
303 AliDebug(AliLog::kDebug + 2, "Too large transverse DCA");
307 // step #5: DCA cut (longitudinal)
308 // the DCA has already been computed above
309 // if the DCA cut is not fixed, compute current value
311 static TString str(fDCAZptFormula);
312 str.ReplaceAll("pt", "x");
313 static const TFormula dcaZ(Form("%s_dcaXY", GetName()), str.Data());
314 fDCAZmax = dcaZ.Eval(track->Pt());
317 if (TMath::Abs(b[1]) > fDCAZmax) {
318 AliDebug(AliLog::kDebug + 2, "Too large longitudinal DCA");
322 // step #6: check eta/pt range
323 if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) {
324 AliDebug(AliLog::kDebug + 2, "Outside ETA acceptance");
327 if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) {
328 AliDebug(AliLog::kDebug + 2, "Outside PT acceptance");
332 // if we are here, all cuts were passed and no exit point was got
336 //_________________________________________________________________________________________________
337 void AliRsnCutTrackQuality::Print(const Option_t *) const
340 // Print information on this cut
343 AliInfo(Form("Cut name : %s", GetName()));
344 AliInfo(Form("Required flags (off, on): %lx %lx", fFlagsOn, fFlagsOff));
345 AliInfo(Form("Ranges in eta, pt : %.2f - %.2f, %.2f - %.2f", fEta[0], fEta[1], fPt[0], fPt[1]));
346 AliInfo(Form("Kink daughters are : %s", (fRejectKinkDaughters ? "rejected" : "accepted")));
347 AliInfo(Form("TPC requirements : min. cluster = %d, max chi2 = %f", fTPCminNClusters, fTPCmaxChi2));
348 AliInfo(Form("ITS requirements : min. cluster = %d (all), %d (SPD), max chi2 = %f", fITSminNClusters, fSPDminNClusters, fITSmaxChi2));
351 AliInfo(Form("DCA r cut : fixed to %f cm", fDCARmax));
353 AliInfo(Form("DCA r cut formula : %s", fDCARptFormula.Data()));
357 AliInfo(Form("DCA z cut : fixed to %f cm", fDCAZmax));
359 AliInfo(Form("DCA z cut formula : %s", fDCAZptFormula.Data()));