From cd2a7d781618ccd86b14e42cc1a6c5a9f83f6e98 Mon Sep 17 00:00:00 2001 From: adbailey <adam.bailey@cern.ch> Date: Mon, 25 Jun 2018 13:05:33 +0200 Subject: [PATCH] Migrated TauTrackFilter to data handles, added that and a few previous tools to run scripts Former-commit-id: 795a22fb9c37bb461ce21939a06fb44d34e49b37 --- .../tauRec/python/TauAlgorithmsHolder.py | 2 +- Reconstruction/tauRec/python/TauRecBuilder.py | 6 ++-- .../tauRecTools/Root/TauTrackFilter.cxx | 29 ++++++++++++------- .../tauRecTools/tauRecTools/TauTrackFilter.h | 2 ++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py index d998386d336d..abc165ae7296 100644 --- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py +++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py @@ -712,7 +712,7 @@ def getTauTrackFinder(removeDuplicateTracks=True): def getTauTrackFilter(): _name = sPrefix + 'TauTrackFilter' from tauRecTools.tauRecToolsConf import TauTrackFilter - TauTrackFilter = TauTrackFilter(name = _name, TrackContainerName=_DefaultTrackContainer) + TauTrackFilter = TauTrackFilter(name = _name, Key_trackParticleInputContainer = _DefaultTrackContainer) cached_instances[_name] = TauTrackFilter return TauTrackFilter diff --git a/Reconstruction/tauRec/python/TauRecBuilder.py b/Reconstruction/tauRec/python/TauRecBuilder.py index d7dc20272099..203b3473db76 100644 --- a/Reconstruction/tauRec/python/TauRecBuilder.py +++ b/Reconstruction/tauRec/python/TauRecBuilder.py @@ -111,10 +111,10 @@ class TauRecCoreBuilder ( TauRecConfigured ) : tools.append(taualgs.getTauTrackFinder(removeDuplicateTracks=(not doMVATrackClassification) )) if doMVATrackClassification : tools.append(taualgs.getTauTrackClassifier()) tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy')) - #tools.append(taualgs.getCellVariables()) - #tools.append(taualgs.getElectronVetoVars()) + tools.append(taualgs.getCellVariables()) + tools.append(taualgs.getElectronVetoVars()) # - #tools.append(taualgs.getTauTrackFilter()) + tools.append(taualgs.getTauTrackFilter()) #tools.append(taualgs.getTauGenericPi0Cone()) # ### already commented out#tools.append(taualgs.getPi0EflowCreateROI()) diff --git a/Reconstruction/tauRecTools/Root/TauTrackFilter.cxx b/Reconstruction/tauRecTools/Root/TauTrackFilter.cxx index d89b61b185c6..ae8bf0ae1e65 100644 --- a/Reconstruction/tauRecTools/Root/TauTrackFilter.cxx +++ b/Reconstruction/tauRecTools/Root/TauTrackFilter.cxx @@ -67,7 +67,7 @@ TauTrackFilter::~TauTrackFilter() { StatusCode TauTrackFilter::initialize() { ATH_MSG_VERBOSE("TauTrackFilter Initialising"); - + ATH_CHECK( m_trackParticleInputContainer.initialize() ); return StatusCode::SUCCESS; } @@ -91,14 +91,15 @@ StatusCode TauTrackFilter::execute(xAOD::TauJet& pTau) { StatusCode sc; - const xAOD::TrackParticleContainer *trackContainer; - - //TODO: trigger uses getObject - sc = evtStore()->retrieve(trackContainer, m_trackContainerName); - if (sc.isFailure() || !trackContainer) { - ATH_MSG_DEBUG(" No track container found in TDS !!"); - return StatusCode::SUCCESS; + // get track particle container + // wait - is this even used? + const xAOD::TrackParticleContainer *trackContainer = NULL; + SG::ReadHandle<xAOD::TrackParticleContainer> trackParticleInHandle( m_trackParticleInputContainer ); + if (!trackParticleInHandle.isValid()) { + ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << trackParticleInHandle.key()); + return StatusCode::FAILURE; } + trackContainer = trackParticleInHandle.cptr(); TLorentzVector tau; tau.SetPtEtaPhiE(pTau.pt()/1000, //GeV @@ -173,10 +174,18 @@ StatusCode TauTrackFilter::execute(xAOD::TauJet& pTau) { } m_nProng = nProng; m_flag = flag; + + // Get track container via link from tau - instead of storegate retrieve + // Check that size > 0 + ElementLink< xAOD::TauTrackContainer > link; + xAOD::TauTrackContainer* tauTracks = 0; + + if (pTau.allTauTrackLinks().size() > 0) { + link = pTau.allTauTrackLinks().at(0);//we don't care about this specific link, just the container + tauTracks = link.getDataNonConstPtr(); + } // Set values in EDM - xAOD::TauTrackContainer* tauTracks = 0; - ATH_CHECK(evtStore()->retrieve(tauTracks, m_tauTrackConName)); for (unsigned int numTrack=0; numTrack<m_TrkPass.size(); numTrack++) { xAOD::TauTrack* tauTrk = xAOD::TauHelpers::tauTrackNonConst(&pTau, tauTracks, numTrack); //pTau.trackNonConst(numTrack); tauTrk->setFlag(xAOD::TauJetParameters::failTrackFilter, !m_TrkPass.at(numTrack)); diff --git a/Reconstruction/tauRecTools/tauRecTools/TauTrackFilter.h b/Reconstruction/tauRecTools/tauRecTools/TauTrackFilter.h index f06180fe6891..a8e2df401e03 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauTrackFilter.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauTrackFilter.h @@ -45,6 +45,8 @@ private: int m_nProng; int m_flag; + SG::ReadHandleKey<xAOD::TrackParticleContainer> m_trackParticleInputContainer{this,"Key_trackParticleInputContainer","InDetTrackParticles","track key"}; + }; #endif -- GitLab