ATLAS Offline Software
FwdAFPJetMonitoringAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 #include <algorithm>
11 
12 #include "Utils.h"
13 
14 FwdAFPJetMonitoringAlg::FwdAFPJetMonitoringAlg(const std::string& name, ISvcLocator* pSvcLocator)
15  : AthMonitorAlgorithm(name, pSvcLocator) {}
16 
18  ATH_CHECK(m_jetKey.initialize());
19 
21 }
22 
23 StatusCode FwdAFPJetMonitoringAlg::fillHistograms(const EventContext& context) const {
24  using namespace Monitored;
25 
26  const auto& trigDecTool = getTrigDecisionTool();
27  SG::ReadHandle<xAOD::JetContainer> jetsHandle(m_jetKey, context);
28 
29  ATH_MSG_DEBUG("Using: " << m_jetKey.key() << ", handle state: " << jetsHandle.isValid());
30  if (not jetsHandle.isValid()) {
31  return StatusCode::SUCCESS;
32  }
33 
34  for (const auto& chain : m_chains) {
35  ATH_MSG_DEBUG("Chain: " << chain << " - Checking...");
36  if (not trigDecTool->isPassed(chain, TrigDefs::requireDecision)) {
37  ATH_MSG_DEBUG("Chain: " << chain << " - Failed");
38  continue;
39  }
40  ATH_MSG_DEBUG("Chain: " << chain << " - Passed");
41 
42  auto jetPt = Collection("jetPt", *jetsHandle, [](const auto& jet) { return jet->pt() * 1.e-3; });
43  auto jetEta = Collection("jetEta", *jetsHandle, &xAOD::Jet::eta);
44  auto jetPhi = Collection("jetPhi", *jetsHandle, &xAOD::Jet::phi);
45 
46  const auto leadingJet = Utils::findLeadingJet(jetsHandle);
47  if (leadingJet == nullptr) {
48  fill(chain + "_" + m_jetKey.key(), jetPt, jetEta, jetPhi);
49  continue;
50  }
51 
52  auto leadingJetPt = Scalar("leadingJetPt", leadingJet->pt() * 1.e-3);
53  auto leadingJetEta = Scalar("leadingJetEta", leadingJet->eta());
54  auto leadingJetPhi = Scalar("leadingJetPhi", leadingJet->phi());
55 
56  fill(chain + "_" + m_jetKey.key(), jetPt, jetEta, jetPhi, leadingJetPt, leadingJetEta, leadingJetPhi);
57  }
58 
59  return StatusCode::SUCCESS;
60 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
FwdAFPJetMonitoringAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
Definition: FwdAFPJetMonitoringAlg.cxx:23
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
AthMsgStreamMacros.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthMonitorAlgorithm::getTrigDecisionTool
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
Definition: AthMonitorAlgorithm.cxx:189
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
FwdAFPJetMonitoringAlg::m_chains
Gaudi::Property< std::vector< std::string > > m_chains
Definition: FwdAFPJetMonitoringAlg.h:24
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
Utils::findLeadingJet
const xAOD::Jet * findLeadingJet(SG::ReadHandle< xAOD::JetContainer > &container)
Find leading jet.
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/Utils.cxx:26
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
FwdAFPJetMonitoringAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: FwdAFPJetMonitoringAlg.cxx:17
MonitoredCollection.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
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
Utils.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::fill
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.
FwdAFPJetMonitoringAlg::FwdAFPJetMonitoringAlg
FwdAFPJetMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FwdAFPJetMonitoringAlg.cxx:14
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
FwdAFPJetMonitoringAlg::m_jetKey
Gaudi::Property< SG::ReadHandleKey< xAOD::JetContainer > > m_jetKey
Definition: FwdAFPJetMonitoringAlg.h:25
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
FwdAFPJetMonitoringAlg.h