CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edm::service::IgProfService Class Reference

#include <IgProfService.h>

Public Member Functions

 IgProfService (const ParameterSet &, ActivityRegistry &)
 
bool isProcessWideService (IgProfService const *)
 
void postBeginJob ()
 
void postBeginLumi (GlobalContext const &gc)
 
void postBeginRun (GlobalContext const &gc)
 
void postCloseFile (std::string const &, bool)
 
void postEndJob ()
 
void postEndLumi (GlobalContext const &gc)
 
void postEndRun (GlobalContext const &gc)
 
void postEvent (StreamContext const &sc)
 
void postOpenFile (std::string const &, bool)
 
void preEvent (StreamContext const &sc)
 

Private Member Functions

void makeDump (const std::string &format)
 

Static Private Member Functions

static std::string replace (const std::string &s, const char *pat, int val)
 
static std::string replaceU64 (const std::string &s, const char *pat, unsigned long long val)
 

Private Attributes

std::string atPostBeginJob_
 
std::string atPostBeginLumi_
 
std::string atPostBeginRun_
 
std::string atPostCloseFile_
 
std::string atPostEndJob_
 
std::string atPostEndLumi_
 
std::string atPostEndRun_
 
std::string atPostEvent_
 
std::string atPostOpenFile_
 
std::string atPreEvent_
 
void(* dump_ )(const char *)
 
int mineventrecord_
 
edm::EventNumber_t nevent_
 
int nfileclosed_
 
int nfileopened_
 
edm::LuminosityBlockNumber_t nlumi_
 
int nrecord_
 
edm::RunNumber_t nrun_
 
int prescale_
 

Detailed Description

Definition at line 20 of file IgProfService.h.

Constructor & Destructor Documentation

IgProfService::IgProfService ( const ParameterSet ps,
ActivityRegistry iRegistry 
)

Definition at line 25 of file IgProfService.cc.

References atPostBeginJob_, atPostBeginLumi_, atPostBeginRun_, atPostCloseFile_, atPostEndJob_, atPostEndLumi_, atPostEndRun_, atPostEvent_, atPostOpenFile_, atPreEvent_, dump_, edm::ParameterSet::getUntrackedParameter(), mineventrecord_, postBeginJob(), postBeginLumi(), postBeginRun(), postCloseFile(), postEndJob(), postEndLumi(), postEndRun(), postEvent(), postOpenFile(), preEvent(), prescale_, AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostCloseFile(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostGlobalBeginLumi(), edm::ActivityRegistry::watchPostGlobalBeginRun(), edm::ActivityRegistry::watchPostGlobalEndLumi(), edm::ActivityRegistry::watchPostGlobalEndRun(), edm::ActivityRegistry::watchPostOpenFile(), and edm::ActivityRegistry::watchPreEvent().

26  : dump_(nullptr),
27  mineventrecord_(1),
28  prescale_(1),
29  nrecord_(0),
30  nevent_(0),
31  nrun_(0),
32  nlumi_(0),
33  nfileopened_(0),
34  nfileclosed_(0) {
35  // Removing the __extension__ gives a warning which
36  // is acknowledged as a language problem in the C++ Standard Core
37  // Language Defect Report
38  //
39  // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195
40  //
41  // since the suggested decision seems to be that the syntax should
42  // actually be "Conditionally-Supported Behavior" in some
43  // future C++ standard I simply silence the warning.
44  if (void *sym = dlsym(nullptr, "igprof_dump_now")) {
45  dump_ = __extension__(void (*)(const char *)) sym;
46  } else
47  edm::LogWarning("IgProfModule") << "IgProfModule requested but application is not"
48  << " currently being profiled with igprof\n";
49 
50  // Get the configuration
51  prescale_ = ps.getUntrackedParameter<int>("reportEventInterval", prescale_);
52  mineventrecord_ = ps.getUntrackedParameter<int>("reportFirstEvent", mineventrecord_);
53 
54  atPostBeginJob_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginJob", atPostBeginJob_);
55  atPostBeginRun_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginRun", atPostBeginRun_);
56  atPostBeginLumi_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginLumi", atPostBeginLumi_);
57 
58  atPreEvent_ = ps.getUntrackedParameter<std::string>("reportToFileAtPreEvent", atPreEvent_);
59  atPostEvent_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostEvent", atPostEvent_);
60 
61  atPostEndLumi_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndLumi", atPostEndLumi_);
62  atPostEndRun_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndRun", atPostEndRun_);
63  atPostEndJob_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndJob", atPostEndJob_);
64 
65  atPostOpenFile_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostOpenFile", atPostOpenFile_);
66  atPostCloseFile_ = ps.getUntrackedParameter<std::string>("reportToFileAtPostCloseFile", atPostCloseFile_);
67 
68  // Register for the framework signals
69  iRegistry.watchPostBeginJob(this, &IgProfService::postBeginJob);
70  iRegistry.watchPostGlobalBeginRun(this, &IgProfService::postBeginRun);
71  iRegistry.watchPostGlobalBeginLumi(this, &IgProfService::postBeginLumi);
72 
73  iRegistry.watchPreEvent(this, &IgProfService::preEvent);
74  iRegistry.watchPostEvent(this, &IgProfService::postEvent);
75 
76  iRegistry.watchPostGlobalEndLumi(this, &IgProfService::postEndLumi);
77  iRegistry.watchPostGlobalEndRun(this, &IgProfService::postEndRun);
78  iRegistry.watchPostEndJob(this, &IgProfService::postEndJob);
79 
80  iRegistry.watchPostOpenFile(this, &IgProfService::postOpenFile);
81  iRegistry.watchPostCloseFile(this, &IgProfService::postCloseFile);
82 }
void postCloseFile(std::string const &, bool)
void postEndRun(GlobalContext const &gc)
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:71
void postEvent(StreamContext const &sc)
void postOpenFile(std::string const &, bool)
void(* dump_)(const char *)
Definition: IgProfService.h:50
void postBeginLumi(GlobalContext const &gc)
void postEndLumi(GlobalContext const &gc)
edm::EventNumber_t nevent_
Definition: IgProfService.h:69
void preEvent(StreamContext const &sc)
Log< level::Warning, false > LogWarning
void postBeginRun(GlobalContext const &gc)

Member Function Documentation

bool edm::service::IgProfService::isProcessWideService ( IgProfService const *  )
inline

Definition at line 43 of file IgProfService.h.

43 { return true; }
void IgProfService::makeDump ( const std::string &  format)
private

Definition at line 125 of file IgProfService.cc.

References dump_, diffTreeTool::format(), nevent_, nfileclosed_, nfileopened_, nlumi_, nrecord_, nrun_, replace(), replaceU64(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by postBeginJob(), postBeginLumi(), postBeginRun(), postCloseFile(), postEndJob(), postEndLumi(), postEndRun(), postEvent(), postOpenFile(), and preEvent().

125  {
126  if (!dump_ || format.empty())
127  return;
128 
129  std::string final(format);
130  final = replace(final, "%I", nrecord_);
131  final = replaceU64(final, "%E", nevent_);
132  final = replaceU64(final, "%R", nrun_);
133  final = replaceU64(final, "%L", nlumi_);
134  final = replace(final, "%F", nfileopened_);
135  final = replace(final, "%C", nfileclosed_);
136  dump_(final.c_str());
137 }
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:71
static std::string replaceU64(const std::string &s, const char *pat, unsigned long long val)
void(* dump_)(const char *)
Definition: IgProfService.h:50
edm::EventNumber_t nevent_
Definition: IgProfService.h:69
static std::string replace(const std::string &s, const char *pat, int val)
void IgProfService::postBeginJob ( )

Definition at line 84 of file IgProfService.cc.

References atPostBeginJob_, and makeDump().

Referenced by IgProfService().

void makeDump(const std::string &format)
void IgProfService::postBeginLumi ( GlobalContext const &  gc)

Definition at line 91 of file IgProfService.cc.

References atPostBeginLumi_, edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), makeDump(), and nlumi_.

Referenced by IgProfService().

91  {
92  nlumi_ = gc.luminosityBlockID().luminosityBlock();
94 }
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:71
void makeDump(const std::string &format)
void IgProfService::postBeginRun ( GlobalContext const &  gc)

Definition at line 86 of file IgProfService.cc.

References atPostBeginRun_, edm::GlobalContext::luminosityBlockID(), makeDump(), nrun_, and edm::LuminosityBlockID::run().

Referenced by IgProfService().

86  {
87  nrun_ = gc.luminosityBlockID().run();
89 }
void makeDump(const std::string &format)
void IgProfService::postCloseFile ( std::string const &  ,
bool   
)

Definition at line 120 of file IgProfService.cc.

References atPostCloseFile_, makeDump(), and nfileclosed_.

Referenced by IgProfService().

120  {
121  ++nfileclosed_;
123 }
void makeDump(const std::string &format)
void IgProfService::postEndJob ( )

Definition at line 113 of file IgProfService.cc.

References atPostEndJob_, and makeDump().

Referenced by IgProfService().

void makeDump(const std::string &format)
void IgProfService::postEndLumi ( GlobalContext const &  gc)

Definition at line 109 of file IgProfService.cc.

References atPostEndLumi_, and makeDump().

Referenced by IgProfService().

void makeDump(const std::string &format)
void IgProfService::postEndRun ( GlobalContext const &  gc)

Definition at line 111 of file IgProfService.cc.

References atPostEndRun_, and makeDump().

Referenced by IgProfService().

void makeDump(const std::string &format)
void IgProfService::postEvent ( StreamContext const &  sc)

Definition at line 103 of file IgProfService.cc.

References atPostEvent_, edm::EventID::event(), edm::StreamContext::eventID(), makeDump(), mineventrecord_, nevent_, nrecord_, and prescale_.

Referenced by IgProfService().

103  {
104  nevent_ = iStream.eventID().event();
105  if ((prescale_ > 0) && (nrecord_ >= mineventrecord_) && (((nrecord_ - mineventrecord_) % prescale_) == 0))
107 }
edm::EventNumber_t nevent_
Definition: IgProfService.h:69
void makeDump(const std::string &format)
void IgProfService::postOpenFile ( std::string const &  ,
bool   
)

Definition at line 115 of file IgProfService.cc.

References atPostOpenFile_, makeDump(), and nfileopened_.

Referenced by IgProfService().

115  {
116  ++nfileopened_;
118 }
void makeDump(const std::string &format)
void IgProfService::preEvent ( StreamContext const &  sc)

Definition at line 96 of file IgProfService.cc.

References atPreEvent_, edm::EventID::event(), edm::StreamContext::eventID(), makeDump(), mineventrecord_, nevent_, nrecord_, and prescale_.

Referenced by IgProfService().

96  {
97  ++nrecord_; // count before events
98  nevent_ = iStream.eventID().event();
99  if ((prescale_ > 0) && (nrecord_ >= mineventrecord_) && (((nrecord_ - mineventrecord_) % prescale_) == 0))
101 }
edm::EventNumber_t nevent_
Definition: IgProfService.h:69
void makeDump(const std::string &format)
std::string IgProfService::replace ( const std::string &  s,
const char *  pat,
int  val 
)
staticprivate

Definition at line 139 of file IgProfService.cc.

References visDQMUpload::buf, dqmiodumpmetadata::n, mps_fire::result, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeDump().

139  {
140  size_t pos = 0;
141  size_t patlen = strlen(pat);
142  std::string result = s;
143  while ((pos = result.find(pat, pos)) != std::string::npos) {
144  char buf[64];
145  int n = sprintf(buf, "%d", val);
146  result.replace(pos, patlen, buf);
147  pos = pos - patlen + n;
148  }
149 
150  return result;
151 }
tuple result
Definition: mps_fire.py:311
std::string IgProfService::replaceU64 ( const std::string &  s,
const char *  pat,
unsigned long long  val 
)
staticprivate

Definition at line 153 of file IgProfService.cc.

References visDQMUpload::buf, dqmiodumpmetadata::n, mps_fire::result, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeDump().

153  {
154  size_t pos = 0;
155  size_t patlen = strlen(pat);
156  std::string result = s;
157  while ((pos = result.find(pat, pos)) != std::string::npos) {
158  char buf[64];
159  int n = sprintf(buf, "%llu", val);
160  result.replace(pos, patlen, buf);
161  pos = pos - patlen + n;
162  }
163 
164  return result;
165 }
tuple result
Definition: mps_fire.py:311

Member Data Documentation

std::string edm::service::IgProfService::atPostBeginJob_
private

Definition at line 52 of file IgProfService.h.

Referenced by IgProfService(), and postBeginJob().

std::string edm::service::IgProfService::atPostBeginLumi_
private

Definition at line 54 of file IgProfService.h.

Referenced by IgProfService(), and postBeginLumi().

std::string edm::service::IgProfService::atPostBeginRun_
private

Definition at line 53 of file IgProfService.h.

Referenced by IgProfService(), and postBeginRun().

std::string edm::service::IgProfService::atPostCloseFile_
private

Definition at line 64 of file IgProfService.h.

Referenced by IgProfService(), and postCloseFile().

std::string edm::service::IgProfService::atPostEndJob_
private

Definition at line 61 of file IgProfService.h.

Referenced by IgProfService(), and postEndJob().

std::string edm::service::IgProfService::atPostEndLumi_
private

Definition at line 59 of file IgProfService.h.

Referenced by IgProfService(), and postEndLumi().

std::string edm::service::IgProfService::atPostEndRun_
private

Definition at line 60 of file IgProfService.h.

Referenced by IgProfService(), and postEndRun().

std::string edm::service::IgProfService::atPostEvent_
private

Definition at line 57 of file IgProfService.h.

Referenced by IgProfService(), and postEvent().

std::string edm::service::IgProfService::atPostOpenFile_
private

Definition at line 63 of file IgProfService.h.

Referenced by IgProfService(), and postOpenFile().

std::string edm::service::IgProfService::atPreEvent_
private

Definition at line 56 of file IgProfService.h.

Referenced by IgProfService(), and preEvent().

void(* edm::service::IgProfService::dump_)(const char *)
private

Definition at line 50 of file IgProfService.h.

Referenced by IgProfService(), and makeDump().

int edm::service::IgProfService::mineventrecord_
private

Definition at line 66 of file IgProfService.h.

Referenced by IgProfService(), postEvent(), and preEvent().

edm::EventNumber_t edm::service::IgProfService::nevent_
private

Definition at line 69 of file IgProfService.h.

Referenced by makeDump(), postEvent(), and preEvent().

int edm::service::IgProfService::nfileclosed_
private

Definition at line 73 of file IgProfService.h.

Referenced by makeDump(), and postCloseFile().

int edm::service::IgProfService::nfileopened_
private

Definition at line 72 of file IgProfService.h.

Referenced by makeDump(), and postOpenFile().

edm::LuminosityBlockNumber_t edm::service::IgProfService::nlumi_
private

Definition at line 71 of file IgProfService.h.

Referenced by makeDump(), and postBeginLumi().

int edm::service::IgProfService::nrecord_
private

Definition at line 68 of file IgProfService.h.

Referenced by makeDump(), postEvent(), and preEvent().

edm::RunNumber_t edm::service::IgProfService::nrun_
private

Definition at line 70 of file IgProfService.h.

Referenced by makeDump(), and postBeginRun().

int edm::service::IgProfService::prescale_
private

Definition at line 67 of file IgProfService.h.

Referenced by IgProfService(), postEvent(), and preEvent().