ATLAS Offline Software
SimpleJetTrackSelectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
10  asg::AsgTool(name) {
11 
12  declareProperty("PtMin", m_ptmin =500.0);
13  declareProperty("InputContainer", m_inputContainer_key);
14  declareProperty("OutputContainer", m_outputContainer_key);
15 }
16 
18  ATH_MSG_INFO("Initializing tool " << name() << "...");
19  ATH_MSG_DEBUG("initializing version with data handles");
20 
23  return StatusCode::SUCCESS;
24 }
25 
27  ATH_MSG_DEBUG(" execute() ... ");
28 
29  auto handle_in = SG::makeHandle(m_inputContainer_key);
30  if(!handle_in.isValid()){
31  ATH_MSG_ERROR("Can't retrieve input track container "
33  return 1;
34  }
35 
36  const auto *inCont = handle_in.cptr();
37 
39  OutContType* outCont = new OutContType(SG::VIEW_ELEMENTS);
40 
41  selectTracks(*inCont, *outCont);
42  ATH_MSG_DEBUG(" in size = "<< inCont->size() << " outSize="<< outCont->size());
43 
45  if(!handle.record(std::unique_ptr<OutContType>(outCont))){
46  ATH_MSG_ERROR("Can't record output track container "
48  return 1;
49  }
50  return 0;
51 }
52 
54  return trk.pt() >= m_ptmin;
55 }
56 
57 template<class T>
59  for ( const xAOD::TrackParticle* ptrk : inCont ) {
60  if ( ptrk != nullptr && keep(*ptrk) ) outCont.push_back(ptrk) ;
61  }
62 }
63 
64 
66  selectionLoop(inCont, outCont);
67 }
68 
69 void SimpleJetTrackSelectionTool::selectTracks(const xAOD::TrackParticleContainer& inCont, std::vector<const xAOD::TrackParticle*> outCont) const {
70  selectionLoop(inCont, outCont);
71 }
WriteHandle.h
Handle class for recording to StoreGate.
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:73
SimpleJetTrackSelectionTool::m_outputContainer_key
SG::WriteHandleKey< ConstDataVector< xAOD::TrackParticleContainer > > m_outputContainer_key
Definition: SimpleJetTrackSelectionTool.h:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
asg
Definition: DataHandleTestTool.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SimpleJetTrackSelectionTool.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SimpleJetTrackSelectionTool::keep
int keep(const xAOD::TrackParticle &trk) const
Method to select.
Definition: SimpleJetTrackSelectionTool.cxx:53
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
DataVector< xAOD::TrackParticle_v1 >
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ReadHandle.h
Handle class for reading from StoreGate.
SimpleJetTrackSelectionTool::execute
int execute() const
Method to be called for each event.
Definition: SimpleJetTrackSelectionTool.cxx:26
SimpleJetTrackSelectionTool::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: SimpleJetTrackSelectionTool.cxx:17
SimpleJetTrackSelectionTool::m_ptmin
float m_ptmin
Definition: SimpleJetTrackSelectionTool.h:46
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
SimpleJetTrackSelectionTool::SimpleJetTrackSelectionTool
SimpleJetTrackSelectionTool(const std::string &name)
Definition: SimpleJetTrackSelectionTool.cxx:9
SimpleJetTrackSelectionTool::m_inputContainer_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputContainer_key
Definition: SimpleJetTrackSelectionTool.h:48
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
SimpleJetTrackSelectionTool::selectionLoop
void selectionLoop(const xAOD::TrackParticleContainer &inCont, T &outCont) const
Definition: SimpleJetTrackSelectionTool.cxx:58
SimpleJetTrackSelectionTool::selectTracks
void selectTracks(const xAOD::TrackParticleContainer &inCont, ConstDataVector< xAOD::TrackParticleContainer > &outCont) const
Definition: SimpleJetTrackSelectionTool.cxx:65
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35