]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnCutPIDTOF.cxx
Implementation of all needed changes in the package in order to speed-up the executio...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDTOF.cxx
index caded4232b7b0476ceb2f08232dd791573b5192c..1e263f12c5413233aed62af1e3acd787c399d37a 100644 (file)
 
 #include "AliAnalysisManager.h"
 #include "AliESDInputHandler.h"
+#include "AliESDtrack.h"
+#include "AliESDpid.h"
+#include "AliAODTrack.h"
+#include "AliAODpidUtil.h"
 
 #include "AliRsnCutPIDTOF.h"
 
@@ -22,12 +26,11 @@ ClassImp(AliRsnCutPIDTOF)
 AliRsnCutPIDTOF::AliRsnCutPIDTOF
 (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) :
    AliRsnCut(name, AliRsnCut::kDaughter, min, max),
-   fInitialized(kFALSE),
    fRejectUnmatched(rejectUnmatched),
    fRefType(AliPID::kUnknown),
    fRefMass(0.0),
-   fESDpid(),
-   fAODpid()
+   fESDpid(0x0),
+   fAODpid(0x0)
 {
 //
 // Default constructor.
@@ -41,7 +44,6 @@ AliRsnCutPIDTOF::AliRsnCutPIDTOF
 //_________________________________________________________________________________________________
 AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) :
    AliRsnCut(copy),
-   fInitialized(kFALSE),
    fRejectUnmatched(copy.fRejectUnmatched),
    fRefType(AliPID::kUnknown),
    fRefMass(0.0),
@@ -66,7 +68,6 @@ AliRsnCutPIDTOF& AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF& copy)
 // which sets the mass accordingly and coherently.
 //
 
-   fInitialized     = kFALSE;
    fRejectUnmatched = copy.fRejectUnmatched;
    fESDpid          = copy.fESDpid;
    fAODpid          = copy.fAODpid;
@@ -83,9 +84,6 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
 // Cut checker.
 //
 
-   // initialize if needed
-   if (!fInitialized) Initialize();
-
    // coherence check
    if (!TargetOK(object)) return kFALSE;
 
@@ -103,7 +101,7 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
    // -- kFALSE --> all unmatched tracks are accepted (it is assumed that other PIDs are done)
    if (!IsMatched(vtrack)) {
       AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF");
-      return (!fRejectUnmatched);
+      if (fRejectUnmatched) return kFALSE;
    }
 
    // retrieve real object type and
@@ -117,29 +115,26 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
    if (esdTrack) {
       // setup the ESD PID object
       AliESDEvent *esd = 0x0;
-      if (fEvent) {
-         esd = fEvent->GetRefESD();
-         if (!esd) {
-            AliError("Processing an ESD track, but target is not an ESD event");
-            return kFALSE;
-         }
-      } else {
-         AliError("NULL event reference");
+      if (fEvent) esd = fEvent->GetRefESD();
+      if (!esd) {
+         AliError("Processing an ESD track, but target is not an ESD event");
          return kFALSE;
       }
-      fESDpid.SetTOFResponse(esd, AliESDpid::kTOF_T0);
+      if (!fESDpid) fESDpid = new AliESDpid;
+      fESDpid->SetTOFResponse(esd, AliESDpid::kTOF_T0);
 
       // get time of flight, reference times and sigma
       esdTrack->GetIntegratedTimes(times);
-      tof   = (Double_t)(esdTrack->GetTOFsignal() - fESDpid.GetTOFResponse().GetStartTime(esdTrack->P()));
-      sigma = (Double_t)fESDpid.GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass);
+      tof   = (Double_t)(esdTrack->GetTOFsignal() - fESDpid->GetTOFResponse().GetStartTime(esdTrack->P()));
+      sigma = (Double_t)fESDpid->GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass);
 
       // port values to standard AliRsnCut checker
       fCutValueD = (tof - ref) / sigma;
       return OkRangeD();
    } else if (aodTrack) {
       // for AOD tracks, all operations are done by the AOD PID utility
-      fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(aodTrack, fRefType);
+      if (!fAODpid) fAODpid = new AliAODpidUtil;
+      fCutValueD = (Double_t)fAODpid->NumberOfSigmasTOF(aodTrack, fRefType);
       return OkRangeD();
    } else {
       AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
@@ -159,19 +154,3 @@ void AliRsnCutPIDTOF::Print(const Option_t *) const
    AliInfo(Form("Unmatched tracks are      : %s", (fRejectUnmatched ? "rejected" : "accepted")));
 }
 
-//_________________________________________________________________________________________________
-void AliRsnCutPIDTOF::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();
-      if (pid) fESDpid = (*pid);
-   }
-
-   fInitialized = kTRUE;
-}