ATLAS Offline Software
TRTMonitoringAlg.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TRTMonitoringAlg.h"
6 
8 
9 TRTMonitoringAlg::TRTMonitoringAlg(const std::string& name, ISvcLocator* pSvcLocator)
10  : AthMonitorAlgorithm(name, pSvcLocator) {}
11 
14 
15  ATH_CHECK(m_trackSelectionTool.retrieve());
16 
18 }
19 
20 StatusCode 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 }
TRTMonitoringAlg::m_triggerList
Gaudi::Property< std::vector< std::string > > m_triggerList
Definition: TRTMonitoringAlg.h:30
TRTMonitoringAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: TRTMonitoringAlg.cxx:12
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
TRTMonitoringAlg::m_trackSelectionTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
Definition: TRTMonitoringAlg.h:28
TRTMonitoringAlg::m_offlineTrkKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_offlineTrkKey
Definition: TRTMonitoringAlg.h:27
TRTMonitoringAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
Definition: TRTMonitoringAlg.cxx:20
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
TrigDecisionTool.h
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
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
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::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
TRTMonitoringAlg::TRTMonitoringAlg
TRTMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TRTMonitoringAlg.cxx:9
ref
const boost::regex ref(r_ef)
TRTMonitoringAlg::m_refTriggerList
Gaudi::Property< std::vector< std::string > > m_refTriggerList
Definition: TRTMonitoringAlg.h:31
TRTMonitoringAlg.h
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34