CMS 3D CMS Logo

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::IgProfService ( const ParameterSet ps,
ActivityRegistry iRegistry 
)

Definition at line 25 of file IgProfService.cc.

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 }

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().

Member Function Documentation

◆ isProcessWideService()

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

Definition at line 43 of file IgProfService.h.

43 { return true; }

◆ makeDump()

void IgProfService::makeDump ( const std::string &  format)
private

Definition at line 125 of file IgProfService.cc.

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 }

References dump_, dqm-mbProfile::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().

◆ postBeginJob()

void IgProfService::postBeginJob ( )

Definition at line 84 of file IgProfService.cc.

References atPostBeginJob_, and makeDump().

Referenced by IgProfService().

◆ postBeginLumi()

void IgProfService::postBeginLumi ( GlobalContext const &  gc)

Definition at line 91 of file IgProfService.cc.

91  {
92  nlumi_ = gc.luminosityBlockID().luminosityBlock();
94 }

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

Referenced by IgProfService().

◆ postBeginRun()

void IgProfService::postBeginRun ( GlobalContext const &  gc)

Definition at line 86 of file IgProfService.cc.

86  {
87  nrun_ = gc.luminosityBlockID().run();
89 }

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

Referenced by IgProfService().

◆ postCloseFile()

void IgProfService::postCloseFile ( std::string const &  ,
bool   
)

Definition at line 120 of file IgProfService.cc.

120  {
121  ++nfileclosed_;
123 }

References atPostCloseFile_, makeDump(), and nfileclosed_.

Referenced by IgProfService().

◆ postEndJob()

void IgProfService::postEndJob ( )

Definition at line 113 of file IgProfService.cc.

References atPostEndJob_, and makeDump().

Referenced by IgProfService().

◆ postEndLumi()

void IgProfService::postEndLumi ( GlobalContext const &  gc)

Definition at line 109 of file IgProfService.cc.

References atPostEndLumi_, and makeDump().

Referenced by IgProfService().

◆ postEndRun()

void IgProfService::postEndRun ( GlobalContext const &  gc)

Definition at line 111 of file IgProfService.cc.

References atPostEndRun_, and makeDump().

Referenced by IgProfService().

◆ postEvent()

void IgProfService::postEvent ( StreamContext const &  sc)

Definition at line 103 of file IgProfService.cc.

103  {
104  nevent_ = iStream.eventID().event();
105  if ((prescale_ > 0) && (nrecord_ >= mineventrecord_) && (((nrecord_ - mineventrecord_) % prescale_) == 0))
107 }

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

Referenced by IgProfService().

◆ postOpenFile()

void IgProfService::postOpenFile ( std::string const &  ,
bool   
)

Definition at line 115 of file IgProfService.cc.

115  {
116  ++nfileopened_;
118 }

References atPostOpenFile_, makeDump(), and nfileopened_.

Referenced by IgProfService().

◆ preEvent()

void IgProfService::preEvent ( StreamContext const &  sc)

Definition at line 96 of file IgProfService.cc.

96  {
97  ++nrecord_; // count before events
98  nevent_ = iStream.eventID().event();
99  if ((prescale_ > 0) && (nrecord_ >= mineventrecord_) && (((nrecord_ - mineventrecord_) % prescale_) == 0))
101 }

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

Referenced by IgProfService().

◆ replace()

std::string IgProfService::replace ( const std::string &  s,
const char *  pat,
int  val 
)
staticprivate

Definition at line 139 of file IgProfService.cc.

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 }

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

Referenced by makeDump().

◆ replaceU64()

std::string IgProfService::replaceU64 ( const std::string &  s,
const char *  pat,
unsigned long long  val 
)
staticprivate

Definition at line 153 of file IgProfService.cc.

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 }

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

Referenced by makeDump().

Member Data Documentation

◆ atPostBeginJob_

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

Definition at line 52 of file IgProfService.h.

Referenced by IgProfService(), and postBeginJob().

◆ atPostBeginLumi_

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

Definition at line 54 of file IgProfService.h.

Referenced by IgProfService(), and postBeginLumi().

◆ atPostBeginRun_

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

Definition at line 53 of file IgProfService.h.

Referenced by IgProfService(), and postBeginRun().

◆ atPostCloseFile_

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

Definition at line 64 of file IgProfService.h.

Referenced by IgProfService(), and postCloseFile().

◆ atPostEndJob_

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

Definition at line 61 of file IgProfService.h.

Referenced by IgProfService(), and postEndJob().

◆ atPostEndLumi_

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

Definition at line 59 of file IgProfService.h.

Referenced by IgProfService(), and postEndLumi().

◆ atPostEndRun_

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

Definition at line 60 of file IgProfService.h.

Referenced by IgProfService(), and postEndRun().

◆ atPostEvent_

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

Definition at line 57 of file IgProfService.h.

Referenced by IgProfService(), and postEvent().

◆ atPostOpenFile_

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

Definition at line 63 of file IgProfService.h.

Referenced by IgProfService(), and postOpenFile().

◆ atPreEvent_

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

Definition at line 56 of file IgProfService.h.

Referenced by IgProfService(), and preEvent().

◆ dump_

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

Definition at line 50 of file IgProfService.h.

Referenced by IgProfService(), and makeDump().

◆ mineventrecord_

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

Definition at line 66 of file IgProfService.h.

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

◆ nevent_

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

Definition at line 69 of file IgProfService.h.

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

◆ nfileclosed_

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

Definition at line 73 of file IgProfService.h.

Referenced by makeDump(), and postCloseFile().

◆ nfileopened_

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

Definition at line 72 of file IgProfService.h.

Referenced by makeDump(), and postOpenFile().

◆ nlumi_

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

Definition at line 71 of file IgProfService.h.

Referenced by makeDump(), and postBeginLumi().

◆ nrecord_

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

Definition at line 68 of file IgProfService.h.

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

◆ nrun_

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

Definition at line 70 of file IgProfService.h.

Referenced by makeDump(), and postBeginRun().

◆ prescale_

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

Definition at line 67 of file IgProfService.h.

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

edm::service::IgProfService::mineventrecord_
int mineventrecord_
Definition: IgProfService.h:66
edm::service::IgProfService::atPostBeginRun_
std::string atPostBeginRun_
Definition: IgProfService.h:53
edm::service::IgProfService::atPostCloseFile_
std::string atPostCloseFile_
Definition: IgProfService.h:64
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::service::IgProfService::postBeginRun
void postBeginRun(GlobalContext const &gc)
Definition: IgProfService.cc:86
pos
Definition: PixelAliasList.h:18
edm::service::IgProfService::preEvent
void preEvent(StreamContext const &sc)
Definition: IgProfService.cc:96
edm::service::IgProfService::nevent_
edm::EventNumber_t nevent_
Definition: IgProfService.h:69
edm::service::IgProfService::replace
static std::string replace(const std::string &s, const char *pat, int val)
Definition: IgProfService.cc:139
edm::service::IgProfService::replaceU64
static std::string replaceU64(const std::string &s, const char *pat, unsigned long long val)
Definition: IgProfService.cc:153
edm::service::IgProfService::atPostEndJob_
std::string atPostEndJob_
Definition: IgProfService.h:61
edm::service::IgProfService::atPostOpenFile_
std::string atPostOpenFile_
Definition: IgProfService.h:63
edm::service::IgProfService::prescale_
int prescale_
Definition: IgProfService.h:67
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::service::IgProfService::postEndLumi
void postEndLumi(GlobalContext const &gc)
Definition: IgProfService.cc:109
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
edm::service::IgProfService::nrun_
edm::RunNumber_t nrun_
Definition: IgProfService.h:70
edm::service::IgProfService::atPostBeginJob_
std::string atPostBeginJob_
Definition: IgProfService.h:52
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::service::IgProfService::atPostEndLumi_
std::string atPostEndLumi_
Definition: IgProfService.h:59
edm::service::IgProfService::atPostEvent_
std::string atPostEvent_
Definition: IgProfService.h:57
edm::service::IgProfService::atPostEndRun_
std::string atPostEndRun_
Definition: IgProfService.h:60
edm::service::IgProfService::makeDump
void makeDump(const std::string &format)
Definition: IgProfService.cc:125
edm::service::IgProfService::nlumi_
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:71
edm::service::IgProfService::postEndJob
void postEndJob()
Definition: IgProfService.cc:113
edm::service::IgProfService::nfileopened_
int nfileopened_
Definition: IgProfService.h:72
edm::service::IgProfService::postOpenFile
void postOpenFile(std::string const &, bool)
Definition: IgProfService.cc:115
pat
Definition: HeavyIon.h:7
edm::service::IgProfService::postCloseFile
void postCloseFile(std::string const &, bool)
Definition: IgProfService.cc:120
edm::service::IgProfService::postEvent
void postEvent(StreamContext const &sc)
Definition: IgProfService.cc:103
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::service::IgProfService::atPostBeginLumi_
std::string atPostBeginLumi_
Definition: IgProfService.h:54
edm::service::IgProfService::postBeginJob
void postBeginJob()
Definition: IgProfService.cc:84
heppy_batch.val
val
Definition: heppy_batch.py:351
edm::service::IgProfService::dump_
void(* dump_)(const char *)
Definition: IgProfService.h:50
edm::service::IgProfService::atPreEvent_
std::string atPreEvent_
Definition: IgProfService.h:56
edm::service::IgProfService::postEndRun
void postEndRun(GlobalContext const &gc)
Definition: IgProfService.cc:111
format
edm::service::IgProfService::nrecord_
int nrecord_
Definition: IgProfService.h:68
mps_fire.result
result
Definition: mps_fire.py:303
edm::service::IgProfService::postBeginLumi
void postBeginLumi(GlobalContext const &gc)
Definition: IgProfService.cc:91
edm::service::IgProfService::nfileclosed_
int nfileclosed_
Definition: IgProfService.h:73