Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:31:47

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 //====================================================================
0012 //  RootPerfMonSvc definition
0013 //--------------------------------------------------------------------
0014 //
0015 //  Author     : M.Frank
0016 //====================================================================
0017 #ifndef GAUDIROOTCNV_GAUDIROOTPERFMONSVC_H
0018 #define GAUDIROOTCNV_GAUDIROOTPERFMONSVC_H
0019 
0020 #include <memory>
0021 // Framework include files
0022 #include <GaudiKernel/IIncidentListener.h>
0023 #include <GaudiKernel/IIncidentSvc.h>
0024 #include <GaudiKernel/Service.h>
0025 
0026 #include <TFile.h>
0027 #include <TTree.h>
0028 
0029 #include <RootCnv/SysProcStat.h>
0030 
0031 // C/C++ include files
0032 #include <set>
0033 
0034 /*
0035  * Gaudi namespace declaration
0036  */
0037 namespace Gaudi {
0038 
0039   /** @class RootPerfMonSvc RootPerfMonSvc.h src/RootPerfMonSvc.h
0040    *
0041    * Description:
0042    *
0043    * RootPerfMonSvc class implementation definition.
0044    *
0045    *  @author  Markus Frank, Ivan Valencik
0046    *  @version 1.0
0047    *  @date    20/12/2009
0048    */
0049   class GAUDI_API RootPerfMonSvc : public extends<Service, IIncidentListener> {
0050   protected:
0051     Gaudi::Property<std::string> m_ioPerfStats{
0052         this, "IOPerfStats", "", "Enable TTree IOperfStats if not empty; otherwise perf stat file name" };
0053     // Passed parameters
0054     Gaudi::Property<std::string> m_setStreams{ this, "Streams", "", "" };
0055     Gaudi::Property<std::string> m_basketSize{ this, "BasketSize", "", "" };
0056     Gaudi::Property<std::string> m_bufferSize{ this, "BufferSize", "", "" };
0057     Gaudi::Property<std::string> m_splitLevel{ this, "SplitLevel", "", "" };
0058 
0059     /// Reference to incident service
0060     SmartIF<IIncidentSvc> m_incidentSvc;
0061     /// Message streamer
0062     std::unique_ptr<MsgStream> m_log;
0063     // Reference to a tree with statistics
0064     TTree* m_perfTree;
0065     // Reference to a file where statistics are persisted
0066     std::unique_ptr<TFile> m_perfFile;
0067     // Reference to all connected output files
0068     std::set<std::string> m_outputs;
0069     // The newest observed values
0070     Int_t   m_eventType;
0071     ULong_t m_utime, m_stime, m_vsize;
0072     Long_t  m_eventNumber, m_rss, m_time;
0073 
0074     // Types of records
0075     enum EventType { EVENT = 1, FSR = 2 };
0076 
0077     // Adding newest observed values to the tree with statistics
0078     virtual void record( EventType eventType );
0079 
0080     /// Helper: Use message streamer
0081     MsgStream& log() const { return *m_log; }
0082 
0083   public:
0084     /// Standard constructor
0085     using extends::extends;
0086 
0087     /** Standard way to print errors. after the printout an exception is thrown.
0088      * @param      msg      [IN]     Message string to be printed.
0089      *
0090      * @return     Status code returning failure.
0091      */
0092     StatusCode error( const std::string& msg );
0093 
0094     /// Service overload: initialize the service
0095     StatusCode initialize() override;
0096 
0097     /// Service overload: Finalize the service
0098     StatusCode finalize() override;
0099 
0100     /// IIncidentListener override: Inform that a new incident has occurred
0101     void handle( const Incident& incident ) override;
0102 
0103     // Service overload: Stop the service
0104     StatusCode stop() override;
0105   };
0106 } // namespace Gaudi
0107 
0108 #endif // GAUDIROOTCNV_GAUDIROOTPERFMONSVC_H