ATLAS Offline Software
TopPhysValMonitoring.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // TopPhysValMonitoring.cxx
8 // Implementation file for class TopPhysValMonitoring
9 // Author:
11 
12 // TopPhysValMonitoring includes
13 #include "../TopPhysValMonitoring/TopPhysValMonitoring.h"
14 
15 // STL includes
16 #include <vector>
17 
18 // FrameWork includes
19 #include "GaudiKernel/IToolSvc.h"
21 
22 namespace TopPhysVal {
23 
25 // Public methods:
27 
28 // Constructors
30 
32  const std::string& name,
33  const IInterface* parent ) :
35  m_jets(nullptr),
36  m_elecs(nullptr),
37  m_photons(nullptr),
38  m_muons(nullptr),
39  m_taus(nullptr),
40  m_h_jetPt(nullptr),
41  m_h_elecPt(nullptr),
42  m_h_photonPt(nullptr),
43  m_h_muonPt(nullptr),
44  m_h_tauPt(nullptr),
45  m_h_tauEta(nullptr),
46  m_h_metEt(nullptr),
47  m_h_NJets(nullptr) {
48 
49  declareProperty( "JetContainerName", m_c_jetName = "AntiKt4LCTopoJets" );
50  declareProperty( "ElectronContainerName", m_c_elecName = "ElectronCollection" );
51  declareProperty( "PhotonContainerName", m_c_photonName = "PhotonCollection" );
52  declareProperty( "MuonContainerName", m_c_muonName = "Muons" );
53  declareProperty( "TauContainerName", m_c_tauName = "TauRecContainer" );
54  declareProperty( "METContainerName", m_c_metContainerName = "MET_RefFinal" );
55  declareProperty( "METName", m_c_metName = "Final" );
56  declareProperty( "HistBaseDirectory", m_c_histBaseDirectory = "Top/");
57 
58 }
59 
60 
61 // Destructor
64 
65 
66 // Athena algtool's Hooks
69 
70  ATH_MSG_INFO ("Initializing " << name() << "...");
72 
73  ATH_MSG_INFO ("Detail level is set to " << m_detailLevel);
74  if (m_detailLevel < 10)
75  ATH_MSG_INFO (" Any detail level below 10 will not create output histograms.");
76  ATH_MSG_INFO ("Container names:");
77  ATH_MSG_INFO (" Jet : " << m_c_jetName);
78  ATH_MSG_INFO (" Electron : " << m_c_elecName);
79  ATH_MSG_INFO (" Photon : " << m_c_photonName);
80  ATH_MSG_INFO (" Muon : " << m_c_muonName);
81  ATH_MSG_INFO (" Tau : " << m_c_tauName);
82  ATH_MSG_INFO (" MET : " << m_c_metContainerName << " (" << m_c_metName << ")");
83  ATH_MSG_INFO ("Root directory for histograms: " << m_c_histBaseDirectory);
84 
85  return StatusCode::SUCCESS;
86 }
87 
88 
90 
91  ATH_MSG_INFO ("Booking hists " << name() << "...");
92 
93  // Physics validation plots are level 10
94  if (m_detailLevel >= 10) {
95 
96  // all histograms go into a subdirectory of [m_c_histBaseDirectory]
97 
98  std::string dir_jet(m_c_histBaseDirectory + "Jet/" + m_c_jetName + "/FourVec/");
99  ATH_CHECK(regHist(m_h_jetPt = new TH1D("Pt",(m_c_jetName + "Jet p_{T}; p_{T}; # Jets").c_str(),100,0,200.), dir_jet, all));
100  ATH_CHECK(regHist(m_h_NJets = new TH1D("N",(m_c_jetName + "Number of Jets; Number; # Jets").c_str(),100,0,200.), dir_jet, all));
101 
102  std::string dir_elec(m_c_histBaseDirectory + "Electron/" + m_c_elecName + "/FourVec/");
103  ATH_CHECK(regHist(m_h_elecPt = new TH1D("Pt",(m_c_elecName + "Elec p_{T}; p_{T}; # Elecs").c_str(),100,0,200.), dir_elec, all));
104 
105  std::string dir_phot(m_c_histBaseDirectory + "Photon/" + m_c_photonName + "/FourVec/");
106  ATH_CHECK(regHist(m_h_photonPt = new TH1D("Pt",(m_c_photonName + "Photon p_{T}; p_{T}; # Photons").c_str(),100,0,200.), dir_phot, all));
107 
108  std::string dir_muon(m_c_histBaseDirectory + "Muon/" + m_c_muonName + "/FourVec/");
109  ATH_CHECK(regHist(m_h_muonPt = new TH1D("Pt",(m_c_muonName + "Muon p_{T}; p_{T}; # Muons").c_str(),100,0,200.), dir_muon, all));
110 
111  std::string dir_tau(m_c_histBaseDirectory + "Tau/" + m_c_tauName + "/FourVec/");
112  ATH_CHECK(regHist(m_h_tauPt = new TH1D("Pt",(m_c_tauName + "Tau p_{T}; p_{T}; # Taus").c_str(),100,0,200.), dir_tau, all));
113  ATH_CHECK(regHist(m_h_tauEta = new TH1D("Eta",(m_c_tauName + "Tau #eta; #eta; # Taus").c_str(),100,-5.,5.), dir_tau, all));
114 
115  std::string dir_MET(m_c_histBaseDirectory + "MET/" + m_c_metContainerName + "/");
116  ATH_CHECK(regHist(m_h_metEt = new TH1D("MET", (m_c_metContainerName + " (" + m_c_metName + ") E_{T}^{miss}; E_{T}^{miss} [GeV]; events / 4 GeV").c_str(),100, 0, 400.), dir_MET, all));
117 
118  }
119 
120  return StatusCode::SUCCESS;
121 
122 }
123 
124 
126 
128 
129  // do nothing if detail level below 10
130  if (m_detailLevel < 10)
131  return StatusCode::SUCCESS;
132 
133  // get and select objects
134  if (!retrieveObjects().isSuccess())
135  return StatusCode::FAILURE;
136 
137  // fill histograms
138  if (!fillBasicHistograms().isSuccess())
139  return StatusCode::FAILURE;
140 
141  return StatusCode::SUCCESS;
142 }
143 
144 
146 
147  // Retrieve jet container:
148  m_jets = evtStore()->retrieve< const xAOD::JetContainer >( m_c_jetName );
149 
150  if (!m_jets) {
151  ATH_MSG_ERROR ("Couldn't retrieve jet container with key: " << m_c_jetName);
152  return StatusCode::FAILURE;
153  }
154 
155  ATH_MSG_DEBUG( "Number of jets: " << m_jets->size() );
156 
157  // Retrieve elec container:
158  m_elecs = evtStore()->retrieve< const xAOD::ElectronContainer >( m_c_elecName );
159 
160  if (!m_elecs) {
161  ATH_MSG_ERROR ("Couldn't retrieve electron container with key: " << m_c_elecName);
162  return StatusCode::FAILURE;
163  }
164 
165  ATH_MSG_DEBUG( "Number of electrons: " << m_elecs->size() );
166 
167  // Retrieve photon container:
168  m_photons = evtStore()->retrieve< const xAOD::PhotonContainer >( m_c_photonName );
169 
170  if (!m_photons) {
171  ATH_MSG_ERROR ("Couldn't retrieve photon container with key: " << m_c_photonName);
172  return StatusCode::FAILURE;
173  }
174 
175  ATH_MSG_DEBUG( "Number of photons: " << m_photons->size() );
176 
177  // Retrieve muon container:
178  m_muons = evtStore()->retrieve< const xAOD::MuonContainer >( m_c_muonName );
179 
180  if (!m_muons) {
181  ATH_MSG_ERROR ("Couldn't retrieve muon container with key: " << m_c_muonName);
182  return StatusCode::FAILURE;
183  }
184 
185  ATH_MSG_DEBUG( "Number of muons: " << m_muons->size() );
186 
187  // Retrieve tau container:
188  m_taus = evtStore()->retrieve< const xAOD::TauJetContainer >( m_c_tauName );
189 
190  if (!m_taus) {
191  ATH_MSG_ERROR ("Couldn't retrieve tau container with key: " << m_c_tauName);
192  return StatusCode::FAILURE;
193  }
194 
195  ATH_MSG_DEBUG( "Number of taus: " << m_taus->size() );
196 
197  return StatusCode::SUCCESS;
198 }
199 
200 
202 
203  // jets
204  int i(0);
205  for (auto jet : *m_jets) {
206  if (m_detailLevel >= 10) m_h_jetPt->Fill(jet->pt()/1000., 1.);
207 
208  ATH_MSG_VERBOSE( " 4-momentum: px = " << jet->px()
209  << ", py = " << jet->py()
210  << ", pz = " << jet->pz()
211  << ", e = " << jet->e() );
212  ++i;
213  }
214  m_h_NJets->Fill((double)i);
215 
216 
217  // electrons
218  i = 0;
219  for (auto elec : *m_elecs) {
220  if (m_detailLevel >= 10) m_h_elecPt->Fill(elec->pt()/1000., 1.);
221 
222  ATH_MSG_VERBOSE( "Investigating elec #" << i );
223  ATH_MSG_VERBOSE( " 4-momentum: px = " << elec->p4().Px()
224  << ", py = " << elec->p4().Py()
225  << ", pz = " << elec->p4().Pz()
226  << ", e = " << elec->e() );
227  ++i;
228  }
229 
230 
231  // photons
232  i = 0;
233  for (auto photon : *m_photons) {
234  if (m_detailLevel >= 10) m_h_photonPt->Fill(photon->pt()/1000., 1.);
235 
236  ATH_MSG_VERBOSE( "Investigating photon #" << i );
237  ATH_MSG_VERBOSE( " 4-momentum: px = " << photon->p4().Px()
238  << ", py = " << photon->p4().Py()
239  << ", pz = " << photon->p4().Pz()
240  << ", e = " << photon->e() );
241  ++i;
242  }
243 
244  // muons
245  i = 0;
246  for (auto muon : *m_muons) {
247  if (m_detailLevel >= 10) m_h_muonPt->Fill(muon->p4().Perp()/1000., 1.);
248 
249  ATH_MSG_VERBOSE( "Investigating muon #" << i );
250  ATH_MSG_VERBOSE( " 4-momentum: px = " << muon->p4().Px()
251  << ", py = " << muon->p4().Py()
252  << ", pz = " << muon->p4().Pz()
253  << ", e = " << muon->p4().E() );
254  ++i;
255  }
256 
257  // taus
258  i = 0;
259  for (auto tau : *m_taus) {
260  if (m_detailLevel >= 10) {
261  m_h_tauPt->Fill(tau->pt()/1000., 1.);
262  m_h_tauEta->Fill(tau->eta(), 1.);
263  }
264 
265  ATH_MSG_VERBOSE( "Investigating tau #" << i );
266  ATH_MSG_VERBOSE( " taus: pt = " << tau->pt()
267  << ", eta = " << tau->eta()
268  << ", phi = " << tau->phi()
269  << ", e = " << tau->e() );
270  ++i;
271  }
272 
273  // Retrieve MET container:
274  if (!m_c_metContainerName.empty()) {
275 
276  const xAOD::MissingETContainer* met_container (0);
277  ATH_CHECK(evtStore()->retrieve(met_container, m_c_metContainerName));
278 
279  const xAOD::MissingET* met = (*met_container)[m_c_metName];
280 
281  if (!met) {
282  ATH_MSG_ERROR ("Couldn't retrieve MET with key " << m_c_metName << " from container");
283  return StatusCode::FAILURE;
284  }
285 
286  ATH_MSG_VERBOSE( " Missing Et = " << met->met());
287  if (m_detailLevel >= 10)
288  m_h_metEt->Fill(met->met()/1000., 1.);
289 
290  }
291 
292  return StatusCode::SUCCESS;
293 }
294 
295 
297 
298  ATH_MSG_INFO ("Finalising hists " << name() << "...");
299  return StatusCode::SUCCESS;
300 
301 }
302 
303 
304 }
305 
306 // LocalWords: str
TopPhysVal::TopPhysValMonitoring::m_elecs
const xAOD::ElectronContainer * m_elecs
Definition: TopPhysValMonitoring.h:93
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
TopPhysVal::TopPhysValMonitoring::m_h_tauEta
TH1D * m_h_tauEta
Definition: TopPhysValMonitoring.h:109
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
TopPhysVal::TopPhysValMonitoring::m_c_histBaseDirectory
std::string m_c_histBaseDirectory
root directory for all plots produced by this module (has to end in "/" if not empty)
Definition: TopPhysValMonitoring.h:89
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TopPhysVal
Definition: TopPhysValMonitoring.cxx:22
TopPhysVal::TopPhysValMonitoring::m_jets
const xAOD::JetContainer * m_jets
Definition: TopPhysValMonitoring.h:92
TopPhysVal::TopPhysValMonitoring::m_c_metName
std::string m_c_metName
Definition: TopPhysValMonitoring.h:87
TopPhysVal::TopPhysValMonitoring::m_c_metContainerName
std::string m_c_metContainerName
Definition: TopPhysValMonitoring.h:88
TH1D
Definition: rootspy.cxx:342
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TopPhysVal::TopPhysValMonitoring::m_c_muonName
std::string m_c_muonName
Definition: TopPhysValMonitoring.h:85
TopPhysVal::TopPhysValMonitoring::initialize
virtual StatusCode initialize()
Definition: TopPhysValMonitoring.cxx:68
TopPhysVal::TopPhysValMonitoring::m_taus
const xAOD::TauJetContainer * m_taus
Definition: TopPhysValMonitoring.h:96
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TopPhysVal::TopPhysValMonitoring::m_c_photonName
std::string m_c_photonName
Definition: TopPhysValMonitoring.h:84
met
Definition: IMETSignificance.h:24
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:669
TopPhysVal::TopPhysValMonitoring::fillBasicHistograms
StatusCode fillBasicHistograms()
Definition: TopPhysValMonitoring.cxx:201
TopPhysVal::TopPhysValMonitoring::m_h_elecPt
TH1D * m_h_elecPt
Definition: TopPhysValMonitoring.h:105
TopPhysVal::TopPhysValMonitoring::procHistograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
Definition: TopPhysValMonitoring.cxx:296
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TopPhysVal::TopPhysValMonitoring::m_h_jetPt
TH1D * m_h_jetPt
Definition: TopPhysValMonitoring.h:104
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TopPhysVal::TopPhysValMonitoring::m_c_elecName
std::string m_c_elecName
Definition: TopPhysValMonitoring.h:83
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TopPhysVal::TopPhysValMonitoring::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: TopPhysValMonitoring.cxx:125
TopPhysVal::TopPhysValMonitoring::m_h_muonPt
TH1D * m_h_muonPt
Definition: TopPhysValMonitoring.h:107
TopPhysVal::TopPhysValMonitoring::m_h_tauPt
TH1D * m_h_tauPt
Definition: TopPhysValMonitoring.h:108
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
TopPhysVal::TopPhysValMonitoring::~TopPhysValMonitoring
virtual ~TopPhysValMonitoring()
Destructor:
Definition: TopPhysValMonitoring.cxx:63
TopPhysVal::TopPhysValMonitoring::m_c_jetName
std::string m_c_jetName
Definition: TopPhysValMonitoring.h:82
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TopPhysVal::TopPhysValMonitoring::m_h_NJets
TH1D * m_h_NJets
Definition: TopPhysValMonitoring.h:111
TopPhysVal::TopPhysValMonitoring::TopPhysValMonitoring
TopPhysValMonitoring()
Default constructor:
TopPhysVal::TopPhysValMonitoring::bookHistograms
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
Definition: TopPhysValMonitoring.cxx:89
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ManagedMonitorToolBase::all
@ all
Definition: ManagedMonitorToolBase.h:116
TopPhysVal::TopPhysValMonitoring::m_h_metEt
TH1D * m_h_metEt
Definition: TopPhysValMonitoring.h:110
TopPhysVal::TopPhysValMonitoring::m_muons
const xAOD::MuonContainer * m_muons
Definition: TopPhysValMonitoring.h:95
TopPhysVal::TopPhysValMonitoring::retrieveObjects
StatusCode retrieveObjects()
Definition: TopPhysValMonitoring.cxx:145
ManagedMonitorToolBase::m_detailLevel
unsigned int m_detailLevel
Definition: ManagedMonitorToolBase.h:899
TopPhysVal::TopPhysValMonitoring::m_c_tauName
std::string m_c_tauName
Definition: TopPhysValMonitoring.h:86
TopPhysVal::TopPhysValMonitoring::m_h_photonPt
TH1D * m_h_photonPt
Definition: TopPhysValMonitoring.h:106
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TopPhysVal::TopPhysValMonitoring::m_photons
const xAOD::PhotonContainer * m_photons
Definition: TopPhysValMonitoring.h:94
ManagedMonitorToolBase::regHist
virtual StatusCode regHist(TH1 *h, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
Definition: ManagedMonitorToolBase.cxx:1454