ATLAS Offline Software
Loading...
Searching...
No Matches
TRTMonitoringAlg.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TRTMonitoringAlg.h"
6
8
9TRTMonitoringAlg::TRTMonitoringAlg(const std::string& name, ISvcLocator* pSvcLocator)
10 : AthMonitorAlgorithm(name, pSvcLocator) {}
11
13 ATH_CHECK(m_offlineTrkKey.initialize());
14
16
18}
19
20StatusCode TRTMonitoringAlg::fillHistograms(const EventContext& context) const {
21 int good_tracks = 0;
22 double lead_track_pt = 0;
23
24 // retrieve event info and make selection
25 auto offlineTrkHandle = SG::makeHandle(m_offlineTrkKey, context);
26 for (const auto trk : *offlineTrkHandle) {
27 if (m_trackSelectionTool->accept(*trk)) {
28 double pT = trk->pt()*1.e-3; // pT in GeV
29 double abs_eta = std::abs(trk->eta());
30 double abs_d0 = std::abs(trk->d0());
31
32 if (pT > 0.1 and abs_eta < 2 and abs_d0 < 2) {
33 ++good_tracks;
34
35 if(pT > lead_track_pt){
36 lead_track_pt = pT;
37 }
38 }
39 }
40 }
41
42 if(!(offlineTrkHandle->size()==2 and good_tracks==2)) // get pT only for exclusive 2 track events
43 lead_track_pt = -1;
44
45 // set monitored values
46 auto n_trk = Monitored::Scalar<int>("n_trk", good_tracks);
47 auto lead_trk_pT = Monitored::Scalar<double>("lead_trk_pT", lead_track_pt);
48
49 // retrieve the trigger decisions
50 const auto& trigDecTool = getTrigDecisionTool();
51 auto passedL1 = [](unsigned int bits) { return (bits & TrigDefs::L1_isPassedBeforePrescale) != 0; };
52 auto activeHLT = [](unsigned int bits) { return (bits & TrigDefs::EF_prescaled) == 0; };
53 auto isHLT = [](const std::string& name) { return name.compare(0, 4, "HLT_") == 0; };
54 auto isRefPassed = [trigDecTool](const std::string& ref) { return trigDecTool->isPassed(ref, TrigDefs::requireDecision); };
55
56 for (const auto& trig : m_triggerList) {
57 // make an "or" of all reference triggers
58 if (std::any_of(m_refTriggerList.begin(), m_refTriggerList.end(), isRefPassed)) {
59 ATH_MSG_DEBUG("ref passed for " << trig);
60
61 // check the monitored trigger decision at L1
62 const unsigned int passBits = trigDecTool->isPassedBits(trig);
63 if (isHLT(trig) and activeHLT(passBits)) {
64 const auto decision = passedL1(passBits);
65 ATH_MSG_DEBUG("chain " << trig << " is " << (decision ? "passed" : "failed") << " at L1");
66
67 auto effPassed = Monitored::Scalar<int>("effPassed", decision);
68 fill(trig, effPassed, n_trk, lead_trk_pT);
69 }
70 }
71 }
72
73 return StatusCode::SUCCESS;
74}
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.
Declare a monitored scalar variable.
Gaudi::Property< std::vector< std::string > > m_refTriggerList
TRTMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_offlineTrkKey
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
virtual StatusCode initialize() override
initialize
Gaudi::Property< std::vector< std::string > > m_triggerList
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::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())