ATLAS Offline Software
AsgSelectionToolWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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>
14 
15 
16 namespace DerivationFramework {
17 
19  const std::string& n,
20  const IInterface* p) :
21  AthAlgTool(t,n,p)
22 
23  {
24  declareInterface<DerivationFramework::IAugmentationTool>(this);
25 
26  }
27 
29  if (m_sgName.value().empty()) {
30  ATH_MSG_ERROR("No SG name provided for the output of invariant mass tool!");
31  return StatusCode::FAILURE;
32  }
33  ATH_CHECK(m_tool.retrieve());
34  ATH_CHECK(m_containerKey.initialize());
35  m_decorKey = m_containerKey.key() + "." + m_sgName;
36  ATH_CHECK(m_decorKey.initialize());
37  return StatusCode::SUCCESS;
38  }
39 
40 
41 
43  {
44  // retrieve container
45 
46  const EventContext& ctx = Gaudi::Hive::currentContext();
48  if( ! particles.isValid() ) {
49  ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerKey.fullKey() );
50  return StatusCode::FAILURE;
51  }
52  // Decorator
54 
55  // Write mask for each element and record to SG for subsequent selection
56  for ( const xAOD::IParticle* part : *particles) {
57  auto theAccept = m_tool->accept(part); // asg::AcceptData or TAccept
58  if(m_cut.empty()){
59  decorator(*part) = true && theAccept;
60  } else{
61  decorator(*part) = true && theAccept.getCutResult(m_cut);
62  }
63  }
64 
65  return StatusCode::SUCCESS;
66  }
67 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::AsgSelectionToolWrapper::AsgSelectionToolWrapper
AsgSelectionToolWrapper(const std::string &t, const std::string &n, const IInterface *p)
Definition: AsgSelectionToolWrapper.cxx:18
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:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
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
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:42
DerivationFramework::AsgSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: AsgSelectionToolWrapper.h:28
DerivationFramework::AsgSelectionToolWrapper::initialize
StatusCode initialize() override final
Definition: AsgSelectionToolWrapper.cxx:28
DerivationFramework::AsgSelectionToolWrapper::m_decorKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_decorKey
Definition: AsgSelectionToolWrapper.h:33
AsgSelectionToolWrapper.h
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26