ATLAS Offline Software
AsgShallowCopyAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 //
10 // includes
11 //
12 
14 
15 #include <CxxUtils/fpcompare.h>
19 #include <xAODJet/JetContainer.h>
20 #include <xAODMuon/MuonContainer.h>
26 
27 //
28 // method implementations
29 //
30 
31 namespace CP
32 {
33  template<typename Type> StatusCode AsgShallowCopyAlg ::
35  {
36  const Type *input = nullptr;
38 
39  const auto& name = m_outputHandle.getName(sys);
40  [[maybe_unused]] Type *output = nullptr;
42  (msg(), *evtStore(), output, input,
43  name, name + "Aux."));
44 
45  return StatusCode::SUCCESS;
46  }
47 
48 
49 
50 
53  {
54  const xAOD::IParticleContainer *input = nullptr;
55  ANA_CHECK (m_inputHandle.retrieve (input, sys));
56 
57  if (dynamic_cast<const xAOD::ElectronContainer*> (input))
58  {
59  m_function =
60  &AsgShallowCopyAlg::executeTemplate<xAOD::ElectronContainer>;
61  }
62  else if (dynamic_cast<const xAOD::PhotonContainer*> (input))
63  {
64  m_function =
65  &AsgShallowCopyAlg::executeTemplate<xAOD::PhotonContainer>;
66  }
67  else if (dynamic_cast<const xAOD::JetContainer*> (input))
68  {
69  m_function =
70  &AsgShallowCopyAlg::executeTemplate<xAOD::JetContainer>;
71  }
72  else if (dynamic_cast<const xAOD::MuonContainer*> (input)) {
73  m_function =
74  &AsgShallowCopyAlg::executeTemplate<xAOD::MuonContainer>;
75  }
76  else if (dynamic_cast<const xAOD::TauJetContainer*> (input))
77  {
78  m_function =
79  &AsgShallowCopyAlg::executeTemplate<xAOD::TauJetContainer>;
80  }
81  else if (dynamic_cast<const xAOD::DiTauJetContainer*> (input))
82  {
83  m_function =
84  &AsgShallowCopyAlg::executeTemplate<xAOD::DiTauJetContainer>;
85  }
86  else if (dynamic_cast<const xAOD::TrackParticleContainer*> (input))
87  {
88  m_function =
89  &AsgShallowCopyAlg::executeTemplate<xAOD::TrackParticleContainer>;
90  }
91  else if (dynamic_cast<const xAOD::TruthParticleContainer*> (input))
92  {
93  m_function =
94  &AsgShallowCopyAlg::executeTemplate<xAOD::TruthParticleContainer>;
95  }
96  else
97  {
98  ANA_MSG_ERROR ("unknown type contained in AsgShallowCopyAlg, please extend it");
99  return StatusCode::FAILURE;
100  }
101 
102  return (this->*m_function) (sys);
103  }
104 
105 
106 
108  AsgShallowCopyAlg (const std::string& name,
109  ISvcLocator* pSvcLocator)
110  : AnaAlgorithm (name, pSvcLocator)
111  {
112  }
113 
114 
115 
117  initialize ()
118  {
119  ANA_CHECK (m_systematicsList.service().registerCopy (m_inputHandle.getNamePattern(), m_outputHandle.getNamePattern()));
123 
124  return StatusCode::SUCCESS;
125  }
126 
127 
128 
130  execute ()
131  {
132  for (const auto& sys : m_systematicsList.systematicsVector())
133  {
134  ANA_CHECK ((this->*m_function) (sys));
135  }
136  return StatusCode::SUCCESS;
137  }
138 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::AsgShallowCopyAlg::execute
StatusCode execute() override
Definition: AsgShallowCopyAlg.cxx:130
TruthParticleContainer.h
CP::AsgShallowCopyAlg::executeTemplate
StatusCode executeTemplate(const CP::SystematicSet &sys)
the templated version of execute for a single systematic
Definition: AsgShallowCopyAlg.cxx:34
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:48
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:54
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:67
CP::AsgShallowCopyAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: AsgShallowCopyAlg.h:45
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:108
fpcompare.h
Workaround x86 precision issues for FP inequality comparisons.
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
CP::AsgShallowCopyAlg::initialize
StatusCode initialize() override
Definition: AsgShallowCopyAlg.cxx:117
TauJetContainer.h
xAODType
Definition: ObjectType.h:13
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
merge.output
output
Definition: merge.py:17
AsgShallowCopyAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:52
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:49
PhotonContainer.h
CP::SysListHandle::service
const ISystematicsSvc & service() const
the service we use
TrackParticleContainer.h