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 EventContext& ctx, 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(), ctx, output, input, name));
36
37 return StatusCode::SUCCESS;
38 }
39
40
41
42 StatusCode AsgShallowCopyAlg ::
43 executeFindType (const EventContext& ctx, const CP::SystematicSet& sys)
44 {
45 const xAOD::IParticleContainer *input = nullptr;
47 {
48 ANA_CHECK (m_inputHandle.retrieve (input, sys, ctx));
49 }
50
51 if (dynamic_cast<const xAOD::ElectronContainer*> (input))
52 {
55 }
56 else if (dynamic_cast<const xAOD::PhotonContainer*> (input))
57 {
60 }
61 else if (dynamic_cast<const xAOD::JetContainer*> (input))
62 {
65 }
66 else if (dynamic_cast<const xAOD::MuonContainer*> (input)) {
69 }
70 else if (dynamic_cast<const xAOD::TauJetContainer*> (input))
71 {
74 }
75 else if (dynamic_cast<const xAOD::DiTauJetContainer*> (input))
76 {
79 }
80 else if (dynamic_cast<const xAOD::TrackParticleContainer*> (input))
81 {
84 }
85 else if (dynamic_cast<const xAOD::TruthParticleContainer*> (input))
86 {
89 }
91 {
94 }
96 {
99 }
100 else
101 {
102 ANA_MSG_ERROR ("unknown type contained in AsgShallowCopyAlg, please extend it");
103 return StatusCode::FAILURE;
104 }
105
106 return (this->*m_function) (ctx, sys);
107 }
108
109
110
111 StatusCode AsgShallowCopyAlg ::
112 initialize ()
113 {
114 for (const auto& deco : m_declareDecorations)
115 ANA_CHECK (m_systematicsList.service().setDecorSystematics (m_inputHandle.getNamePattern(), deco, {}));
116 ANA_CHECK (m_systematicsList.service().registerCopy (m_inputHandle.getNamePattern(), m_outputHandle.getNamePattern()));
119 ANA_CHECK (m_systematicsList.initialize());
120
121#ifndef XAOD_STANDALONE
122 const CLID clidRead = detail::getClidForDependency<xAOD::IParticleContainer>("", "deco", false);
123 const CLID clidWrite = detail::getClidForDependency<xAOD::IParticleContainer>("", "deco", true);
124 std::function<void(const DataObjID&, Gaudi::DataHandle::Mode)> addAlgDependency = [this] (const DataObjID& id, Gaudi::DataHandle::Mode mode) {
125 this->addDependency(id, mode);
126 };
127 for (const auto& decoName : m_systematicsList.service().getObjectDecorations(m_inputHandle.getNamePattern()))
128 {
129 ANA_CHECK (detail::addSysDependency(msg(), m_systematicsList.service(), addAlgDependency, clidRead, m_inputHandle.getNamePattern(), Gaudi::DataHandle::Reader, decoName, false));
130 ANA_CHECK (detail::addSysDependency(msg(), m_systematicsList.service(), addAlgDependency, clidWrite, m_outputHandle.getNamePattern(), Gaudi::DataHandle::Writer, decoName, true));
131 }
132#endif
133
134 return StatusCode::SUCCESS;
135 }
136
137
138
139 StatusCode AsgShallowCopyAlg ::
140 execute (const EventContext& ctx)
141 {
142 for (const auto& sys : m_systematicsList.systematicsVector())
143 {
144 ANA_CHECK ((this->*m_function) (ctx, sys));
145 }
146 return StatusCode::SUCCESS;
147 }
148}
#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.
ServiceHandle< StoreGateSvc > & evtStore()
StatusCode(AsgShallowCopyAlg::* m_function)(const EventContext &ctx, const CP::SystematicSet &sys)
StatusCode executeTemplate(const EventContext &ctx, const CP::SystematicSet &sys)
the templated version of execute for a single systematic
SysWriteHandle< xAOD::IParticleContainer > m_outputHandle
the output view container we produce
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.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
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