ATLAS Offline Software
Loading...
Searching...
No Matches
HLTMinBiasEffMonitoringAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5#include "Utils.h"
7
8HLTMinBiasEffMonitoringAlg::HLTMinBiasEffMonitoringAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthMonitorAlgorithm(name, pSvcLocator) {}
9
11
13{
14 using namespace Monitored;
16 ATH_CHECK(m_offlineTrkKey.initialize());
17 ATH_CHECK(m_trkCountsKey.initialize());
18 ATH_CHECK(m_vertexKey.initialize());
20 std::set<std::string> temp(m_triggerList.begin(), m_triggerList.end());
21 m_uniqueTriggerList.insert(m_uniqueTriggerList.end(), temp.begin(), temp.end());
22
24
26}
27
29{
30 return StatusCode::SUCCESS;
31}
32
33StatusCode HLTMinBiasEffMonitoringAlg::fillHistograms(const EventContext& context) const
34{
35 using namespace Monitored;
36
37 const auto& trigDecTool = getTrigDecisionTool();
38
39 auto vertexHandle = SG::makeHandle(m_vertexKey, context);
40 const xAOD::Vertex* priVtx = Utils::selectPV(vertexHandle);
41
42 auto offlineTrkHandle = SG::makeHandle(m_offlineTrkKey, context);
43 int countPassing = 0;
44 int countPassingVtx = 0;
45 int countPassing_pt05 = 0; // count of tracks passing higher pt (here 0.5 GeV)
46 int countPassing_pt1 = 0; // count of tracks passing higher pt (here 1 GeV)
47 int countPassing_pt2 = 0; // ...
48 int countPassing_pt4 = 0;
49 int countPassing_pt6 = 0;
50 int countPassing_pt8 = 0;
51 auto leadingTrackPt = Scalar<double>("leadingTrackPt");
52 for (const auto trk : *offlineTrkHandle)
53 {
54 if (m_trackSelectionTool->accept(*trk) and std::fabs(trk->pt()) > m_minPt) {
55 ++countPassing;
56 if (priVtx and std::abs(Utils::z0wrtPV(trk, priVtx)) < m_z0
57 and std::abs(trk->d0()) < m_d0) {
58 ++countPassingVtx;
59 }
60
61 const double pt = std::fabs(trk->pt()) * 1e-3; // fabs used in case the charge is encoded in pt ( i.e. it is really q * pt)
62
63 if (pt > 0.5)
64 ++countPassing_pt05;
65 if (pt > 1.)
66 ++countPassing_pt1;
67 if (pt > 2.)
68 ++countPassing_pt2;
69 if (pt > 4.)
70 ++countPassing_pt4;
71 if (pt > 6.)
72 ++countPassing_pt6;
73 if (pt > 8.)
74 ++countPassing_pt8;
75 if (pt > leadingTrackPt) leadingTrackPt = pt;
76 }
77 }
78 ATH_MSG_DEBUG("::monitorTrkCounts countPassing = " << countPassing);
79 auto nTrkOffline = Scalar("nTrkOffline", countPassing);
80 auto nTrkOfflineVtx = Scalar("nTrkOfflineVtx", countPassingVtx);
81 auto nTrkOffline_pt05 = Scalar("nTrkOffline_pt05", countPassing_pt05);
82 auto nTrkOffline_pt1 = Scalar("nTrkOffline_pt1", countPassing_pt1);
83 auto nTrkOffline_pt2 = Scalar("nTrkOffline_pt2", countPassing_pt2);
84 auto nTrkOffline_pt4 = Scalar("nTrkOffline_pt4", countPassing_pt4);
85 auto nTrkOffline_pt6 = Scalar("nTrkOffline_pt6", countPassing_pt6);
86 auto nTrkOffline_pt8 = Scalar("nTrkOffline_pt8", countPassing_pt8);
87
88
89 auto passedL1 = [](unsigned int bits) { return (bits & TrigDefs::L1_isPassedBeforePrescale) != 0; };
90 auto passedHLT = [](unsigned int bits) { return (bits & TrigDefs::EF_passedRaw) != 0; };
91 auto activeHLT = [](unsigned int bits) { return (bits & TrigDefs::EF_prescaled) == 0; };
92 auto isL1 = [](const std::string& name) { return name.compare(0, 3, "L1_") == 0; };
93 auto isHLT = [](const std::string& name) { return name.compare(0, 4, "HLT_") == 0; };
94
95
96 for (size_t index = 0; index < m_refTriggerList.size(); ++index)
97 {
98 const auto& trig = m_triggerList[index];
99 const auto& ref = m_refTriggerList[index];
100
101 ATH_MSG_DEBUG("checking " << trig << " vs " << ref);
102
103 if (trigDecTool->isPassed(ref, TrigDefs::requireDecision))
104 {
105 ATH_MSG_DEBUG("ref passed for " << trig << " vs " << ref);
106
107 const unsigned int passBits = trigDecTool->isPassedBits(trig);
108 const bool wasRun = isL1(trig) or (isHLT(trig) and activeHLT(passBits));
109
110 if (wasRun) {
111 const auto decision = (isL1(trig) and passedL1(passBits)) or (isHLT(trig) and passedHLT(passBits));
112 ATH_MSG_DEBUG("chain " << trig << (decision ? " passed" : " failed"));
113
114 auto effPassed = Scalar<int>("EffPassed", decision);
115 fill(trig + ref, effPassed, nTrkOffline, nTrkOfflineVtx, nTrkOffline_pt05, nTrkOffline_pt1, nTrkOffline_pt2, nTrkOffline_pt4, nTrkOffline_pt6, nTrkOffline_pt8, leadingTrackPt);
116 }
117 }
118 }
119
120 for (const auto& trig : m_uniqueTriggerList)
121 {
122 if (trigDecTool->isPassed(trig, TrigDefs::requireDecision))
123 {
124 auto whichtrigger = Scalar<std::string>("TrigCounts", trig);
125 auto nTrkOffline = Scalar("nTrkOffline_counts_" + trig, countPassing);
126 fill("TrigAll", whichtrigger, nTrkOffline);
127 }
128 }
129
130 return StatusCode::SUCCESS;
131}
const boost::regex ref(r_ef)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_trkCountsKey
HLTMinBiasEffMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
initialize
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_offlineTrkKey
std::vector< std::string > m_uniqueTriggerList
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
SG::ReadHandleKey< xAOD::TrigT2MbtsBitsContainer > m_TrigT2MbtsBitsContainerKey
virtual StatusCode finalize() override
Gaudi::Property< std::vector< std::string > > m_triggerList
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
Gaudi::Property< std::vector< std::string > > m_refTriggerList
Declare a monitored scalar variable.
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.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const xAOD::Vertex * selectPV(SG::ReadHandle< xAOD::VertexContainer > &container)
Finds the Primary Vertex.
double z0wrtPV(const xAOD::TrackParticle *trk, const xAOD::Vertex *vtx)
Provide the trk DCA w.r.t. the PV.
Definition index.py:1
Vertex_v1 Vertex
Define the latest version of the vertex class.