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 ( const ParameterSet ,
ActivityRegistry  
)

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

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

Member Function Documentation

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

Definition at line 46 of file IgProfService.h.

References makeDump(), replace(), replaceU64(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

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

Definition at line 151 of file IgProfService.cc.

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

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

151  {
152  if (! dump_ || format.empty())
153  return;
154 
155  std::string final(format);
156  final = replace(final, "%I", nrecord_);
157  final = replaceU64(final, "%E", nevent_);
158  final = replaceU64(final, "%R", nrun_);
159  final = replaceU64(final, "%L", nlumi_);
160  final = replace(final, "%F", nfileopened_);
161  final = replace(final, "%C", nfileclosed_);
162  dump_(final.c_str());
163 }
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:79
static std::string replaceU64(const std::string &s, const char *pat, unsigned long long val)
format
Some error handling for the usage.
void(* dump_)(const char *)
Definition: IgProfService.h:58
edm::EventNumber_t nevent_
Definition: IgProfService.h:77
static std::string replace(const std::string &s, const char *pat, int val)
void IgProfService::postBeginJob ( )

Definition at line 102 of file IgProfService.cc.

References atPostBeginJob_, and makeDump().

Referenced by IgProfService().

102  {
104 }
void makeDump(const std::string &format)
void IgProfService::postBeginLumi ( GlobalContext const &  gc)

Definition at line 110 of file IgProfService.cc.

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

Referenced by IgProfService().

110  {
111  nlumi_ = gc.luminosityBlockID().luminosityBlock(); makeDump(atPostBeginLumi_);
112 }
edm::LuminosityBlockNumber_t nlumi_
Definition: IgProfService.h:79
void makeDump(const std::string &format)
void IgProfService::postBeginRun ( GlobalContext const &  gc)

Definition at line 106 of file IgProfService.cc.

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

Referenced by IgProfService().

106  {
107  nrun_ = gc.luminosityBlockID().run(); makeDump(atPostBeginRun_);
108 }
void makeDump(const std::string &format)
void IgProfService::postCloseFile ( std::string const &  ,
bool   
)

Definition at line 146 of file IgProfService.cc.

References atPostCloseFile_, makeDump(), and nfileclosed_.

Referenced by IgProfService().

146  {
147  ++nfileclosed_;
149 }
void makeDump(const std::string &format)
void IgProfService::postEndJob ( )

Definition at line 137 of file IgProfService.cc.

References atPostEndJob_, and makeDump().

Referenced by IgProfService().

137  {
139 }
void makeDump(const std::string &format)
void IgProfService::postEndLumi ( GlobalContext const &  gc)

Definition at line 129 of file IgProfService.cc.

References atPostEndLumi_, and makeDump().

Referenced by IgProfService().

129  {
131 }
void makeDump(const std::string &format)
void IgProfService::postEndRun ( GlobalContext const &  gc)

Definition at line 133 of file IgProfService.cc.

References atPostEndRun_, and makeDump().

Referenced by IgProfService().

133  {
135 }
void makeDump(const std::string &format)
void IgProfService::postEvent ( StreamContext const &  sc)

Definition at line 122 of file IgProfService.cc.

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

Referenced by IgProfService().

122  {
123  nevent_ = iStream.eventID().event();
124  if ((prescale_ > 0) &&
125  (nrecord_ >= mineventrecord_) &&
127 }
edm::EventNumber_t nevent_
Definition: IgProfService.h:77
void makeDump(const std::string &format)
void IgProfService::postOpenFile ( std::string const &  ,
bool   
)

Definition at line 141 of file IgProfService.cc.

References atPostOpenFile_, makeDump(), and nfileopened_.

Referenced by IgProfService().

141  {
142  ++nfileopened_;
144 }
void makeDump(const std::string &format)
void IgProfService::preEvent ( StreamContext const &  sc)

Definition at line 114 of file IgProfService.cc.

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

Referenced by IgProfService().

114  {
115  ++nrecord_; // count before events
116  nevent_ = iStream.eventID().event();
117  if ((prescale_ > 0) &&
118  (nrecord_ >= mineventrecord_) &&
120 }
edm::EventNumber_t nevent_
Definition: IgProfService.h:77
void makeDump(const std::string &format)
std::string IgProfService::replace ( const std::string &  s,
const char *  pat,
int  val 
)
staticprivate

Definition at line 166 of file IgProfService.cc.

References gen::n, mps_fire::result, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by isProcessWideService(), and makeDump().

166  {
167  size_t pos = 0;
168  size_t patlen = strlen(pat);
169  std::string result = s;
170  while ((pos = result.find(pat, pos)) != std::string::npos)
171  {
172  char buf[64];
173  int n = sprintf(buf, "%d", val);
174  result.replace(pos, patlen, buf);
175  pos = pos - patlen + n;
176  }
177 
178  return result;
179 }
Definition: HeavyIon.h:7
std::string IgProfService::replaceU64 ( const std::string &  s,
const char *  pat,
unsigned long long  val 
)
staticprivate

Definition at line 182 of file IgProfService.cc.

References DEFINE_FWK_SERVICE, gen::n, mps_fire::result, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by isProcessWideService(), and makeDump().

182  {
183  size_t pos = 0;
184  size_t patlen = strlen(pat);
185  std::string result = s;
186  while ((pos = result.find(pat, pos)) != std::string::npos)
187  {
188  char buf[64];
189  int n = sprintf(buf, "%llu", val);
190  result.replace(pos, patlen, buf);
191  pos = pos - patlen + n;
192  }
193 
194  return result;
195 }
Definition: HeavyIon.h:7

Member Data Documentation

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

Definition at line 60 of file IgProfService.h.

Referenced by IgProfService(), and postBeginJob().

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

Definition at line 62 of file IgProfService.h.

Referenced by IgProfService(), and postBeginLumi().

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

Definition at line 61 of file IgProfService.h.

Referenced by IgProfService(), and postBeginRun().

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

Definition at line 72 of file IgProfService.h.

Referenced by IgProfService(), and postCloseFile().

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

Definition at line 69 of file IgProfService.h.

Referenced by IgProfService(), and postEndJob().

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

Definition at line 67 of file IgProfService.h.

Referenced by IgProfService(), and postEndLumi().

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

Definition at line 68 of file IgProfService.h.

Referenced by IgProfService(), and postEndRun().

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

Definition at line 65 of file IgProfService.h.

Referenced by IgProfService(), and postEvent().

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

Definition at line 71 of file IgProfService.h.

Referenced by IgProfService(), and postOpenFile().

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

Definition at line 64 of file IgProfService.h.

Referenced by IgProfService(), and preEvent().

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

Definition at line 58 of file IgProfService.h.

Referenced by IgProfService(), and makeDump().

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

Definition at line 74 of file IgProfService.h.

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

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

Definition at line 77 of file IgProfService.h.

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

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

Definition at line 81 of file IgProfService.h.

Referenced by makeDump(), and postCloseFile().

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

Definition at line 80 of file IgProfService.h.

Referenced by makeDump(), and postOpenFile().

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

Definition at line 79 of file IgProfService.h.

Referenced by makeDump(), and postBeginLumi().

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

Definition at line 76 of file IgProfService.h.

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

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

Definition at line 78 of file IgProfService.h.

Referenced by makeDump(), and postBeginRun().

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

Definition at line 75 of file IgProfService.h.

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