]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnCutTrackQuality.cxx
Protection against negative argument of log, add histograms to study shape/size of...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutTrackQuality.cxx
index 957a5bde7393a15dbb6a9edf925e5f5efc4e5a88..7adc15bbb5defc5b0451ddcdbc158e67d2f55ef8 100644 (file)
@@ -21,8 +21,6 @@
 #include <TBits.h>
 
 #include "AliLog.h"
-#include "AliESDtrack.h"
-#include "AliAODTrack.h"
 #include "AliESDtrackCuts.h"
 
 #include "AliRsnEvent.h"
@@ -33,29 +31,30 @@ ClassImp(AliRsnCutTrackQuality)
 
 //_________________________________________________________________________________________________
 AliRsnCutTrackQuality::AliRsnCutTrackQuality(const char *name) :
-   AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
+   AliRsnCut(name, AliRsnTarget::kDaughter, 0.0, 0.0),
    fFlagsOn(0x0),
    fFlagsOff(0x0),
    fRejectKinkDaughters(kTRUE),
    fDCARfixed(kTRUE),
    fDCARptFormula(""),
-   fDCARmax(fgkVeryBig),
+   fDCARmax(1E20),
    fDCAZfixed(kTRUE),
    fDCAZptFormula(""),
-   fDCAZmax(fgkVeryBig),
+   fDCAZmax(1E20),
    fSPDminNClusters(0),
    fITSminNClusters(0),
-   fITSmaxChi2(fgkVeryBig),
+   fITSmaxChi2(1E20),
    fTPCminNClusters(0),
-   fTPCmaxChi2(fgkVeryBig)
+   fTPCmaxChi2(1E20),
+   fAODTestFilterBit(-1)
 {
 //
 // Default constructor.
 // Initializes all cuts in such a way that all of them are disabled.
 //
 
-   SetPtRange(0.0, fgkVeryBig);
-   SetEtaRange(-fgkVeryBig, fgkVeryBig);
+   SetPtRange(0.0, 1E20);
+   SetEtaRange(-1E20, 1E20);
 }
 
 //_________________________________________________________________________________________________
@@ -74,7 +73,8 @@ AliRsnCutTrackQuality::AliRsnCutTrackQuality(const AliRsnCutTrackQuality &copy)
    fITSminNClusters(copy.fITSminNClusters),
    fITSmaxChi2(copy.fITSmaxChi2),
    fTPCminNClusters(copy.fTPCminNClusters),
-   fTPCmaxChi2(copy.fTPCmaxChi2)
+   fTPCmaxChi2(copy.fTPCmaxChi2),
+   fAODTestFilterBit(copy.fAODTestFilterBit)
 {
 //
 // Copy constructor.
@@ -108,6 +108,7 @@ AliRsnCutTrackQuality& AliRsnCutTrackQuality::operator=(const AliRsnCutTrackQual
    fITSmaxChi2 = copy.fITSmaxChi2;
    fTPCminNClusters = copy.fTPCminNClusters;
    fTPCmaxChi2 = copy.fTPCmaxChi2;
+   fAODTestFilterBit = copy.fAODTestFilterBit;
 
    SetPtRange(copy.fPt[0], copy.fPt[1]);
    SetEtaRange(copy.fEta[0], copy.fEta[1]);
@@ -127,18 +128,19 @@ void AliRsnCutTrackQuality::DisableAll()
    fRejectKinkDaughters = kFALSE;
    fDCARfixed = kTRUE;
    fDCARptFormula = "";
-   fDCARmax = fgkVeryBig;
+   fDCARmax = 1E20;
    fDCAZfixed = kTRUE;
    fDCAZptFormula = "";
-   fDCAZmax = fgkVeryBig;
+   fDCAZmax = 1E20;
    fSPDminNClusters = 0;
    fITSminNClusters = 0;
-   fITSmaxChi2 = fgkVeryBig;
+   fITSmaxChi2 = 1E20;
    fTPCminNClusters = 0;
-   fTPCmaxChi2 = fgkVeryBig;
+   fTPCmaxChi2 = 1E20;
+   fAODTestFilterBit = -1;
 
-   SetPtRange(0.0, fgkVeryBig);
-   SetEtaRange(-fgkVeryBig, fgkVeryBig);
+   SetPtRange(0.0, 1E20);
+   SetEtaRange(-1E20, 1E20);
 }
 
 //_________________________________________________________________________________________________
@@ -157,26 +159,31 @@ Bool_t AliRsnCutTrackQuality::IsSelected(TObject *object)
    // as a convention, if a the collection of 'on' flags is '0x0', it
    // is assumed that no flags are required, and this check is skipped;
    // for the collection of 'off' flags this is not needed
-   AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
+   AliVTrack *vtrack = fDaughter->Ref2Vtrack();
    if (!vtrack) {
-      AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
+      AliDebug(AliLog::kDebug + 2, "This object is not either an ESD nor AOD track");
       return kFALSE;
    }
    ULong_t status   = (ULong_t)vtrack->GetStatus();
    ULong_t checkOn  = status & fFlagsOn;
    ULong_t checkOff = status & fFlagsOff;
    if (fFlagsOn != 0x0 && checkOn != fFlagsOn) {
-      AliDebug(AliLog::kDebug + 2, Form("Not all required flags are present: required %lx, track has %lx", fFlagsOn, status));
+      AliDebug(AliLog::kDebug + 2, Form("Failed flag check: required  %s", Binary(fFlagsOn)));
+      AliDebug(AliLog::kDebug + 2, Form("                   track has %s", Binary(status  )));
       return kFALSE;
    }
    if (checkOff != 0) {
-      AliDebug(AliLog::kDebug + 2, Form("Some forbidden flags are present: required %lx, track has %lx", fFlagsOff, status));
+      AliDebug(AliLog::kDebug + 2, Form("Failed flag check: forbidden %s", Binary(fFlagsOff)));
+      AliDebug(AliLog::kDebug + 2, Form("                   track has %s", Binary(status  )));
       return kFALSE;
    }
+   AliDebug(AliLog::kDebug + 3, Form("Flag check OK: required  %s", Binary(fFlagsOn)));
+   AliDebug(AliLog::kDebug + 3, Form("               forbidden %s", Binary(fFlagsOff)));
+   AliDebug(AliLog::kDebug + 3, Form("               track has %s", Binary(status  )));
 
    // retrieve real object type
-   AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
-   AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
+   AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
+   AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
    if (esdTrack) {
       AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
       return CheckESD(esdTrack);
@@ -242,6 +249,27 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
 // an equivalend checker for AOD tracks
 //
 
+   // if a test bit is used, check it and skip the following
+   if (fAODTestFilterBit >= 0) {
+      UInt_t bit = 1 << fAODTestFilterBit;
+      AliDebugClass(2, Form("Required a test filter bit for AOD check: %u (result: %s)", bit, (track->TestFilterBit(bit) ? "accept" : "reject")));
+      if (!track->TestFilterBit(bit)) 
+         return kFALSE;
+      else {
+         if (track->Pt() < fPt[0] || track->Pt() > fPt[1]) return kFALSE;
+         if (track->Eta() < fEta[0] || track->Eta() > fEta[1]) return kFALSE;
+         return kTRUE;
+      }
+   }
+   
+   // try to retrieve the reference AOD event
+   AliAODEvent *aodEvent = 0x0;
+   if (fEvent) aodEvent = fEvent->GetRefAOD();
+   if (!aodEvent) {
+      AliError("AOD reference event is not initialized!");
+      return kFALSE;
+   }
+
    // step #0: check SPD and ITS clusters
    Int_t nSPD = 0;
    nSPD  = TESTBIT(track->GetITSClusterMap(), 0);
@@ -281,13 +309,18 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
    }
 
    // step #4: DCA cut (transverse)
+   // --> reject all tracks not ITS refitted
    Double_t b[2], cov[3];
-   vertex = AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetPrimaryVertex();
+   vertex = aodEvent->GetPrimaryVertex();
    if (!vertex) {
       AliDebug(AliLog::kDebug + 2, "NULL vertex");
       return kFALSE;
    }
-   if (!track->PropagateToDCA(vertex, AliRsnTarget::GetCurrentEvent()->GetRefAOD()->GetMagneticField(), kVeryBig, b, cov)) {
+   if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) {
+      AliDebug(AliLog::kDebug + 2, "Not ITS refitted");
+      return kFALSE;
+   }
+   if (!track->PropagateToDCA(vertex, aodEvent->GetMagneticField(), kVeryBig, b, cov)) {
       AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex");
       return kFALSE;
    }
@@ -330,6 +363,7 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track)
    }
 
    // if we are here, all cuts were passed and no exit point was got
+   AliDebug(AliLog::kDebug + 2, "============================= ACCEPTED TRACK =====================================================");
    return kTRUE;
 }