ATLAS Offline Software
InDetTrackSelectionToolWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // InDetTrackSelectionToolWrapper.cxx
8 
11 #include "StoreGate/ReadHandle.h"
13 #include <vector>
14 #include <string>
15 #include <string_view>
16 
17 namespace DerivationFramework {
18 
20  const std::string& n,
21  const IInterface* p) :
22  AthAlgTool(t,n,p)
23  {
24  declareInterface<DerivationFramework::IAugmentationTool>(this);
25  }
26 
28  {
29  if (m_decorationKey.empty()) {
30  ATH_MSG_ERROR("No decoration prefix name provided for the output of InDetTrackSelectionToolWrapper!");
31  return StatusCode::FAILURE;
32  }
33 
35  std::string::size_type pos = m_tracksKey.key().find('+');
36  pos = (pos != std::string::npos) ? pos+1 : 0;
37  std::string_view container_name( &(m_tracksKey.key()[pos]), m_tracksKey.key().size() - pos);
38  std::string_view decor_name(m_decorationKey.key());
39  if (!(decor_name.compare(0,m_tracksKey.key().size(),std::string_view(m_tracksKey.key()))==0 && decor_name.compare(0,container_name.size(),container_name)==0)) {
40  m_decorationKey = std::string(container_name) + "." + m_decorationKey.key();
41  }
42  std::cout << "DEBUG " << name() << " InDetTrackSelectionToolWrapper::initialize container key " << m_tracksKey.key() << " -> " << container_name << " decor=" << m_decorationKey.key() << std::endl;
44  ATH_MSG_INFO("Using " << m_tracksKey << "as the source collection for inner detector track particles");
45  ATH_CHECK(m_tool.retrieve());
46  ATH_MSG_INFO(" InDetTrackSelectionToolWrapper::initialize i: " << inputHandles().size() << " o:" << outputHandles().size() );
47  return StatusCode::SUCCESS;
48  }
49 
51  {
52  return StatusCode::SUCCESS;
53  }
54 
56  {
57 
58  // Get current context
59  const EventContext& ctx = Gaudi::Hive::currentContext();
60 
61  // retrieve track container
63  if (!tracks.isValid()) {
64  //if( ! tracks ) {
65  ATH_MSG_ERROR ("Couldn't retrieve TrackParticles with key: " << tracks.key() );
66  return StatusCode::FAILURE;
67  }
68  // Run tool for each element and decorate with the decision
70  for (const auto *trItr : *tracks) {
71  accept( *trItr ) = m_tool->accept(trItr).getCutResult(0);
72  } // end of loop over tracks
73 
74  return StatusCode::SUCCESS;
75  }
76 
77 }
DerivationFramework::InDetTrackSelectionToolWrapper::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: InDetTrackSelectionToolWrapper.cxx:55
DerivationFramework::InDetTrackSelectionToolWrapper::finalize
StatusCode finalize()
Definition: InDetTrackSelectionToolWrapper.cxx:50
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
DerivationFramework::InDetTrackSelectionToolWrapper::InDetTrackSelectionToolWrapper
InDetTrackSelectionToolWrapper(const std::string &t, const std::string &n, const IInterface *p)
Definition: InDetTrackSelectionToolWrapper.cxx:19
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::InDetTrackSelectionToolWrapper::m_tool
ToolHandle< InDet::IInDetTrackSelectionTool > m_tool
Definition: InDetTrackSelectionToolWrapper.h:32
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
InDetTrackSelectionToolWrapper.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles
virtual std::vector< Gaudi::DataHandle * > inputHandles() const override
Return this algorithm's input handles.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::InDetTrackSelectionToolWrapper::m_tracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Definition: InDetTrackSelectionToolWrapper.h:35
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DerivationFramework::InDetTrackSelectionToolWrapper::initialize
StatusCode initialize()
Definition: InDetTrackSelectionToolWrapper.cxx:27
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::InDetTrackSelectionToolWrapper::m_decorationKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decorationKey
Definition: InDetTrackSelectionToolWrapper.h:38
TrackParticleContainer.h