ATLAS Offline Software
AsgSelectionToolWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // AsgSelectionToolWrapper.cxx, (c) ATLAS Detector software
8 // Author: James Catmore (james.catmore@cern.ch)
9 //
10 
12 #include "PATCore/AcceptData.h"
13 #include "StoreGate/ReadHandle.h"
15 
16 
17 namespace DerivationFramework {
18 
20  const std::string& n,
21  const IInterface* p) :
22  AthAlgTool(t,n,p)
23 
24  {
25  declareInterface<DerivationFramework::IAugmentationTool>(this);
26 
27  }
28 
30  if (m_sgName.value().empty()) {
31  ATH_MSG_ERROR("No SG name provided for the output of invariant mass tool!");
32  return StatusCode::FAILURE;
33  }
34  ATH_CHECK(m_tool.retrieve());
35  ATH_CHECK(m_containerKey.initialize());
36  m_decorKey = m_containerKey.key() + "." + m_sgName;
37  ATH_CHECK(m_decorKey.initialize());
38  return StatusCode::SUCCESS;
39  }
40 
41 
42 
44  {
45  // retrieve container
46 
47  const EventContext& ctx = Gaudi::Hive::currentContext();
49  if( ! decorator.isValid() ) {
50  ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerKey.fullKey() );
51  return StatusCode::FAILURE;
52  }
53 
54  // Write mask for each element and record to SG for subsequent selection
55  for ( const xAOD::IParticle* part : *decorator) {
56  auto theAccept = m_tool->accept(part); // asg::AcceptData or TAccept
57  if(m_cut.empty()){
58  decorator(*part) = true && theAccept;
59  } else{
60  decorator(*part) = true && theAccept.getCutResult(m_cut);
61  }
62  }
63 
64  return StatusCode::SUCCESS;
65  }
66 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
DerivationFramework::AsgSelectionToolWrapper::AsgSelectionToolWrapper
AsgSelectionToolWrapper(const std::string &t, const std::string &n, const IInterface *p)
Definition: AsgSelectionToolWrapper.cxx:19
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
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.
DerivationFramework::AsgSelectionToolWrapper::m_sgName
Gaudi::Property< std::string > m_sgName
Definition: AsgSelectionToolWrapper.h:29
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:31
DerivationFramework::AsgSelectionToolWrapper::addBranches
virtual StatusCode addBranches() const override final
Pass the thinning service
Definition: AsgSelectionToolWrapper.cxx:43
DerivationFramework::AsgSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: AsgSelectionToolWrapper.h:28
DerivationFramework::AsgSelectionToolWrapper::initialize
StatusCode initialize() override final
Definition: AsgSelectionToolWrapper.cxx:29
DerivationFramework::AsgSelectionToolWrapper::m_decorKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decorKey
Definition: AsgSelectionToolWrapper.h:33
AsgSelectionToolWrapper.h
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26