ATLAS Offline Software
ObjectCollectionMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 // $Id: ObjectCollectionMaker.cxx 790414 2016-12-19 00:49:08Z tpelzer $
8 #include "TopEvent/EventTools.h"
9 
10 // EDM include(s):
13 #include "xAODMuon/MuonContainer.h"
15 #include "xAODJet/JetContainer.h"
17 
18 
19 namespace top {
21  asg::AsgTool(name),
22  m_config(nullptr),
23 
24  m_egammaMaker(nullptr),
25  m_muonMaker(nullptr),
26  m_softmuonMaker(nullptr),
27  m_tauMaker(nullptr),
28  m_jetMaker(nullptr),
29  m_metMaker(nullptr),
30  m_trackSystMaker(nullptr)
31  {
32  declareProperty("config", m_config);
33  }
34 
36  ATH_MSG_INFO(" top::ObjectCollectionMaker initialize");
37 
39  std::unique_ptr<top::EgammaObjectCollectionMaker> (new top::EgammaObjectCollectionMaker(
40  "top::EgammaObjectCollectionMaker"));
41  m_muonMaker =
42  std::unique_ptr<top::MuonObjectCollectionMaker> (new top::MuonObjectCollectionMaker(
43  "top::MuonObjectCollectionMaker"));
45  std::unique_ptr<top::SoftMuonObjectCollectionMaker> (new top::SoftMuonObjectCollectionMaker(
46  "top::SoftMuonObjectCollectionMaker"));
47  m_tauMaker =
48  std::unique_ptr<top::TauObjectCollectionMaker> (new top::TauObjectCollectionMaker(
49  "top::TauObjectCollectionMaker"));
50  m_jetMaker =
51  std::unique_ptr<top::JetObjectCollectionMaker> (new top::JetObjectCollectionMaker(
52  "top::JetObjectCollectionMaker"));
53  m_metMaker =
54  std::unique_ptr<top::MissingETObjectCollectionMaker> (new top::MissingETObjectCollectionMaker(
55  "top::MissingETObjectCollectionMaker"));
57  std::unique_ptr<top::GhostTrackSystematicsMaker> (new top::GhostTrackSystematicsMaker(
58  "top::GhostTrackSystematicsMaker"));
59 
61  std::unique_ptr<top::TrackSystematicsMaker> (new top::TrackSystematicsMaker(
62  "top::TrackSystematicsMaker"));
63 
64 
65  if (m_config->usePhotons() || m_config->useElectrons() || m_config->useFwdElectrons()) {
66  top::check(m_egammaMaker->setProperty("config", m_config), "Failed to setProperty");
67  top::check(m_egammaMaker->initialize(), "Failed to initialize");
68  }
69 
70  if (m_config->useMuons()) {
71  top::check(m_muonMaker->setProperty("config", m_config), "Failed to setProperty");
72  top::check(m_muonMaker->initialize(), "Failed to initialize");
73  }
74 
75  if (m_config->useSoftMuons()) {
76  top::check(m_softmuonMaker->setProperty("config", m_config), "Failed to setProperty");
77  top::check(m_softmuonMaker->initialize(), "Failed to initialize");
78  }
79 
80  if (m_config->useTaus()) {
81  top::check(m_tauMaker->setProperty("config", m_config), "Failed to setProperty");
82  top::check(m_tauMaker->initialize(), "Failed to initialize");
83  }
84 
85  if (m_config->useJets() || m_config->useLargeRJets()) {
86  top::check(m_jetMaker->setProperty("config", m_config), "Failed to setProperty");
87  top::check(m_jetMaker->initialize(), "Failed to initialize");
88  }
89 
90  if (m_config->useJets() && m_config->useJetGhostTrack()) {
91  top::check(m_ghostTrackSystMaker->setProperty("config", m_config),
92  "Failed to setProperty");
93 
94  top::check(m_ghostTrackSystMaker->initialize(),
95  "Failed to initialize");
96  }
97 
98  if (m_config->useTracks()) {
99  top::check(m_trackSystMaker->setProperty("config", m_config),
100  "Failed to setProperty");
101 
102  top::check(m_trackSystMaker->initialize(),
103  "Failed to initialize");
104  }
105 
106 
107  top::check(m_metMaker->setProperty("config", m_config), "Failed to setProperty");
108  top::check(m_metMaker->initialize(), "Failed to initialize");
109 
110  return StatusCode::SUCCESS;
111  }
112 
114  if (executeNominal) {
115  top::check(this->executeNominal(), "Failed to executeNominal()");
116  } else {
117  top::check(this->executeSystematics(), "Failed to executeSystematics()");
118  }
119  return StatusCode::SUCCESS;
120  }
121 
123  if (m_config->usePhotons()) {
124  top::check(m_egammaMaker->executePhotons(true), "Failed to executePhotons()");
125  }
126  if (m_config->useElectrons()) {
127  top::check(m_egammaMaker->executeElectrons(true), "Failed to executeElectrons()");
128  }
129  if (m_config->useFwdElectrons()) {
130  top::check(m_egammaMaker->executeFwdElectrons(true), "Failed to executeFwdElectrons()");
131  }
132  if (m_config->useMuons()) {
133  top::check(m_muonMaker->execute(true), "Failed to executeMuons()");
134  }
135  if (m_config->useSoftMuons()) {
136  top::check(m_softmuonMaker->execute(true), "Failed to executeSoftMuons()");
137  }
138  if (m_config->useTaus()) {
139  top::check(m_tauMaker->execute(true), "Failed to executeTaus()");
140  }
141  if (m_config->useJets()) {
142  top::check(m_jetMaker->executeJets(true), "Failed to executeJets()");
143  }
144  if (m_config->useLargeRJets()) {
145  top::check(m_jetMaker->executeLargeRJets(true), "Failed to executeLargeRJets()");
146  }
147  if (m_config->useTrackJets()) {
148  top::check(m_jetMaker->executeTrackJets(true), "Failed to executeTrackJets() ");
149  }
150  if (m_config->useTracks()) {
151  top::check(m_trackSystMaker->execute(true), "Failed to executeTracks() ");
152  }
153 
154  // This must come _AFTER_ the jets have been calibrated!
155  if (m_config->useJets() && m_config->useJetGhostTrack()) {
156  top::check(m_ghostTrackSystMaker->execute(true), "Failed to executeGhostTrackSystematics() ");
157  }
158 
159  m_config->setNominalAvailable(true);
160 
161  return StatusCode::SUCCESS;
162  }
163 
165  if (m_config->isNominalAvailable() == false) {
166  ATH_MSG_ERROR("ObjectCollectionMaker::executeNominal has not been called before executeSystematics");
167  return StatusCode::FAILURE;
168  }
169 
170  if (m_config->usePhotons()) {
171  top::check(m_egammaMaker->executePhotons(false), "Failed to executePhotons()");
172  }
173  if (m_config->useElectrons()) {
174  top::check(m_egammaMaker->executeElectrons(false), "Failed to executeElectrons()");
175  }
176  if (m_config->useFwdElectrons()) {
177  top::check(m_egammaMaker->executeFwdElectrons(false), "Failed to executeFwdElectrons()");
178  }
179  if (m_config->useMuons()) {
180  top::check(m_muonMaker->execute(false), "Failed to executeMuons()");
181  }
182  if (m_config->useSoftMuons()) {
183  top::check(m_softmuonMaker->execute(false), "Failed to executeSoftMuons()");
184  }
185  if (m_config->useTaus()) {
186  top::check(m_tauMaker->execute(false), "Failed to executeTaus()");
187  }
188  if (m_config->useJets()) {
189  top::check(m_jetMaker->executeJets(false), "Failed to executeJets()");
190  }
191  if (m_config->useLargeRJets()) {
192  top::check(m_jetMaker->executeLargeRJets(false), "Failed to executeLargeRJets()");
193  }
194  if (m_config->useTrackJets()) {
195  top::check(m_jetMaker->executeTrackJets(false), "Failed to executeTrackJets() ");
196  }
197 
198  // This must come _AFTER_ the jets have been calibrated!
199  if (m_config->useJets() && m_config->useJetGhostTrack()) {
200  top::check(m_ghostTrackSystMaker->execute(false), "Failed to executeGhostTrackSystematics() ");
201  }
202 
203 
204  if (m_config->useTracks()) {
205  top::check(m_trackSystMaker->execute(false), "Failed to executeTracks() ");
206  }
207 
208 
209  return StatusCode::SUCCESS;
210  }
211 
213  top::check(m_metMaker->recalculateMET(executeNominal), "Failed to recalculateMET()");
214  return StatusCode::SUCCESS;
215  }
216 
218  if (m_config->usePhotons()) {
219  top::check(m_egammaMaker->printoutPhotons(), "Failed to printoutPhotons()");
220  }
221  if (m_config->useElectrons()) {
222  top::check(m_egammaMaker->printoutElectrons(), "Failed to printoutElectrons()");
223  }
224  if (m_config->useFwdElectrons()) {
225  top::check(m_egammaMaker->printoutFwdElectrons(), "Failed to printoutFwdElectrons()");
226  }
227  if (m_config->useMuons()) {
228  top::check(m_muonMaker->printout(), "Failed to printoutMuons()");
229  }
230  if (m_config->useSoftMuons()) {
231  top::check(m_softmuonMaker->printout(), "Failed to printoutSoftMuons()");
232  }
233  if (m_config->useTaus()) {
234  top::check(m_tauMaker->printout(), "Failed to printoutTaus()");
235  }
236  if (m_config->useJets()) {
237  top::check(m_jetMaker->printoutJets(), "Failed to printoutJets()");
238  }
239  if (m_config->useLargeRJets()) {
240  top::check(m_jetMaker->printoutLargeRJets(), "Failed to printoutLargeRJets()");
241  }
242 
243  return StatusCode::SUCCESS;
244  }
245 
248  if (m_config->usePhotons()) {
249  if (!evtStore()->contains<xAOD::PhotonContainer>(m_config->sgKeyPhotons())) {
250  return true;
251  }
252  }
253 
254  if (m_config->useElectrons()) {
255  if (!evtStore()->contains<xAOD::ElectronContainer>(m_config->sgKeyElectrons())) {
256  return true;
257  }
258  }
259 
260  if (m_config->useMuons()) {
261  if (!evtStore()->contains<xAOD::MuonContainer>(m_config->sgKeyMuons())) {
262  return true;
263  }
264  }
265 
266  if (m_config->useTaus()) {
267  if (!evtStore()->contains<xAOD::TauJetContainer>(m_config->sgKeyTaus())) {
268  return true;
269  }
270  }
271 
272  if (m_config->useJets()) {
273  if (!evtStore()->contains<xAOD::JetContainer>(m_config->sgKeyJets())) {
274  return true;
275  }
276  }
277 
280  return false;
281  }
282 }
top::ObjectCollectionMaker::m_tauMaker
std::unique_ptr< top::TauObjectCollectionMaker > m_tauMaker
Definition: ObjectCollectionMaker.h:67
top::GhostTrackSystematicsMaker
Definition: GhostTrackSystematicsMaker.h:79
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::ObjectCollectionMaker::ObjectCollectionMaker
ObjectCollectionMaker(const std::string &name)
Definition: ObjectCollectionMaker.cxx:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
top::ObjectCollectionMaker::m_softmuonMaker
std::unique_ptr< top::SoftMuonObjectCollectionMaker > m_softmuonMaker
Definition: ObjectCollectionMaker.h:66
top::ObjectCollectionMaker::m_jetMaker
std::unique_ptr< top::JetObjectCollectionMaker > m_jetMaker
Definition: ObjectCollectionMaker.h:68
top::SoftMuonObjectCollectionMaker
Definition: SoftMuonObjectCollectionMaker.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
asg
Definition: DataHandleTestTool.h:28
top::EgammaObjectCollectionMaker
Definition: EgammaObjectCollectionMaker.h:45
top::TauObjectCollectionMaker
Definition: TauObjectCollectionMaker.h:40
top::ObjectCollectionMaker::execute
StatusCode execute(bool)
Definition: ObjectCollectionMaker.cxx:113
ObjectCollectionMaker.h
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
top::ObjectCollectionMaker::m_metMaker
std::unique_ptr< top::MissingETObjectCollectionMaker > m_metMaker
Definition: ObjectCollectionMaker.h:69
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
top::ObjectCollectionMaker::executeSystematics
StatusCode executeSystematics()
Definition: ObjectCollectionMaker.cxx:164
ElectronContainer.h
top::MuonObjectCollectionMaker
Definition: MuonObjectCollectionMaker.h:46
top::ObjectCollectionMaker::m_trackSystMaker
std::unique_ptr< top::TrackSystematicsMaker > m_trackSystMaker
Definition: ObjectCollectionMaker.h:71
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
top::ObjectCollectionMaker::isTruthDxAOD
bool isTruthDxAOD() const
Definition: ObjectCollectionMaker.cxx:246
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
top::ObjectCollectionMaker::m_egammaMaker
std::unique_ptr< top::EgammaObjectCollectionMaker > m_egammaMaker
Definition: ObjectCollectionMaker.h:64
TauJetContainer.h
top::MissingETObjectCollectionMaker
Definition: MissingETObjectCollectionMaker.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TopConfig.h
MuonContainer.h
top::ObjectCollectionMaker::m_muonMaker
std::unique_ptr< top::MuonObjectCollectionMaker > m_muonMaker
Definition: ObjectCollectionMaker.h:65
JetContainer.h
top::TrackSystematicsMaker
Definition: TrackSystematicsMaker.h:44
top::ObjectCollectionMaker::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: ObjectCollectionMaker.cxx:35
top::ObjectCollectionMaker::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: ObjectCollectionMaker.h:63
top::JetObjectCollectionMaker
Definition: JetObjectCollectionMaker.h:61
PhotonContainer.h
top::ObjectCollectionMaker::m_ghostTrackSystMaker
std::unique_ptr< top::GhostTrackSystematicsMaker > m_ghostTrackSystMaker
Definition: ObjectCollectionMaker.h:70
top::ObjectCollectionMaker::recalculateMET
StatusCode recalculateMET(bool)
Definition: ObjectCollectionMaker.cxx:212
TrackParticleContainer.h
top::ObjectCollectionMaker::executeNominal
StatusCode executeNominal()
Definition: ObjectCollectionMaker.cxx:122
top::ObjectCollectionMaker::printout
StatusCode printout()
Definition: ObjectCollectionMaker.cxx:217