ATLAS Offline Software
PhysValExample.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2021 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"
20 #include "xAODJet/JetContainer.h"
23 #include "xAODMuon/MuonContainer.h"
24 #include "xAODTau/TauJetContainer.h"
25 #include "xAODMissingET/MissingET.h"
28 #include "xAODTracking/Vertex.h"
29 #include "xAODEventInfo/EventInfo.h"
30 #include "xAODBTagging/BTagging.h"
32 
34 
35 namespace PhysVal {
36 
38 // Public methods:
40 
41 // Constructors
43 
44  PhysValExample::PhysValExample( const std::string& type,
45  const std::string& name,
46  const IInterface* parent ) :
48  m_jetPlots(nullptr, "Summary/Jet/", "Jet"),
49  m_elecPlots(nullptr, "Summary/Electron/", "Electron"),
50  m_photonPlots(nullptr, "Summary/Photon/", "Photon"),
51  m_muonPlots(nullptr, "Summary/Muon/", "Muon"),
52  m_tauPlots(nullptr, "Summary/Tau/", "Tau"),
53  m_trkvtxPlots(nullptr, "Summary/TrackAndVertex/"),
54  m_evtPlots(nullptr, "EventInfo/"),
55  m_metPlots(nullptr, "Summary/MET/", "RefFinal"),
56  m_btagPlots(nullptr, "Summary/BTag/", "IP3D")
57  {
58 
59  declareProperty( "JetContainerName", m_jetName = "AntiKt4EMTopoJets" );
60  declareProperty( "ElectronContainerName", m_elecName = "ElectronCollection" );
61  declareProperty( "PhotonContainerName", m_photonName = "PhotonCollection" );
62  declareProperty( "MuonContainerName", m_muonName = "Muons" );
63  declareProperty( "TauContainerName", m_tauName = "TauRecContainer" );
64  declareProperty( "TrackContainerName", m_trackName = "InDetTrackParticles" );
65  declareProperty( "VertexContainerName", m_vertexName = "PrimaryVertices" );
66  declareProperty( "METContainerName", m_metName = "MET_RefFinal" );
67  declareProperty( "DoExMET", m_doExMET = true );
68  declareProperty( "DoExJet", m_doExJet = true );
69  declareProperty( "DoExBtag", m_doExBtag = true );
70  }
71 
72  // Destructor
75  {}
76 
77  // Athena algtool's Hooks
80  {
81  ATH_MSG_INFO ("Initializing " << name() << "...");
83 
84  return StatusCode::SUCCESS;
85  }
86 
88  {
89  plots.initialize();
90  std::vector<HistData> hists = plots.retrieveBookedHistograms();
91 
92  for (auto& hist : hists){
93  ATH_MSG_INFO ("Initializing " << hist.first << " " << hist.first->GetName() << " " << hist.second << "...");
94  ATH_CHECK(regHist(hist.first,hist.second,all));
95  }
96  return StatusCode::SUCCESS;
97  }
98 
100  ATH_MSG_INFO("Booking hists " << name() << "...");
101 
102  if (m_detailLevel >= 10) {
112  }
113 
114  return StatusCode::SUCCESS;
115  }
116 
118  {
119  ATH_MSG_INFO ("Filling hists " << name() << "...");
120 
121  if (m_detailLevel < 10) return StatusCode::SUCCESS;
122 
123  // event Info
124  const xAOD::EventInfo* event(nullptr);
125  ATH_CHECK(evtStore()->retrieve(event, "EventInfo"));
127 
128  // Jets
129  int nbtag(0);
130  if (m_doExJet){
132  const xAOD::JetContainer* jets(nullptr);
134  for (auto jet : *jets) {
136  if (m_doExBtag){
138  if (btag && btag->IP3D_loglikelihoodratio() > 1.2) ++nbtag;
139  }
140  }
142  }
143  m_btagPlots.fill(nbtag,event);
144 
145  // Electrons
147  const xAOD::ElectronContainer* electrons(nullptr);
149  for (auto elec : *electrons) m_elecPlots.fill(elec,event);
151 
152  // Photons
154  const xAOD::PhotonContainer* photons(nullptr);
155  ATH_CHECK(evtStore()->retrieve(photons, m_photonName));
156  for (auto photon : *photons) m_photonPlots.fill(photon,event);
158 
159  // Muons
161  const xAOD::MuonContainer* muons(nullptr);
163  for (auto muon : *muons) m_muonPlots.fill(muon,event);
165 
166  // Taus
168  const xAOD::TauJetContainer* taus(nullptr);
170  for (auto tau : *taus) m_tauPlots.fill(tau,event);
172 
173  // Tracks/Vertices
174  const xAOD::TrackParticleContainer* trks(nullptr);
176 
177  const xAOD::VertexContainer* vtxs(nullptr);
179  for (auto vtx : *vtxs) m_trkvtxPlots.fill(vtx,event);
180 
181 
182  m_trkvtxPlots.fill(trks->size(), vtxs->size(), event);
183 
184 
185 
186  if (m_doExMET){
187  const xAOD::MissingETContainer* met_container (nullptr);
188  ATH_CHECK(evtStore()->retrieve(met_container, m_metName));
189 
190  const xAOD::MissingET* met = (*met_container)["FinalClus"];
191  if (!met) {
192  ATH_MSG_WARNING ("Couldn't retrieve MET Final");
193  return StatusCode::SUCCESS;
194  }
196  }
197 
198  return StatusCode::SUCCESS;
199  }
200 
202  {
203  ATH_MSG_INFO ("Finalising hists " << name() << "...");
204  return StatusCode::SUCCESS;
205  }
206 
207 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
BTaggingUtilities.h
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
PhysVal::PhysValExample::PhysValExample
PhysValExample()
Default constructor:
PlotBase
Definition: PlotBase.h:34
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PhysVal::PhysValExample::m_photonName
std::string m_photonName
Definition: PhysValExample.h:80
BTagging.h
PhysVal::PhysValExample::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: PhysValExample.cxx:117
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:73
PhysVal::PhysValExample::m_metPlots
PhysVal::METPlots m_metPlots
Definition: PhysValExample.h:95
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
plotmaker.hist
hist
Definition: plotmaker.py:148
PhysVal::PhysValExample::m_tauName
std::string m_tauName
Definition: PhysValExample.h:82
PhysVal::METPlots::fill
void fill(const xAOD::MissingET *met, const xAOD::EventInfo *evt)
Definition: METPlots.cxx:26
PhysVal::PhysValExample::~PhysValExample
virtual ~PhysValExample()
Destructor:
Definition: PhysValExample.cxx:74
PhysVal::KinematicsPlots::fill
void fill(const xAOD::IParticle *part, const xAOD::EventInfo *evt)
Definition: PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx:34
PhysValExample.h
PhysVal::PhysValExample::m_doExJet
bool m_doExJet
Definition: PhysValExample.h:101
PhysVal::PhysValExample::m_doExMET
bool m_doExMET
Definition: PhysValExample.h:103
PhysVal::PhysValExample::m_trackName
std::string m_trackName
Definition: PhysValExample.h:84
PhysVal::PhysValExample::m_elecName
std::string m_elecName
Definition: PhysValExample.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
met
Definition: IMETSignificance.h:24
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
PhysVal::TrkAndVtxPlots::fill
void fill(const xAOD::TrackParticle *trk, const xAOD::EventInfo *evt)
Definition: TrkAndVtxPlots.cxx:33
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:617
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ElectronContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PhysVal::BTagPlots::fill
void fill(const xAOD::BTagging *btag, const xAOD::EventInfo *evt)
Definition: BTagPlots.cxx:23
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
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
PhysVal::PhysValExample::m_muonPlots
PhysVal::KinematicsPlots m_muonPlots
Definition: PhysValExample.h:91
TauJetContainer.h
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Vertex.h
PhysVal::PhysValExample::m_jetPlots
PhysVal::KinematicsPlots m_jetPlots
Definition: PhysValExample.h:88
PhysVal::PhysValExample::m_metName
std::string m_metName
Definition: PhysValExample.h:83
PhysVal::PhysValExample::m_doExBtag
bool m_doExBtag
Definition: PhysValExample.h:102
PhysVal::PhysValExample::procHistograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
Definition: PhysValExample.cxx:201
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
MissingET.h
xAOD::BTagging_v1::IP3D_loglikelihoodratio
float IP3D_loglikelihoodratio() const
get IP3D log likelihood ratio
Definition: BTagging_v1.h:159
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
PhysVal
Definition: BTagPlots.cxx:13
PhysVal::PhysValExample::initialize
virtual StatusCode initialize()
Definition: PhysValExample.cxx:79
PhysVal::PhysValExample::m_elecPlots
PhysVal::KinematicsPlots m_elecPlots
Definition: PhysValExample.h:89
PhysVal::PhysValExample::m_btagPlots
PhysVal::BTagPlots m_btagPlots
Definition: PhysValExample.h:96
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
MuonContainer.h
PhysVal::PhysValExample::m_vertexName
std::string m_vertexName
Definition: PhysValExample.h:85
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
TrackParticle.h
PhysVal::PhysValExample::bookHistograms
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
Definition: PhysValExample.cxx:99
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
JetContainer.h
PhysVal::PhysValExample::m_photonPlots
PhysVal::KinematicsPlots m_photonPlots
Definition: PhysValExample.h:90
PhysVal::PhysValExample::m_tauPlots
PhysVal::KinematicsPlots m_tauPlots
Definition: PhysValExample.h:92
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PhysVal::PhysValExample::book
StatusCode book(PlotBase &plots)
Definition: PhysValExample.cxx:87
PhysVal::PhysValExample::m_jetName
std::string m_jetName
Definition: PhysValExample.h:78
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ManagedMonitorToolBase::all
@ all
Definition: ManagedMonitorToolBase.h:115
covarianceTool.plots
plots
Definition: covarianceTool.py:698
PhysVal::PhysValExample::m_trkvtxPlots
PhysVal::TrkAndVtxPlots m_trkvtxPlots
Definition: PhysValExample.h:93
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
PhysVal::KinematicsPlots::initializeEvent
void initializeEvent()
Definition: PhysicsAnalysis/PhysicsValidation/PhysValMonitoring/src/KinematicsPlots.cxx:62
PhysVal::PhysValExample::m_evtPlots
PhysVal::EventInfoPlots m_evtPlots
Definition: PhysValExample.h:94
ManagedMonitorToolBase::m_detailLevel
unsigned int m_detailLevel
Definition: ManagedMonitorToolBase.h:836
PhysVal::EventInfoPlots::fill
void fill(const xAOD::EventInfo *evt)
Definition: EventInfoPlots.cxx:27
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhotonContainer.h
PhysVal::PhysValExample::m_muonName
std::string m_muonName
Definition: PhysValExample.h:81
MissingETContainer.h
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:1346
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17