ATLAS Offline Software
SGAudSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 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 template <class TYPE> class SvcFactory;
36 class IChronoStatSvc;
37 class IAlgContextSvc;
38 class AlgContextSvc;
39 
40 class SGAudSvc : virtual public ISGAudSvc,
41  virtual public IIncidentListener,
42  public AthService
43 {
44 
45 protected:
46 
47  friend class SvcFactory<SGAudSvc>;
48 
49 
50 public:
51 
53  SGAudSvc( const std::string& name, ISvcLocator* pSvcLocator );
54 
56  virtual ~SGAudSvc();
57 
59 
62  virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
64 
65  static const InterfaceID& interfaceID();
66 
67 
70  void handle( const Incident& incident );
71 
72  // do the auditing, called from DataStore.cxx
73  virtual void SGAudit(const std::string& key, const CLID& id,
74  const int& fnc, const int& store_id);
75 
76 
80  bool SGGetCurrentAlg();
84  void setFakeCurrentAlg(const std::string&);
88  void clearFakeCurrentAlg();
89 
90  private:
91 
94 
95  void SGAudRETRIEVE(std::string SGobject);
96  void SGAudRECORD(std::string SGobject);
97 
98  void getNobj(std::string name);
99  void addRead();
100  void addWrite();
101 
103  void monitor();
104 
105  void writeJSON();
106 
108  // Private data:
110  private:
111 
113  MsgStream m_msg;
114 
116  IAlgContextSvc *p_algCtxSvc;
117  IClassIDSvc* m_pCID;
118 
121 
124 
126  bool m_useCLID;
127 
129  std::vector<std::string> m_vObj;
131  std::vector<std::string> m_vAlg;
133  std::map<int,int> m_timesRead;
135  std::map<int,int> m_timesWritten;
136  std::string m_currAlg;
137  std::string m_currObj;
138  std::string m_fakeCurrAlg;
143 
144  // map<"alg_name", set<"cid/key"> >
145  typedef std::map<std::string, std::set<std::string> > DataMap;
148 
149  std::ofstream m_ofa, m_ofs;
150  bool m_inExec;
151 };
152 
153 
157 
158 inline const InterfaceID& SGAudSvc::interfaceID()
159 {
160  return ISGAudSvc::interfaceID();
161 }
162 
163 #endif
SGAudSvc::addWrite
void addWrite()
Definition: SGAudSvc.cxx:462
SGAudSvc::SGGetCurrentAlg
bool SGGetCurrentAlg()
Gets name of curently running algorithm from AlgContextSvc.
Definition: SGAudSvc.cxx:392
SGAudSvc::initialize
StatusCode initialize()
Gaudi Service Implementation.
Definition: SGAudSvc.cxx:82
SGAudSvc::interfaceID
static const InterfaceID & interfaceID()
Inline methods:
Definition: SGAudSvc.h:158
SGAudSvc::m_timesWritten
std::map< int, int > m_timesWritten
map counting Writes of each object by each algorithm.
Definition: SGAudSvc.h:135
SGAudSvc::m_sumFileName
std::string m_sumFileName
Definition: SGAudSvc.h:120
SGAudSvc::monitor
void monitor()
just counts events. called at EndEvent incident
Definition: SGAudSvc.cxx:264
SGAudSvc::SGAudRECORD
void SGAudRECORD(std::string SGobject)
Definition: SGAudSvc.cxx:296
SGAudSvc::m_ofa
std::ofstream m_ofa
Definition: SGAudSvc.h:149
SvcFactory
Definition: AthCnvSvc.h:28
SGAudSvc::SGAudSvc
SGAudSvc()
Default constructor:
SGAudSvc::getNobj
void getNobj(std::string name)
Definition: SGAudSvc.cxx:427
SGAudSvc::m_useCLID
bool m_useCLID
Whether to use CLID or Data Obj Name in JSON output file.
Definition: SGAudSvc.h:126
SGAudSvc::m_nCurrObj
int m_nCurrObj
Definition: SGAudSvc.h:140
SGAudSvc::writeJSON
void writeJSON()
Definition: SGAudSvc.cxx:487
SGAudSvc::m_inExec
bool m_inExec
Definition: SGAudSvc.h:150
SGAudSvc::m_write
DataMap m_write
Definition: SGAudSvc.h:147
SGAudSvc::m_ignoreFakeAlgs
bool m_ignoreFakeAlgs
Whether to ignore fake current algs.
Definition: SGAudSvc.h:123
SGAudSvc::DataMap
std::map< std::string, std::set< std::string > > DataMap
Definition: SGAudSvc.h:145
SGAudSvc::m_currObj
std::string m_currObj
Definition: SGAudSvc.h:137
SGAudSvc::m_timesRead
std::map< int, int > m_timesRead
map counting Reads of each object by each algorithm.
Definition: SGAudSvc.h:133
SGAudSvc::m_currAlg
std::string m_currAlg
Definition: SGAudSvc.h:136
SGAudSvc::m_outFileName
std::string m_outFileName
Name of the output file.
Definition: SGAudSvc.h:120
ISGAudSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: ISGAudSvc.h:57
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
SGAudSvc::m_startEvent
int m_startEvent
Definition: SGAudSvc.h:142
SGAudSvc::clearFakeCurrentAlg
void clearFakeCurrentAlg()
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:482
SGAudSvc::finalize
StatusCode finalize()
Definition: SGAudSvc.cxx:132
SGAudSvc::setFakeCurrentAlg
void setFakeCurrentAlg(const std::string &)
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:477
SGAudSvc::m_pCID
IClassIDSvc * m_pCID
Definition: SGAudSvc.h:117
SGAudSvc::SGAudRETRIEVE
void SGAudRETRIEVE(std::string SGobject)
Definition: SGAudSvc.cxx:272
SGAudSvc::m_vAlg
std::vector< std::string > m_vAlg
Vector of names of algorithms accessing SG.
Definition: SGAudSvc.h:131
SGAudSvc::addRead
void addRead()
Definition: SGAudSvc.cxx:447
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SGAudSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: SGAudSvc.cxx:190
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ISGAudSvc
Definition: ISGAudSvc.h:21
SGAudSvc::~SGAudSvc
virtual ~SGAudSvc()
Destructor:
Definition: SGAudSvc.cxx:72
SGAudSvc::m_allFileName
std::string m_allFileName
Definition: SGAudSvc.h:120
SGAudSvc::m_ofs
std::ofstream m_ofs
Definition: SGAudSvc.h:149
SGAudSvc::m_msg
MsgStream m_msg
MsgStream for talking with the outside world.
Definition: SGAudSvc.h:113
SGAudSvc::SGAudit
virtual void SGAudit(const std::string &key, const CLID &id, const int &fnc, const int &store_id)
Definition: SGAudSvc.cxx:317
SGAudSvc::p_algCtxSvc
IAlgContextSvc * p_algCtxSvc
Pointer to the AlgContextScv.
Definition: SGAudSvc.h:116
ISGAudSvc.h
SGAudSvc
Definition: SGAudSvc.h:43
AthService.h
SGAudSvc::m_vObj
std::vector< std::string > m_vObj
Vector of accessed SG objects names.
Definition: SGAudSvc.h:129
SGAudSvc::m_nCurrAlg
int m_nCurrAlg
Definition: SGAudSvc.h:139
SGAudSvc::m_fakeCurrAlg
std::string m_fakeCurrAlg
Definition: SGAudSvc.h:138
SGAudSvc::handle
void handle(const Incident &incident)
incident service handle for EndEvent.
Definition: SGAudSvc.cxx:213
SGAudSvc::m_read
DataMap m_read
Definition: SGAudSvc.h:146
SGAudSvc::m_nEvents
int m_nEvents
Definition: SGAudSvc.h:141
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37