ATLAS Offline Software
Loading...
Searching...
No Matches
JetMonitoringAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include "xAODJet/Jet.h"
10
11JetMonitoringAlg::JetMonitoringAlg( const std::string& name, ISvcLocator* pSvcLocator )
12:AthMonitorAlgorithm(name,pSvcLocator)
14{
15 declareProperty("JetContainerName",m_jetContainerKey);
16 declareProperty("FillerTools", m_jetFillerTools);
17 declareProperty("FailureOnMissingContainer", m_failureOnMissingContainer);
18 declareProperty("OnlyPassingJets", m_onlyPassingJets);
19 declareProperty("EventFiresAnyJetChain", m_eventFiresAnyJetChain);
20}
21
22
24
25
26
28
29 ATH_CHECK( m_jetContainerKey.initialize() );
30 ATH_CHECK( m_jetFillerTools.retrieve() );
31
32 // print out what we have
33 ATH_MSG_INFO( "Scheduled Histo fillers/selectors : ");
34 for(const auto& t: m_jetFillerTools){
35 ATH_MSG_INFO( "--> "<< t->name() );
36 }
37
39}
40
41
42
43StatusCode JetMonitoringAlg::fillHistograms( const EventContext& ctx ) const {
44
46 ATH_MSG_DEBUG("JetMonitoringAlg::fillHistograms(const EventContext&) -> enter triggerChainString = "<<m_triggerChainString);
47 std::list<const xAOD::Jet*> tmpList;
48 const std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > fc = getTrigDecisionTool()->features<xAOD::JetContainer>( m_triggerChainString );
49 for(const auto& jetLinkInfo : fc) {
50 if (!jetLinkInfo.isValid()) {
51 ATH_MSG_ERROR("Invalid ElementLink to online jet");
52 continue;
53 }
54 ElementLink<xAOD::JetContainer> j = jetLinkInfo.link;
55 const xAOD::Jet *trigjet = dynamic_cast<const xAOD::Jet*>(*j);
56 tmpList.push_back( trigjet );
57 }
58 auto sort = [] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return j1->p4().Et() > j2->p4().Et(); } ;
59 tmpList.sort( sort );
61 for(const xAOD::Jet* jet : tmpList ) tmpCont.push_back(jet);
62 const xAOD::JetContainer * trigJetsCont = tmpCont.asDataVector();
63 if (trigJetsCont->empty()) {
64 ATH_MSG_WARNING("Empty trigger jet container for chain "<<m_triggerChainString);
65 return StatusCode::SUCCESS;
66 }
67 for(const auto& t: m_jetFillerTools){
68 ATH_MSG_DEBUG( " now run "<< t->name() );
69 ATH_CHECK( t->processJetContainer(*this, *trigJetsCont, ctx) );
70 }
71 } else {
72 // retrieve the jet container
74 if (! jets.isValid() ) {
76 ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
77 return StatusCode::FAILURE;
78 } else {
79 ATH_MSG_WARNING("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
80 return StatusCode::SUCCESS;
81 }
82 }
83
84 if (m_eventFiresAnyJetChain && m_triggerChainString == "") { //this option makes sure to check if any jet trigger was fired in the event
85 bool eventFiresAnyJetChain = false;
86 const Trig::ChainGroup* cg = getTrigDecisionTool()->getChainGroup( "HLT_[1-9]?0?j[0-9]+.*" ); //retrieve or create chaingroup using regular expression
87 for (const std::string& trig : cg->getListOfTriggers()) {
88 if (isPassed(trig)) { eventFiresAnyJetChain = true; break; }
89 }
90 if (!eventFiresAnyJetChain) return StatusCode::SUCCESS;
91 }
92
93 // call each histograming tool on the container
94 for(const auto& t: m_jetFillerTools){
95 ATH_MSG_DEBUG( " now run "<< t->name() );
96 ATH_CHECK( t->processJetContainer(*this, *jets, ctx) );
97 }
98 }
99 return StatusCode::SUCCESS;
100}
101
102
103
104
105bool JetMonitoringAlg::isPassed(const std::string &c) const {
106 return getTrigDecisionTool()->isPassed(c);
107}
108unsigned int JetMonitoringAlg::isPassedBits(const std::string &c) const {
109 //std::cout << " test " << c <<" " << getTrigDecisionTool()->isPassedBits(c) << std::endl;
110 return getTrigDecisionTool()->isPassedBits(c);
111}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Gaudi::Property< std::string > m_triggerChainString
Trigger chain string pulled from the job option and parsed into a vector.
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.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
bool empty() const noexcept
Returns true if the collection is empty.
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
unsigned int isPassedBits(const std::string &c) const
ToolHandleArray< IJetHistoFiller > m_jetFillerTools
virtual ~JetMonitoringAlg()
JetMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool isPassed(const std::string &c) const
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
virtual StatusCode initialize() override
initialize
std::vector< std::string > getListOfTriggers() const
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".