ATLAS Offline Software
Loading...
Searching...
No Matches
JetMonitoringAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include "xAODJet/Jet.h"
11
12JetMonitoringAlg::JetMonitoringAlg( const std::string& name, ISvcLocator* pSvcLocator )
13:AthMonitorAlgorithm(name,pSvcLocator)
15{
16 declareProperty("JetContainerName",m_jetContainerKey);
17 declareProperty("FillerTools", m_jetFillerTools);
18 declareProperty("FailureOnMissingContainer", m_failureOnMissingContainer);
19 declareProperty("OnlyPassingJets", m_onlyPassingJets);
20 declareProperty("EventFiresAnyJetChain", m_eventFiresAnyJetChain);
21}
22
23
25
26
27
29
30 ATH_CHECK( m_jetContainerKey.initialize() );
31 ATH_CHECK( m_jetFillerTools.retrieve() );
32
33 // print out what we have
34 ATH_MSG_DEBUG( "Scheduled Histo fillers/selectors : ");
35 for(const auto& t: m_jetFillerTools){
36 ATH_MSG_DEBUG( "--> "<< t->name() );
37 }
38
40}
41
42
43
44StatusCode JetMonitoringAlg::fillHistograms( const EventContext& ctx ) const {
45
47 ATH_MSG_DEBUG("JetMonitoringAlg::fillHistograms(const EventContext&) -> enter triggerChainString = "<<m_triggerChainString);
48 std::list<const xAOD::Jet*> tmpList;
49 const std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > fc = getTrigDecisionTool()->features<xAOD::JetContainer>( m_triggerChainString );
50 for(const auto& jetLinkInfo : fc) {
51 if (!jetLinkInfo.isValid()) {
52 ATH_MSG_ERROR("Invalid ElementLink to online jet");
53 continue;
54 }
55 ElementLink<xAOD::JetContainer> j = jetLinkInfo.link;
56 const xAOD::Jet *trigjet = dynamic_cast<const xAOD::Jet*>(*j);
57 tmpList.push_back( trigjet );
58 }
59 auto sort = [] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return j1->p4().Et() > j2->p4().Et(); } ;
60 tmpList.sort( sort );
62 for(const xAOD::Jet* jet : tmpList ) tmpCont.push_back(jet);
63 const xAOD::JetContainer * trigJetsCont = tmpCont.asDataVector();
64 if (trigJetsCont->empty()) {
65 ATH_MSG_WARNING("Empty trigger jet container for chain "<<m_triggerChainString);
66 return StatusCode::SUCCESS;
67 }
68 for(const auto& t: m_jetFillerTools){
69 ATH_MSG_DEBUG( " now run "<< t->name() );
70 ATH_CHECK( t->processJetContainer(*this, *trigJetsCont, ctx) );
71 }
72 } else {
73 // retrieve the jet container
75 if (! jets.isValid() ) {
77 ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
78 return StatusCode::FAILURE;
79 } else {
80 ATH_MSG_WARNING("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
81 return StatusCode::SUCCESS;
82 }
83 }
84
85 if (m_eventFiresAnyJetChain && m_triggerChainString == "") { //this option makes sure to check if any jet trigger was fired in the event
86 bool eventFiresAnyJetChain = false;
87 const Trig::ChainGroup* cg = getTrigDecisionTool()->getChainGroup( "HLT_[1-9]?0?j[0-9]+.*" ); //retrieve or create chaingroup using regular expression
88 for (const std::string& trig : cg->getListOfTriggers()) {
89 if (isPassed(trig)) { eventFiresAnyJetChain = true; break; }
90 }
91 if (!eventFiresAnyJetChain) return StatusCode::SUCCESS;
92 }
93
94 // Apply more up-to-date jet calibrations for offline jet DQ monitoring
95 auto shallowCopy = xAOD::shallowCopyContainer( *jets );
96 if(!m_calibrationTool.empty()){
97 ANA_CHECK (m_calibrationTool->applyCalibration(*shallowCopy.first));
98 }
99
100 // call each histograming tool on the container
101 for(const auto& t: m_jetFillerTools){
102 ATH_MSG_DEBUG( " now run "<< t->name() );
103 ATH_CHECK( t->processJetContainer(*this, *shallowCopy.first, ctx) );
104 }
105 }
106 return StatusCode::SUCCESS;
107}
108
109
110
111
112bool JetMonitoringAlg::isPassed(const std::string &c) const {
113 return getTrigDecisionTool()->isPassed(c);
114}
115unsigned int JetMonitoringAlg::isPassedBits(const std::string &c) const {
116 //std::cout << " test " << c <<" " << getTrigDecisionTool()->isPassedBits(c) << std::endl;
117 return getTrigDecisionTool()->isPassedBits(c);
118}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define ANA_CHECK(EXP)
check whether the given expression was successful
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()
ToolHandle< IJetCalibrationTool > m_calibrationTool
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".
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".