diff --git a/Reconstruction/Jet/JetRec/src/JetRecAlg.cxx b/Reconstruction/Jet/JetRec/src/JetRecAlg.cxx index 5368dde708bc6f9a7bf1b9fb5219a3ddca67fb23..fba500de2eb5c157e39df4339e16425d75a1fdb3 100644 --- a/Reconstruction/Jet/JetRec/src/JetRecAlg.cxx +++ b/Reconstruction/Jet/JetRec/src/JetRecAlg.cxx @@ -10,6 +10,9 @@ #include "JetInterface/IJetExecuteTool.h" #include "xAODJet/JetAuxContainer.h" +#if !defined (GENERATIONBASE) && !defined (XAOD_STANDALONE) + #include "AthenaMonitoringKernel/Monitored.h" +#endif using std::string; @@ -32,6 +35,12 @@ StatusCode JetRecAlg::initialize() { ATH_MSG_INFO(" --> : "<< t->name()); } + ATH_CHECK(m_output.initialize()); + +#if !defined (GENERATIONBASE) && !defined (XAOD_STANDALONE) + if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve()); +#endif + return StatusCode::SUCCESS; } @@ -50,9 +59,47 @@ StatusCode JetRecAlg::execute(const EventContext& ctx) const { // needn't know the type of the jet aux container // We can subsequently access the jets from the handle and don't have to // worry about memory management. + +#if !defined (GENERATIONBASE) && !defined (XAOD_STANDALONE) + auto t_total = Monitored::Timer<std::chrono::milliseconds>( "TIME_total" ); + SG::WriteHandle<xAOD::JetContainer> jetContHandle(m_output,ctx); + + auto t_jpv = Monitored::Timer<std::chrono::microseconds>( "TIME_jetprovider" ); ATH_CHECK( m_jetprovider->getAndRecordJets(jetContHandle) ); + auto mon_jpv = Monitored::Group(m_monTool, t_jpv); + + ATH_MSG_DEBUG("Created jet container of size "<< jetContHandle->size() << " | writing to "<< m_output.key() ); + + ATH_MSG_DEBUG("Applying jet modifiers to " << m_output.key()); + + // Calculate moments, calibrate, sort, filter... ----------- + auto t_mod = Monitored::Timer<std::chrono::milliseconds>( "TIME_modifiers_total" ); + for(const ToolHandle<IJetModifier>& t : m_modifiers){ + std::string modname = t.name(); + auto t_mods = Monitored::Timer<std::chrono::microseconds>( Form("TIME_modifier_%s",modname.c_str()) ); + ATH_MSG_DEBUG("Running " << modname); + ATH_CHECK(t->modify(*jetContHandle)); + auto mon_mods = Monitored::Group(m_monTool, t_mods); + } + auto mon_mod_total = Monitored::Group(m_monTool, t_mod); + + // monitor jet multiplicity and basic jet kinematics + auto njets = Monitored::Scalar<int>("nJets"); + auto pt = Monitored::Collection("pt", *jetContHandle, [c=0.001]( const xAOD::Jet* jet ) { return jet->pt()*c; }); + auto et = Monitored::Collection("et", *jetContHandle, [c=0.001]( const xAOD::Jet* jet ) { return jet->p4().Et()*c; }); + auto eta = Monitored::Collection("eta", *jetContHandle, []( const xAOD::Jet* jet ) { return jet->eta(); }); + auto phi = Monitored::Collection("phi", *jetContHandle, []( const xAOD::Jet* jet ) { return jet->phi(); }); + auto mon = Monitored::Group(m_monTool,njets,pt,et,eta,phi); + njets = jetContHandle->size(); + + auto mon_total = Monitored::Group(m_monTool, t_total); +#else + + SG::WriteHandle<xAOD::JetContainer> jetContHandle(m_output,ctx); + + ATH_CHECK( m_jetprovider->getAndRecordJets(jetContHandle) ); ATH_MSG_DEBUG("Created jet container of size "<< jetContHandle->size() << " | writing to "<< m_output.key() ); ATH_MSG_DEBUG("Applying jet modifiers to " << m_output.key()); @@ -63,6 +110,8 @@ StatusCode JetRecAlg::execute(const EventContext& ctx) const { ATH_CHECK(t->modify(*jetContHandle)); } +#endif + return StatusCode::SUCCESS; } diff --git a/Reconstruction/Jet/JetRec/src/JetRecAlg.h b/Reconstruction/Jet/JetRec/src/JetRecAlg.h index 1ccd79b6e5e43c8861eebb22d32c00b5886ef642..80e5229ba37b336b841c47224f0ba016c9a33aa4 100644 --- a/Reconstruction/Jet/JetRec/src/JetRecAlg.h +++ b/Reconstruction/Jet/JetRec/src/JetRecAlg.h @@ -1,6 +1,6 @@ // this is a -*- C++ -*- file /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //////////////////////////////////////////////////// @@ -23,6 +23,9 @@ #include "JetInterface/IJetProvider.h" #include "JetInterface/IJetModifier.h" +#if !defined(GENERATIONBASE) && !defined(XAOD_ANALYSIS) + #include "AthenaMonitoringKernel/GenericMonitoringTool.h" +#endif class IJetExecuteTool; @@ -43,7 +46,10 @@ private: ToolHandle<IJetProvider> m_jetprovider ={this , "Provider" , {} , "Tool providing the jets (fastjet, copy, grooming...)"}; ToolHandleArray<IJetModifier> m_modifiers = {this , "Modifiers", {}, "moment calculators" }; SG::WriteHandleKey<xAOD::JetContainer> m_output= {this, "OutputContainer", "AntiKt4LCtopoJets", "The output jet container name"}; - +#if !defined (GENERATIONBASE) && !defined (XAOD_STANDALONE) + ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"}; +#endif + }; #endif diff --git a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py index beeaf5bfbcbfdbdd42620d4f734887b199eeb358..d807163ac317f470a4a3c1f2ff29cf87ca46940f 100644 --- a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py +++ b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py @@ -292,7 +292,7 @@ def getJetAlgorithm(jetname, jetdef, pjContNames, monTool = None): # New JetRecAlgorithm to replace JetRecTool # This call is for a JRA that runs jet-finding # -def getJetRecAlg( jetdef): +def getJetRecAlg( jetdef, monTool = None): """ """ pjContNames = jetdef._internalAtt['finalPJContainer'] jclust = CompFactory.JetClusterer( @@ -312,7 +312,8 @@ def getJetRecAlg( jetdef): "jetrecalg_"+jetname, Provider = jclust, Modifiers = mods, - OutputContainer = jetname) + OutputContainer = jetname, + MonTool = monTool) autoconfigureModifiers(jra.Modifiers, jetname)