ATLAS Offline Software
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 
11 JetMonitoringAlg::JetMonitoringAlg( const std::string& name, ISvcLocator* pSvcLocator )
12 :AthMonitorAlgorithm(name,pSvcLocator)
13 ,m_jetContainerKey("AntiKt4LCTopoJets"), m_jetFillerTools(this), m_failureOnMissingContainer(true), m_onlyPassingJets(true)
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 
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 
43 StatusCode 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 
105 bool JetMonitoringAlg::isPassed(const std::string &c) const {
106  return getTrigDecisionTool()->isPassed(c);
107 }
108 unsigned int JetMonitoringAlg::isPassedBits(const std::string &c) const {
109  //std::cout << " test " << c <<" " << getTrigDecisionTool()->isPassedBits(c) << std::endl;
110  return getTrigDecisionTool()->isPassedBits(c);
111 }
JetMonitoringAlg::m_jetContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
Definition: JetMonitoringAlg.h:37
Jet.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
AthMonitorAlgorithm::m_triggerChainString
Gaudi::Property< std::string > m_triggerChainString
Trigger chain string pulled from the job option and parsed into a vector.
Definition: AthMonitorAlgorithm.h:355
AthMonitorAlgorithm::getTrigDecisionTool
const ToolHandle< Trig::TrigDecisionTool > & getTrigDecisionTool() const
Get the trigger decision tool member.
Definition: AthMonitorAlgorithm.cxx:194
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
TrigDecisionTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
JetMonitoringAlg::m_jetFillerTools
ToolHandleArray< IJetHistoFiller > m_jetFillerTools
Definition: JetMonitoringAlg.h:39
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
JetMonitoringAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: JetMonitoringAlg.cxx:43
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
JetMonitoringAlg::~JetMonitoringAlg
virtual ~JetMonitoringAlg()
TrigCompositeUtils.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
JetMonitoringAlg::isPassed
bool isPassed(const std::string &c) const
Definition: JetMonitoringAlg.cxx:105
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
JetMonitoringAlg::isPassedBits
unsigned int isPassedBits(const std::string &c) const
Definition: JetMonitoringAlg.cxx:108
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
Trig::ChainGroup
Definition: ChainGroup.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
JetMonitoringAlg::m_failureOnMissingContainer
bool m_failureOnMissingContainer
Definition: JetMonitoringAlg.h:41
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
JetMonitoringAlg::JetMonitoringAlg
JetMonitoringAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JetMonitoringAlg.cxx:11
JetMonitoringAlg::m_onlyPassingJets
bool m_onlyPassingJets
Definition: JetMonitoringAlg.h:42
JetMonitoringAlg::m_eventFiresAnyJetChain
bool m_eventFiresAnyJetChain
Definition: JetMonitoringAlg.h:43
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetMonitoringAlg.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
JetMonitoringAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: JetMonitoringAlg.cxx:27
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: ChainGroup.cxx:467
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22