ATLAS Offline Software
AsgSelectionToolWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Author: James Catmore (james.catmore@cern.ch)
6 
8 #include "PATCore/AcceptData.h"
9 #include "StoreGate/ReadHandle.h"
11 
12 
13 namespace DerivationFramework {
14 
16  ATH_CHECK(m_tool.retrieve());
17  ATH_CHECK(m_containerKey.initialize());
18  ATH_CHECK(m_decorKey.initialize());
19  return StatusCode::SUCCESS;
20  }
21 
22 
23 
24  StatusCode AsgSelectionToolWrapper::addBranches(const EventContext& ctx) const
25  {
26  // retrieve container
27 
29  if( ! decorator.isValid() ) {
30  ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerKey.fullKey() );
31  return StatusCode::FAILURE;
32  }
33 
34  // Write mask for each element and record to SG for subsequent selection
35  for ( const xAOD::IParticle* part : *decorator) {
36  auto theAccept = m_tool->accept(part); // asg::AcceptData or TAccept
37  if(m_cut.empty()){
38  decorator(*part) = true && theAccept;
39  } else{
40  decorator(*part) = true && theAccept.getCutResult(m_cut);
41  }
42  }
43 
44  return StatusCode::SUCCESS;
45  }
46 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::AsgSelectionToolWrapper::m_tool
PublicToolHandle< IAsgSelectionTool > m_tool
Definition: AsgSelectionToolWrapper.h:27
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
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
AcceptData.h
DerivationFramework::AsgSelectionToolWrapper::m_containerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
Definition: AsgSelectionToolWrapper.h:29
DerivationFramework::AsgSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: AsgSelectionToolWrapper.h:28
DerivationFramework::AsgSelectionToolWrapper::initialize
virtual StatusCode initialize() override final
Definition: AsgSelectionToolWrapper.cxx:15
DerivationFramework::AsgSelectionToolWrapper::m_decorKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decorKey
Definition: AsgSelectionToolWrapper.h:30
AsgSelectionToolWrapper.h
DerivationFramework::AsgSelectionToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: AsgSelectionToolWrapper.cxx:24
ReadHandle.h
Handle class for reading from StoreGate.