ATLAS Offline Software
PhysValFE.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PhysValFE.h"
7 
8 PhysValFE::PhysValFE (const std::string& type, const std::string& name, const IInterface* parent ) :
10  m_useNeutralFE(false)
11 {
12  declareProperty("useNeutralFE", m_useNeutralFE, "Select whether to use neutral or charged FE");
13 }
14 
16 
20  ATH_CHECK(m_FEContainerHandleKey.initialize());
21 
24 
27 
30 
33 
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 
41 
42  std::string theName = "PFlow/FlowElement/"+m_FEContainerHandleKey.key();
43  std::vector<HistData> hists;
44  std::vector<HistData> additional_hists;
45  if (!m_useNeutralFE){
46  m_FEChargedValidationPlots.reset(new PFOChargedValidationPlots(0,theName,theName));
47  m_FEChargedValidationPlots->setDetailLevel(100);
48  m_FEChargedValidationPlots->initialize();
49  hists = m_FEChargedValidationPlots->retrieveBookedHistograms();
50  m_LeptonLinkerPlots_CFE.reset(new LeptonCFEValidationPlots(0,theName,theName));
51  m_LeptonLinkerPlots_CFE->setDetailLevel(100);
52  m_LeptonLinkerPlots_CFE->initialize();
53  m_LeptonLinkerPlots_CFE->retrieveBookedHistograms();
54  additional_hists=m_LeptonLinkerPlots_CFE->retrieveBookedHistograms();
55 
56  }
57  else if (m_useNeutralFE){
58  m_FENeutralValidationPlots.reset(new PFONeutralValidationPlots(0,theName, theName));
59  m_FENeutralValidationPlots->setDetailLevel(100);
60  m_FENeutralValidationPlots->initialize();
61  hists = m_FENeutralValidationPlots->retrieveBookedHistograms();
62 
63  m_LeptonLinkerPlots_NFE.reset(new LeptonNFEValidationPlots(0,theName,theName));
64  m_LeptonLinkerPlots_NFE->setDetailLevel(100);
65  m_LeptonLinkerPlots_NFE->initialize();
66  additional_hists=m_LeptonLinkerPlots_NFE->retrieveBookedHistograms();
67 
68  }
69 
70  hists.insert(hists.end(),additional_hists.begin(),additional_hists.end()); // append lepton-FE linker plots to collection of hists
71 
72  for (auto hist : hists) {
73  ATH_MSG_DEBUG("Processing histogram named: "<<hist.first->GetName()<<" (title) "<<hist.first->GetTitle());
74  ATH_CHECK(regHist(hist.first,hist.second,all));
75  }
76 
77  return StatusCode::SUCCESS;
78 
79 }
80 
82 
83  const xAOD::Vertex* theVertex = nullptr;
84 
85  if (!m_useNeutralFE){
87  if(!vertexContainerReadHandle.isValid()){
88  ATH_MSG_WARNING("Invalid ReadHandle for xAOD::VertexContainer with key: " << vertexContainerReadHandle.key());
89  }
90  else {
91  //Vertex finding logic based on logic in JetRecTools/PFlowPseudoJetGetter tool
92  //Usually the 0th vertex is the primary one, but this is not always the case. So we will choose the first vertex of type PriVtx
93  for (auto vertex : *vertexContainerReadHandle) {
94  if (xAOD::VxType::PriVtx == vertex->vertexType() ) {
95  theVertex = vertex;
96  break;
97  }//If we have a vertex of type primary vertex
98  }//iterate over the vertices and check their type
99 
100  if (nullptr == theVertex) ATH_MSG_WARNING("Did not find either a PriVtx or a NoVtx in this event");
101 
102  }//if valid read handle
103  }
104 
106  if (!eventInfoReadHandle.isValid()){
107  ATH_MSG_WARNING("Invalid ReadHandle for xAOD::EventInfo with key: " << eventInfoReadHandle.key());
108  }
109 
111  if(!FEContainerReadHandle.isValid()){
112  ATH_MSG_WARNING("Invalid ReadHandle for xAOD::FlowElementContainer with key: " << FEContainerReadHandle.key());
113  return StatusCode::SUCCESS;
114  }
115 
116  for (auto theFE : *FEContainerReadHandle){
117  if(theFE){
118  if (!m_useNeutralFE) m_FEChargedValidationPlots->fill(*theFE,theVertex,*eventInfoReadHandle);
119  else if (m_useNeutralFE) m_FENeutralValidationPlots->fill(*theFE,*eventInfoReadHandle);
120  }
121  else ATH_MSG_WARNING("Invalid pointer to xAOD::FlowElement");
122  }
123 
124  if(!m_useNeutralFE){
126  if(!MuonContainerReadDecorHandle.isValid()){
127  ATH_MSG_WARNING("Muon readhandle is a dud");
128  }
129  else{
130  for (auto Muon: *MuonContainerReadDecorHandle) m_LeptonLinkerPlots_CFE->fill(*Muon,*eventInfoReadHandle);
131  }
132  }
133  else{
135  if(!MuonContainerReadDecorHandle.isValid()){
136  ATH_MSG_WARNING("Muon readhandle is a dud");
137  }
138  else{
139  for (auto Muon: *MuonContainerReadDecorHandle) m_LeptonLinkerPlots_NFE->fill(*Muon,*eventInfoReadHandle);
140  }
141  }
142 
143  if(!m_useNeutralFE){
145  if(!ElectronContainerReadDecorHandle.isValid()){
146  ATH_MSG_WARNING("Electron readhandle is a dud");
147  }
148  else{
149  for (auto Electron: *ElectronContainerReadDecorHandle) m_LeptonLinkerPlots_CFE->fill(*Electron,*eventInfoReadHandle);
150  }
151  }
152  else{
154  if(!ElectronContainerReadDecorHandle.isValid()){
155  ATH_MSG_WARNING("Electron readhandle is a dud");
156  }
157  else{
158  for (auto Electron: *ElectronContainerReadDecorHandle) m_LeptonLinkerPlots_NFE->fill(*Electron,*eventInfoReadHandle);
159  }
160  }
161 
162  if(!m_useNeutralFE){
164  if(!PhotonContainerReadDecorHandle.isValid()){
165  ATH_MSG_WARNING("Photon readhandle is a dud");
166  }
167  else{
168  for (auto Photon: *PhotonContainerReadDecorHandle) m_LeptonLinkerPlots_CFE->fill(*Photon,*eventInfoReadHandle);
169  }
170  }
171  else{
173  if(!PhotonContainerReadDecorHandle.isValid()){
174  ATH_MSG_WARNING("Photon readhandle is a dud");
175  }
176  else{
177  for (auto Photon: *PhotonContainerReadDecorHandle) m_LeptonLinkerPlots_NFE->fill(*Photon,*eventInfoReadHandle);
178  }
179  }
180 
181  if(!m_useNeutralFE){
183  if(!TauJetContainerReadDecorHandle.isValid()){
184  ATH_MSG_WARNING("TauJet readhandle is a dud");
185  }
186  else{
187  for (auto TauJet: *TauJetContainerReadDecorHandle) m_LeptonLinkerPlots_CFE->fill(*TauJet,*eventInfoReadHandle);
188  }
189  }
190  else{
192  if(!TauJetContainerReadDecorHandle.isValid()){
193  ATH_MSG_WARNING("TauJet readhandle is a dud");
194  }
195  else{
196  for (auto TauJet: *TauJetContainerReadDecorHandle) m_LeptonLinkerPlots_NFE->fill(*TauJet,*eventInfoReadHandle);
197  }
198  }
199 
200  return StatusCode::SUCCESS;
201 
202 }
203 
205  return StatusCode::SUCCESS;
206 }
207 
208 
PhysValFE::m_tauJetChargedFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_tauJetChargedFEReadHandleKey
Read key for getting charged Flow Element link decorations to taus.
Definition: PhysValFE.h:67
PhysValFE::m_photonChargedFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::PhotonContainer > m_photonChargedFEReadHandleKey
Read key for getting charged Flow Element link decorations to photons.
Definition: PhysValFE.h:61
FlowElementContainer.h
PhysValFE::~PhysValFE
virtual ~PhysValFE()
Standard Destructor.
Definition: PhysValFE.cxx:15
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:73
PhysValFE::m_electronChargedFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::ElectronContainer > m_electronChargedFEReadHandleKey
Read key for getting charged Flow Element link decorations to electrons.
Definition: PhysValFE.h:55
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PhysValFE::m_useNeutralFE
bool m_useNeutralFE
Select whether to use neutral or charged FE.
Definition: PhysValFE.h:86
plotmaker.hist
hist
Definition: plotmaker.py:148
PhysValFE::m_FENeutralValidationPlots
std::unique_ptr< PFONeutralValidationPlots > m_FENeutralValidationPlots
Pointer to class that deals with histograms for neutral FE.
Definition: PhysValFE.h:79
PhysValFE::m_FEChargedValidationPlots
std::unique_ptr< PFOChargedValidationPlots > m_FEChargedValidationPlots
Pointer to class that deals with histograms for charged FE.
Definition: PhysValFE.h:76
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Photon
Class describing an photon
PhysValFE::m_vertexContainerReadHandleKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerReadHandleKey
ReadHandle to retrieve xAOD::VertexContainer.
Definition: PhysValFE.h:43
PhysValFE::PhysValFE
PhysValFE(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: PhysValFE.cxx:8
PhysValFE::m_photonNeutralFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::PhotonContainer > m_photonNeutralFEReadHandleKey
Read key for getting neutral Flow Element link decorations to photons.
Definition: PhysValFE.h:64
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:617
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
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
LeptonCFEValidationPlots
Definition: LeptonCFEValidationPlots.h:16
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PhysValFE::m_LeptonLinkerPlots_CFE
std::unique_ptr< LeptonCFEValidationPlots > m_LeptonLinkerPlots_CFE
Pointer to class that deals with histograms for lepton links.
Definition: PhysValFE.h:82
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PhysValFE::m_eventInfoReadHandleKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoReadHandleKey
ReadHandleKey for EventInfo.
Definition: PhysValFE.h:73
PhysValFE::m_tauJetNeutralFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::TauJetContainer > m_tauJetNeutralFEReadHandleKey
Read key for getting neutral Flow Element link decorations to taus.
Definition: PhysValFE.h:70
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
PhysValFE::m_muonChargedFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_muonChargedFEReadHandleKey
Read key for getting charged Flow Element link decorations to muons.
Definition: PhysValFE.h:49
PhysValFE::m_LeptonLinkerPlots_NFE
std::unique_ptr< LeptonNFEValidationPlots > m_LeptonLinkerPlots_NFE
Definition: PhysValFE.h:83
PhysValFE::m_muonNeutralFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::MuonContainer > m_muonNeutralFEReadHandleKey
Read key for getting neutral Flow Element link decorations to muons.
Definition: PhysValFE.h:52
PFOChargedValidationPlots
Definition: PFOChargedValidationPlots.h:17
TauJet
@ TauJet
Definition: TruthClasses.h:47
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
PhysValFE::initialize
virtual StatusCode initialize()
Standard AlgTool Functions.
Definition: PhysValFE.cxx:17
PhysValFE::procHistograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
Definition: PhysValFE.cxx:204
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
PFONeutralValidationPlots
Definition: PFONeutralValidationPlots.h:17
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Electron
Class describing an electron.
ManagedMonitorToolBase::all
@ all
Definition: ManagedMonitorToolBase.h:115
PhysValFE::m_electronNeutralFEReadHandleKey
SG::ReadDecorHandleKey< xAOD::ElectronContainer > m_electronNeutralFEReadHandleKey
Read key for getting neutral Flow Element link decorations to electrons.
Definition: PhysValFE.h:58
PhysValFE::m_FEContainerHandleKey
SG::ReadHandleKey< xAOD::FlowElementContainer > m_FEContainerHandleKey
ReadHandle to retrieve xAOD::FlowElementContainer (charged)
Definition: PhysValFE.h:46
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
PhysValFE.h
LeptonNFEValidationPlots
Definition: LeptonNFEValidationPlots.h:17
PhysValFE::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: PhysValFE.cxx:81
PhysValFE::bookHistograms
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
Definition: PhysValFE.cxx:40