]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
Changes for #82873: Module debugging broken (Christian)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDITS.cxx
index 82b2699d9a463c692cf2c46af6b89f6889413311..ba5a9b10e966f57c4cba6be14b1c7e6e6f418f0c 100644 (file)
 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
 //
 
+#include "AliESDtrackCuts.h"
+#include "AliAODpidUtil.h"
 #include "AliAnalysisManager.h"
 #include "AliESDInputHandler.h"
 
+#include "AliRsnDaughter.h"
+
 #include "AliRsnCutPIDITS.h"
 
 ClassImp(AliRsnCutPIDITS)
@@ -27,7 +31,7 @@ ClassImp(AliRsnCutPIDITS)
 AliRsnCutPIDITS::AliRsnCutPIDITS
 (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
    AliRsnCut(name, AliRsnCut::kDaughter, min, max),
-   fInitialized(kFALSE),
+   fIsMC(kFALSE),
    fRejectOutside(rejectOutside),
    fMomMin(0.0),
    fMomMax(1E+20),
@@ -44,7 +48,7 @@ AliRsnCutPIDITS::AliRsnCutPIDITS
 AliRsnCutPIDITS::AliRsnCutPIDITS
 (const AliRsnCutPIDITS& copy) :
    AliRsnCut(copy),
-   fInitialized(kFALSE),
+   fIsMC(copy.fIsMC),
    fRejectOutside(copy.fRejectOutside),
    fMomMin(copy.fMomMin),
    fMomMax(copy.fMomMax),
@@ -66,7 +70,7 @@ AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
 
    AliRsnCut::operator=(copy);
 
-   fInitialized   = kFALSE;
+   fIsMC          = copy.fIsMC;
    fRejectOutside = copy.fRejectOutside;
    fMomMin        = copy.fMomMin;
    fMomMax        = copy.fMomMax;
@@ -77,19 +81,6 @@ AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
    return (*this);
 }
 
-//_________________________________________________________________________________________________
-void AliRsnCutPIDITS::SetMC(Bool_t yn)
-{
-//
-// Properly set the PID response
-//
-
-   AliITSPIDResponse itsresponse(yn);
-
-   fESDpid.GetITSResponse() = itsresponse;
-   fAODpid.GetITSResponse() = itsresponse;
-}
-
 //_________________________________________________________________________________________________
 Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
 {
@@ -97,15 +88,12 @@ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
 // Cut checker.
 //
 
-   // initialize if needed
-   if (!fInitialized) Initialize();
-
    // coherence check
    if (!TargetOK(object)) return kFALSE;
 
    // reject not ITS tracks
    // status is checked in the same way for all tracks
-   AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
+   AliVTrack *vtrack = fDaughter->Ref2Vtrack();
    if (!vtrack) {
       AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
       return kFALSE;
@@ -124,14 +112,8 @@ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
    // common evaluation variables
    Int_t        k, nITSpidLayers = 0;
    Double_t     mom      = vtrack->P();
-   AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
-   AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
-
-   // check momentum
-   if (mom < fMomMin || mom > fMomMax) {
-      AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
-      return (!fRejectOutside);
-   }
+   AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
+   AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
 
    // count number of PID layers...
    if (esdTrack) {
@@ -151,13 +133,29 @@ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
 
    // assign PID nsigmas to default cut check value
    // since bad object types are rejected before, here we have an ESD track or AOD track
-   if (esdTrack)
-      fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
-   else
-      fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
+   if (esdTrack) {
+      if (!fESDpid) fESDpid = new AliESDpid(fIsMC);
+      fCutValueD = fESDpid->GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
+   } else {
+      if (!fAODpid) fAODpid = new AliAODpidUtil(fIsMC);
+      fCutValueD = fAODpid->NumberOfSigmasITS(aodTrack, fRefType);
+   }
 
-   // use default cut checking method
-   return OkRangeD();
+   // use AliRsnCut default method to check cut
+   Bool_t cutCheck = OkRangeD();
+
+   // now check the momentum:
+   // -- if it stays inside the accepted range, track just checked
+   //    with respect to the nsigma band
+   // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
+   //    track is always rejected, while if 'fRejectOutside' is kFALSE,
+   //    track is accepted if it stays inside the nsigma band
+   if ((mom >= fMomMin && mom <= fMomMax))
+      return cutCheck;
+   else {
+      AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
+      return ((!fRejectOutside) && cutCheck);
+   }
 }
 
 //_________________________________________________________________________________________________
@@ -172,20 +170,3 @@ void AliRsnCutPIDITS::Print(const Option_t *) const
    AliInfo(Form("--> momentum range          : %.3f %.3f", fMomMin, fMomMax));
    AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
 }
-
-//_________________________________________________________________________________________________
-void AliRsnCutPIDITS::Initialize()
-{
-//
-// Initialize ESD pid object from global one
-//
-
-   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-   AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
-   if (handler) {
-      AliESDpid *pid = handler->GetESDpid();
-      fESDpid = (*pid);
-   }
-
-   fInitialized = kTRUE;
-}