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),
41 fDCARptFormulaMin(""),
52 fCutMaxChi2TPCConstrainedVsGlobal(1E20),
53 fTPCminNCrossedRows(0),
54 fTPCminCrossedRowsOverFindableCls(0),
55 fCutMinLengthActiveVolumeTPC(0),
56 fAODTestFilterBit(-1),
57 fCheckOnlyFilterBit(kTRUE),
61 // Default constructor.
62 // Initializes all cuts in such a way that all of them are disabled.
64 SetPtRange(0.0, 1E20);
65 SetEtaRange(-1E20, 1E20);
68 //_________________________________________________________________________________________________
69 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const AliRsnCutTrackQuality ©) :
71 fFlagsOn(copy.fFlagsOn),
72 fFlagsOff(copy.fFlagsOff),
73 fRejectKinkDaughters(copy.fRejectKinkDaughters),
74 fDCARmaxfixed(copy.fDCARmaxfixed),
75 fDCARminfixed(copy.fDCARminfixed),
76 fDCARptFormula(copy.fDCARptFormula),
77 fDCARptFormulaMin(copy.fDCARptFormulaMin),
78 fDCARmax(copy.fDCARmax),
79 fDCARmin(copy.fDCARmin),
80 fDCAZfixed(copy.fDCAZfixed),
81 fDCAZptFormula(copy.fDCAZptFormula),
82 fDCAZmax(copy.fDCAZmax),
83 fSPDminNClusters(copy.fSPDminNClusters),
84 fITSminNClusters(copy.fITSminNClusters),
85 fITSmaxChi2(copy.fITSmaxChi2),
86 fTPCminNClusters(copy.fTPCminNClusters),
87 fTPCmaxChi2(copy.fTPCmaxChi2),
88 fCutMaxChi2TPCConstrainedVsGlobal(copy.fCutMaxChi2TPCConstrainedVsGlobal),
89 fTPCminNCrossedRows(copy.fTPCminNCrossedRows),
90 fTPCminCrossedRowsOverFindableCls(copy.fTPCminCrossedRowsOverFindableCls),
91 fCutMinLengthActiveVolumeTPC(copy.fCutMinLengthActiveVolumeTPC),
92 fAODTestFilterBit(copy.fAODTestFilterBit),
93 fCheckOnlyFilterBit(copy.fCheckOnlyFilterBit),
94 fESDtrackCuts(copy.fESDtrackCuts)
98 // Just copy all data member values.
101 SetPtRange(copy.fPt[0], copy.fPt[1]);
102 SetEtaRange(copy.fEta[0], copy.fEta[1]);
105 //_________________________________________________________________________________________________
106 AliRsnCutTrackQuality &AliRsnCutTrackQuality::operator=(const AliRsnCutTrackQuality ©)
109 // Assignment operator.
110 // Just copy all data member values.
116 fFlagsOn = copy.fFlagsOn;
117 fFlagsOff = copy.fFlagsOff;
118 fRejectKinkDaughters = copy.fRejectKinkDaughters;
119 fDCARmaxfixed = copy.fDCARmaxfixed;
120 fDCARminfixed = copy.fDCARminfixed;
121 fDCARptFormula = copy.fDCARptFormula;
122 fDCARptFormulaMin = copy.fDCARptFormulaMin;
123 fDCARmax = copy.fDCARmax;
124 fDCARmin = copy.fDCARmin;
125 fDCAZfixed = copy.fDCAZfixed;
126 fDCAZptFormula = copy.fDCAZptFormula;
127 fDCAZmax = copy.fDCAZmax;
128 fSPDminNClusters = copy.fSPDminNClusters;
129 fITSminNClusters = copy.fITSminNClusters;
130 fITSmaxChi2 = copy.fITSmaxChi2;
131 fTPCminNClusters = copy.fTPCminNClusters;
132 fTPCmaxChi2 = copy.fTPCmaxChi2;
133 fCutMaxChi2TPCConstrainedVsGlobal = copy.fCutMaxChi2TPCConstrainedVsGlobal;
134 fTPCminNCrossedRows = copy.fTPCminNCrossedRows;
135 fTPCminCrossedRowsOverFindableCls = copy.fTPCminCrossedRowsOverFindableCls;
136 fCutMinLengthActiveVolumeTPC = copy.fCutMinLengthActiveVolumeTPC;
138 fAODTestFilterBit = copy.fAODTestFilterBit;
139 fCheckOnlyFilterBit = copy.fCheckOnlyFilterBit;
140 fESDtrackCuts = copy.fESDtrackCuts;
141 SetPtRange(copy.fPt[0], copy.fPt[1]);
142 SetEtaRange(copy.fEta[0], copy.fEta[1]);
147 //_________________________________________________________________________________________________
148 void AliRsnCutTrackQuality::DisableAll()
156 fRejectKinkDaughters = kFALSE;
157 fDCARmaxfixed = kTRUE;
158 fDCARminfixed = kTRUE;
160 fDCARptFormulaMin = "";
166 fSPDminNClusters = 0;
167 fITSminNClusters = 0;
169 fTPCminNClusters = 0;
171 fAODTestFilterBit = -1;
172 fCutMaxChi2TPCConstrainedVsGlobal = 1E20;
173 fTPCminNCrossedRows = 0;
174 fTPCminCrossedRowsOverFindableCls = 0;
175 fCutMinLengthActiveVolumeTPC = 0.0;
178 const char *cutsName = fESDtrackCuts->GetName();
179 const char *cutsTitle = fESDtrackCuts->GetTitle();
180 delete fESDtrackCuts;
181 fESDtrackCuts = new AliESDtrackCuts(cutsName,cutsTitle);
183 SetPtRange(0.0, 1E20);
184 SetEtaRange(-1E20, 1E20);
187 //_________________________________________________________________________________________________
188 Bool_t AliRsnCutTrackQuality::IsSelected(TObject *object)
192 // Checks the type of object being evaluated
193 // and then calls the appropriate sub-function (for ESD or AOD)
197 if (!TargetOK(object)) return kFALSE;
199 // status is checked in the same way for all tracks, using AliVTrack
200 // as a convention, if a the collection of 'on' flags is '0x0', it
201 // is assumed that no flags are required, and this check is skipped;
202 // for the collection of 'off' flags this is not needed
203 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
205 AliDebug(AliLog::kDebug + 2, "This object is not either an ESD nor AOD track");
208 ULong_t status = (ULong_t)vtrack->GetStatus();
209 ULong_t checkOn = status & fFlagsOn;
210 ULong_t checkOff = status & fFlagsOff;
211 if (fFlagsOn != 0x0 && checkOn != fFlagsOn) {
212 AliDebug(AliLog::kDebug + 2, Form("Failed flag check: required %s", Binary(fFlagsOn)));
213 AliDebug(AliLog::kDebug + 2, Form(" track has %s", Binary(status )));
217 AliDebug(AliLog::kDebug + 2, Form("Failed flag check: forbidden %s", Binary(fFlagsOff)));
218 AliDebug(AliLog::kDebug + 2, Form(" track has %s", Binary(status )));
221 AliDebug(AliLog::kDebug + 3, Form("Flag check OK: required %s", Binary(fFlagsOn)));
222 AliDebug(AliLog::kDebug + 3, Form(" forbidden %s", Binary(fFlagsOff)));
223 AliDebug(AliLog::kDebug + 3, Form(" track has %s", Binary(status )));
225 // retrieve real object type
226 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
227 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
229 AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
231 return fESDtrackCuts->IsSelected(esdTrack);
233 return CheckESD(esdTrack);
234 } else if (aodTrack) {
235 AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
236 return CheckAOD(aodTrack);
238 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
243 //_________________________________________________________________________________________________
244 Bool_t AliRsnCutTrackQuality::CheckESD(AliESDtrack *track)
247 // Check an ESD track.
248 // This is done using the default track checker for ESD.
249 // It is declared static, not to recreate it every time.
251 //static AliESDtrackCuts cuts;
252 AliESDtrackCuts cuts;
254 // general acceptance/pt cuts
255 cuts.SetPtRange(fPt[0], fPt[1]);
256 cuts.SetEtaRange(fEta[0], fEta[1]);
258 // transverse DCA cuts
260 cuts.SetMaxDCAToVertexXY(fDCARmax);
262 cuts.SetMaxDCAToVertexXYPtDep(fDCARptFormula.Data());
265 cuts.SetMinDCAToVertexXY(fDCARmin);
267 cuts.SetMinDCAToVertexXYPtDep(fDCARptFormulaMin.Data());
269 // longitudinal DCA cuts
271 cuts.SetMaxDCAToVertexZ(fDCAZmax);
273 cuts.SetMaxDCAToVertexZPtDep(fDCAZptFormula.Data());
275 // these options are always disabled in current version
276 cuts.SetDCAToVertex2D(kFALSE);
277 cuts.SetRequireSigmaToVertex(kFALSE);
279 // TPC related cuts for TPC+ITS tracks
280 if (fIsUseCrossedRowsCut) {
281 cuts.SetMinNCrossedRowsTPC(fTPCminNCrossedRows);
282 cuts.SetMinRatioCrossedRowsOverFindableClustersTPC(fTPCminCrossedRowsOverFindableCls);
284 cuts.SetMinNClustersTPC(fTPCminNClusters);
286 cuts.SetMaxChi2PerClusterTPC(fTPCmaxChi2);
287 cuts.SetAcceptKinkDaughters(!fRejectKinkDaughters);
288 cuts.SetMaxChi2TPCConstrainedGlobal(fCutMaxChi2TPCConstrainedVsGlobal);
290 if (fIsUseLengthActiveVolumeTPCCut)
291 cuts.SetMinLengthActiveVolumeTPC(fCutMinLengthActiveVolumeTPC);
293 // ITS related cuts for TPC+ITS tracks
294 if (fSPDminNClusters > 0)
295 cuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
296 cuts.SetMaxChi2PerClusterITS(fITSmaxChi2);
298 // now that all is initialized, do the check
299 return cuts.IsSelected(track);
302 //_________________________________________________________________________________________________
303 Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
306 // Check an AOD track.
307 // This is done doing directly all checks, since there is not
308 // an equivalend checker for AOD tracks
311 // if a test bit is used, check it and skip the following
312 if (fAODTestFilterBit >= 0) {
313 UInt_t bit = 1 << fAODTestFilterBit;
314 AliDebugClass(2, Form("Required a test filter bit for AOD check: %u (result: %s)", bit, (track->TestFilterBit(bit) ? "accept" : "reject")));
315 if (!track->TestFilterBit(bit))
318 if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) return kFALSE;
319 if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) return kFALSE;
320 if (fCheckOnlyFilterBit) return kTRUE;
324 // try to retrieve the reference AOD event
325 AliAODEvent *aodEvent = 0x0;
326 if (fEvent) aodEvent = fEvent->GetRefAOD();
328 AliError("AOD reference event is not initialized!");
332 // step #0: check SPD and ITS clusters
334 nSPD = TESTBIT(track->GetITSClusterMap(), 0);
335 nSPD += TESTBIT(track->GetITSClusterMap(), 1);
336 if (nSPD < fSPDminNClusters) {
337 AliDebug(AliLog::kDebug + 2, "Not enough SPD clusters in this track. Rejected");
342 //step #1: check number of clusters
343 if ((!fIsUseCrossedRowsCut) && (track->GetTPCNcls() < fTPCminNClusters)) {
344 AliDebug(AliLog::kDebug + 2, "Too few TPC clusters. Rejected");
348 if (track->GetITSNcls() < fITSminNClusters) {
349 AliDebug(AliLog::kDebug + 2, "Too few ITS clusters. Rejected");
354 if (track->Chi2perNDF() > fTPCmaxChi2) {
355 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
358 if (track->Chi2perNDF() > fITSmaxChi2) {
359 AliDebug(AliLog::kDebug + 2, "Bad chi2. Rejected");
363 //step #2a: check number of crossed rows in TPC
364 if (fIsUseCrossedRowsCut) {
365 Float_t nCrossedRowsTPC = track->GetTPCNCrossedRows();
366 if (nCrossedRowsTPC < fTPCminNCrossedRows) {
367 AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows. Rejected");
370 if (track->GetTPCNclsF()>0) {
371 Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC / track->GetTPCNclsF();
372 if (ratioCrossedRowsOverFindableClustersTPC < fTPCminCrossedRowsOverFindableCls){
373 AliDebug(AliLog::kDebug + 2, "Too few TPC crossed rows/findable clusters. Rejected");
377 AliDebug(AliLog::kDebug + 2, "Negative value for TPC crossed rows/findable clusters. Rejected");
381 //step #2b: check on track length in active volume of TPC implemented only for ESD tracks
382 //if (fIsUseLengthActiveVolumeTPCCut) { // not yet implemented in AODs}
384 //step #3: reject kink daughters
385 AliAODVertex *vertex = track->GetProdVertex();
386 if (vertex && fRejectKinkDaughters) {
387 if (vertex->GetType() == AliAODVertex::kKink) {
388 AliDebug(AliLog::kDebug + 2, "Kink daughter. Rejected");
393 // step #4: DCA cut (transverse)
394 // --> reject all tracks not ITS refitted
395 Double_t b[2], cov[3];
396 vertex = aodEvent->GetPrimaryVertex();
398 AliDebug(AliLog::kDebug + 2, "NULL vertex");
401 if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
402 AliDebug(AliLog::kDebug + 2, "Not ITS refitted");
405 if (!track->PropagateToDCA(vertex, aodEvent->GetMagneticField(), kVeryBig, b, cov)) {
406 AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
409 // if the DCA cut is not fixed, compute current value
410 if (!fDCARmaxfixed) {
411 TString str(fDCARptFormula);
412 str.ReplaceAll("pt", "x");
413 TFormula dcaXY(Form("%s_dcaXY", GetName()), str.Data());
414 fDCARmax = dcaXY.Eval(track->Pt());
416 if (!fDCARminfixed) {
417 TString str2(fDCARptFormulaMin);
418 str2.ReplaceAll("pt", "x");
419 TFormula dcaXY_2(Form("%s_dcaXY_2", GetName()), str2.Data());
420 fDCARmin = dcaXY_2.Eval(track->Pt());
423 if (TMath::Abs(b[0]) > fDCARmax) {
424 AliDebug(AliLog::kDebug + 2, "Too large transverse DCA");
428 if (TMath::Abs(b[0]) < fDCARmin) {
429 AliDebug(AliLog::kDebug + 2, "Too short transverse DCA");
433 // step #5: DCA cut (longitudinal)
434 // the DCA has already been computed above
435 // if the DCA cut is not fixed, compute current value
437 TString str(fDCAZptFormula);
438 str.ReplaceAll("pt", "x");
439 TFormula dcaZ(Form("%s_dcaXY", GetName()), str.Data());
440 fDCAZmax = dcaZ.Eval(track->Pt());
443 if (TMath::Abs(b[1]) > fDCAZmax) {
444 AliDebug(AliLog::kDebug + 2, "Too large longitudinal DCA");
448 // step #6: check eta/pt range
449 if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) {
450 AliDebug(AliLog::kDebug + 2, "Outside ETA acceptance");
453 if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) {
454 AliDebug(AliLog::kDebug + 2, "Outside PT acceptance");
458 // if we are here, all cuts were passed and no exit point was got
459 AliDebug(AliLog::kDebug + 2, "============================= ACCEPTED TRACK =====================================================");
463 //_________________________________________________________________________________________________
464 void AliRsnCutTrackQuality::Print(const Option_t *) const
467 // Print information on this cut
470 AliInfo(Form("Cut name : %s", GetName()));
471 AliInfo(Form("Required flags (off, on): %lx %lx", fFlagsOn, fFlagsOff));
472 AliInfo(Form("Ranges in eta, pt : %.2f - %.2f, %.2f - %.2f", fEta[0], fEta[1], fPt[0], fPt[1]));
473 AliInfo(Form("Kink daughters are : %s", (fRejectKinkDaughters ? "rejected" : "accepted")));
474 AliInfo(Form("TPC requirements (clusters) : min. cluster = %i, max chi2 = %f", fTPCminNClusters, fTPCmaxChi2));
475 AliInfo(Form("TPC requirements (crossed rows) : min. crossed rows = %f, min. crossed rows/findable clusters = %f", fTPCminNCrossedRows, fTPCminCrossedRowsOverFindableCls));
476 AliInfo(Form("TPC requirements (track length) : min. track length in active volume TPC = %f", fCutMinLengthActiveVolumeTPC));
478 AliInfo(Form("ITS requirements : min. cluster = %d (all), %d (SPD), max chi2 = %f", fITSminNClusters, fSPDminNClusters, fITSmaxChi2));
481 AliInfo(Form("Max DCA r cut : fixed to %f cm", fDCARmax));
483 AliInfo(Form("Max DCA r cut formula : %s", fDCARptFormula.Data()));
487 AliInfo(Form("Min DCA r cut : fixed to %f cm", fDCARmin));
489 AliInfo(Form("Min DCA r cut formula : %s", fDCARptFormulaMin.Data()));
493 AliInfo(Form("DCA z cut : fixed to %f cm", fDCAZmax));
495 AliInfo(Form("DCA z cut formula : %s", fDCAZptFormula.Data()));
498 AliInfo(Form("fAODTestFilterBit : filter bit %i",fAODTestFilterBit));
499 AliInfo(Form("fCheckOnlyFilterBit : %i",((int) fCheckOnlyFilterBit)));
501 //__________________________________________________________________________________________________
502 void AliRsnCutTrackQuality::SetDefaults2010()
505 // Default settings for cuts used in 2010
507 AddStatusFlag(AliESDtrack::kTPCin , kTRUE);
508 AddStatusFlag(AliESDtrack::kTPCrefit, kTRUE);
509 AddStatusFlag(AliESDtrack::kITSrefit, kTRUE);
510 SetPtRange(0.15, 1E+20);
511 SetEtaRange(-0.8, 0.8);
512 SetDCARPtFormula("0.0182+0.0350/pt^1.01");
514 SetSPDminNClusters(1);
515 SetITSminNClusters(0);
516 // SetITSmaxChi2(36);
517 // SetMaxChi2TPCConstrainedGlobal(36);
518 SetTPCminNClusters(70);
520 SetRejectKinkDaughters();
521 SetAODTestFilterBit(5);
524 //__________________________________________________________________________________________________
525 void AliRsnCutTrackQuality::SetDefaultsHighPt2011(Bool_t useTPCCrossedRows)
528 // Default settings for cuts used in 2011 (for high-pT)
530 fIsUseCrossedRowsCut=useTPCCrossedRows;
531 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE, useTPCCrossedRows);
532 fESDtrackCuts->SetMinNCrossedRowsTPC(120); //default is min 70 crossed rows -> use 120 to go to higher pt
533 fESDtrackCuts->SetMaxFractionSharedTPCClusters(0.4);//default is not set --> use to go to higher pt
534 //fESDtrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);//already in 2011 std
535 //fESDtrackCuts->SetMaxChi2PerClusterITS(36);//already in 2011 std
536 //fESDtrackCuts->SetMaxChi2TPCConstrainedGlobal(36);//already in 2011 std
537 // AddStatusFlag(AliESDtrack::kTPCin , kTRUE); //already in 2011 std
538 // AddStatusFlag(AliESDtrack::kTPCrefit, kTRUE);//already in 2011 std
539 // AddStatusFlag(AliESDtrack::kITSrefit, kTRUE);//already in 2011 std
540 SetPtRange(0.15, 1E+20);
541 SetEtaRange(-0.8, 0.8);
542 SetAODTestFilterBit(10);
546 //__________________________________________________________________________________________________
547 void AliRsnCutTrackQuality::SetDefaults2011(Bool_t useTPCCrossedRows)
550 // Default std cuts 2011 with crossed rows (=70)
552 fIsUseCrossedRowsCut=useTPCCrossedRows;
553 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE,useTPCCrossedRows);
554 SetPtRange(0.15, 1E+20);
555 SetEtaRange(-0.8, 0.8);
556 SetAODTestFilterBit(5);
559 //__________________________________________________________________________________________________
560 const char *AliRsnCutTrackQuality::Binary(UInt_t number)
563 // Convert an integer in binary
570 for (z = 512; z > 0; z >>= 1)
571 strncat(b, ((number & z) == z) ? "1" : "0", 1);