ATLAS Offline Software
JetMonitoringAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "xAODJet/Jet.h"
8 
9 JetMonitoringAlg::JetMonitoringAlg( const std::string& name, ISvcLocator* pSvcLocator )
10 :AthMonitorAlgorithm(name,pSvcLocator)
11 ,m_jetContainerKey("AntiKt4LCTopoJets"), m_jetFillerTools(this), m_failureOnMissingContainer(true), m_onlyPassingJets(true)
12 {
13  declareProperty("JetContainerName",m_jetContainerKey);
14  declareProperty("FillerTools", m_jetFillerTools);
15  declareProperty("FailureOnMissingContainer", m_failureOnMissingContainer);
16  declareProperty("OnlyPassingJets", m_onlyPassingJets);
17  declareProperty("EventFiresAnyJetChain", m_eventFiresAnyJetChain);
18 }
19 
20 
22 
23 
24 
26 
27  ATH_CHECK( m_jetContainerKey.initialize() );
28  ATH_CHECK( m_jetFillerTools.retrieve() );
29 
30  // print out what we have
31  ATH_MSG_INFO( "Scheduled Histo fillers/selectors : ");
32  for(const auto& t: m_jetFillerTools){
33  ATH_MSG_INFO( "--> "<< t->name() );
34  }
35 
37 }
38 
39 
40 
41 StatusCode JetMonitoringAlg::fillHistograms( const EventContext& ctx ) const {
42 
44  ATH_MSG_DEBUG("JetMonitoringAlg::fillHistograms(const EventContext&) -> enter triggerChainString = "<<m_triggerChainString);
45  std::list<const xAOD::Jet*> tmpList;
46  const std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > fc = getTrigDecisionTool()->features<xAOD::JetContainer>( m_triggerChainString );
47  for(const auto& jetLinkInfo : fc) {
48  if (!jetLinkInfo.isValid()) {
49  ATH_MSG_ERROR("Invalid ElementLink to online jet");
50  continue;
51  }
52  ElementLink<xAOD::JetContainer> j = jetLinkInfo.link;
53  const xAOD::Jet *trigjet = dynamic_cast<const xAOD::Jet*>(*j);
54  tmpList.push_back( trigjet );
55  }
56  auto sort = [] (const xAOD::Jet * j1, const xAOD::Jet * j2) {return j1->p4().Et() > j2->p4().Et(); } ;
57  tmpList.sort( sort );
59  for(const xAOD::Jet* jet : tmpList ) tmpCont.push_back(jet);
60  const xAOD::JetContainer * trigJetsCont = tmpCont.asDataVector();
61  if (trigJetsCont->empty()) {
62  ATH_MSG_WARNING("Empty trigger jet container for chain "<<m_triggerChainString);
63  return StatusCode::SUCCESS;
64  }
65  for(const auto& t: m_jetFillerTools){
66  ATH_MSG_DEBUG( " now run "<< t->name() );
67  ATH_CHECK( t->processJetContainer(*this, *trigJetsCont, ctx) );
68  }
69  } else {
70  // retrieve the jet container
72  if (! jets.isValid() ) {
74  ATH_MSG_ERROR("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
75  return StatusCode::FAILURE;
76  } else {
77  ATH_MSG_WARNING("evtStore() does not contain jet Collection with name "<< m_jetContainerKey);
78  return StatusCode::SUCCESS;
79  }
80  }
81 
82  if (m_eventFiresAnyJetChain && m_triggerChainString == "") { //this option makes sure to check if any jet trigger was fired in the event
83  bool eventFiresAnyJetChain = false;
84  const Trig::ChainGroup* cg = getTrigDecisionTool()->getChainGroup( "HLT_[1-9]?0?j[0-9]+.*" ); //retrieve or create chaingroup using regular expression
85  for (const std::string& trig : cg->getListOfTriggers()) {
86  if (isPassed(trig)) { eventFiresAnyJetChain = true; break; }
87  }
88  if (!eventFiresAnyJetChain) return StatusCode::SUCCESS;
89  }
90 
91  // call each histograming tool on the container
92  for(const auto& t: m_jetFillerTools){
93  ATH_MSG_DEBUG( " now run "<< t->name() );
94  ATH_CHECK( t->processJetContainer(*this, *jets, ctx) );
95  }
96  }
97  return StatusCode::SUCCESS;
98 }
99 
100 
101 
102 
103 bool JetMonitoringAlg::isPassed(const std::string &c) const {
104  return getTrigDecisionTool()->isPassed(c);
105 }
106 unsigned int JetMonitoringAlg::isPassedBits(const std::string &c) const {
107  //std::cout << " test " << c <<" " << getTrigDecisionTool()->isPassedBits(c) << std::endl;
108  return getTrigDecisionTool()->isPassedBits(c);
109 }
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:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:189
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:41
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
JetMonitoringAlg::~JetMonitoringAlg
virtual ~JetMonitoringAlg()
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:103
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:106
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trig::ChainGroup
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/ChainGroup.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
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:9
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:25
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: Trigger/TrigAnalysis/TrigDecisionTool/Root/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