From 617ae848e8313a807cf91686ef09b76bbf8c3948 Mon Sep 17 00:00:00 2001 From: James Richard Catmore <james.catmore@cern.ch> Date: Wed, 20 May 2020 23:21:58 +0200 Subject: [PATCH] Manually sweeping DerivationFrameworkInDet/InDetTrackSelectionToolWrapper from 21.2 to master The tool InDetTrackSelectionToolWrapper is required to allow the derivation framework to decorate InDetTrackParticles with track selection flags and thereby allow their selection. This MR sweeps the tool from 21.2 to master. In consequence of this MR the full set of InDetTrackParticle thinning criteria can be applied in DAOD_PHYS; this is also set in the MR. --- .../InDetTrackSelectionToolWrapper.h | 36 ++++++++++ .../python/InDetCommon.py | 15 ++++- .../src/InDetTrackSelectionToolWrapper.cxx | 67 +++++++++++++++++++ .../DerivationFrameworkInDet_entries.cxx | 2 + .../DerivationFrameworkPhys/share/PHYS.py | 3 +- 5 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h create mode 100644 PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/InDetTrackSelectionToolWrapper.cxx diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h new file mode 100644 index 00000000000..ed9e2eb4fdf --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// InDetTrackSelectionToolWrapper.h +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_INDETTRACKSELECTIONTOOLWRAPPER_H +#define DERIVATIONFRAMEWORK_INDETTRACKSELECTIONTOOLWRAPPER_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "GaudiKernel/ToolHandle.h" + +namespace DerivationFramework { + + class InDetTrackSelectionToolWrapper : public AthAlgTool, public IAugmentationTool { + public: + InDetTrackSelectionToolWrapper(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + ToolHandle< InDet::IInDetTrackSelectionTool > m_tool; + std::string m_sgName; + std::string m_containerName; + }; +} + +#endif // DERIVATIONFRAMEWORK_INDETTRACKSELECTIONTOOLWRAPPER_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py index facd6de4964..56339d7b609 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py @@ -13,6 +13,17 @@ from RecExConfig.InputFilePeeker import inputFileSummary from AthenaCommon.BeamFlags import jobproperties if (jobproperties.Beam.beamType()!="cosmics") and ( not inputFileSummary['eventdata_items'] or any('PrimaryVertices' in elements for elements in inputFileSummary['eventdata_items']) ): +#==================================================================== +# LABELLING TRACKS WITH OUTCOME OF SELECTOR TOOL +#==================================================================== + + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__InDetTrackSelectionToolWrapper + DFCommonTrackSelection = DerivationFramework__InDetTrackSelectionToolWrapper(name = "DFCommonTrackSelection", + ContainerName = "InDetTrackParticles", + DecorationName = "DFCommonTightPrimary" ) + DFCommonTrackSelection.TrackSelectionTool.CutLevel = "TightPrimary" + ToolSvc += DFCommonTrackSelection + #==================================================================== # EXPRESSION OF Z0 AT THE PRIMARY VERTEX #==================================================================== @@ -23,11 +34,13 @@ if (jobproperties.Beam.beamType()!="cosmics") and ( not inputFileSummary['eventd Z0SGEntryName = "DFCommonInDetTrackZ0AtPV" ) ToolSvc += DFCommonZ0AtPV + + #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM #======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("InDetCommonKernel", - AugmentationTools = [DFCommonZ0AtPV] + AugmentationTools = [DFCommonTrackSelection,DFCommonZ0AtPV] ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/InDetTrackSelectionToolWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/InDetTrackSelectionToolWrapper.cxx new file mode 100644 index 00000000000..203c5090ac0 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/InDetTrackSelectionToolWrapper.cxx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// InDetTrackSelectionToolWrapper.cxx +/////////////////////////////////////////////////////////////////// + +#include "DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h" +#include "xAODTracking/TrackParticleContainer.h" +#include <vector> +#include <string> + +namespace DerivationFramework { + + InDetTrackSelectionToolWrapper::InDetTrackSelectionToolWrapper(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p), + m_tool("InDet::InDetTrackSelectionTool/TrackSelectionTool", this ), + m_sgName(""), + m_containerName("") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("TrackSelectionTool", m_tool); + declareProperty("DecorationName", m_sgName); + declareProperty("ContainerName", m_containerName); + } + + StatusCode InDetTrackSelectionToolWrapper::initialize() + { + if (m_sgName=="") { + ATH_MSG_ERROR("No decoration prefix name provided for the output of InDetTrackSelectionToolWrapper!"); + return StatusCode::FAILURE; + } + if (m_containerName=="") { + ATH_MSG_ERROR("No TrackParticle collection provided for InDetTrackSelectionToolWrapper!"); + return StatusCode::FAILURE; + } + ATH_CHECK(m_tool.retrieve()); + return StatusCode::SUCCESS; + } + + StatusCode InDetTrackSelectionToolWrapper::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode InDetTrackSelectionToolWrapper::addBranches() const + { + + // retrieve track container + const xAOD::TrackParticleContainer* tracks = evtStore()->retrieve< const xAOD::TrackParticleContainer >( m_containerName ); + if( ! tracks ) { + ATH_MSG_ERROR ("Couldn't retrieve TrackParticles with key: " << m_containerName ); + return StatusCode::FAILURE; + } + // Run tool for each element and decorate with the decision + for (xAOD::TrackParticleContainer::const_iterator trItr = tracks->begin(); trItr!=tracks->end(); ++trItr) { + SG::AuxElement::Decorator< bool > accept(m_sgName); + accept( **trItr ) = m_tool->accept(*trItr).getCutResult(0); + } // end of loop over tracks + + return StatusCode::SUCCESS; + } + +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/components/DerivationFrameworkInDet_entries.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/components/DerivationFrameworkInDet_entries.cxx index 68df09c97aa..eb3e0aad67b 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/components/DerivationFrameworkInDet_entries.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/src/components/DerivationFrameworkInDet_entries.cxx @@ -15,6 +15,7 @@ #include "DerivationFrameworkInDet/TrackMeasurementThinning.h" #include "DerivationFrameworkInDet/EventInfoPixelDecorator.h" #include "DerivationFrameworkInDet/PixelNtupleMaker.h" +#include "DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h" using namespace DerivationFramework; @@ -35,3 +36,4 @@ DECLARE_COMPONENT( EGammaTracksThinning ) DECLARE_COMPONENT( TrackMeasurementThinning ) DECLARE_COMPONENT( EventInfoPixelDecorator ) DECLARE_COMPONENT( PixelNtupleMaker ) +DECLARE_COMPONENT( InDetTrackSelectionToolWrapper ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py index c839a9aa48d..8bca9d9b5d4 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py @@ -71,8 +71,7 @@ for trig_item in inputFileSummary['metadata']['/TRIGGER/HLT/Menu']: # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations # Inner detector group recommendations for indet tracks in analysis -#PHYS_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV" -PHYS_thinning_expression = "abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV" +PHYS_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV" from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning PHYSTrackParticleThinningTool = DerivationFramework__TrackParticleThinning(name = "PHYSTrackParticleThinningTool", StreamName = PHYSStream.Name, -- GitLab