ATLAS Offline Software
Loading...
Searching...
No Matches
PhysValExample.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// PhysValExample.cxx
8// Implementation file for class PhysValExample
9// Author: S.Binet<binet@cern.ch>
11
12// PhysVal includes
13#include "PhysValExample.h"
14
15// STL includes
16#include <vector>
17
18// FrameWork includes
19#include "GaudiKernel/IToolSvc.h"
28#include "xAODTracking/Vertex.h"
30
32
33namespace PhysVal {
34
36// Public methods:
38
39// Constructors
41
43 const std::string& name,
44 const IInterface* parent ) :
45 ManagedMonitorToolBase( type, name, parent ),
46 m_jetPlots(nullptr, "Summary/Jet/", "Jet"),
47 m_elecPlots(nullptr, "Summary/Electron/", "Electron"),
48 m_photonPlots(nullptr, "Summary/Photon/", "Photon"),
49 m_muonPlots(nullptr, "Summary/Muon/", "Muon"),
50 m_tauPlots(nullptr, "Summary/Tau/", "Tau"),
51 m_trkvtxPlots(nullptr, "Summary/TrackAndVertex/"),
52 m_evtPlots(nullptr, "EventInfo/"),
53 m_metPlots(nullptr, "Summary/MET/", "RefFinal")
54 {
55
56 declareProperty( "JetContainerName", m_jetName = "AntiKt4EMTopoJets" );
57 declareProperty( "ElectronContainerName", m_elecName = "ElectronCollection" );
58 declareProperty( "PhotonContainerName", m_photonName = "PhotonCollection" );
59 declareProperty( "MuonContainerName", m_muonName = "Muons" );
60 declareProperty( "TauContainerName", m_tauName = "TauRecContainer" );
61 declareProperty( "TrackContainerName", m_trackName = "InDetTrackParticles" );
62 declareProperty( "VertexContainerName", m_vertexName = "PrimaryVertices" );
63 declareProperty( "METContainerName", m_metName = "MET_RefFinal" );
64 declareProperty( "DoExMET", m_doExMET = true );
65 declareProperty( "DoExJet", m_doExJet = true );
66 }
67
68 // Destructor
72
73 // Athena algtool's Hooks
76 {
77 ATH_MSG_INFO ("Initializing " << name() << "...");
79
80 return StatusCode::SUCCESS;
81 }
82
83 StatusCode PhysValExample::book(PlotBase& plots)
84 {
85 plots.initialize();
86 std::vector<HistData> hists = plots.retrieveBookedHistograms();
87
88 for (auto& hist : hists){
89 ATH_MSG_INFO ("Initializing " << hist.first << " " << hist.first->GetName() << " " << hist.second << "...");
90 ATH_CHECK(regHist(hist.first,hist.second,all));
91 }
92 return StatusCode::SUCCESS;
93 }
94
96 ATH_MSG_INFO("Booking hists " << name() << "...");
97
98 if (m_detailLevel >= 10) {
107 }
108
109 return StatusCode::SUCCESS;
110 }
111
112 StatusCode PhysValExample::fillHistograms(const EventContext& /*ctx*/)
113 {
114 ATH_MSG_DEBUG ("Filling hists " << name() << "...");
115
116 if (m_detailLevel < 10) return StatusCode::SUCCESS;
117
118 // event Info
119 const xAOD::EventInfo* event(nullptr);
120 ATH_CHECK(evtStore()->retrieve(event, "EventInfo"));
121 m_evtPlots.fill(event);
122
123 // Jets
124 if (m_doExJet){
125 m_jetPlots.initializeEvent();
126 const xAOD::JetContainer* jets(nullptr);
127 ATH_CHECK(evtStore()->retrieve(jets, m_jetName));
128 for (auto jet : *jets) {
129 m_jetPlots.fill(jet,event);
130 }
131 m_jetPlots.fill(event);
132 }
133
134 // Electrons
135 m_elecPlots.initializeEvent();
136 const xAOD::ElectronContainer* electrons(nullptr);
137 ATH_CHECK(evtStore()->retrieve(electrons, m_elecName));
138 for (auto elec : *electrons) m_elecPlots.fill(elec,event);
139 m_elecPlots.fill(event);
140
141 // Photons
142 m_photonPlots.initializeEvent();
143 const xAOD::PhotonContainer* photons(nullptr);
144 ATH_CHECK(evtStore()->retrieve(photons, m_photonName));
145 for (auto photon : *photons) m_photonPlots.fill(photon,event);
146 m_photonPlots.fill(event);
147
148 // Muons
149 m_muonPlots.initializeEvent();
150 const xAOD::MuonContainer* muons(nullptr);
151 ATH_CHECK(evtStore()->retrieve(muons, m_muonName));
152 for (auto muon : *muons) m_muonPlots.fill(muon,event);
153 m_muonPlots.fill(event);
154
155 // Taus
156 m_tauPlots.initializeEvent();
157 const xAOD::TauJetContainer* taus(nullptr);
158 ATH_CHECK(evtStore()->retrieve(taus, m_tauName));
159 for (auto tau : *taus) m_tauPlots.fill(tau,event);
160 m_tauPlots.fill(event);
161
162 // Tracks/Vertices
163 const xAOD::TrackParticleContainer* trks(nullptr);
164 ATH_CHECK(evtStore()->retrieve(trks, m_trackName));
165
166 const xAOD::VertexContainer* vtxs(nullptr);
167 ATH_CHECK(evtStore()->retrieve(vtxs, m_vertexName));
168 for (auto vtx : *vtxs) m_trkvtxPlots.fill(vtx,event);
169
170
171 m_trkvtxPlots.fill(trks->size(), vtxs->size(), event);
172
173
174
175 if (m_doExMET){
176 const xAOD::MissingETContainer* met_container (nullptr);
177 ATH_CHECK(evtStore()->retrieve(met_container, m_metName));
178
179 const xAOD::MissingET* met = (*met_container)["FinalClus"];
180 if (!met) {
181 ATH_MSG_WARNING ("Couldn't retrieve MET Final");
182 return StatusCode::SUCCESS;
183 }
184 m_metPlots.fill(met,event);
185 }
186
187 return StatusCode::SUCCESS;
188 }
189
191 {
192 ATH_MSG_INFO ("Finalising hists " << name() << "...");
193 return StatusCode::SUCCESS;
194 }
195
196}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
static Double_t taus
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
size_type size() const noexcept
Returns the number of elements in the collection.
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 ...
ManagedMonitorToolBase(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode book(PlotBase &plots)
virtual StatusCode fillHistograms(const EventContext &ctx)
An inheriting class should either override this function or fillHists().
PhysVal::KinematicsPlots m_elecPlots
virtual ~PhysValExample()
Destructor:
PhysValExample()
Default constructor:
PhysVal::TrkAndVtxPlots m_trkvtxPlots
PhysVal::KinematicsPlots m_jetPlots
virtual StatusCode initialize()
PhysVal::KinematicsPlots m_muonPlots
PhysVal::METPlots m_metPlots
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
PhysVal::KinematicsPlots m_photonPlots
PhysVal::EventInfoPlots m_evtPlots
PhysVal::KinematicsPlots m_tauPlots
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
MissingET_v1 MissingET
Version control by type defintion.
Definition MissingET.h:15
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
MissingETContainer_v1 MissingETContainer
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".