ATLAS Offline Software
Loading...
Searching...
No Matches
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
22
23
24namespace CP
25{
26 template<typename Type> StatusCode AsgShallowCopyAlg ::
27 executeTemplate (const CP::SystematicSet& sys)
28 {
29 const Type *input = nullptr;
30 ANA_CHECK (evtStore()->retrieve (input, m_inputHandle.getName (sys)));
31
32 const auto& name = m_outputHandle.getName(sys);
33 [[maybe_unused]] Type *output = nullptr;
35 (msg(), *evtStore(), output, input,
36 name, name + "Aux."));
37
38 return StatusCode::SUCCESS;
39 }
40
41
42
43 StatusCode AsgShallowCopyAlg ::
44 executeFindType (const CP::SystematicSet& sys)
45 {
46 const xAOD::IParticleContainer *input = nullptr;
48 {
49 ANA_CHECK (m_inputHandle.retrieve (input, sys));
50 }
51
52 if (dynamic_cast<const xAOD::ElectronContainer*> (input))
53 {
56 }
57 else if (dynamic_cast<const xAOD::PhotonContainer*> (input))
58 {
61 }
62 else if (dynamic_cast<const xAOD::JetContainer*> (input))
63 {
66 }
67 else if (dynamic_cast<const xAOD::MuonContainer*> (input)) {
70 }
71 else if (dynamic_cast<const xAOD::TauJetContainer*> (input))
72 {
75 }
76 else if (dynamic_cast<const xAOD::DiTauJetContainer*> (input))
77 {
80 }
81 else if (dynamic_cast<const xAOD::TrackParticleContainer*> (input))
82 {
85 }
86 else if (dynamic_cast<const xAOD::TruthParticleContainer*> (input))
87 {
90 }
92 {
95 }
97 {
100 }
101 else
102 {
103 ANA_MSG_ERROR ("unknown type contained in AsgShallowCopyAlg, please extend it");
104 return StatusCode::FAILURE;
105 }
106
107 return (this->*m_function) (sys);
108 }
109
110
111
112 AsgShallowCopyAlg ::
113 AsgShallowCopyAlg (const std::string& name,
114 ISvcLocator* pSvcLocator)
115 : AnaAlgorithm (name, pSvcLocator)
116 {
117 }
118
119
120
121 StatusCode AsgShallowCopyAlg ::
122 initialize ()
123 {
124 for (const auto& deco : m_declareDecorations)
125 ANA_CHECK (m_systematicsList.service().setDecorSystematics (m_inputHandle.getNamePattern(), deco, {}));
126 ANA_CHECK (m_systematicsList.service().registerCopy (m_inputHandle.getNamePattern(), m_outputHandle.getNamePattern()));
129 ANA_CHECK (m_systematicsList.initialize());
130
131#ifndef XAOD_STANDALONE
132 const CLID clidRead = detail::getClidForDependency<xAOD::IParticleContainer>("", "deco", false);
133 const CLID clidWrite = detail::getClidForDependency<xAOD::IParticleContainer>("", "deco", true);
134 std::function<void(const DataObjID&, Gaudi::DataHandle::Mode)> addAlgDependency = [this] (const DataObjID& id, Gaudi::DataHandle::Mode mode) {
135 this->addDependency(id, mode);
136 };
137 for (const auto& decoName : m_systematicsList.service().getObjectDecorations(m_inputHandle.getNamePattern()))
138 {
139 ANA_CHECK (detail::addSysDependency(msg(), m_systematicsList.service(), addAlgDependency, clidRead, m_inputHandle.getNamePattern(), Gaudi::DataHandle::Reader, decoName, false));
140 ANA_CHECK (detail::addSysDependency(msg(), m_systematicsList.service(), addAlgDependency, clidWrite, m_outputHandle.getNamePattern(), Gaudi::DataHandle::Writer, decoName, true));
141 }
142#endif
143
144 return StatusCode::SUCCESS;
145 }
146
147
148
149 StatusCode AsgShallowCopyAlg ::
150 execute ()
151 {
152 for (const auto& sys : m_systematicsList.systematicsVector())
153 {
154 ANA_CHECK ((this->*m_function) (sys));
155 }
156 return StatusCode::SUCCESS;
157 }
158}
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
uint32_t CLID
The Class ID type.
StatusCode(AsgShallowCopyAlg::* m_function)(const CP::SystematicSet &sys)
SysWriteHandle< xAOD::IParticleContainer > m_outputHandle
the output view container we produce
StatusCode executeTemplate(const CP::SystematicSet &sys)
the templated version of execute for a single systematic
Gaudi::Property< std::vector< std::string > > m_declareDecorations
an (optional) list of decorations to copy
SysListHandle m_systematicsList
the systematics list we run
SysReadHandle< xAOD::IParticleContainer > m_inputHandle
the input collection we run on
Class to wrap a set of SystematicVariations.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
CLID getClidForDependency(const std::string &typeName, const std::string &decoName, bool decoWrite)
StatusCode addSysDependency(MsgStream &msg, const ISystematicsSvc &svc, const std::function< void(const DataObjID &, Gaudi::DataHandle::Mode)> &addAlgDependency, const CLID clid, const std::string &name, Gaudi::DataHandle::Mode mode, const std::string &decoName, bool decoWrite)
Select isolated Photons, Electrons and Muons.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
a helper class to create shallow copies and register them in the event store
MsgStream & msg
Definition testRead.cxx:32