ATLAS Offline Software
FwdAFPJetEffMonitoringAlg.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 #include <iterator>
12 
13 #include "Utils.h"
14 
15 FwdAFPJetEffMonitoringAlg::FwdAFPJetEffMonitoringAlg(const std::string& name, ISvcLocator* pSvcLocator)
16  : AthMonitorAlgorithm(name, pSvcLocator) {}
17 
19  ATH_CHECK(m_jetKey.initialize());
20 
22 }
23 
24 StatusCode FwdAFPJetEffMonitoringAlg::fillHistograms(const EventContext& context) const {
25  using namespace Monitored;
26 
27  const auto& trigDecTool = getTrigDecisionTool();
28  SG::ReadHandle<xAOD::JetContainer> jetsHandle(m_jetKey, context);
29 
30  ATH_MSG_DEBUG("Using: " << m_jetKey.key() << ", handle state: " << jetsHandle.isValid());
31  if (not jetsHandle.isValid()) {
32  return StatusCode::SUCCESS;
33  }
34 
35  auto passedL1 = [](unsigned int bits) { return (bits & TrigDefs::L1_isPassedBeforePrescale) != 0; };
36  auto passedHLT = [](unsigned int bits) { return (bits & TrigDefs::EF_passedRaw) != 0; };
37  auto activeHLT = [](unsigned int bits) { return (bits & TrigDefs::EF_prescaled) == 0; };
38  auto isL1 = [](const std::string& name) { return name.compare(0, 3, "L1_") == 0; };
39  auto isHLT = [](const std::string& name) { return name.compare(0, 4, "HLT_") == 0; };
40 
41  for (size_t index = 0; index < m_references.size(); ++index) {
42  const auto trig = m_chains[index];
43  const auto ref = m_references[index];
44 
45  ATH_MSG_VERBOSE("Check: " << trig << " vs " << ref << "...");
46 
47  if (trigDecTool->isPassed(ref, TrigDefs::requireDecision)) {
48  ATH_MSG_VERBOSE("Reference: " << ref << " - Passed!");
49 
50  const unsigned int passBits = trigDecTool->isPassedBits(trig);
51  const bool wasRun = isL1(trig) or (isHLT(trig) and activeHLT(passBits));
52 
53  if (wasRun) {
54  const auto decision = (isL1(trig) and passedL1(passBits)) or (isHLT(trig) and passedHLT(passBits));
55  ATH_MSG_DEBUG("Chain " << trig << " vs " << ref << " - " << (decision ? "Passed!" : "Failed!"));
56 
57  auto leadingJet = Utils::findLeadingJet(jetsHandle);
58  auto leadingJetPt = Scalar<float>("leadingJetPt", leadingJet ? leadingJet->pt() * 1e-3 : -1);
59  auto effPassed = Scalar<int>("effPassed", decision);
60  fill(trig + "_" + ref, effPassed, leadingJetPt);
61  }
62  }
63  }
64 
65  return StatusCode::SUCCESS;
66 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AthMsgStreamMacros.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
AthMonitorAlgorithm::getTrigDecisionTool
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
Definition: AthMonitorAlgorithm.cxx:189
xAOD::passBits
passBits
Definition: TrigPassBits_v1.cxx:115
FwdAFPJetEffMonitoringAlg.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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
MonitoredCollection.h
FwdAFPJetEffMonitoringAlg::m_jetKey
Gaudi::Property< SG::ReadHandleKey< xAOD::JetContainer > > m_jetKey
Definition: FwdAFPJetEffMonitoringAlg.h:26
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
FwdAFPJetEffMonitoringAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
Definition: FwdAFPJetEffMonitoringAlg.cxx:24
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.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
FwdAFPJetEffMonitoringAlg::m_chains
Gaudi::Property< std::vector< std::string > > m_chains
Definition: FwdAFPJetEffMonitoringAlg.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FwdAFPJetEffMonitoringAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: FwdAFPJetEffMonitoringAlg.cxx:18
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
DeMoScan.index
string index
Definition: DeMoScan.py:364
ref
const boost::regex ref(r_ef)
FwdAFPJetEffMonitoringAlg::m_references
Gaudi::Property< std::vector< std::string > > m_references
Definition: FwdAFPJetEffMonitoringAlg.h:25
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
FwdAFPJetEffMonitoringAlg::FwdAFPJetEffMonitoringAlg
FwdAFPJetEffMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FwdAFPJetEffMonitoringAlg.cxx:15