diff --git a/Control/AthenaMonitoring/AthenaMonitoring/AthMonitorAlgorithm.h b/Control/AthenaMonitoring/AthenaMonitoring/AthMonitorAlgorithm.h index e027e0e0009bed376a7b3cdbf9606c5f6f89ef65..710a88b38e71a2d3318208acf8c7c63a825ebb9c 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/AthMonitorAlgorithm.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/AthMonitorAlgorithm.h @@ -25,12 +25,14 @@ #include "AthenaMonitoring/ITriggerTranslatorTool.h" #include "AthenaMonitoring/Monitored.h" -#include "LumiBlockComps/ILuminosityTool.h" #include "TrigDecisionInterface/ITrigDecisionTool.h" -#include "LumiBlockComps/ITrigLivefractionTool.h" #include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" #include "xAODEventInfo/EventInfo.h" +#include "LumiBlockData/LuminosityCondData.h" +#include "LumiBlockData/LBDurationCondData.h" +#include "LumiBlockData/TrigLiveFractionCondData.h" class AthMonitorAlgorithm : public AthReentrantAlgorithm { public: @@ -227,42 +229,42 @@ public: /** * Calculate the average mu, i.e. <mu>. */ - virtual float lbAverageInteractionsPerCrossing() const; + virtual float lbAverageInteractionsPerCrossing (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate instantaneous number of interactions, i.e. mu. */ - virtual float lbInteractionsPerCrossing() const; + virtual float lbInteractionsPerCrossing (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1). */ - virtual float lbAverageLuminosity() const; + virtual float lbAverageLuminosity (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate the instantaneous luminosity per bunch crossing. */ - virtual float lbLuminosityPerBCID() const; + virtual float lbLuminosityPerBCID (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate the duration of the luminosity block (in seconds) */ - virtual double lbDuration() const; + virtual double lbDuration (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate the average luminosity livefraction */ - virtual float lbAverageLivefraction() const; + virtual float lbAverageLivefraction (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate the live fraction per bunch crossing ID. */ - virtual float livefractionPerBCID() const; + virtual float livefractionPerBCID (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Calculate the average integrated luminosity multiplied by the live fraction. */ - virtual double lbLumiWeight() const; + virtual double lbLumiWeight (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** @} */ // end of lumi group @@ -299,8 +301,12 @@ protected: ToolHandle<ITriggerTranslatorTool> m_trigTranslator {this,"TriggerTranslatorTool",""}; ///< Tool to unpack trigger categories into a trigger list ToolHandleArray<IDQFilterTool> m_DQFilterTools {this,"FilterTools",{}}; ///< Array of Data Quality filter tools - ToolHandle<ILuminosityTool> m_lumiTool {this,"lumiTool","LuminosityTool"}; ///< Tool for calculating various luminosity quantities - ToolHandle<ITrigLivefractionTool> m_liveTool {this,"liveTool","TrigLivefractionTool"}; ///< Tool for calculating various live luminosity quantities + SG::ReadCondHandleKey<LuminosityCondData> m_lumiDataKey + {this,"LuminosityCondDataKey","LuminosityCondData","SG Key of LuminosityCondData object"}; + SG::ReadCondHandleKey<LBDurationCondData> m_lbDurationDataKey + {this,"LBDurationCondDataKey","LBDurationCondData","SG Key of LBDurationCondData object"}; + SG::ReadCondHandleKey<TrigLiveFractionCondData> m_trigLiveFractionDataKey + {this,"TrigLiveFractionCondDataKey","TrigLiveFractionCondData", "SG Key of TrigLiveFractionCondData object"}; AthMonitorAlgorithm::Environment_t m_environment; ///< Instance of the Environment_t enum AthMonitorAlgorithm::DataType_t m_dataType; ///< Instance of the DataType_t enum @@ -311,7 +317,6 @@ protected: std::vector<std::string> m_vTrigChainNames; ///< Vector of trigger chain names parsed from trigger chain string Gaudi::Property<std::string> m_fileKey {this,"FileKey",""}; ///< Internal Athena name for file - bool m_hasRetrievedLumiTool; ///< Allows use of various luminosity functions Gaudi::Property<bool> m_useLumi {this,"EnableLumi",false}; ///< Allows use of various luminosity functions Gaudi::Property<float> m_defaultLBDuration {this,"DefaultLBDuration",60.}; ///< Default duration of one lumi block Gaudi::Property<int> m_detailLevel {this,"DetailLevel",0}; ///< Sets the level of detail used in the monitoring diff --git a/Control/AthenaMonitoring/AthenaMonitoring/FastPhysMonToolBase.h b/Control/AthenaMonitoring/AthenaMonitoring/FastPhysMonToolBase.h index 2c5b729590eeb2e38c37e9e033d0ae1547e234af..eadb81ea3c5de0e871c29d7599218e2c8a384d27 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/FastPhysMonToolBase.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/FastPhysMonToolBase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ //Dear emacs, this is -*-c++-*- @@ -7,6 +7,7 @@ #define FASTPHYSMONTOOLBASE_H #include "AthenaMonitoring/ManagedMonitorToolBase.h" +#include "CxxUtils/checker_macros.h" #include "GaudiKernel/IIncidentListener.h" class TTree; @@ -25,8 +26,9 @@ class TTree; * we could implement them here too. */ -class FastPhysMonToolBase: public ManagedMonitorToolBase, - public IIncidentListener { +// Legacy ManagedMonitorToolBase is not thread-safe. +class ATLAS_NOT_THREAD_SAFE FastPhysMonToolBase: public ManagedMonitorToolBase, + public IIncidentListener { public: /** diff --git a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h index f5c2a2be4bef58f2222e457414baf75f71f359f0..b9d9458a6e5e350dc99c95d864933638e8cc5e31 100755 --- a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef ManagedMonitorToolBase_H @@ -21,10 +21,12 @@ #include "AthenaMonitoring/AthenaMonManager.h" #include "AthenaMonitoring/IMonitorToolBase.h" #include "AthenaMonitoring/ITriggerTranslatorTool.h" +#include "StoreGate/ReadCondHandleKey.h" #include "GaudiKernel/ToolHandle.h" -#include "LumiBlockComps/ILuminosityTool.h" -#include "LumiBlockComps/ITrigLivefractionTool.h" +#include "LumiBlockData/LuminosityCondData.h" +#include "LumiBlockData/LBDurationCondData.h" +#include "LumiBlockData/TrigLiveFractionCondData.h" #include "TrigDecisionInterface/ITrigDecisionTool.h" @@ -655,49 +657,49 @@ class ManagedMonitorToolBase : public AthAlgTool, virtual public IMonitorToolBas * Average mu, i.e. \<mu\> * */ - virtual float lbAverageInteractionsPerCrossing(); + virtual float lbAverageInteractionsPerCrossing (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Instantaneous number of interactions, i.e. mu * */ - virtual float lbInteractionsPerCrossing(); + virtual float lbInteractionsPerCrossing (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1) * */ - virtual float lbAverageLuminosity(); + virtual float lbAverageLuminosity (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Instantaneous luminosity * */ - virtual float lbLuminosityPerBCID(); + virtual float lbLuminosityPerBCID (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Luminosity block time (in seconds) * */ - virtual double lbDuration(); + virtual double lbDuration (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Average luminosity livefraction * */ - virtual float lbAverageLivefraction(); + virtual float lbAverageLivefraction (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Livefraction per bunch crossing ID * */ - virtual float livefractionPerBCID(); + virtual float livefractionPerBCID (const EventContext& ctx = Gaudi::Hive::currentContext()) const; /** * Average Integrated Luminosity Live Fraction * */ - virtual double lbLumiWeight(); + virtual double lbLumiWeight (const EventContext& ctx = Gaudi::Hive::currentContext()) const; protected: @@ -919,9 +921,13 @@ protected: //bool findStream(const std::string& id, std::string& stream, std::string& rem) const; //std::string dirname(std::string& dir) const; - ToolHandle<ILuminosityTool> m_lumiTool; - ToolHandle<ITrigLivefractionTool> m_liveTool; - bool m_hasRetrievedLumiTool; + SG::ReadCondHandleKey<LuminosityCondData> m_lumiDataKey + {this,"LuminosityCondDataKey","LuminosityCondData","SG Key of LuminosityCondData object"}; + SG::ReadCondHandleKey<LBDurationCondData> m_lbDurationDataKey + {this,"LBDurationCondDataKey","LBDurationCondData","SG Key of LBDurationCondData object"}; + SG::ReadCondHandleKey<TrigLiveFractionCondData> m_trigLiveFractionDataKey + {this,"TrigLiveFractionCondDataKey","TrigLiveFractionCondData","SG Key of TrigLiveFractionCondData object"}; + bool m_bookHistogramsInitial; bool m_useLumi; float m_defaultLBDuration; diff --git a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolTest.h b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolTest.h index 12e2561cc66c4ecd4c22c73c5c68c78485d5dede..4e648ade4d1313ae31c97bfe0a04ec6317d4c59a 100755 --- a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolTest.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolTest.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef ManagedMonitorToolTest_H @@ -9,6 +9,7 @@ #include "AthenaMonitoring/ManagedMonitorToolBase.h" #include "TRandom3.h" +#include "CxxUtils/checker_macros.h" class TH1; class TGraph; @@ -19,7 +20,7 @@ class TH1F_LW; class TH2F; class TH2F_LW; -class ManagedMonitorToolTest : public ManagedMonitorToolBase +class ATLAS_NOT_THREAD_SAFE ManagedMonitorToolTest : public ManagedMonitorToolBase { public: diff --git a/Control/AthenaMonitoring/CMakeLists.txt b/Control/AthenaMonitoring/CMakeLists.txt index 5dac607f587f6972a00376d8d030840cccaa190a..40b8f009a40b15f3f79fd26a7886a558046ace1b 100644 --- a/Control/AthenaMonitoring/CMakeLists.txt +++ b/Control/AthenaMonitoring/CMakeLists.txt @@ -10,6 +10,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps GaudiKernel LumiBlock/LumiBlockComps + LumiBlock/LumiBlockData Trigger/TrigEvent/TrigDecisionInterface PRIVATE Control/AthenaKernel @@ -34,7 +35,7 @@ atlas_add_library( AthenaMonitoringLib PUBLIC_HEADERS AthenaMonitoring INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel LumiBlockCompsLib + LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps GaudiKernel LumiBlockCompsLib LumiBlockData PRIVATE_LINK_LIBRARIES ${CORAL_LIBRARIES} AthenaKernel SGAudCore AthenaPoolUtilities EventInfo LWHists ) atlas_add_component( AthenaMonitoring diff --git a/Control/AthenaMonitoring/python/AthMonitorCfgHelper.py b/Control/AthenaMonitoring/python/AthMonitorCfgHelper.py index 9e99d3d0a03bdd9a07a0e374d4b1d25bf3d8230a..5b9a8921bbd88b73016ebfffb3e56747ecd9eeca 100644 --- a/Control/AthenaMonitoring/python/AthMonitorCfgHelper.py +++ b/Control/AthenaMonitoring/python/AthMonitorCfgHelper.py @@ -65,6 +65,14 @@ class AthMonitorCfgHelper(object): algObj.TrigDecisionTool = self.resobj.getPublicTool("TrigDecisionTool") algObj.TriggerTranslatorTool = self.resobj.popToolsAndMerge(getTriggerTranslatorToolSimple(self.inputFlags)) + if getattr (algObj, 'EnableLumi', False): + from LumiBlockComps.LuminosityCondAlgConfig import LuminosityCondAlgCfg + from LumiBlockComps.LBDurationCondAlgConfig import LBDurationCondAlgCfg + from LumiBlockComps.TrigLiveFractionCondAlgConfig import TrigLiveFractionCondAlgCfg + self.resobj.merge (LuminosityCondAlgCfg (self.inputFlags)) + self.resobj.merge (LBDurationCondAlgCfg (self.inputFlags)) + self.resobj.merge (TrigLiveFractionCondAlgCfg (self.inputFlags)) + self.monSeq += algObj return algObj diff --git a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py index 0819c9b039d8829d3035c887f2081d7ef1ff75ba..8a71101a4b7bc6b8348219a798acf81792601ecd 100644 --- a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py +++ b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py @@ -19,20 +19,20 @@ if DQMonFlags.doMonitoring(): # don't set up lumi access if in MC or enableLumiAccess == False if globalflags.DataSource.get_Value() != 'geant4' and DQMonFlags.enableLumiAccess(): - if not hasattr(ToolSvc,"LuminosityTool"): - if athenaCommonFlags.isOnline: - local_logger.debug("luminosity tool not found, importing online version") - from LumiBlockComps.LuminosityToolDefault import LuminosityToolOnline - ToolSvc+=LuminosityToolOnline() - else: - local_logger.debug("luminosity tool not found, importing offline version") - from LumiBlockComps.LuminosityToolDefault import LuminosityToolDefault - ToolSvc+=LuminosityToolDefault() - - if not hasattr(ToolSvc,"TrigLivefractionTool"): - local_logger.debug("live fraction tool not found, importing") - from LumiBlockComps.TrigLivefractionToolDefault import TrigLivefractionToolDefault - ToolSvc+=TrigLivefractionToolDefault() + if athenaCommonFlags.isOnline: + local_logger.debug("luminosity tool not found, importing online version") + from LumiBlockComps.LuminosityCondAlgDefault import LuminosityCondAlgOnlineDefault + LuminosityCondAlgOnlineDefault() + else: + local_logger.debug("luminosity tool not found, importing offline version") + from LumiBlockComps.LuminosityCondAlgDefault import LuminosityCondAlgDefault + LuminosityCondAlgDefault() + + from LumiBlockComps.LBDurationCondAlgDefault import LBDurationCondAlgDefault + LBDurationCondAlgDefault() + + from LumiBlockComps.TrigLiveFractionCondAlgDefault import TrigLiveFractionCondAlgDefault + TrigLiveFractionCondAlgDefault() from AthenaMonitoring.AtlasReadyFilterTool import GetAtlasReadyFilterTool from AthenaMonitoring.FilledBunchFilterTool import GetFilledBunchFilterTool diff --git a/Control/AthenaMonitoring/share/ManagedMonitorToolTest.py b/Control/AthenaMonitoring/share/ManagedMonitorToolTest.py index 9db38fabfe896029b0923b27f210cef2a005f490..c16c0d88306a374473e7f6ec724ac40fcd094ee3 100755 --- a/Control/AthenaMonitoring/share/ManagedMonitorToolTest.py +++ b/Control/AthenaMonitoring/share/ManagedMonitorToolTest.py @@ -32,16 +32,9 @@ OutputLevel = INFO # main jobOption - must always be included include ("RecExCommon/RecExCommon_topOptions.py") -# Must do tool configuration here for DB access to be autoconfigured from RecExCommon -from LumiBlockComps.LuminosityToolDefault import LuminosityToolDefault -lumiTool = LuminosityToolDefault() -lumiTool.OutputLevel = DEBUG -ToolSvc += lumiTool - -from LumiBlockComps.TrigLivefractionToolDefault import TrigLivefractionToolDefault -liveTool = TrigLivefractionToolDefault() -liveTool.OutputLevel = DEBUG -ToolSvc += liveTool +from LumiBlockComps.TrigLiveFractionCondAlgDefault import TrigLiveFractionCondAlgDefault +liveAlg = TrigLiveFractionCondAlgDefault() +liveAlg.OutputLevel = DEBUG from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() diff --git a/Control/AthenaMonitoring/src/AthMonitorAlgorithm.cxx b/Control/AthenaMonitoring/src/AthMonitorAlgorithm.cxx index 613e1298a2fc174dfda9448b363335c7d0be56ef..7b80631d003308ba4d29c017c14933aad60e57bb 100644 --- a/Control/AthenaMonitoring/src/AthMonitorAlgorithm.cxx +++ b/Control/AthenaMonitoring/src/AthMonitorAlgorithm.cxx @@ -3,13 +3,13 @@ */ #include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "StoreGate/ReadCondHandle.h" AthMonitorAlgorithm::AthMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) :AthReentrantAlgorithm(name,pSvcLocator) ,m_environment(Environment_t::user) ,m_dataType(DataType_t::userDefined) ,m_vTrigChainNames({}) -,m_hasRetrievedLumiTool(false) {} @@ -51,21 +51,9 @@ StatusCode AthMonitorAlgorithm::initialize() { m_dataType = dataTypeStringToEnum(m_dataTypeStr); m_environment = envStringToEnum(m_environmentStr); - // Retrieve the luminosity tool if requested and whenever not using Monte Carlo - if (m_useLumi) { - if (m_dataType == DataType_t::monteCarlo) { - ATH_MSG_WARNING("Lumi tool requested, but AthMonitorAlgorithm is configured for MC. Disabling lumi tool."); - } else { - // Retrieve the luminosity and live fraction tools - StatusCode sc_lumiTool = m_lumiTool.retrieve(); - StatusCode sc_liveTool = m_liveTool.retrieve(); - - // Set m_hasRetrievedLumiTool to true if both tools are retrieved successfully - if ( sc_lumiTool.isSuccess() && sc_liveTool.isSuccess() ) { - m_hasRetrievedLumiTool = true; - } - } - } + ATH_CHECK( m_lumiDataKey.initialize (m_useLumi && m_dataType != DataType_t::monteCarlo) ); + ATH_CHECK( m_lbDurationDataKey.initialize (m_useLumi && m_dataType != DataType_t::monteCarlo) ); + ATH_CHECK( m_trigLiveFractionDataKey.initialize (m_useLumi && m_dataType != DataType_t::monteCarlo) ); // get event info key ATH_CHECK( m_EventInfoKey.initialize() ); @@ -198,9 +186,11 @@ bool AthMonitorAlgorithm::trigChainsArePassed( const std::vector<std::string>& v } -float AthMonitorAlgorithm::lbAverageInteractionsPerCrossing() const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbAverageInteractionsPerCrossing(); +float AthMonitorAlgorithm::lbAverageInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbAverageInteractionsPerCrossing(); } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbAverageInteractionsPerCrossing() - luminosity tools are not retrieved."); return -1.0; @@ -208,13 +198,15 @@ float AthMonitorAlgorithm::lbAverageInteractionsPerCrossing() const { } -float AthMonitorAlgorithm::lbInteractionsPerCrossing() const { - if ( m_hasRetrievedLumiTool ) { - float instmu = 0.; - if (m_lumiTool->muToLumi() > 0.) { - instmu = m_lumiTool->lbLuminosityPerBCID()/m_lumiTool->muToLumi(); +float AthMonitorAlgorithm::lbInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + float muToLumi = lumi->muToLumi(); + if (muToLumi > 0) { + return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()) / muToLumi; } - return instmu; + return 0; } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbInteractionsPerCrossing() - luminosity tools are not retrieved."); return -1.0; @@ -222,9 +214,11 @@ float AthMonitorAlgorithm::lbInteractionsPerCrossing() const { } -float AthMonitorAlgorithm::lbAverageLuminosity() const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbAverageLuminosity(); +float AthMonitorAlgorithm::lbAverageLuminosity (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbAverageLuminosity(); } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbAverageLuminosity() - luminosity tools are not retrieved."); return -1.0; @@ -232,9 +226,11 @@ float AthMonitorAlgorithm::lbAverageLuminosity() const { } -float AthMonitorAlgorithm::lbLuminosityPerBCID() const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbLuminosityPerBCID(); +float AthMonitorAlgorithm::lbLuminosityPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()); } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbLuminosityPerBCID() - luminosity tools are not retrieved."); return -1.0; @@ -242,37 +238,42 @@ float AthMonitorAlgorithm::lbLuminosityPerBCID() const { } -float AthMonitorAlgorithm::lbAverageLivefraction() const { +float AthMonitorAlgorithm::lbAverageLivefraction (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ if (m_environment == Environment_t::online) { return 1.0; } - if ( m_hasRetrievedLumiTool ) { - return m_liveTool->lbAverageLivefraction(); + if (!m_trigLiveFractionDataKey.empty()) { + SG::ReadCondHandle<TrigLiveFractionCondData> live (m_trigLiveFractionDataKey, ctx); + return live->lbAverageLiveFraction(); } else { - ATH_MSG_DEBUG("AthMonitorAlgorithm::lbAverageLivefraction() - luminosity tools are not retrieved."); + ATH_MSG_DEBUG("AthMonitorAlgorithm::lbAverageLivefraction() - luminosity not available."); return -1.0; } } -float AthMonitorAlgorithm::livefractionPerBCID() const { +float AthMonitorAlgorithm::livefractionPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ if (m_environment == Environment_t::online) { return 1.0; } - if ( m_hasRetrievedLumiTool ) { - return m_liveTool->livefractionPerBCID(); + if (!m_trigLiveFractionDataKey.empty()) { + SG::ReadCondHandle<TrigLiveFractionCondData> live (m_trigLiveFractionDataKey, ctx); + return live->l1LiveFractionVector().at (ctx.eventID().bunch_crossing_id()); } else { - ATH_MSG_DEBUG("AthMonitorAlgorithm::livefractionPerBCID() - luminosity tools are not retrieved."); + ATH_MSG_DEBUG("AthMonitorAlgorithm::livefractionPerBCID() - luminosity not available."); return -1.0; } } -double AthMonitorAlgorithm::lbLumiWeight() const { - if ( m_hasRetrievedLumiTool ) { - return (lbAverageLuminosity()*lbDuration())*lbAverageLivefraction(); +double AthMonitorAlgorithm::lbLumiWeight (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ + if (!m_lumiDataKey.empty()) { + return (lbAverageLuminosity(ctx)*lbDuration(ctx))*lbAverageLivefraction(ctx); } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbLumiWeight() - luminosity tools are not retrieved."); return -1.0; @@ -280,13 +281,15 @@ double AthMonitorAlgorithm::lbLumiWeight() const { } -double AthMonitorAlgorithm::lbDuration() const { +double AthMonitorAlgorithm::lbDuration (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const +{ if ( m_environment == Environment_t::online ) { return m_defaultLBDuration; } - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbDuration(); + if (!m_lbDurationDataKey.empty()) { + SG::ReadCondHandle<LBDurationCondData> dur (m_lbDurationDataKey, ctx); + return dur->lbDuration(); } else { ATH_MSG_DEBUG("AthMonitorAlgorithm::lbDuration() - luminosity tools are not retrieved."); return m_defaultLBDuration; diff --git a/Control/AthenaMonitoring/src/DQFilledBunchFilterTool.cxx b/Control/AthenaMonitoring/src/DQFilledBunchFilterTool.cxx index 46cf10b3c466c2ba09352a59343b0171147c9543..ac43549272bd3a6125404eba20081eeb33a3ed44 100644 --- a/Control/AthenaMonitoring/src/DQFilledBunchFilterTool.cxx +++ b/Control/AthenaMonitoring/src/DQFilledBunchFilterTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "AthenaMonitoring/DQFilledBunchFilterTool.h" @@ -37,10 +37,7 @@ bool DQFilledBunchFilterTool::accept() const { if (m_alwaysReturnTrue) { return true; } else { - const EventInfo* eventInfo(0); - CHECK( evtStore()->retrieve( eventInfo ), false ); - - EventID::number_type bcid = eventInfo->event_ID()->bunch_crossing_id(); + EventID::number_type bcid = Gaudi::Hive::currentContext().eventID().bunch_crossing_id(); bool value = m_bunchtool->isFilled(bcid) ^ m_invert; ATH_MSG_VERBOSE("Filled bunch DQ tool accept called, value " << value); return value; diff --git a/Control/AthenaMonitoring/src/ExampleMonitorAlgorithm.cxx b/Control/AthenaMonitoring/src/ExampleMonitorAlgorithm.cxx index 2ca2d01be4758059790513a349f4dd4731217963..ed38e8189b237b6a0c0ac84df244ad61211be3a4 100644 --- a/Control/AthenaMonitoring/src/ExampleMonitorAlgorithm.cxx +++ b/Control/AthenaMonitoring/src/ExampleMonitorAlgorithm.cxx @@ -33,7 +33,7 @@ StatusCode ExampleMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co auto pT_passed = Monitored::Scalar<float>("pT_passed",false); // Set the values of the monitored variables for the event - lumiPerBCID = lbAverageInteractionsPerCrossing(); + lumiPerBCID = lbAverageInteractionsPerCrossing (ctx); lb = GetEventInfo(ctx)->lumiBlock(); run = GetEventInfo(ctx)->runNumber(); testweight = 2.0; diff --git a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx index ab73e8a71ae54a545212ddacba8f47b807389c05..494a5685eb567a0a09675d26e04db61452bf7355 100755 --- a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx +++ b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx @@ -21,6 +21,7 @@ #include "LWHists/LWHistControls.h" #include "LWHistAthMonWrapper.h" #include "AthMonBench.h" +#include "StoreGate/ReadCondHandle.h" #include "GaudiKernel/IHistogramSvc.h" #include "GaudiKernel/IJobOptionsSvc.h" @@ -412,9 +413,6 @@ ManagedMonitorToolBase( const std::string & type, const std::string & name, , m_nEventsIgnoreTrigger(1) , m_nLumiBlocks(1) , m_haveClearedLastEventBlock(true) - , m_lumiTool("LuminosityTool") - , m_liveTool("TrigLivefractionTool") - , m_hasRetrievedLumiTool(false) , m_bookHistogramsInitial(false) , m_useLumi(false) , m_defaultLBDuration(60.) @@ -775,26 +773,9 @@ initialize() m_dataType = AthenaMonManager::dataTypeStringToEnum( m_dataTypeStr ); m_environment = AthenaMonManager::envStringToEnum( m_environmentStr ); - if (m_useLumi) { - if (m_dataType == AthenaMonManager::monteCarlo) { - ATH_MSG_WARNING("Lumi use in monitoring enabled but tool configured for MC; disabling lumi tool use"); - } else { - // Get the luminosity tool - //CHECK(m_lumiTool.retrieve()); - StatusCode sc_lumiTool = m_lumiTool.retrieve(); - - // Get the livefration tool - //CHECK(m_liveTool.retrieve()); - StatusCode sc_liveTool = m_liveTool.retrieve(); - - // Set m_hasRetrievedLumiTool to true when both tools are retrieved successfully - if ( sc_lumiTool.isSuccess() && sc_liveTool.isSuccess() ) - m_hasRetrievedLumiTool = true; - } - } else { - ATH_MSG_DEBUG("!! Luminosity tool is disabled !!"); - } - + ATH_CHECK( m_lumiDataKey.initialize (m_useLumi && m_dataType != AthenaMonManager::monteCarlo) ); + ATH_CHECK( m_lbDurationDataKey.initialize (m_useLumi && m_dataType != AthenaMonManager::monteCarlo) ); + ATH_CHECK( m_trigLiveFractionDataKey.initialize (m_useLumi && m_dataType != AthenaMonManager::monteCarlo) ); delete m_streamNameFcn; m_streamNameFcn = getNewStreamNameFcn(); @@ -1844,10 +1825,11 @@ preSelector() // Average mu, i.e. <mu> float ManagedMonitorToolBase:: -lbAverageInteractionsPerCrossing() +lbAverageInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbAverageInteractionsPerCrossing(); + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbAverageInteractionsPerCrossing(); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageInteractionsPerCrossing() can't work properly! "); ATH_MSG_DEBUG("Warning: lbAverageInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); @@ -1859,15 +1841,15 @@ lbAverageInteractionsPerCrossing() // Instantaneous number of interactions, i.e. mu float ManagedMonitorToolBase:: -lbInteractionsPerCrossing() +lbInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { - if ( m_hasRetrievedLumiTool ) { - float instmu = 0.; - - if (m_lumiTool->muToLumi() > 0.) - instmu = m_lumiTool->lbLuminosityPerBCID()/m_lumiTool->muToLumi(); - - return instmu; + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + float muToLumi = lumi->muToLumi(); + if (muToLumi > 0) { + return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()) / muToLumi; + } + return 0; } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbInteractionsPerCrossing() can't work properly! "); ATH_MSG_DEBUG("Warning: lbInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); @@ -1879,10 +1861,11 @@ lbInteractionsPerCrossing() // Average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1) float ManagedMonitorToolBase:: -lbAverageLuminosity() +lbAverageLuminosity (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbAverageLuminosity(); + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbAverageLuminosity(); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageLuminosity() can't work properly! "); ATH_MSG_DEBUG("Warning: lbAverageLuminosity() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); @@ -1894,10 +1877,11 @@ lbAverageLuminosity() // Instantaneous luminosity float ManagedMonitorToolBase:: -lbLuminosityPerBCID() +lbLuminosityPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbLuminosityPerBCID(); + if (!m_lumiDataKey.empty()) { + SG::ReadCondHandle<LuminosityCondData> lumi (m_lumiDataKey, ctx); + return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbLuminosityPerBCID() can't work properly! "); ATH_MSG_DEBUG("Warning: lbLuminosityPerBCID() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); @@ -1910,16 +1894,17 @@ lbLuminosityPerBCID() // Average luminosity livefraction float ManagedMonitorToolBase:: -lbAverageLivefraction() +lbAverageLivefraction (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { if (m_environment == AthenaMonManager::online) return 1.0; - if ( m_hasRetrievedLumiTool ) { - return m_liveTool->lbAverageLivefraction(); + if (!m_trigLiveFractionDataKey.empty()) { + SG::ReadCondHandle<TrigLiveFractionCondData> live (m_trigLiveFractionDataKey, ctx); + return live->lbAverageLiveFraction(); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageLivefraction() can't work properly! "); - ATH_MSG_DEBUG("Warning: lbAverageLivefraction() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); + ATH_MSG_DEBUG("Warning: lbAverageLivefraction() - luminosity not availble (i.e. EnableLumi = False)"); return -1.0; } // not reached @@ -1928,16 +1913,17 @@ lbAverageLivefraction() // Live Fraction per Bunch Crossing ID float ManagedMonitorToolBase:: -livefractionPerBCID() +livefractionPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { if (m_environment == AthenaMonManager::online) return 1.0; - if ( m_hasRetrievedLumiTool ) { - return m_liveTool->livefractionPerBCID(); + if (!m_trigLiveFractionDataKey.empty()) { + SG::ReadCondHandle<TrigLiveFractionCondData> live (m_trigLiveFractionDataKey, ctx); + return live->l1LiveFractionVector().at (ctx.eventID().bunch_crossing_id()); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! livefractionPerBCID() can't work properly! "); - ATH_MSG_DEBUG("Warning: livefractionPerBCID() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); + ATH_MSG_DEBUG("Warning: livefractionPerBCID() - luminosity retrieved available (i.e. EnableLumi = False)"); return -1.0; } // not reached @@ -1946,10 +1932,10 @@ livefractionPerBCID() // Average Integrated Luminosity Live Fraction double ManagedMonitorToolBase:: -lbLumiWeight() +lbLumiWeight (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { - if ( m_hasRetrievedLumiTool ) { - return (lbAverageLuminosity()*lbDuration())*lbAverageLivefraction(); + if (!m_lumiDataKey.empty()) { + return (lbAverageLuminosity(ctx)*lbDuration(ctx))*lbAverageLivefraction(ctx); } else{ //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbLumiWeight() can't work properly! "); ATH_MSG_DEBUG("Warning: lbLumiWeight() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); @@ -1962,13 +1948,14 @@ lbLumiWeight() // Luminosity block time (in seconds) double ManagedMonitorToolBase:: -lbDuration() +lbDuration (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const { if ( m_environment == AthenaMonManager::online ) { return m_defaultLBDuration; } - if ( m_hasRetrievedLumiTool ) { - return m_lumiTool->lbDuration(); + if (!m_lbDurationDataKey.empty()) { + SG::ReadCondHandle<LBDurationCondData> dur (m_lbDurationDataKey, ctx); + return dur->lbDuration(); } else { //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbDuration() can't work properly! "); ATH_MSG_DEBUG("Warning: lbDuration() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)"); diff --git a/Control/AthenaMonitoring/src/ManagedMonitorToolTest.cxx b/Control/AthenaMonitoring/src/ManagedMonitorToolTest.cxx index eb78cfe55415912aa377a5e6ddeb821f45ae72d2..550d94a7df1a08c6af317d3f128378cd855b777e 100755 --- a/Control/AthenaMonitoring/src/ManagedMonitorToolTest.cxx +++ b/Control/AthenaMonitoring/src/ManagedMonitorToolTest.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // **********************************************************************