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 "AliESDtrackCuts.h"
26 #include "AliRsnEvent.h"
27 #include "AliRsnDaughter.h"
28 #include "AliRsnCutTrackQuality.h"
30 ClassImp(AliRsnCutTrackQuality)
32 //_________________________________________________________________________________________________
33 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const char *name) :
34 AliRsnCut(name, AliRsnTarget::kDaughter, 0.0, 0.0),
37 fRejectKinkDaughters(kTRUE),
52 // Default constructor.
53 // Initializes all cuts in such a way that all of them are disabled.
56 SetPtRange(0.0, 1E20);
57 SetEtaRange(-1E20, 1E20);
60 //_________________________________________________________________________________________________
61 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const AliRsnCutTrackQuality ©) :
63 fFlagsOn(copy.fFlagsOn),
64 fFlagsOff(copy.fFlagsOff),
65 fRejectKinkDaughters(copy.fRejectKinkDaughters),
66 fDCARfixed(copy.fDCARfixed),
67 fDCARptFormula(copy.fDCARptFormula),
68 fDCARmax(copy.fDCARmax),
69 fDCAZfixed(copy.fDCAZfixed),
70 fDCAZptFormula(copy.fDCAZptFormula),
71 fDCAZmax(copy.fDCAZmax),
72 fSPDminNClusters(copy.fSPDminNClusters),
73 fITSminNClusters(copy.fITSminNClusters),
74 fITSmaxChi2(copy.fITSmaxChi2),
75 fTPCminNClusters(copy.fTPCminNClusters),
76 fTPCmaxChi2(copy.fTPCmaxChi2),
77 fAODTestFilterBit(copy.fAODTestFilterBit)
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;
111 fAODTestFilterBit = copy.fAODTestFilterBit;
113 SetPtRange(copy.fPt[0], copy.fPt[1]);
114 SetEtaRange(copy.fEta[0], copy.fEta[1]);
119 //_________________________________________________________________________________________________
120 void AliRsnCutTrackQuality::DisableAll()
128 fRejectKinkDaughters = kFALSE;
135 fSPDminNClusters = 0;
136 fITSminNClusters = 0;
138 fTPCminNClusters = 0;
140 fAODTestFilterBit = -1;
142 SetPtRange(0.0, 1E20);
143 SetEtaRange(-1E20, 1E20);
146 //_________________________________________________________________________________________________
147 Bool_t AliRsnCutTrackQuality::IsSelected(TObject *object)
151 // Checks the type of object being evaluated
152 // and then calls the appropriate sub-function (for ESD or AOD)
156 if (!TargetOK(object)) return kFALSE;
158 // status is checked in the same way for all tracks, using AliVTrack
159 // as a convention, if a the collection of 'on' flags is '0x0', it
160 // is assumed that no flags are required, and this check is skipped;
161 // for the collection of 'off' flags this is not needed
162 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
164 AliDebug(AliLog::kDebug + 2, "This object is not either an ESD nor AOD track");
167 ULong_t status = (ULong_t)vtrack->GetStatus();
168 ULong_t checkOn = status & fFlagsOn;
169 ULong_t checkOff = status & fFlagsOff;
170 if (fFlagsOn != 0x0 && checkOn != fFlagsOn) {
171 AliDebug(AliLog::kDebug + 2, Form("Failed flag check: required %s", Binary(fFlagsOn)));
172 AliDebug(AliLog::kDebug + 2, Form(" track has %s", Binary(status )));
176 AliDebug(AliLog::kDebug + 2, Form("Failed flag check: forbidden %s", Binary(fFlagsOff)));
177 AliDebug(AliLog::kDebug + 2, Form(" track has %s", Binary(status )));
180 AliDebug(AliLog::kDebug + 3, Form("Flag check OK: required %s", Binary(fFlagsOn)));
181 AliDebug(AliLog::kDebug + 3, Form(" forbidden %s", Binary(fFlagsOff)));
182 AliDebug(AliLog::kDebug + 3, Form(" track has %s", Binary(status )));
184 // retrieve real object type
185 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
186 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
188 AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
189 return CheckESD(esdTrack);
190 } else if (aodTrack) {
191 AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
192 return CheckAOD(aodTrack);
194 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
199 //_________________________________________________________________________________________________
200 Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
203 // Check an ESD track.
204 // This is done using the default track checker for ESD.
205 // It is declared static, not to recreate it every time.
208 static AliESDtrackCuts cuts;
210 // general acceptance/pt cuts
211 cuts.SetPtRange(fPt[0], fPt[1]);
212 cuts.SetEtaRange(fEta[0], fEta[1]);
214 // transverse DCA cuts
216 cuts.SetMaxDCAToVertexXY(fDCARmax);
218 cuts.SetMaxDCAToVertexXYPtDep(fDCARptFormula.Data());
220 // longitudinal DCA cuts
222 cuts.SetMaxDCAToVertexZ(fDCAZmax);
224 cuts.SetMaxDCAToVertexZPtDep(fDCAZptFormula.Data());
226 // these options are always disabled in current version
227 cuts.SetDCAToVertex2D(kFALSE);
228 cuts.SetRequireSigmaToVertex(kFALSE);
230 // TPC related cuts for TPC+ITS tracks
231 cuts.SetMinNClustersTPC(fTPCminNClusters);
232 cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
233 cuts.SetAcceptKinkDaughters(!fRejectKinkDaughters);
235 // ITS related cuts for TPC+ITS tracks
236 if (fSPDminNClusters > 0)
237 cuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
239 // now that all is initialized, do the check
240 return cuts.IsSelected(track);
243 //_________________________________________________________________________________________________
244 Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
247 // Check an AOD track.
248 // This is done doing directly all checks, since there is not
249 // an equivalend checker for AOD tracks
252 // if a test bit is used, check it and skip the following
253 if (fAODTestFilterBit >= 0) {
254 UInt_t bit = (UInt_t)fAODTestFilterBit;
255 AliDebugClass(2, Form("Required a test filter bit for AOD check: %u (result: %s)", bit, (track->TestFilterBit(bit) ? "accept" : "reject")));
256 if (!track->TestFilterBit(bit))
259 if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) return kFALSE;
260 if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) return kFALSE;
265 // try to retrieve the reference AOD event
266 AliAODEvent *aodEvent = 0x0;
267 if (fEvent) aodEvent = fEvent->GetRefAOD();
269 AliError("AOD reference event is not initialized!");
273 // step #0: check SPD and ITS clusters
275 nSPD = TESTBIT(track->GetITSClusterMap(), 0);
276 nSPD += TESTBIT(track->GetITSClusterMap(), 1);
277 if (nSPD < fSPDminNClusters) {
278 AliDebug(AliLog::kDebug + 2, "Not enough SPD clusters in this track. Rejected");
282 // step #1: check number of clusters in TPC
283 if (track->GetTPCNcls() < fTPCminNClusters) {
284 AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
287 if (track->GetITSNcls() < fITSminNClusters) {
288 AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
292 // step #2: check chi square
293 if (track->Chi2perNDF() > fTPCmaxChi2) {
294 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
297 if (track->Chi2perNDF() > fITSmaxChi2) {
298 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
302 // step #3: reject kink daughters
303 AliAODVertex *vertex = track->GetProdVertex();
304 if (vertex && fRejectKinkDaughters) {
305 if (vertex->GetType() == AliAODVertex::kKink) {
306 AliDebug(AliLog::kDebug + 2, "Kink daughter. Rejected");
311 // step #4: DCA cut (transverse)
312 // --> reject all tracks not ITS refitted
313 Double_t b[2], cov[3];
314 vertex = aodEvent->GetPrimaryVertex();
316 AliDebug(AliLog::kDebug + 2, "NULL vertex");
319 if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
320 AliDebug(AliLog::kDebug + 2, "Not ITS refitted");
323 if (!track->PropagateToDCA(vertex, aodEvent->GetMagneticField(), kVeryBig, b, cov)) {
324 AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
327 // if the DCA cut is not fixed, compute current value
329 static TString str(fDCARptFormula);
330 str.ReplaceAll("pt", "x");
331 static const TFormula dcaXY(Form("%s_dcaXY", GetName()), str.Data());
332 fDCARmax = dcaXY.Eval(track->Pt());
335 if (TMath::Abs(b[0]) > fDCARmax) {
336 AliDebug(AliLog::kDebug + 2, "Too large transverse DCA");
340 // step #5: DCA cut (longitudinal)
341 // the DCA has already been computed above
342 // if the DCA cut is not fixed, compute current value
344 static TString str(fDCAZptFormula);
345 str.ReplaceAll("pt", "x");
346 static const TFormula dcaZ(Form("%s_dcaXY", GetName()), str.Data());
347 fDCAZmax = dcaZ.Eval(track->Pt());
350 if (TMath::Abs(b[1]) > fDCAZmax) {
351 AliDebug(AliLog::kDebug + 2, "Too large longitudinal DCA");
355 // step #6: check eta/pt range
356 if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) {
357 AliDebug(AliLog::kDebug + 2, "Outside ETA acceptance");
360 if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) {
361 AliDebug(AliLog::kDebug + 2, "Outside PT acceptance");
365 // if we are here, all cuts were passed and no exit point was got
366 AliDebug(AliLog::kDebug + 2, "============================= ACCEPTED TRACK =====================================================");
370 //_________________________________________________________________________________________________
371 void AliRsnCutTrackQuality::Print(const Option_t *) const
374 // Print information on this cut
377 AliInfo(Form("Cut name : %s", GetName()));
378 AliInfo(Form("Required flags (off, on): %lx %lx", fFlagsOn, fFlagsOff));
379 AliInfo(Form("Ranges in eta, pt : %.2f - %.2f, %.2f - %.2f", fEta[0], fEta[1], fPt[0], fPt[1]));
380 AliInfo(Form("Kink daughters are : %s", (fRejectKinkDaughters ? "rejected" : "accepted")));
381 AliInfo(Form("TPC requirements : min. cluster = %d, max chi2 = %f", fTPCminNClusters, fTPCmaxChi2));
382 AliInfo(Form("ITS requirements : min. cluster = %d (all), %d (SPD), max chi2 = %f", fITSminNClusters, fSPDminNClusters, fITSmaxChi2));
385 AliInfo(Form("DCA r cut : fixed to %f cm", fDCARmax));
387 AliInfo(Form("DCA r cut formula : %s", fDCARptFormula.Data()));
391 AliInfo(Form("DCA z cut : fixed to %f cm", fDCAZmax));
393 AliInfo(Form("DCA z cut formula : %s", fDCAZptFormula.Data()));