diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/DerivationFrameworkInDet/InDetTrackSelectionToolWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..ed9e2eb4fdf8e71da51bc4fd36203b118b80108c --- /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 facd6de4964edccc10c37d46022a7dd5d7d3c81c..56339d7b609b24aa23c80d36e4e834923c7e13ba 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 0000000000000000000000000000000000000000..203c5090ac0f4ba6e718417a7efd390aeef2c5ed --- /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 68df09c97aaea1c60f7c685bc1b0a53c736b029a..eb3e0aad67b6bdf61b545f7ad56709abbf9358f4 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 c839a9aa48de9bafa3bed6cf7647333cc096f51b..8bca9d9b5d4135ef88017e4f94a12c8a37f5ca3a 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,