Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AsgShallowCopyAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
9 
14 #include <xAODJet/JetContainer.h>
16 #include <xAODMuon/MuonContainer.h>
21 
22 
23 namespace CP
24 {
25  template<typename Type> StatusCode AsgShallowCopyAlg ::
27  {
28  const Type *input = nullptr;
29  ANA_CHECK (evtStore()->retrieve (input, m_inputHandle.getName (sys)));
30 
31  const auto& name = m_outputHandle.getName(sys);
32  [[maybe_unused]] Type *output = nullptr;
34  (msg(), *evtStore(), output, input,
35  name, name + "Aux."));
36 
37  return StatusCode::SUCCESS;
38  }
39 
40 
41 
44  {
45  const xAOD::IParticleContainer *input = nullptr;
46  if (evtStore()->contains<xAOD::IParticleContainer>(m_inputHandle.getName(sys)))
47  {
48  ANA_CHECK (m_inputHandle.retrieve (input, sys));
49  }
50 
51  if (dynamic_cast<const xAOD::ElectronContainer*> (input))
52  {
53  m_function =
54  &AsgShallowCopyAlg::executeTemplate<xAOD::ElectronContainer>;
55  }
56  else if (dynamic_cast<const xAOD::PhotonContainer*> (input))
57  {
58  m_function =
59  &AsgShallowCopyAlg::executeTemplate<xAOD::PhotonContainer>;
60  }
61  else if (dynamic_cast<const xAOD::JetContainer*> (input))
62  {
63  m_function =
64  &AsgShallowCopyAlg::executeTemplate<xAOD::JetContainer>;
65  }
66  else if (dynamic_cast<const xAOD::MuonContainer*> (input)) {
67  m_function =
68  &AsgShallowCopyAlg::executeTemplate<xAOD::MuonContainer>;
69  }
70  else if (dynamic_cast<const xAOD::TauJetContainer*> (input))
71  {
72  m_function =
73  &AsgShallowCopyAlg::executeTemplate<xAOD::TauJetContainer>;
74  }
75  else if (dynamic_cast<const xAOD::DiTauJetContainer*> (input))
76  {
77  m_function =
78  &AsgShallowCopyAlg::executeTemplate<xAOD::DiTauJetContainer>;
79  }
80  else if (dynamic_cast<const xAOD::TrackParticleContainer*> (input))
81  {
82  m_function =
83  &AsgShallowCopyAlg::executeTemplate<xAOD::TrackParticleContainer>;
84  }
85  else if (dynamic_cast<const xAOD::TruthParticleContainer*> (input))
86  {
87  m_function =
88  &AsgShallowCopyAlg::executeTemplate<xAOD::TruthParticleContainer>;
89  }
90  else if (evtStore()->contains<xAOD::MissingETContainer>(m_inputHandle.getName(sys)))
91  {
92  m_function =
93  &AsgShallowCopyAlg::executeTemplate<xAOD::MissingETContainer>;
94  }
95  else
96  {
97  ANA_MSG_ERROR ("unknown type contained in AsgShallowCopyAlg, please extend it");
98  return StatusCode::FAILURE;
99  }
100 
101  return (this->*m_function) (sys);
102  }
103 
104 
105 
107  AsgShallowCopyAlg (const std::string& name,
108  ISvcLocator* pSvcLocator)
109  : AnaAlgorithm (name, pSvcLocator)
110  {
111  }
112 
113 
114 
116  initialize ()
117  {
118  ANA_CHECK (m_systematicsList.service().registerCopy (m_inputHandle.getNamePattern(), m_outputHandle.getNamePattern()));
122 
123  return StatusCode::SUCCESS;
124  }
125 
126 
127 
129  execute ()
130  {
131  for (const auto& sys : m_systematicsList.systematicsVector())
132  {
133  ANA_CHECK ((this->*m_function) (sys));
134  }
135  return StatusCode::SUCCESS;
136  }
137 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::AsgShallowCopyAlg::execute
StatusCode execute() override
Definition: AsgShallowCopyAlg.cxx:129
TruthParticleContainer.h
CP::AsgShallowCopyAlg::executeTemplate
StatusCode executeTemplate(const CP::SystematicSet &sys)
the templated version of execute for a single systematic
Definition: AsgShallowCopyAlg.cxx:26
AuxContainerBase.h
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
DiTauJetContainer.h
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:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::detail::ShallowCopy
a helper class to create shallow copies and register them in the event store
Definition: SystematicsHandles/SystematicsHandles/CopyHelpers.h:61
CP::AsgShallowCopyAlg::m_outputHandle
SysWriteHandle< xAOD::IParticleContainer > m_outputHandle
the output view container we produce
Definition: AsgShallowCopyAlg.h:53
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::AsgShallowCopyAlg::m_function
StatusCode(AsgShallowCopyAlg::* m_function)(const CP::SystematicSet &sys)
Definition: AsgShallowCopyAlg.h:66
CP::AsgShallowCopyAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: AsgShallowCopyAlg.h:44
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
ElectronContainer.h
CP::ISystematicsSvc::registerCopy
virtual StatusCode registerCopy(const std::string &fromName, const std::string &toName) const =0
register a (shallow) copy from one object to the next
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::AsgShallowCopyAlg::AsgShallowCopyAlg
AsgShallowCopyAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: AsgShallowCopyAlg.cxx:107
CP::AsgShallowCopyAlg::initialize
StatusCode initialize() override
Definition: AsgShallowCopyAlg.cxx:116
TauJetContainer.h
xAODType
Definition: ObjectType.h:13
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AsgShallowCopyAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonContainer.h
CopyHelpers.h
JetContainer.h
CP::AsgShallowCopyAlg::executeFindType
StatusCode executeFindType(const CP::SystematicSet &sys)
the version of execute to find the type
Definition: AsgShallowCopyAlg.cxx:43
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
CP::AsgShallowCopyAlg::m_inputHandle
SysReadHandle< xAOD::IParticleContainer > m_inputHandle
the input collection we run on
Definition: AsgShallowCopyAlg.h:48
PhotonContainer.h
MissingETContainer.h
CP::SysListHandle::service
const ISystematicsSvc & service() const
the service we use
TrackParticleContainer.h