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 = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
163 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
166 ULong_t status = (ULong_t)vtrack->GetStatus();
167 ULong_t checkOn = status & fFlagsOn;
168 ULong_t checkOff = status & fFlagsOff;
169 if (fFlagsOn != 0x0 && checkOn != fFlagsOn)
171 AliDebug(AliLog::kDebug + 2, Form("Not all required flags are present: required %lx, track has %lx", fFlagsOn, status));
176 AliDebug(AliLog::kDebug + 2, Form("Some forbidden flags are present: required %lx, track has %lx", fFlagsOff, status));
180 // retrieve real object type
181 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
182 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
185 AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
186 return CheckESD(esdTrack);
190 AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
191 return CheckAOD(aodTrack);
195 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
200 //_________________________________________________________________________________________________
201 Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
204 // Check an ESD track.
205 // This is done using the default track checker for ESD.
206 // It is declared static, not to recreate it every time.
209 static AliESDtrackCuts cuts;
211 // general acceptance/pt cuts
212 cuts.SetPtRange (fPt[0], fPt[1]);
213 cuts.SetEtaRange(fEta[0], fEta[1]);
215 // transverse DCA cuts
217 cuts.SetMaxDCAToVertexXY(fDCARmax);
219 cuts.SetMaxDCAToVertexXYPtDep(fDCARptFormula.Data());
221 // longitudinal DCA cuts
223 cuts.SetMaxDCAToVertexZ(fDCAZmax);
225 cuts.SetMaxDCAToVertexZPtDep(fDCAZptFormula.Data());
227 // these options are always disabled in current version
228 cuts.SetDCAToVertex2D(kFALSE);
229 cuts.SetRequireSigmaToVertex(kFALSE);
231 // TPC related cuts for TPC+ITS tracks
232 cuts.SetMinNClustersTPC(fTPCminNClusters);
233 cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
234 cuts.SetAcceptKinkDaughters(!fRejectKinkDaughters);
236 // ITS related cuts for TPC+ITS tracks
237 if (fSPDminNClusters > 0)
238 cuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
240 // now that all is initialized, do the check
241 return cuts.IsSelected(track);
244 //_________________________________________________________________________________________________
245 Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
248 // Check an AOD track.
249 // This is done doing directly all checks, since there is not
250 // an equivalend checker for AOD tracks
253 // step #0: check SPD and ITS clusters
255 nSPD = TESTBIT(track->GetITSClusterMap(), 0);
256 nSPD += TESTBIT(track->GetITSClusterMap(), 1);
257 if (nSPD < fSPDminNClusters)
259 AliDebug(AliLog::kDebug + 2, "Not enough SPD clusters in this track. Rejected");
263 // step #1: check number of clusters in TPC
264 if (track->GetTPCNcls() < fTPCminNClusters)
266 AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
269 if (track->GetITSNcls() < fITSminNClusters)
271 AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
275 // step #2: check chi square
276 if (track->Chi2perNDF() > fTPCmaxChi2)
278 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
281 if (track->Chi2perNDF() > fITSmaxChi2)
283 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
287 // step #3: reject kink daughters
288 AliAODVertex *vertex = track->GetProdVertex();
289 if (vertex && fRejectKinkDaughters)
291 if (vertex->GetType() == AliAODVertex::kKink)
293 AliDebug(AliLog::kDebug + 2, "Kink daughter. Rejected");
298 // step #4: DCA cut (transverse)
299 Double_t b[2], cov[3];
300 vertex = AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetPrimaryVertex();
303 AliDebug(AliLog::kDebug + 2, "NULL vertex");
306 if (!track->PropagateToDCA(vertex, AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetMagneticField(), kVeryBig, b, cov))
308 AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
311 // if the DCA cut is not fixed, compute current value
314 static TString str(fDCARptFormula);
315 str.ReplaceAll("pt", "x");
316 static const TFormula dcaXY(Form("%s_dcaXY", GetName()), str.Data());
317 fDCARmax = dcaXY.Eval(track->Pt());
320 if (TMath::Abs(b[0]) > fDCARmax)
322 AliDebug(AliLog::kDebug + 2, "Too large transverse DCA");
326 // step #5: DCA cut (longitudinal)
327 // the DCA has already been computed above
328 // if the DCA cut is not fixed, compute current value
331 static TString str(fDCAZptFormula);
332 str.ReplaceAll("pt", "x");
333 static const TFormula dcaZ(Form("%s_dcaXY", GetName()), str.Data());
334 fDCAZmax = dcaZ.Eval(track->Pt());
337 if (TMath::Abs(b[1]) > fDCAZmax)
339 AliDebug(AliLog::kDebug + 2, "Too large longitudinal DCA");
343 // step #6: check eta/pt range
344 if (track->Eta() < fEta[0] || track->Eta() > fEta[1])
346 AliDebug(AliLog::kDebug + 2, "Outside ETA acceptance");
349 if (track->Pt() < fPt[0] || track->Pt() > fPt[1])
351 AliDebug(AliLog::kDebug + 2, "Outside PT acceptance");
355 // if we are here, all cuts were passed and no exit point was got
359 //_________________________________________________________________________________________________
360 void AliRsnCutTrackQuality::Print(const Option_t *) const
363 // Print information on this cut
366 AliInfo(Form("Cut name : %s", GetName()));
367 AliInfo(Form("Required flags (off, on): %lx %lx", fFlagsOn, fFlagsOff));
368 AliInfo(Form("Ranges in eta, pt : %.2f - %.2f, %.2f - %.2f", fEta[0], fEta[1], fPt[0], fPt[1]));
369 AliInfo(Form("Kink daughters are : %s", (fRejectKinkDaughters ? "rejected" : "accepted")));
370 AliInfo(Form("TPC requirements : min. cluster = %d, max chi2 = %f", fTPCminNClusters, fTPCmaxChi2));
371 AliInfo(Form("ITS requirements : min. cluster = %d (all), %d (SPD), max chi2 = %f", fITSminNClusters, fSPDminNClusters, fITSmaxChi2));
375 AliInfo(Form("DCA r cut : fixed to %f cm", fDCARmax));
379 AliInfo(Form("DCA r cut formula : %s", fDCARptFormula.Data()));
384 AliInfo(Form("DCA z cut : fixed to %f cm", fDCAZmax));
388 AliInfo(Form("DCA z cut formula : %s", fDCAZptFormula.Data()));