ATLAS Offline Software
SGAudSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // SGAudSvc.h
6 // Header file for class SGAudSvc
7 // Author: Ilija Vukotic <ivukotic@cern.ch>
9 #ifndef SGCOMPS_SGAUDSVC_H
10 #define SGCOMPS_SGAUDSVC_H
11 
12 // STL includes
13 #include <string>
14 #include <iosfwd>
15 #include <map>
16 #include <set>
17 #include <fstream>
18 
19 // FrameWork includes
21 #include "GaudiKernel/ServiceHandle.h"
22 #include "GaudiKernel/IIncidentListener.h"
23 #include "GaudiKernel/IClassIDSvc.h"
24 
25 #include "AthenaKernel/ISGAudSvc.h"
26 
27 // Forward declaration
28 class ISvcLocator;
29 class IChronoStatSvc;
30 class IAlgContextSvc;
31 class AlgContextSvc;
32 
33 
42 class SGAudSvc : public extends<AthService,
43  ISGAudSvc, IIncidentListener>
44 {
45 public:
46 
48  SGAudSvc( const std::string& name, ISvcLocator* pSvcLocator );
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 
100  Gaudi::Property<std::string> m_outFileName{this, "OutFileName", "SGAudSvc.out",
101  "Name of the output file to hold SGAudSvc data"};
102 
103  Gaudi::Property<std::string> m_allFileName{ "FullFileName", "",
104  "Name of the output file to hold the full SG aud data"};
105 
106  Gaudi::Property<std::string> m_sumFileName{this, "SummaryFileName", "",
107  "Name of the output file to hold the summary output in json format"};
108 
109  Gaudi::Property<bool> m_ignoreFakeAlgs{this, "IgnoreFakeAlgs", false,
110  "Set to ignore any attempts to override current-alg"};
111 
112  Gaudi::Property<int> m_startEvent{this, "StartEvent", 3,
113  "Event number to start recording data"};
114 
115  Gaudi::Property<bool> m_useCLID{this, "UseCLID", true,
116  "Use CLID or DataObj name in Summary File"};
117 
121 
123  std::vector<std::string> m_vObj;
125  std::vector<std::string> m_vAlg;
127  std::map<int,int> m_timesRead;
129  std::map<int,int> m_timesWritten;
130  std::string m_currAlg;
131  std::string m_currObj;
132  std::string m_fakeCurrAlg;
133  int m_nCurrAlg{0};
134  int m_nCurrObj{0};
135  int m_nEvents{0};
136 
137  // map<"alg_name", set<"cid/key"> >
138  typedef std::map<std::string, std::set<std::string> > DataMap;
141 
142  std::ofstream m_ofa, m_ofs;
143  bool m_inExec{false};
144 };
145 
146 #endif
SGAudSvc::addWrite
void addWrite()
Definition: SGAudSvc.cxx:371
SGAudSvc::SGGetCurrentAlg
bool SGGetCurrentAlg()
Gets name of curently running algorithm from AlgContextSvc.
Definition: SGAudSvc.cxx:301
SGAudSvc::m_pCID
ServiceHandle< IClassIDSvc > m_pCID
Definition: SGAudSvc.h:120
SGAudSvc::m_timesWritten
std::map< int, int > m_timesWritten
map counting Writes of each object by each algorithm.
Definition: SGAudSvc.h:129
SGAudSvc::monitor
void monitor()
just counts events. called at EndEvent incident
Definition: SGAudSvc.cxx:173
SGAudSvc::SGAudRECORD
void SGAudRECORD(std::string SGobject)
Definition: SGAudSvc.cxx:205
SGAudSvc::clearFakeCurrentAlg
virtual void clearFakeCurrentAlg() override
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:391
SGAudSvc::m_ofa
std::ofstream m_ofa
Definition: SGAudSvc.h:142
SGAudSvc::m_allFileName
Gaudi::Property< std::string > m_allFileName
Definition: SGAudSvc.h:103
SGAudSvc::getNobj
void getNobj(const std::string &name)
Definition: SGAudSvc.cxx:336
SGAudSvc::m_startEvent
Gaudi::Property< int > m_startEvent
Definition: SGAudSvc.h:112
SGAudSvc::SGAudSvc
SGAudSvc()
Default constructor:
SGAudSvc::m_useCLID
Gaudi::Property< bool > m_useCLID
Definition: SGAudSvc.h:115
SGAudSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition: SGAudSvc.cxx:52
SGAudSvc::m_nCurrObj
int m_nCurrObj
Definition: SGAudSvc.h:134
SGAudSvc::writeJSON
void writeJSON()
Definition: SGAudSvc.cxx:396
SGAudSvc::finalize
virtual StatusCode finalize() override
Definition: SGAudSvc.cxx:81
SGAudSvc::handle
virtual void handle(const Incident &incident) override
incident service handle for EndEvent.
Definition: SGAudSvc.cxx:136
SGAudSvc::m_inExec
bool m_inExec
Definition: SGAudSvc.h:143
SGAudSvc::m_write
DataMap m_write
Definition: SGAudSvc.h:140
SGAudSvc::setFakeCurrentAlg
virtual void setFakeCurrentAlg(const std::string &) override
For implementing custom increased granularity auditing of for instance tools.
Definition: SGAudSvc.cxx:386
SGAudSvc::DataMap
std::map< std::string, std::set< std::string > > DataMap
Definition: SGAudSvc.h:138
SGAudSvc::m_currObj
std::string m_currObj
Definition: SGAudSvc.h:131
SGAudSvc::m_timesRead
std::map< int, int > m_timesRead
map counting Reads of each object by each algorithm.
Definition: SGAudSvc.h:127
SGAudSvc::m_currAlg
std::string m_currAlg
Definition: SGAudSvc.h:130
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SGAudSvc::m_outFileName
Gaudi::Property< std::string > m_outFileName
Definition: SGAudSvc.h:100
SGAudSvc::SGAudit
virtual void SGAudit(const std::string &key, const CLID &id, const int &fnc, const int &store_id) override
Definition: SGAudSvc.cxx:226
SGAudSvc::SGAudRETRIEVE
void SGAudRETRIEVE(std::string SGobject)
Definition: SGAudSvc.cxx:181
SGAudSvc::m_vAlg
std::vector< std::string > m_vAlg
Vector of names of algorithms accessing SG.
Definition: SGAudSvc.h:125
SGAudSvc::addRead
void addRead()
Definition: SGAudSvc.cxx:356
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:240
SGAudSvc::m_ignoreFakeAlgs
Gaudi::Property< bool > m_ignoreFakeAlgs
Definition: SGAudSvc.h:109
SGAudSvc::m_sumFileName
Gaudi::Property< std::string > m_sumFileName
Definition: SGAudSvc.h:106
SGAudSvc::m_ofs
std::ofstream m_ofs
Definition: SGAudSvc.h:142
SGAudSvc::p_algCtxSvc
ServiceHandle< IAlgContextSvc > p_algCtxSvc
Pointer to the AlgContextScv.
Definition: SGAudSvc.h:119
ISGAudSvc.h
SGAudSvc
This service gives a graphical representation of algorithms accessing StoreGate.
Definition: SGAudSvc.h:44
AthService.h
SGAudSvc::m_vObj
std::vector< std::string > m_vObj
Vector of accessed SG objects names.
Definition: SGAudSvc.h:123
SGAudSvc::m_nCurrAlg
int m_nCurrAlg
Definition: SGAudSvc.h:133
SGAudSvc::m_fakeCurrAlg
std::string m_fakeCurrAlg
Definition: SGAudSvc.h:132
SGAudSvc::m_read
DataMap m_read
Definition: SGAudSvc.h:139
SGAudSvc::m_nEvents
int m_nEvents
Definition: SGAudSvc.h:135
ServiceHandle< IAlgContextSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37