ATLAS Offline Software
Loading...
Searching...
No Matches
METMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
8#include "xAODJet/Jet.h"
9#include "GaudiKernel/SystemOfUnits.h"
10
11
12static const std::map<std::string, std::pair<std::string, std::string> > key2SubSkeyMap( {
13 { "MET_RefFinal", { "MET_Reference_AntiKt4EMTopo", "FinalTrk" } },// add track
14 { "MET_RefEle", { "MET_Reference_AntiKt4EMTopo", "RefEle" } },
15 { "MET_RefGamma", { "MET_Reference_AntiKt4EMTopo", "RefGamma" } } ,
16 { "MET_RefTau", { "MET_Reference_AntiKt4EMTopo", "RefTau" } },
17 { "MET_SoftClus", { "MET_Reference_AntiKt4EMTopo", "SoftClus" } },
18 { "MET_SoftTrk", { "MET_Reference_AntiKt4EMTopo", "FinalTrk" } },
19 { "MET_PVSoftTrk", { "MET_Reference_AntiKt4EMTopo", "PVSoftTrk" } },
20 { "MET_RefJet_JVFCut", { "MET_Reference_AntiKt4EMTopo", "RefJet" } }, // RefJet_JVFCut
21 { "MET_RefJet", { "MET_Reference_AntiKt4EMTopo", "RefJet" } },
22 { "MET_Muon", { "MET_Reference_AntiKt4EMTopo", "Muons" } },
23 { "MET_PFlow", { "MET_Reference_AntiKt4EMPFlow", "FinalTrk" } }, // add track
24 { "MET_PFlow_RefEle", { "MET_Reference_AntiKt4EMPFlow", "RefEle" } },
25 { "MET_PFlow_RefGamma", { "MET_Reference_AntiKt4EMPFlow", "RefGamma" } },
26 { "MET_PFlow_RefTau", { "MET_Reference_AntiKt4EMPFlow", "RefTau" } },
27 { "MET_PFlow_SoftClus", { "MET_Reference_AntiKt4EMPFlow", "SoftClus" } },
28 { "MET_PFlow_SoftTrk", { "MET_Reference_AntiKt4EMPFlow", "FinalTrk" } },
29 { "MET_PFlow_PVSoftTrk", { "MET_Reference_AntiKt4EMPFlow", "PVSoftTrk" } },
30 { "MET_PFlow_RefJet_JVFCut", { "MET_Reference_AntiKt4EMPFlow", "RefJet" } }, // RefJet_JVFCut
31 { "MET_PFlow_RefJet", { "MET_Reference_AntiKt4EMPFlow", "RefJet" } },
32 { "MET_PFlow_Muon", { "MET_Reference_AntiKt4EMPFlow", "Muons" } },
33 { "MET_LocalHadTopo", { "MET_LocHadTopo", "LocHadTopo" } },
34 { "MET_LocHadTopo", { "MET_LocHadTopo", "LocHadTopo" } }, // same as above
35 { "MET_Topo", { "MET_EMTopo", "EMTopo" } },
36 { "MET_Track", { "MET_Track", "Track" } },
37 { "MET_PFlow", { "MET_Reference_AntiKt4EMPFlow", "FinalClus" } } } );
38
39
40METMonitoringAlg::METMonitoringAlg( const std::string& name, ISvcLocator* pSvcLocator ) :AthMonitorAlgorithm(name,pSvcLocator) {
41
42}
43
44
46
48 for (const auto& key : m_metKeys) {
49 auto foundIterator = key2SubSkeyMap.find( key );
50 if ( foundIterator == key2SubSkeyMap.end() ) {
51 ATH_MSG_FATAL("Unable to find MET key " << key << " in lookup table; quit");
52 return StatusCode::FAILURE;
53 }
54 if (foundIterator->second.first != m_metContainerKey.key()) {
55 ATH_MSG_FATAL("Mismatch of requested MET key " << key << ", which comes from "
56 << foundIterator->second.first
57 << ", with configured container key " << m_metContainerKey
58 << "; quit");
59 return StatusCode::FAILURE;
60 }
61 }
62 ATH_CHECK(m_metContainerKey.initialize());
63 ATH_CHECK(m_metCaloContainerKey.initialize());
65
66 ATH_CHECK(m_jetContainerKey.initialize());
67 if (m_doJetCleaning) {
68 ATH_MSG_DEBUG("::initializing JetCleaningTool");
69 ATH_CHECK(m_jetCleaningTool.retrieve());
70 ATH_MSG_DEBUG("::initialized JetCleaningTool");
71 } else {
72
73 m_jetCleaningTool.disable();
74 }
75
77}
78
79StatusCode METMonitoringAlg::fillHistograms( const EventContext& ctx ) const {
80 using namespace Monitored;
81 using Gaudi::Units::GeV;
82
84 if (!metContainer.isValid() ) {
85 ATH_MSG_ERROR("evtStore() does not contain MET Collection with name "<< m_metContainerKey);
86 return StatusCode::FAILURE;
87 }
89 if (!metCaloContainer.isValid() ) {
90 ATH_MSG_ERROR("evtStore() does not contain METCalo Collection with name "<< m_metCaloContainerKey);
91 return StatusCode::FAILURE;
92 }
93
95 if (!metCaloContainer.isValid() ) {
96 ATH_MSG_ERROR("evtStore() does not contain METAKt4EMTopo Collection with name "<< m_metAKt4EMTopoContainerKey);
97 return StatusCode::FAILURE;
98 }
99 const auto* trigDecTool = (getTrigDecisionTool().empty() ?
100 nullptr : getTrigDecisionTool().operator->());
101 bool isMETtopocalo = false;
102 for (const auto& key : m_metKeys) {
103 if (key == "MET_Topo") isMETtopocalo = true;
104 }
105 if (isMETtopocalo){
106 if (m_dometcut && (*metAKt4EMTopoContainer)[m_metTotalKey]->met() < m_metcut*GeV) return StatusCode::SUCCESS;
107
108 } else {
109 if (m_dometcut && (*metContainer)[m_metTotalKey]->met() < m_metcut*GeV) return StatusCode::SUCCESS;
110
111 }
112
113 if (m_dotrig) {
114 if (trigDecTool !=0 && !(trigDecTool->isPassed("L1_jXE100")))
115 return StatusCode::SUCCESS;
116 }
117
118 for (const auto& metKey : m_metKeys)
119 {
120 const std::string& xaod_subkey = key2SubSkeyMap.at(metKey).second;
121 const xAOD::MissingET* xMissEt = (*metContainer)[xaod_subkey];
122 if (xMissEt) {
123 std::string name = metKey + "_et";
124 auto et = Monitored::Scalar<double>(name,-1.0);
125 name = metKey + "_ex";
126 auto ex = Monitored::Scalar<double>(name,-1.0);
127 name = metKey + "_ey";
128 auto ey = Monitored::Scalar<double>(name,-1.0);
129 name = metKey + "_phi";
130 auto phi = Monitored::Scalar<double>(name,-1.0);
131 name = metKey + "_sumet";
132 auto sumet = Monitored::Scalar<double>(name,-1.0);
133 ex = xMissEt->mpx() / GeV;
134 ey = xMissEt->mpy() / GeV;
135 et = xMissEt->met() / GeV;
136 phi = xMissEt->phi();
137 sumet = xMissEt->sumet() / GeV;
138
139 if (m_alltrigger && m_doBadJets == false) {
140 fill("METMonitor",ex,ey,et,phi,sumet);
141 } else if (m_doBadJets) {
142 if (!isGoodEvent(ctx)) {
143 fill("METMonitor",ex,ey,et,phi,sumet);
144 }
145 } else if (m_doJetCleaning && m_doBadJets == false) {
146 if (isGoodEvent(ctx)) {
147 fill("METMonitor",ex,ey,et,phi,sumet);
148 }
149 } else {
150 fill("METMonitor",ex,ey,et,phi,sumet);
151 }
152 }
153 }
154
155 for (const auto& calString : m_calStrings) {
156 const xAOD::MissingET* xmetCal = (*metCaloContainer)[calString];
157 if (xmetCal){
158 std::string name = "MET_"+calString + "_et";
159 auto et = Monitored::Scalar<double>(name,-1.0);
160 name = "MET_" + calString + "_ex";
161 auto ex = Monitored::Scalar<double>(name,-1.0);
162 name = "MET_" +calString + "_ey";
163 auto ey = Monitored::Scalar<double>(name,-1.0);
164 name = "MET_" +calString + "_phi";
165 auto phi = Monitored::Scalar<double>(name,-1.0);
166 name = "MET_" +calString + "_sumet";
167 auto sumet = Monitored::Scalar<double>(name,-1.0);
168 ex = xmetCal->mpx() / GeV;
169 ey = xmetCal->mpy() / GeV;
170 et = xmetCal->met() / GeV;
171 phi = xmetCal->phi();
172 sumet = xmetCal->sumet() / GeV;
173
174 if (m_alltrigger && m_doBadJets == false) {
175 fill("METMonitor",ex,ey,et,phi,sumet);
176 } else if (m_doBadJets) {
177 if (!isGoodEvent(ctx)) {
178 fill("METMonitor",ex,ey,et,phi,sumet);
179 }
180 } else if (m_doJetCleaning && m_doBadJets == false) {
181 if (isGoodEvent(ctx)) {
182 fill("METMonitor",ex,ey,et,phi,sumet);
183
184 }
185 } else {
186 fill("METMonitor",ex,ey,et,phi,sumet);
187 }
188
189 }
190 }
191 return StatusCode::SUCCESS;
192}
193
194
195bool METMonitoringAlg::isGoodEvent( const EventContext& ctx ) const {
196 if (! m_doJetCleaning) return true;
197
199 if (! jetContainer.isValid() ) {
200 ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
201 return false;
202 }
203
204 for (const xAOD::Jet* jet : *jetContainer) {
205 if (m_jetCleaningTool->keep(*jet) == false) return false;
206 }
207 return true;
208}
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static const std::map< std::string, std::pair< std::string, std::string > > key2SubSkeyMap({ { "MET_RefFinal", { "MET_Reference_AntiKt4EMTopo", "FinalTrk" } }, { "MET_RefEle", { "MET_Reference_AntiKt4EMTopo", "RefEle" } }, { "MET_RefGamma", { "MET_Reference_AntiKt4EMTopo", "RefGamma" } }, { "MET_RefTau", { "MET_Reference_AntiKt4EMTopo", "RefTau" } }, { "MET_SoftClus", { "MET_Reference_AntiKt4EMTopo", "SoftClus" } }, { "MET_SoftTrk", { "MET_Reference_AntiKt4EMTopo", "FinalTrk" } }, { "MET_PVSoftTrk", { "MET_Reference_AntiKt4EMTopo", "PVSoftTrk" } }, { "MET_RefJet_JVFCut", { "MET_Reference_AntiKt4EMTopo", "RefJet" } }, { "MET_RefJet", { "MET_Reference_AntiKt4EMTopo", "RefJet" } }, { "MET_Muon", { "MET_Reference_AntiKt4EMTopo", "Muons" } }, { "MET_PFlow", { "MET_Reference_AntiKt4EMPFlow", "FinalTrk" } }, { "MET_PFlow_RefEle", { "MET_Reference_AntiKt4EMPFlow", "RefEle" } }, { "MET_PFlow_RefGamma", { "MET_Reference_AntiKt4EMPFlow", "RefGamma" } }, { "MET_PFlow_RefTau", { "MET_Reference_AntiKt4EMPFlow", "RefTau" } }, { "MET_PFlow_SoftClus", { "MET_Reference_AntiKt4EMPFlow", "SoftClus" } }, { "MET_PFlow_SoftTrk", { "MET_Reference_AntiKt4EMPFlow", "FinalTrk" } }, { "MET_PFlow_PVSoftTrk", { "MET_Reference_AntiKt4EMPFlow", "PVSoftTrk" } }, { "MET_PFlow_RefJet_JVFCut", { "MET_Reference_AntiKt4EMPFlow", "RefJet" } }, { "MET_PFlow_RefJet", { "MET_Reference_AntiKt4EMPFlow", "RefJet" } }, { "MET_PFlow_Muon", { "MET_Reference_AntiKt4EMPFlow", "Muons" } }, { "MET_LocalHadTopo", { "MET_LocHadTopo", "LocHadTopo" } }, { "MET_LocHadTopo", { "MET_LocHadTopo", "LocHadTopo" } }, { "MET_Topo", { "MET_EMTopo", "EMTopo" } }, { "MET_Track", { "MET_Track", "Track" } }, { "MET_PFlow", { "MET_Reference_AntiKt4EMPFlow", "FinalClus" } } })
Header file to be included by clients of the Monitored infrastructure.
virtual StatusCode initialize() override
initialize
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Property< std::string > m_metTotalKey
Gaudi::Property< double > m_metcut
Gaudi::Property< bool > m_alltrigger
SG::ReadHandleKey< xAOD::MissingETContainer > m_metAKt4EMTopoContainerKey
METMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool isGoodEvent(const EventContext &ctx) const
SG::ReadHandleKey< xAOD::MissingETContainer > m_metContainerKey
Gaudi::Property< bool > m_doJetCleaning
ToolHandle< IJetSelector > m_jetCleaningTool
Gaudi::Property< std::vector< std::string > > m_metKeys
Gaudi::Property< bool > m_doBadJets
Gaudi::Property< std::vector< std::string > > m_calStrings
SG::ReadHandleKey< xAOD::MissingETContainer > m_metCaloContainerKey
Gaudi::Property< bool > m_dotrig
Gaudi::Property< bool > m_dometcut
StatusCode initialize() override
initialize
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
float sumet() const
Returns.
float met() const
Returns .
float phi() const
Returns .
float mpx() const
Returns .
float mpy() const
Returns .
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
Generic monitoring tool for athena components.
Jet_v1 Jet
Definition of the current "jet version".
MissingET_v1 MissingET
Version control by type defintion.
Extra patterns decribing particle interation process.