diff --git a/Control/AthenaExamples/AthExMonitored/src/MonitoredAlg.cxx b/Control/AthenaExamples/AthExMonitored/src/MonitoredAlg.cxx index a7b196bf4cf1e6f295519ef4de24d7ad11ec859f..9a4ddf5b5162461df10f5c48e19ff4b9d16c7452 100644 --- a/Control/AthenaExamples/AthExMonitored/src/MonitoredAlg.cxx +++ b/Control/AthenaExamples/AthExMonitored/src/MonitoredAlg.cxx @@ -1,9 +1,9 @@ /* - 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 "MonitoredAlg.h" -#include "AthenaMonitoring/MonitoredScope.h" +#include "AthenaMonitoring/Monitored.h" #include <vector> #include <cmath> @@ -35,21 +35,20 @@ private: StatusCode MonitoredAlg::execute() { - using namespace Monitored; std::vector<Track> tracks; // In case you want to measure the execution time - auto timer = MonitoredTimer::declare("TIME_execute"); + auto timer = Monitored::Timer("TIME_execute"); - auto count = MonitoredScalar::declare<int>("nTracks", 0); // explicit type + auto count = Monitored::Scalar<int>("nTracks", 0); // explicit type // Access via member - auto eta = MonitoredCollection::declare("eta", tracks, &Track::eta); + auto eta = Monitored::Collection("eta", tracks, &Track::eta); // Access via function/lambda - auto absphi = MonitoredCollection::declare("AbsPhi", tracks, []( const Track& t ) { return abs(t.phi()); }); + auto absphi = Monitored::Collection("AbsPhi", tracks, []( const Track& t ) { return abs(t.phi()); }); - auto mon = MonitoredScope::declare(m_monTool, count, eta, absphi, timer); + auto mon = Monitored::Group(m_monTool, count, eta, absphi, timer); count = 1 + (rand() % 10); // random number of tracks diff --git a/Control/AthenaMonitoring/AthenaMonitoring/GenericMonitoringTool.h b/Control/AthenaMonitoring/AthenaMonitoring/GenericMonitoringTool.h index 8e47b3f46438defc9f646b08579099311f004496..6d627d8aebce77e9b10ee016de454b788e4d3135 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/GenericMonitoringTool.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/GenericMonitoringTool.h @@ -102,9 +102,4 @@ public: ToolHandle<GenericMonitoringTool>("", parent) {} }; -//#include "AthenaMonitoring/MonitoredScope.h" -#include "AthenaMonitoring/MonitoredScalar.h" -#include "AthenaMonitoring/MonitoredCollection.h" -#include "AthenaMonitoring/MonitoredTimer.h" - #endif /* AthenaMonitoring_GenericMonitoringTool_h */ diff --git a/Control/AthenaMonitoring/AthenaMonitoring/IMonitoredVariable.h b/Control/AthenaMonitoring/AthenaMonitoring/IMonitoredVariable.h index 6e994a2f2a730d0641d7f4a28f37c9fd9c243eaa..06918ca74b6d13cd524a863b0815b667a8b61d05 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/IMonitoredVariable.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/IMonitoredVariable.h @@ -9,11 +9,11 @@ #include <vector> namespace Monitored { - class MonitoredScope; + class MonitoredGroup; class IMonitoredVariable { public: - friend MonitoredScope; + friend MonitoredGroup; virtual ~IMonitoredVariable() {} const std::string& name() const { return m_name; } diff --git a/Control/AthenaMonitoring/AthenaMonitoring/Monitored.h b/Control/AthenaMonitoring/AthenaMonitoring/Monitored.h new file mode 100644 index 0000000000000000000000000000000000000000..30e2fc11bf61c7a3335cbf92bfee54923db60abb --- /dev/null +++ b/Control/AthenaMonitoring/AthenaMonitoring/Monitored.h @@ -0,0 +1,16 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef AthenaMonitoring_Monitored_h +#define AthenaMonitoring_Monitored_h + +/** + * @file AthenaMonitoring/Monitored.h + * @brief Header file to be included by clients of the Monitored infrastructure + */ +#include "AthenaMonitoring/MonitoredGroup.h" +#include "AthenaMonitoring/MonitoredScalar.h" +#include "AthenaMonitoring/MonitoredCollection.h" +#include "AthenaMonitoring/MonitoredTimer.h" + +#endif diff --git a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredCollection.h b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredCollection.h index 29791abec7fc05ffe0209791fe20887c9f6aa274..db2e72146fcc2bcdb152a10b323100f191d777bc 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredCollection.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredCollection.h @@ -1,166 +1,175 @@ /* - 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 AthenaMonitoring_MonitoredCollection_h #define AthenaMonitoring_MonitoredCollection_h #include <functional> -#include <vector> #include <type_traits> +#include <vector> #include "AthenaMonitoring/IMonitoredVariable.h" namespace Monitored { - /** - * Monitoring of (double-convertable) collections - */ - namespace MonitoredCollection { - - // Forward declares - template<class T> class MonitoredValuesCollection; - template<class T> class MonitoredObjectsCollection; - - /** - * Declare a monitored (double-convertable) collection - * - * Any iterable container with elements covertable to double can be monitored. - * - * @param name Name of monitored quantity - * @param collection Collection to be monitored (e.g. STL container or array) - * - * \code - * std::vector<float> eta( {0.2, 0.1} ); - * auto m = MonitoredCollection::declare("Eta", eta); - * \endcode - */ - template<class T> - MonitoredValuesCollection<T> declare(std::string name, const T& collection) { - return MonitoredValuesCollection<T>(std::move(name), collection); - } - - /** - * Declare a monitored collection of objects - * - * A converter function/accessor needs to be provided to extract the relevant quantity. - * - * @param name Name of monitored quantity - * @param collection Collection to be monitored (e.g. STL container or array) - * @param converterToDouble Function taking an element and returning a double - * - * \code - * std::vector<Track> tracks; - * auto phi = MonitoredCollection::declare( "Phi", tracks, []( const Track& t ) { return t.phi(); } ); - * \endcode - */ - template<class T> - MonitoredObjectsCollection<T> declare(std::string name, const T& collection, - std::function<double(const typename MonitoredObjectsCollection<T>::const_value_type&)> converterToDouble) { - return MonitoredObjectsCollection<T>(std::move(name), collection, - std::move(converterToDouble)); - } - - namespace detail { - /// Get element type for containers - template <typename T> - struct get_value_type { - typedef typename T::value_type value_type; - }; - /// Get element type for arrays - template <typename T, size_t N> - struct get_value_type<T[N]> { - typedef T value_type; - }; - - template <typename T> - struct make_pointer_const { - typedef T type; - }; - template <typename T> - struct make_pointer_const<T*> { - typedef const T* type; - }; - } - - - /** - * Monitoring of collections - * - * This class is not supposed to be used by the end user. - */ - template<class T> - class MonitoredValuesCollection : public IMonitoredVariable { - public: - /// Type of the collection elements - using value_type = typename detail::get_value_type<T>::value_type; - - static_assert(std::is_convertible<value_type, double>::value, - "Collection values must be convertable to double"); - - /// @brief . \if empty doc string required due to doxygen bug 787131 \endif - friend MonitoredValuesCollection<T> declare<T>(std::string name, const T& collection); - - MonitoredValuesCollection(MonitoredValuesCollection&&) = default; - - const std::vector<double> getVectorRepresentation() const override { - return std::vector<double>(std::begin(m_collection), std::end(m_collection)); - } - private: - const T& m_collection; - - MonitoredValuesCollection(std::string name, const T& collection) - : IMonitoredVariable(std::move(name)), m_collection(collection) { } - MonitoredValuesCollection(MonitoredValuesCollection const&) = delete; - MonitoredValuesCollection& operator=(MonitoredValuesCollection const&) = delete; - }; - - - /** - * Monitoring of object collections - * - * This class is not supposed to be used by the end user. - */ - template<class T> - class MonitoredObjectsCollection : public IMonitoredVariable { - public: - /// Type of the collection elements - using value_type = typename detail::get_value_type<T>::value_type; - using const_value_type = typename detail::make_pointer_const<value_type>::type; - - /// @brief . \if empty doc string required due to doxygen bug 787131 \endif - // With a non-template friend declaration, clang 4.0.1 - // fails to match the friend. - template <class U> - friend MonitoredObjectsCollection<U> declare(std::string name, const U& collection, - std::function<double(const typename MonitoredObjectsCollection<U>::const_value_type&)> converterToDouble); - - MonitoredObjectsCollection(MonitoredObjectsCollection&&) = default; - - const std::vector<double> getVectorRepresentation() const override { - // Could be replaced with std::size in C++17 - auto N = std::distance(std::begin(m_collection), std::end(m_collection)); - - // Reserve space and fill vector - std::vector<double> result; - result.reserve(N); - for(auto value : m_collection) result.push_back(m_converterToDouble(value)); - - return result; - } - private: - const T& m_collection; - std::function<double(const const_value_type&)> m_converterToDouble; - - MonitoredObjectsCollection(std::string name, const T& collection, - std::function<double(const const_value_type&)> converterToDouble) - : IMonitoredVariable(std::move(name)), - m_collection(collection), - m_converterToDouble(std::move(converterToDouble)) { } - MonitoredObjectsCollection(MonitoredObjectsCollection const&) = delete; - MonitoredObjectsCollection& operator=(MonitoredObjectsCollection const&) = delete; - }; + /** + * Monitoring of (double-convertable) collections + */ + + // Forward declares + template <class T> class ValuesCollection; + template <class T> class ObjectsCollection; + + /** + * Declare a monitored (double-convertable) collection + * + * Any iterable container with elements covertable to double can be monitored. + * + * @param name Name of monitored quantity + * @param collection Collection to be monitored (e.g. STL container or array) + * + * \code + * std::vector<float> eta( {0.2, 0.1} ); + * auto m = Monitored::Collection("Eta", eta); + * \endcode + */ + template <class T> ValuesCollection<T> Collection(std::string name, const T& collection) { + return ValuesCollection<T>(std::move(name), collection); + } + + /** + * Declare a monitored collection of objects + * + * A converter function/accessor needs to be provided to extract the relevant quantity. + * + * @param name Name of monitored quantity + * @param collection Collection to be monitored (e.g. STL container or array) + * @param converterToDouble Function taking an element and returning a double + * + * \code + * std::vector<Track> tracks; + * auto phi = Monitored::Collection("Phi", tracks, [](const Track& t) {return t.phi();}); + * \endcode + */ + template <class T> ObjectsCollection<T> + Collection(std::string name, const T& collection, + std::function<double(const typename ObjectsCollection<T>::const_value_type&)> + converterToDouble) { + return ObjectsCollection<T>(std::move(name), collection, std::move(converterToDouble)); + } + + // TEMPORARY: for backwards compatibility + namespace MonitoredCollection { + + template <class T> ValuesCollection<T> declare(std::string name, const T& collection) { + return ValuesCollection<T>(std::move(name), collection); + } + + template <class T> ObjectsCollection<T> + declare(std::string name, const T& collection, + std::function<double(const typename ObjectsCollection<T>::const_value_type&)> + converterToDouble) { + return ObjectsCollection<T>(std::move(name), collection, std::move(converterToDouble)); + } + } // namespace MonitoredCollection + + namespace detail { + /// Get element type for containers + template <typename T> struct get_value_type { typedef typename T::value_type value_type; }; + /// Get element type for arrays + template <typename T, size_t N> struct get_value_type<T[N]> { typedef T value_type; }; + + template <typename T> struct make_pointer_const { typedef T type; }; + template <typename T> struct make_pointer_const<T*> { typedef const T* type; }; + } // namespace detail + + /** + * Monitoring of collections + * + * This class is not supposed to be used by the end user. + */ + template <class T> class ValuesCollection : public IMonitoredVariable { + public: + /// Type of the collection elements + using value_type = typename detail::get_value_type<T>::value_type; + + static_assert(std::is_convertible<value_type, double>::value, + "Collection values must be convertable to double"); + + /// @brief . \if empty doc string required due to doxygen bug 787131 \endif + friend ValuesCollection<T> Collection<T>(std::string name, const T& collection); + // TEMPORARY: for backwards compatibility + friend ValuesCollection<T> MonitoredCollection::declare<T>(std::string name, + const T& collection); + + ValuesCollection(ValuesCollection&&) = default; + + const std::vector<double> getVectorRepresentation() const override { + return std::vector<double>(std::begin(m_collection), std::end(m_collection)); } -} + + private: + const T& m_collection; + + ValuesCollection(std::string name, const T& collection) + : IMonitoredVariable(std::move(name)), m_collection(collection) {} + ValuesCollection(ValuesCollection const&) = delete; + ValuesCollection& operator=(ValuesCollection const&) = delete; + }; + + /** + * Monitoring of object collections + * + * This class is not supposed to be used by the end user. + */ + template <class T> class ObjectsCollection : public IMonitoredVariable { + public: + /// Type of the collection elements + using value_type = typename detail::get_value_type<T>::value_type; + using const_value_type = typename detail::make_pointer_const<value_type>::type; + + /// @brief . \if empty doc string required due to doxygen bug 787131 \endif + // With a non-template friend declaration, clang 4.0.1 + // fails to match the friend. + template <class U> friend ObjectsCollection<U> + Collection(std::string name, const U& collection, + std::function<double(const typename ObjectsCollection<U>::const_value_type&)> + converterToDouble); + + // TEMPORARY: for backwards compatibility + template <class U> friend ObjectsCollection<U> MonitoredCollection::declare( + std::string name, const U& collection, + std::function<double(const typename ObjectsCollection<U>::const_value_type&)> + converterToDouble); + + ObjectsCollection(ObjectsCollection&&) = default; + + const std::vector<double> getVectorRepresentation() const override { + // Could be replaced with std::size in C++17 + auto N = std::distance(std::begin(m_collection), std::end(m_collection)); + + // Reserve space and fill vector + std::vector<double> result; + result.reserve(N); + for (auto value : m_collection) result.push_back(m_converterToDouble(value)); + + return result; + } + + private: + const T& m_collection; + std::function<double(const const_value_type&)> m_converterToDouble; + + ObjectsCollection(std::string name, const T& collection, + std::function<double(const const_value_type&)> converterToDouble) + : IMonitoredVariable(std::move(name)), + m_collection(collection), + m_converterToDouble(std::move(converterToDouble)) {} + ObjectsCollection(ObjectsCollection const&) = delete; + ObjectsCollection& operator=(ObjectsCollection const&) = delete; + }; + +} // namespace Monitored #endif /* AthenaMonitoring_MonitoredCollection_h */ diff --git a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredGroup.h b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e7f59c76c66279c68fba86e858bf61a8a30dc0 --- /dev/null +++ b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredGroup.h @@ -0,0 +1,123 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef AthenaMonitoring_MonitoredGroup_h +#define AthenaMonitoring_MonitoredGroup_h + +#include <functional> +#include <string> +#include <vector> + +#include "AthenaMonitoring/GenericMonitoringTool.h" +#include "AthenaMonitoring/HistogramFiller.h" +#include "AthenaMonitoring/IMonitoredVariable.h" +#include "GaudiKernel/ToolHandle.h" + +namespace Monitored { + + namespace impl { + /** + * @brief Group local monitoring quantities and retain correlation when filling histograms + * + * In order to maintain correlations when filling histograms (e.g. eta and phi of a track) the + * monitored quantities need to be grouped within a Monitored::Group. The filling of the + * histogram occurs when the Monitored::Group object goes out of scope or when fill() is called + * explicitly. + * + * \code + * { + * auto phi = Monitored::Scalar("phi"); + * auto eta = Monitored::Scalar("eta"); + * auto mon = Monitored::Group(m_monTool, phi, eta); + * } + * \endcode + **/ + class Group { + public: + /** + * @brief Named constructor + * @param tool a handle to a monitoring tool, if invalid nothing is done + * @param monitoredGroup list of variables to be monitored + **/ + template <typename... T> + Group(const ToolHandle<GenericMonitoringTool>& tool, T&&... monitoredGroup) + : m_tool(tool), + m_autoFill(true), + m_monitoredGroup{monitoredGroup...}, + m_histogramsFillers(!m_tool.empty() ? m_tool->getHistogramsFillers(m_monitoredGroup) + : std::vector<HistogramFiller*>()) {} + + virtual ~Group() { + if (m_autoFill) { + fill(); + } + for (auto filler : m_histogramsFillers) { + delete filler; + } + } + + /** + * @brief explicitely fill the monitoring output + **/ + virtual void fill() { + for (auto filler : m_histogramsFillers) { + filler->fill(); + } + } + /** + * @brief enables/disables filling when Monitored::Group leaves the scope + * + * By default Monitored::Group will perform a one time fill each time it goes + * out of scope. In tight loops one may want to re-use the same Monitored::Group + * and instead trigger the filling manually: + * + * \code + * auto pt = Monitored::Scalar("pt"); + * auto mon = Monitored::Group(m_monTool, pt); + * mon.setAutoFill(false); + * for (...) { + * // fill pt + * mon.fill(); + * } + * \endcode + **/ + void setAutoFill(bool isEnabled) { m_autoFill = isEnabled; } + + protected: + ToolHandle<GenericMonitoringTool> m_tool; + bool m_autoFill; + const std::vector<std::reference_wrapper<IMonitoredVariable>> m_monitoredGroup; + const std::vector<HistogramFiller*> m_histogramsFillers; + }; + + template <typename... T> + void fill(const ToolHandle<GenericMonitoringTool>& tool, T&&... variables) { + if (!tool.empty()) { + for (auto filler : tool->getHistogramsFillers({std::forward<T>(variables)...})) { + filler->fill(); + } + } + } + } // namespace impl + + // TEMPORARY: for backwards compatibility + namespace MonitoredScope { + template <typename... T> + static impl::Group declare(const ToolHandle<GenericMonitoringTool>& tool, T&&... monitoredGroup) { + return impl::Group(tool, monitoredGroup...); + } + } // namespace MonitoredScope + +#if __cplusplus >= 201700 + using impl::Group; +#else + template <typename... T> + static impl::Group Group(const ToolHandle<GenericMonitoringTool>& tool, T&&... monitoredGroup) { + return impl::Group(tool, monitoredGroup...); + } +#endif + +} // namespace Monitored + +#endif /* AthenaMonitoring_MonitoredGroup_h */ diff --git a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScalar.h b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScalar.h index 62d1bb03d0fdf6ca9a86cded1267b1ec3d1b0291..347a299b484a214aaf14c269d8b91debda117333 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScalar.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScalar.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 AthenaMonitoring_MonitoredScalar_h @@ -11,70 +11,71 @@ namespace Monitored { + namespace impl { /** - * Monitoring of scalars + * Declare a monitored scalar + * + * Monitoring for any double-convertable scalar + * + * @param name Name of monitored quantity + * @param defaultValue default value assigned to the monitored scalar + * + * \code + * auto phi = Monitored::Scalar("phi", 4.2); // deduced double + * auto eta = Monitored::Scalar<float>("eta", 0); // explicit float + * \endcode */ - namespace MonitoredScalar { - template<class T> - class MonitoredScalar; - - template<class T> - MonitoredScalar<T> declare(std::string name, const T& defaultValue = {}); - - /** - * Monitoring of scalars - * - * This class is not supposed to be used by the end user. - */ - template<class T> - class MonitoredScalar : public IMonitoredVariable { - public: - static_assert(std::is_convertible<T,double>::value,"Value must be convertable to double"); + template <class T> + class Scalar : public IMonitoredVariable { + public: + static_assert(std::is_convertible<T, double>::value, "Value must be convertable to double"); - /// @brief . \if empty doc string required due to doxygen bug 787131 \endif - friend MonitoredScalar<T> declare<T>(std::string name, const T& defaultValue); - - MonitoredScalar(MonitoredScalar&&) = default; - - T operator=(T value) { m_value = value; return value; } - - operator T() const { return m_value; } - operator T&() { return m_value; } + Scalar(std::string name, const T& defaultValue = {}) + : IMonitoredVariable(std::move(name)), m_value(defaultValue) {} + Scalar(Scalar&&) = default; + Scalar(Scalar const&) = delete; - // Needed to work around an apparent bug in clang 4.0.1. - // Without these declarations, clang rejects `--SCALAR' - // (but ++SCALAR, SCALAR++, and SCALAR-- are all accepted!). - T operator--() { return --m_value; } - T operator--(int) { return m_value--; } - - const std::vector<double> getVectorRepresentation() const override { return { double(m_value) }; } - private: - T m_value; - - MonitoredScalar(std::string name, const T& defaultValue = {}) - : IMonitoredVariable(std::move(name)), m_value(defaultValue) { } - MonitoredScalar(MonitoredScalar const&) = delete; - MonitoredScalar& operator=(MonitoredScalar const& ) = delete; - }; - - /** - * Declare a monitored scalar - * - * Monitoring for any double-convertable scalar - * - * @param name Name of monitored quantity - * @param defaultValue default value assigned to the monitored scalar - * - * \code - * auto phi = MonitoredScalar::declare("phi", 4.2); // deduced double - * auto eta = MonitoredScalar::declare<float>("eta", 0); // explicit float - * \endcode - */ - template<class T> - MonitoredScalar<T> declare(std::string name, const T& defaultValue) { - return MonitoredScalar<T>(std::move(name), defaultValue); - } + Scalar& operator=(Scalar const&) = delete; + T operator=(T value) { + m_value = value; + return value; + } + + operator T() const { return m_value; } + operator T&() { return m_value; } + + // Needed to work around an apparent bug in clang 4.0.1. + // Without these declarations, clang rejects `--SCALAR' + // (but ++SCALAR, SCALAR++, and SCALAR-- are all accepted!). + T operator--() { return --m_value; } + T operator--(int) { return m_value--; } + + const std::vector<double> getVectorRepresentation() const override { + return {double(m_value)}; + } + + private: + T m_value; + }; + } // namespace impl + + // TEMPORARY: for backwards compatibility + namespace MonitoredScalar { + template <typename T> + static impl::Scalar<T> declare(std::string name, const T& defaultValue = {}) { + return impl::Scalar<T>(name, defaultValue); } -} + } // namespace MonitoredTimer + +#if __cplusplus >= 201700 + using impl::Scalar; +#else + template <typename T> + static impl::Scalar<T> Scalar(std::string name, const T& defaultValue = {}) { + return impl::Scalar<T>(name, defaultValue); + } +#endif + +} // namespace Monitored #endif /* AthenaMonitoring_MonitoredScalar_h */ diff --git a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScope.h b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScope.h index 80b82b17ccbbf3e957f4c68dacbc8abcb450e883..79b028c64cdaa8ad093487e87ef33b14eef1bde2 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScope.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredScope.h @@ -5,95 +5,8 @@ #ifndef AthenaMonitoring_MonitoredScope_h #define AthenaMonitoring_MonitoredScope_h -#include <functional> -#include <vector> -#include <string> +//#warning "This is an obsolete header. Use MonitoredGroup.h instead" +#include "AthenaMonitoring/MonitoredGroup.h" +#include "AthenaMonitoring/Monitored.h" // TEMPORARY: for backwards compatibility -#include "GaudiKernel/ToolHandle.h" -#include "AthenaMonitoring/IMonitoredVariable.h" -#include "AthenaMonitoring/GenericMonitoringTool.h" -#include "AthenaMonitoring/HistogramFiller.h" - -namespace Monitored { - /** - * @brief Group local monitoring quantities and retain correlation when filling histograms - * - * In order to maintain correlations when filling histograms (e.g. eta and phi of a track) the - * monitored quantities need to be grouped within a MonitoredScope. The filling of the histogram - * occurs when the MonitoredScope object goes out of scope or when save() is called explicitly. - * - * \code - * { - * auto phi = MonitoredScalar::declare("phi"); - * auto eta = MonitoredScalar::declare("eta"); - * auto mon = MonitoredScope::declare(m_monTool, phi, eta); - * } - * \endcode - **/ - class MonitoredScope { - public: - - /** - * @brief Named constructor - * @param tool a handle to a monitoring tool, if invalid nothing is done - * @param scopeMonitored list of variables to be monitored - **/ - template <typename... T> - static MonitoredScope declare(const ToolHandle<GenericMonitoringTool>& tool, - T&&... scopeMonitored) { - return MonitoredScope(tool, {std::forward<T>(scopeMonitored)...}); - } - - virtual ~MonitoredScope() { - if (m_autoSave) { - save(); - } - - for (auto filler : m_histogramsFillers) { - delete filler; - } - } - - /** - * @brief explicitely fill the monitoring output - **/ - virtual void save() { - for (auto filler : m_histogramsFillers) { - filler->fill(); - } - } - /** - * @brief enables/disables filling when MonitoredScope leaves the scope - * - * Tpically one time fill, this should be left enabled (true) - * while in tight loops this should disabled "setAutoSave(false)" - * and explicit call save() used with the same scope object. - **/ - void setAutoSave(bool isEnabled) { - m_autoSave = isEnabled; - } - protected: - ToolHandle<GenericMonitoringTool> m_tool; - bool m_autoSave; - const std::vector<std::reference_wrapper<IMonitoredVariable>> m_scopeMonitored; - const std::vector<HistogramFiller*> m_histogramsFillers; - - MonitoredScope(const ToolHandle<GenericMonitoringTool>& tool, - std::initializer_list<std::reference_wrapper<IMonitoredVariable>> scopeMonitored) - : m_tool(tool), - m_autoSave(true), - m_scopeMonitored(scopeMonitored), - m_histogramsFillers(!m_tool.empty() ? m_tool->getHistogramsFillers(m_scopeMonitored) : std::vector<HistogramFiller*>()) { } - }; - - template <typename... T> - void save( const ToolHandle<GenericMonitoringTool>& tool, T&&... variables ) { - if ( ! tool.empty() ) { - for( auto filler: tool->getHistogramsFillers( {std::forward<T>(variables)...} ) ) { - filler->fill(); - } - } - } -} - -#endif /* AthenaMonitoring_MonitoredScope_h */ +#endif diff --git a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredTimer.h b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredTimer.h index ec965cc72abd07ed4702e39e7448de9ad67c345a..3df81e061188737d64b23fcae266e6506229a15a 100644 --- a/Control/AthenaMonitoring/AthenaMonitoring/MonitoredTimer.h +++ b/Control/AthenaMonitoring/AthenaMonitoring/MonitoredTimer.h @@ -1,70 +1,55 @@ /* - 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 AthenaMonitoring_MonitoredTimer_h #define AthenaMonitoring_MonitoredTimer_h -#include <vector> #include <chrono> +#include <vector> #include "AthenaMonitoring/IMonitoredVariable.h" namespace Monitored { /** - * Monitoring for timers - */ + * Monitored Timer + * + * The time is measured either between explicit stop/start calls or between the creation + * and the time the value is read by the monitoring tool. + * + * The timer name needs to start with the string "TIME_". + * \code + * auto t1 = Monitored::Timer("TIME_t1"); + * \endcode + **/ + class Timer : public IMonitoredVariable { + public: + Timer(std::string name); + Timer(Timer&&) = default; + Timer(Timer const&) = delete; + + void start(); //<! (re)starts the timer + void stop() const; //<! stops the timer + + operator double() const; //!< duration between start and stop in microseconds + + const std::vector<double> getVectorRepresentation() const override { return {double(*this)}; } + + private: + static constexpr const char* TIMER_PREFIX = "TIME_"; //<! prefix required for all timers + + typedef std::chrono::high_resolution_clock clock_type; + clock_type::time_point m_startTime; + mutable clock_type::time_point m_stopTime; + + Timer& operator=(Timer const&) = delete; + }; + + // TEMPORARY: for backwards compatibility namespace MonitoredTimer { - - class MonitoredTimer; - - /** - * Declare a monitored timer - * - * The timer name needs to start with "TIME_" - * - * \code - * auto t1 = MonitoredTimer::declare("TIME_t1"); - * \endcode - **/ - MonitoredTimer declare(std::string name); - - /** - * Monitored Timer - * - * The time is measured either between explicit stop/start calls or between the creation - * and the time the value is read by the monitoring tool. - * The timer name needs to start with the string "TIME_". - **/ - class MonitoredTimer : public IMonitoredVariable { - public: - - friend MonitoredTimer declare(std::string name) { - return MonitoredTimer(std::move(name)); - } - - MonitoredTimer(MonitoredTimer&&) = default; - - void start(); //<! (re)starts the timer - void stop() const; //<! stops the timer - - operator double() const; //!< duration between start and stop in microseconds - - const std::vector<double> getVectorRepresentation() const override { return { double(*this) }; } - - private: - static constexpr const char* TIMER_PREFIX = "TIME_"; //<! prefix required for all timers - - typedef std::chrono::high_resolution_clock clock_type; - clock_type::time_point m_startTime; - mutable clock_type::time_point m_stopTime; - - MonitoredTimer(std::string name); - MonitoredTimer(MonitoredTimer const&) = delete; - MonitoredTimer& operator=(MonitoredTimer const&) = delete; - }; + Timer declare(std::string name); } -} +} // namespace Monitored #endif /* AthenaMonitoring_MonitoredTimer_h */ diff --git a/Control/AthenaMonitoring/doc/Monitored_page.h b/Control/AthenaMonitoring/doc/Monitored_page.h index e006ceb42e816ca1f2b8cf5b49740d13930e0522..d72db19fca17076dbcaada44707f6dd3081f989f 100644 --- a/Control/AthenaMonitoring/doc/Monitored_page.h +++ b/Control/AthenaMonitoring/doc/Monitored_page.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @namespace Monitored @brief athenaMT monitoring infrastructure - + + ## General use ## The Monitored namespace collects the infrastructure to create histograms from quantitities within an athena component. While this infrastrcucture has been created specifically for the use in athenaMT it is of course also usable in @@ -33,24 +34,19 @@ 3) Declare the monitored quantities to the monitoring framework. Several classes are available to export different types to the monitoring framwork: - - Monitored::MonitoredScalar - - Monitored::MonitoredCollection - - Monitored::MonitoredTimer + - Monitored::Scalar + - Monitored::Collection + - Monitored::Timer - The declaration in all cases is done via the `declare` method in the relevant namespace. For example to declare a simple scalar, use: \code - Monitored::MonitoredScalar::declare(std::string name, const T& defaultVaule): + Monitored::Scalar(std::string name, const T& defaultVaule): \endcode - @copydetails Monitored::MonitoredScalar::declare(std::string name, const T& defaultVaule) + @copydetails Monitored::Scalar(std::string name, const T& defaultVaule) - All above functions are within the Monitored namespace. Consider adding - \code using namespace Monitored;\endcode - to your function (but avoid doing this at global scope). - 4) - @copydoc Monitored::MonitoredScope + @copydoc Monitored::impl::Group 5) Configure the list of histograms in python \code @@ -68,8 +64,17 @@ \remark Without this python configuration, i.e. the last line, no monitoring tool is instantiated and no monitoring histograms created thus reducing the overhead (both time and memory) to a minimum. - - Additional documentation: + + ## Advanced usage ## + ### Filling in tight loops ### + @copydetails Monitored::impl::Group::setAutoFill() + + ### Monitoring of collections (of objects) ### + Existing iterable collections can be monitored directly without the need to create temporaries. + If the collection contains objects, an accessor can be defined to retrieve the relevant quantity. + See the examples in Monitored::Collection. + + ## Additional documentation ## - The MonitoredAlg standalone example and its MonitoredOptions.py job options - <a href="https://gitlab.cern.ch/atlas/athena/blob/master/Control/AthenaMonitoring/test/GenericMonFilling_test.cxx">GenericMonFilling_test.cxx</a> diff --git a/Control/AthenaMonitoring/src/MonitoredTimer.cxx b/Control/AthenaMonitoring/src/MonitoredTimer.cxx index 8b9631af62ee2d8daa8ebc5bc725a90f8179df44..66cde068757ed37f8a99b1bac765f2b0bc514dc5 100644 --- a/Control/AthenaMonitoring/src/MonitoredTimer.cxx +++ b/Control/AthenaMonitoring/src/MonitoredTimer.cxx @@ -1,40 +1,37 @@ /* - 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 <ratio> #include <boost/algorithm/string/predicate.hpp> +#include <ratio> #include "AthenaMonitoring/MonitoredTimer.h" #include <iostream> namespace Monitored { - namespace MonitoredTimer{ - constexpr const char* MonitoredTimer::TIMER_PREFIX; + constexpr const char* Timer::TIMER_PREFIX; - MonitoredTimer::MonitoredTimer(std::string name) - : IMonitoredVariable(std::move(name)) { - // Enforce some naming convention for timers - if (!boost::algorithm::starts_with(m_name, TIMER_PREFIX)) { - throw std::runtime_error("Name of MonitoredTimer \""+m_name+"\" needs to start with \""+TIMER_PREFIX+"\""); - } - start(); - } - - void MonitoredTimer::start() { - m_startTime = clock_type::now(); - } + Timer MonitoredTimer::declare(std::string name) { return Monitored::Timer(name); } - void MonitoredTimer::stop() const { - m_stopTime = clock_type::now(); + Timer::Timer(std::string name) : IMonitoredVariable(std::move(name)) { + // Enforce some naming convention for timers + if (!boost::algorithm::starts_with(m_name, TIMER_PREFIX)) { + throw std::runtime_error("Name of Timer \"" + m_name + "\" needs to start with \"" + + TIMER_PREFIX + "\""); } + start(); + } - MonitoredTimer::operator double() const { - if ( m_stopTime == clock_type::time_point() ) // never stoppped - stop(); - auto d = std::chrono::duration_cast<std::chrono::microseconds>(m_stopTime - m_startTime); - return d.count(); - } + void Timer::start() { m_startTime = clock_type::now(); } + + void Timer::stop() const { m_stopTime = clock_type::now(); } + + Timer::operator double() const { + if (m_stopTime == clock_type::time_point()) // never stoppped + stop(); + auto d = std::chrono::duration_cast<std::chrono::microseconds>(m_stopTime - m_startTime); + return d.count(); } -} + +} // namespace Monitored diff --git a/Control/AthenaMonitoring/test/GenericMonFilling_test.cxx b/Control/AthenaMonitoring/test/GenericMonFilling_test.cxx index 34cc70dc60917a108895949daf3aa89c208772a6..d2c4adfd6f1303d3e446cb309571f3d747b0ceb6 100644 --- a/Control/AthenaMonitoring/test/GenericMonFilling_test.cxx +++ b/Control/AthenaMonitoring/test/GenericMonFilling_test.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 <iostream> @@ -14,14 +14,9 @@ #include "AthenaKernel/getMessageSvc.h" #include "CxxUtils/ubsan_suppress.h" - #include "AthenaMonitoring/GenericMonitoringTool.h" -#include "AthenaMonitoring/MonitoredScope.h" -#include "AthenaMonitoring/MonitoredScalar.h" -#include "AthenaMonitoring/MonitoredTimer.h" - +#include "AthenaMonitoring/Monitored.h" -using namespace Monitored; TH1* getHist( ITHistSvc* histSvc, const std::string& histName ) { TH1* h( nullptr ); @@ -67,8 +62,8 @@ double contentInBin2DHist( ITHistSvc* histSvc, const std::string& histName, int bool noToolBehaviourCorrect( ToolHandle<GenericMonitoringTool>& monTool ) { - auto x = MonitoredScalar::declare( "x", -99.0 ); - auto monitorIt = MonitoredScope::declare( monTool, x ); + auto x = Monitored::Scalar( "x", -99.0 ); + auto monitorIt = Monitored::Group( monTool, x ); return true; } @@ -76,9 +71,9 @@ bool noToolBehaviourCorrect( ToolHandle<GenericMonitoringTool>& monTool ) { bool fillFromScalarWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc ) { resetHists( histSvc ); { - auto roiPhi = MonitoredScalar::declare( "Phi", -99.0 ); //deduced double - auto roiEta = MonitoredScalar::declare<double>( "Eta", -99 ); //explicit double - auto monitorIt = MonitoredScope::declare( monTool, roiPhi, roiEta ); + auto roiPhi = Monitored::Scalar( "Phi", -99.0 ); //deduced double + auto roiEta = Monitored::Scalar<double>( "Eta", -99 ); //explicit double + auto monitorIt = Monitored::Group( monTool, roiPhi, roiEta ); roiPhi = 0.1; roiEta = -0.2; } @@ -94,11 +89,11 @@ bool fillFromScalarWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc bool fillFromScalarIndependentScopesWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc ) { resetHists( histSvc ); - auto roiPhi = MonitoredScalar::declare( "Phi", -99.0 ); - auto roiEta = MonitoredScalar::declare<double>( "Eta", -99 ); + auto roiPhi = Monitored::Scalar( "Phi", -99.0 ); + auto roiEta = Monitored::Scalar<double>( "Eta", -99 ); for ( size_t i =0; i < 3; ++i ) { - auto monitorIt = MonitoredScope::declare( monTool, roiPhi ); + auto monitorIt = Monitored::Group( monTool, roiPhi ); roiPhi = 0.1; roiEta = -0.2; } @@ -110,7 +105,7 @@ bool fillFromScalarIndependentScopesWorked( ToolHandle<GenericMonitoringTool>& m VALUE( contentInBin1DHist( histSvc, "/EXPERT/TestGroup/Eta", 2 ) ) EXPECTED( 0 ); for ( size_t i =0; i < 10; ++i ) { - auto monitorIt = MonitoredScope::declare( monTool, roiEta ); + auto monitorIt = Monitored::Group( monTool, roiEta ); roiPhi = 0.1; roiEta = -0.2; } @@ -128,10 +123,10 @@ bool fill2DWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSv resetHists( histSvc ); - auto roiPhi = MonitoredScalar::declare( "Phi", -99.0 ); - auto roiEta = MonitoredScalar::declare( "Eta", -99.0 ); + auto roiPhi = Monitored::Scalar( "Phi", -99.0 ); + auto roiEta = Monitored::Scalar( "Eta", -99.0 ); { - auto monitorIt = MonitoredScope::declare( monTool, roiEta, roiPhi ); + auto monitorIt = Monitored::Group( monTool, roiEta, roiPhi ); roiEta = 0.2; roiPhi = -0.1; } @@ -148,7 +143,7 @@ bool fill2DWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSv resetHists( histSvc ); VALUE( getHist( histSvc, "/EXPERT/TestGroup/Eta_vs_Phi" )->GetEntries() ) EXPECTED( 0 ); { - auto monitorIt = MonitoredScope::declare( monTool, roiEta ); + auto monitorIt = Monitored::Group( monTool, roiEta ); roiEta = 0.2; roiPhi = -0.1; } @@ -156,7 +151,7 @@ bool fill2DWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSv VALUE( contentInBin1DHist( histSvc, "/EXPERT/TestGroup/Eta", 2 ) ) EXPECTED( 1 ); { - auto monitorIt = MonitoredScope::declare( monTool, roiPhi ); + auto monitorIt = Monitored::Group( monTool, roiPhi ); roiEta = 0.2; roiPhi = -0.1; } @@ -171,11 +166,11 @@ bool fill2DWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSv bool fillExplcitelyWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc ) { resetHists( histSvc ); - auto roiPhi = MonitoredScalar::declare( "Phi", -99.0 ); - auto roiEta = MonitoredScalar::declare( "Eta", -99.0 ); + auto roiPhi = Monitored::Scalar( "Phi", -99.0 ); + auto roiEta = Monitored::Scalar( "Eta", -99.0 ); { - auto monitorIt = MonitoredScope::declare( monTool, roiEta, roiPhi ); - monitorIt.setAutoSave( false ); + auto monitorIt = Monitored::Group( monTool, roiEta, roiPhi ); + monitorIt.setAutoFill( false ); roiEta = 0.2; roiPhi = -0.1; } @@ -183,10 +178,10 @@ bool fillExplcitelyWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc VALUE( getHist( histSvc, "/EXPERT/TestGroup/Eta" )->GetEntries() ) EXPECTED( 0 ); // auto filling was disabled so no entries VALUE( getHist( histSvc, "/EXPERT/TestGroup/Phi" )->GetEntries() ) EXPECTED( 0 ); // auto filling was disabled so no entries - auto monitorIt = MonitoredScope::declare( monTool, roiEta, roiPhi ); - monitorIt.setAutoSave( false ); + auto monitorIt = Monitored::Group( monTool, roiEta, roiPhi ); + monitorIt.setAutoFill( false ); for ( size_t i = 0; i < 3; ++i ) { - monitorIt.save(); + monitorIt.fill(); } VALUE( getHist( histSvc, "/EXPERT/TestGroup/Eta_vs_Phi" )->GetEntries() ) EXPECTED( 3 ); VALUE( getHist( histSvc, "/EXPERT/TestGroup/Eta" )->GetEntries() ) EXPECTED( 3 ); @@ -220,8 +215,8 @@ private: bool fillFromNonTrivialSourcesWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc ) { resetHists( histSvc ); { - auto eta = MonitoredScalar::declare( "Eta", Scalar( 0.2 ) ); //class object convertable to number - auto monitorIt = MonitoredScope::declare( monTool, eta ); + auto eta = Monitored::Scalar( "Eta", Scalar( 0.2 ) ); //class object convertable to number + auto monitorIt = Monitored::Group( monTool, eta ); } VALUE( contentInBin1DHist( histSvc, "/EXPERT/TestGroup/Eta", 2 ) ) EXPECTED( 1 ); @@ -229,9 +224,9 @@ bool fillFromNonTrivialSourcesWorked( ToolHandle<GenericMonitoringTool>& monTool { std::vector<float> eta( {0.2, 0.1} ); std::set<double> phi( {-1, 1} ) ; - auto vectorT = MonitoredCollection::declare( "Eta", eta ); - auto setT = MonitoredCollection::declare( "Phi", phi ); - auto monitorIt = MonitoredScope::declare( monTool, vectorT, setT ); + auto vectorT = Monitored::Collection( "Eta", eta ); + auto setT = Monitored::Collection( "Phi", phi ); + auto monitorIt = Monitored::Group( monTool, vectorT, setT ); } VALUE( contentInBin1DHist( histSvc, "/EXPERT/TestGroup/Eta", 2 ) ) EXPECTED( 2 ); @@ -240,9 +235,9 @@ bool fillFromNonTrivialSourcesWorked( ToolHandle<GenericMonitoringTool>& monTool std::array<double, 2> eta( {{0.1, 0.7}} ); double phi[2]={-2., -1.}; - auto arrayT = MonitoredCollection::declare( "Eta", eta ); - auto rawArrayT = MonitoredCollection::declare( "Phi", phi ); - auto monitorIt = MonitoredScope::declare( monTool, arrayT, rawArrayT ); + auto arrayT = Monitored::Collection( "Eta", eta ); + auto rawArrayT = Monitored::Collection( "Phi", phi ); + auto monitorIt = Monitored::Group( monTool, arrayT, rawArrayT ); } VALUE( contentInBin1DHist( histSvc, "/EXPERT/TestGroup/Eta", 2 ) ) EXPECTED( 2 ); @@ -250,10 +245,10 @@ bool fillFromNonTrivialSourcesWorked( ToolHandle<GenericMonitoringTool>& monTool { Track tracks[2]; - auto eta = MonitoredCollection::declare( "Eta", tracks, &Track::eta ); - auto phi = MonitoredCollection::declare( "Phi", tracks, []( const Track& t ) { return t.phi(); } ); + auto eta = Monitored::Collection( "Eta", tracks, &Track::eta ); + auto phi = Monitored::Collection( "Phi", tracks, []( const Track& t ) { return t.phi(); } ); - auto monitorIt = MonitoredScope::declare( monTool, eta, phi ); // this is binding to histograms + auto monitorIt = Monitored::Group( monTool, eta, phi ); // this is binding to histograms tracks[0] = Track( 0.1, 0.9 ); tracks[1] = Track( 1.3, 1. ); @@ -267,10 +262,10 @@ bool fillFromNonTrivialSourcesWorked( ToolHandle<GenericMonitoringTool>& monTool bool assignWorked() { - auto eta = MonitoredScalar::declare( "Eta", -3. ); + auto eta = Monitored::Scalar( "Eta", -3. ); eta = 0.6; VALUE ( double( eta ) ) EXPECTED ( 0.6 ); - auto etaBis = MonitoredScalar::declare( "EtaBis", 0. ); + auto etaBis = Monitored::Scalar( "EtaBis", 0. ); etaBis = 0.4; VALUE( double( etaBis ) ) EXPECTED( 0.4 ); etaBis = double( eta ); @@ -279,7 +274,7 @@ bool assignWorked() { } bool operatorsWorked() { - auto count = MonitoredScalar::declare<float>( "Count", 0 ); + auto count = Monitored::Scalar<float>( "Count", 0 ); VALUE( count==count ) EXPECTED (true); @@ -297,10 +292,10 @@ bool operatorsWorked() { bool timerFillingWorked( ToolHandle<GenericMonitoringTool>& monTool, ITHistSvc* histSvc ) { - auto t1 = MonitoredTimer::declare( "TIME_t1" ); - auto t2 = MonitoredTimer::declare( "TIME_t2" ); + auto t1 = Monitored::Timer( "TIME_t1" ); + auto t2 = Monitored::Timer( "TIME_t2" ); { - auto monitorIt = MonitoredScope::declare( monTool, t1, t2 ); // this is binding to histograms + auto monitorIt = Monitored::Group( monTool, t1, t2 ); // this is binding to histograms t1.start(); t1.stop(); diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoTool.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoTool.cxx index cbf19b41912b8647521043a1edd463d0f994b5fe..d5670dfd513a21caea93d0b3f6b91a79f9ed138f 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoTool.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoTool.cxx @@ -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 */ // ************************************************ @@ -62,8 +62,8 @@ bool TrigBjetHypoTool::decide( const xAOD::BTagging* bTag, const TrigRoiDescrip ATH_MSG_DEBUG( "Executing TrigBjetHypoTool" ); // initialise monitoring variables - Monitored::MonitoredScalar::MonitoredScalar< int > PassedCuts = Monitored::MonitoredScalar::declare<int>( "CutCounter", -1 ); - Monitored::MonitoredScope monitorIt = Monitored::MonitoredScope::declare( m_monTool, PassedCuts ); + auto PassedCuts = Monitored::MonitoredScalar::declare<int>( "CutCounter", -1 ); + auto monitorIt = Monitored::MonitoredScope::declare( m_monTool, PassedCuts ); // when leaving scope it will ship data to monTool PassedCuts = PassedCuts + 1; //got called (data in place)