ATLAS Offline Software
SGAudSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // SGAudSvc.h
8 // Header file for class SGAudSvc
9 // Author: Ilija Vukotic <ivukotic@cern.ch>
11 #ifndef SGMONITORING_SGAUDSVC_H
12 #define SGMONITORING_SGAUDSVC_H
13 
14 // STL includes
15 #include <string>
16 #include <iosfwd>
17 #include <map>
18 #include <set>
19 #include <fstream>
20 
21 
22 // FrameWork includes
24 #include "GaudiKernel/ServiceHandle.h"
25 #include "GaudiKernel/ToolHandle.h"
26 #include "GaudiKernel/IIncidentListener.h"
27 #include "GaudiKernel/MsgStream.h"
28 #include "GaudiKernel/Algorithm.h"
29 #include "GaudiKernel/IClassIDSvc.h"
30 
31 #include "SGAudCore/ISGAudSvc.h"
32 
33 // Forward declaration
34 class ISvcLocator;
35 class IChronoStatSvc;
36 class IAlgContextSvc;
37 class AlgContextSvc;
38 
39 class SGAudSvc : public extends<AthService,
40  ISGAudSvc, IIncidentListener>
41 {
42 public:
43 
45  SGAudSvc( const std::string& name, ISvcLocator* pSvcLocator );
46 
48  virtual ~SGAudSvc();
49 
51 
52  virtual StatusCode initialize() override;
53  virtual StatusCode finalize() override;
55 
58  virtual void handle( const Incident& incident ) override;
59 
60  // do the auditing, called from DataStore.cxx
61  virtual void SGAudit(const std::string& key, const CLID& id,
62  const int& fnc, const int& store_id) override;
63 
64 
68  bool SGGetCurrentAlg();
72  virtual void setFakeCurrentAlg(const std::string&) override;
76  virtual void clearFakeCurrentAlg() override;
77 
78  private:
79 
82 
83  void SGAudRETRIEVE(std::string SGobject);
84  void SGAudRECORD(std::string SGobject);
85 
86  void getNobj(const std::string& name);
87  void addRead();
88  void addWrite();
89 
91  void monitor();
92 
93  void writeJSON();
94 
96  // Private data:
98  private:
99 
101  MsgStream m_msg;
102 
106 
109 
112 
114  bool m_useCLID;
115 
117  std::vector<std::string> m_vObj;
119  std::vector<std::string> m_vAlg;
121  std::map<int,int> m_timesRead;
123  std::map<int,int> m_timesWritten;
124  std::string m_currAlg;
125  std::string m_currObj;
126  std::string m_fakeCurrAlg;
131 
132  // map<"alg_name", set<"cid/key"> >
133  typedef std::map<std::string, std::set<std::string> > DataMap;
136 
137  std::ofstream m_ofa, m_ofs;
138  bool m_inExec;
139 };
140 
141 #endif
SGAudSvc::addWrite
void addWrite()
Definition: SGAudSvc.cxx:427
SGAudSvc::SGGetCurrentAlg
bool SGGetCurrentAlg()
Gets name of curently running algorithm from AlgContextSvc.
Definition: SGAudSvc.cxx:357
SGAudSvc::m_pCID
ServiceHandle< IClassIDSvc > m_pCID
Definition: SGAudSvc.h:105
SGAudSvc::m_timesWritten
std::map< int, int > m_timesWritten
map counting Writes of each object by each algorithm.
Definition: SGAudSvc.h:123
SGAudSvc::m_sumFileName
std::string m_sumFileName
Definition: SGAudSvc.h:108
SGAudSvc::monitor
void monitor()
just counts events. called at EndEvent incident
Definition: SGAudSvc.cxx:229
SGAudSvc::SGAudRECORD
void SGAudRECORD(std::string SGobject)
Definition: SGAudSvc.cxx:261
SGAudSvc::clearFakeCurrentAlg
virtual void clearFakeCurrentAlg() override
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:447
SGAudSvc::m_ofa
std::ofstream m_ofa
Definition: SGAudSvc.h:137
SGAudSvc::getNobj
void getNobj(const std::string &name)
Definition: SGAudSvc.cxx:392
SGAudSvc::SGAudSvc
SGAudSvc()
Default constructor:
SGAudSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition: SGAudSvc.cxx:84
SGAudSvc::m_useCLID
bool m_useCLID
Whether to use CLID or Data Obj Name in JSON output file.
Definition: SGAudSvc.h:114
SGAudSvc::m_nCurrObj
int m_nCurrObj
Definition: SGAudSvc.h:128
SGAudSvc::writeJSON
void writeJSON()
Definition: SGAudSvc.cxx:452
SGAudSvc::finalize
virtual StatusCode finalize() override
Definition: SGAudSvc.cxx:121
SGAudSvc::handle
virtual void handle(const Incident &incident) override
incident service handle for EndEvent.
Definition: SGAudSvc.cxx:178
SGAudSvc::m_inExec
bool m_inExec
Definition: SGAudSvc.h:138
SGAudSvc::m_write
DataMap m_write
Definition: SGAudSvc.h:135
SGAudSvc::m_ignoreFakeAlgs
bool m_ignoreFakeAlgs
Whether to ignore fake current algs.
Definition: SGAudSvc.h:111
SGAudSvc::setFakeCurrentAlg
virtual void setFakeCurrentAlg(const std::string &) override
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:442
SGAudSvc::DataMap
std::map< std::string, std::set< std::string > > DataMap
Definition: SGAudSvc.h:133
SGAudSvc::m_currObj
std::string m_currObj
Definition: SGAudSvc.h:125
SGAudSvc::m_timesRead
std::map< int, int > m_timesRead
map counting Reads of each object by each algorithm.
Definition: SGAudSvc.h:121
SGAudSvc::m_currAlg
std::string m_currAlg
Definition: SGAudSvc.h:124
SGAudSvc::m_outFileName
std::string m_outFileName
Name of the output file.
Definition: SGAudSvc.h:108
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SGAudSvc::m_startEvent
int m_startEvent
Definition: SGAudSvc.h:130
SGAudSvc::SGAudit
virtual void SGAudit(const std::string &key, const CLID &id, const int &fnc, const int &store_id) override
Definition: SGAudSvc.cxx:282
SGAudSvc::SGAudRETRIEVE
void SGAudRETRIEVE(std::string SGobject)
Definition: SGAudSvc.cxx:237
SGAudSvc::m_vAlg
std::vector< std::string > m_vAlg
Vector of names of algorithms accessing SG.
Definition: SGAudSvc.h:119
SGAudSvc::addRead
void addRead()
Definition: SGAudSvc.cxx:412
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SGAudSvc::~SGAudSvc
virtual ~SGAudSvc()
Destructor:
Definition: SGAudSvc.cxx:74
SGAudSvc::m_allFileName
std::string m_allFileName
Definition: SGAudSvc.h:108
SGAudSvc::m_ofs
std::ofstream m_ofs
Definition: SGAudSvc.h:137
SGAudSvc::m_msg
MsgStream m_msg
MsgStream for talking with the outside world.
Definition: SGAudSvc.h:101
SGAudSvc::p_algCtxSvc
ServiceHandle< IAlgContextSvc > p_algCtxSvc
Pointer to the AlgContextScv.
Definition: SGAudSvc.h:104
ISGAudSvc.h
SGAudSvc
Definition: SGAudSvc.h:41
AthService.h
SGAudSvc::m_vObj
std::vector< std::string > m_vObj
Vector of accessed SG objects names.
Definition: SGAudSvc.h:117
SGAudSvc::m_nCurrAlg
int m_nCurrAlg
Definition: SGAudSvc.h:127
SGAudSvc::m_fakeCurrAlg
std::string m_fakeCurrAlg
Definition: SGAudSvc.h:126
SGAudSvc::m_read
DataMap m_read
Definition: SGAudSvc.h:134
SGAudSvc::m_nEvents
int m_nEvents
Definition: SGAudSvc.h:129
ServiceHandle< IAlgContextSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37