ATLAS Offline Software
AsgUnionSelectionAlg.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 
7 //
8 // includes
9 //
10 
12 
13 #include <xAODBase/IParticle.h>
14 
15 //
16 // method implementations
17 //
18 
19 namespace CP
20 {
21 
23  initialize ()
24  {
25  if (m_selectionDecoration.empty())
26  {
27  ANA_MSG_ERROR("Selection decoration can not be empty.");
28  return StatusCode::FAILURE;
29  }
30 
32 
36 
37  return StatusCode::SUCCESS;
38  }
39 
40 
41 
43  execute ()
44  {
45  std::vector<bool> selections;
46 
47  // first loop through systematics and define if particle passes each of them
48  for (const auto& sys : m_systematicsList.systematicsVector())
49  {
52 
53  if (selections.empty())
54  {
55  selections.resize(particles->size(), false);
56  }
57  else if (selections.size() != particles->size())
58  {
59  ANA_MSG_ERROR("All input containers should have the same size.");
60  return StatusCode::FAILURE;
61  }
62 
63  for (size_t i{}; i < particles->size(); i++)
64  {
66  }
67  }
68 
69  // Now decorate the selection decoration
70  // Looping over systematics is needed to ensure all containers are processed
71  for (const auto& sys : m_systematicsList.systematicsVector())
72  {
75 
76  for (size_t i{}; i < particles->size(); i++)
77  {
78  m_selectionAccessor->setBool (*particles->at(i), selections[i]);
79  }
80  }
81 
82  return StatusCode::SUCCESS;
83  }
84 
85 } // namespace CP
IParticle.h
CP::AsgUnionSelectionAlg::m_selectionDecoration
Gaudi::Property< std::string > m_selectionDecoration
the decoration of the selection
Definition: AsgUnionSelectionAlg.h:50
CP::AsgUnionSelectionAlg::initialize
virtual StatusCode initialize() override
Definition: AsgUnionSelectionAlg.cxx:23
CP::AsgUnionSelectionAlg::m_selectionAccessor
std::unique_ptr< ISelectionWriteAccessor > m_selectionAccessor
the accessor for m_selectionDecoration
Definition: AsgUnionSelectionAlg.h:54
CP::AsgUnionSelectionAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: AsgUnionSelectionAlg.h:45
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
CP::makeSelectionWriteAccessor
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
Definition: ISelectionAccessor.cxx:170
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AsgUnionSelectionAlg.h
CP::AsgUnionSelectionAlg::execute
virtual StatusCode execute() override
Definition: AsgUnionSelectionAlg.cxx:43
CP::AsgUnionSelectionAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle continer we run on
Definition: AsgUnionSelectionAlg.h:40
python.combo.selections
def selections(items, n)
Definition: combo.py:104
CP::AsgUnionSelectionAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run and have containers
Definition: AsgUnionSelectionAlg.h:36
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84