CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

edm::service::IgProfService Class Reference

#include <IgProfService.h>

List of all members.

Public Member Functions

 IgProfService (const ParameterSet &, ActivityRegistry &)
bool isProcessWideService (IgProfService const *)
void postBeginJob ()
void postBeginLumi (LuminosityBlock const &run, EventSetup const &es)
void postBeginRun (Run const &run, EventSetup const &es)
void postCloseFile ()
void postEndJob ()
void postEndLumi (LuminosityBlock const &run, EventSetup const &es)
void postEndRun (Run const &run, EventSetup const &es)
void postEvent (Event const &ev, EventSetup const &es)
void postOpenFile ()
void preEvent (EventID const &id, Timestamp const &ts)

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)

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_
int nevent_
int nfileclosed_
int nfileopened_
int nlumi_
int nrecord_
int nrun_
int prescale_

Detailed Description

Definition at line 16 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_, edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostBeginLumi(), edm::ActivityRegistry::watchPostBeginRun(), edm::ActivityRegistry::watchPostCloseFile(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostEndLumi(), edm::ActivityRegistry::watchPostEndRun(), edm::ActivityRegistry::watchPostOpenFile(), edm::ActivityRegistry::watchPostProcessEvent(), and edm::ActivityRegistry::watchPreProcessEvent().

  : dump_(0),
    mineventrecord_(1),
    prescale_(1),
    nrecord_(0),
    nevent_(0),
    nrun_(0),
    nlumi_(0),
    nfileopened_(0),
    nfileclosed_(0) {


    // Removing the __extension__ gives a warning which
    // is acknowledged as a language problem in the C++ Standard Core 
    // Language Defect Report
    //
    // https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195
    //
    // since the suggested decision seems to be that the syntax should
    // actually be "Conditionally-Supported Behavior" in some 
    // future C++ standard I simply silence the warning.
    if (void *sym = dlsym(0, "igprof_dump_now")) {
      dump_ = __extension__ (void(*)(const char *)) sym;
    } else
      edm::LogWarning("IgProfModule")
        << "IgProfModule requested but application is not"
        << " currently being profiled with igprof\n";

  // Get the configuration
  prescale_    
    = ps.getUntrackedParameter<int>("reportEventInterval", prescale_);
  mineventrecord_    
    = ps.getUntrackedParameter<int>("reportFirstEvent", mineventrecord_);

  atPostBeginJob_  
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginJob", atPostBeginJob_);
  atPostBeginRun_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginRun", atPostBeginRun_);
  atPostBeginLumi_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostBeginLumi", atPostBeginLumi_);

  atPreEvent_     
    = ps.getUntrackedParameter<std::string>("reportToFileAtPreEvent", atPreEvent_);
  atPostEvent_     
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostEvent", atPostEvent_);

  atPostEndLumi_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndLumi", atPostEndLumi_);
  atPostEndRun_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndRun", atPostEndRun_);
  atPostEndJob_  
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostEndJob", atPostEndJob_);

  atPostOpenFile_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostOpenFile", atPostOpenFile_);
  atPostCloseFile_ 
    = ps.getUntrackedParameter<std::string>("reportToFileAtPostCloseFile", atPostCloseFile_);


  // Register for the framework signals
  iRegistry.watchPostBeginJob(this, &IgProfService::postBeginJob);
  iRegistry.watchPostBeginRun(this, &IgProfService::postBeginRun);
  iRegistry.watchPostBeginLumi(this, &IgProfService::postBeginLumi);

  iRegistry.watchPreProcessEvent(this, &IgProfService::preEvent);
  iRegistry.watchPostProcessEvent(this, &IgProfService::postEvent);

  iRegistry.watchPostEndLumi(this, &IgProfService::postEndLumi);
  iRegistry.watchPostEndRun(this, &IgProfService::postEndRun);
  iRegistry.watchPostEndJob(this, &IgProfService::postEndJob);

  iRegistry.watchPostOpenFile(this, &IgProfService::postOpenFile);
  iRegistry.watchPostCloseFile(this, &IgProfService::postCloseFile);

}

Member Function Documentation

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

Definition at line 42 of file IgProfService.h.

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

Definition at line 154 of file IgProfService.cc.

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

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

                                                    {
  if (! dump_ || format.empty())
    return;

  std::string final(format);
  final = replace(final, "%I", nrecord_);
  final = replace(final, "%E", nevent_);
  final = replace(final, "%R", nrun_);
  final = replace(final, "%L", nlumi_);
  final = replace(final, "%F", nfileopened_);
  final = replace(final, "%C", nfileclosed_);
  dump_(final.c_str());
}
void IgProfService::postBeginJob ( )

Definition at line 102 of file IgProfService.cc.

References atPostBeginJob_, and makeDump().

Referenced by IgProfService().

void IgProfService::postBeginLumi ( LuminosityBlock const &  run,
EventSetup const &  es 
)

Definition at line 110 of file IgProfService.cc.

References atPostBeginLumi_, edm::LuminosityBlockBase::luminosityBlock(), makeDump(), and nlumi_.

Referenced by IgProfService().

                                                         { 
  nlumi_ = l.luminosityBlock(); makeDump(atPostBeginLumi_); 
}
void IgProfService::postBeginRun ( Run const &  run,
EventSetup const &  es 
)

Definition at line 106 of file IgProfService.cc.

References atPostBeginRun_, makeDump(), nrun_, and edm::RunBase::run().

Referenced by IgProfService().

                                                                       { 
  nrun_ = r.run(); makeDump(atPostBeginRun_); 
}
void IgProfService::postCloseFile ( )

Definition at line 149 of file IgProfService.cc.

References atPostCloseFile_, makeDump(), and nfileclosed_.

Referenced by IgProfService().

void IgProfService::postEndJob ( )

Definition at line 140 of file IgProfService.cc.

References atPostEndJob_, and makeDump().

Referenced by IgProfService().

void IgProfService::postEndLumi ( LuminosityBlock const &  run,
EventSetup const &  es 
)

Definition at line 131 of file IgProfService.cc.

References atPostEndLumi_, and makeDump().

Referenced by IgProfService().

void IgProfService::postEndRun ( Run const &  run,
EventSetup const &  es 
)

Definition at line 136 of file IgProfService.cc.

References atPostEndRun_, and makeDump().

Referenced by IgProfService().

void IgProfService::postEvent ( Event const &  ev,
EventSetup const &  es 
)
void IgProfService::postOpenFile ( )

Definition at line 144 of file IgProfService.cc.

References atPostOpenFile_, makeDump(), and nfileopened_.

Referenced by IgProfService().

void IgProfService::preEvent ( EventID const &  id,
Timestamp const &  ts 
)

Definition at line 115 of file IgProfService.cc.

References atPreEvent_, makeDump(), mineventrecord_, nevent_, nrecord_, and prescale_.

Referenced by IgProfService().

                                                         {
  ++nrecord_; // count before events
  nevent_ = id.event();
  if ((prescale_ > 0) && 
      (nrecord_ >= mineventrecord_) &&
      (((nrecord_ - mineventrecord_)% prescale_) == 0)) makeDump(atPreEvent_);
}
std::string IgProfService::replace ( const std::string &  s,
const char *  pat,
int  val 
) [static, private]

Definition at line 169 of file IgProfService.cc.

References n, pos, query::result, and alignCSCRings::s.

Referenced by makeDump().

                                                                   {
  size_t pos = 0;
  size_t patlen = strlen(pat);
  std::string result = s;
  while ((pos = result.find(pat, pos)) != std::string::npos)
  {
    char buf[64];
    int n = sprintf(buf, "%d", val);
    result.replace(pos, patlen, buf);
    pos = pos - patlen + n;
  }

  return result;
}

Member Data Documentation

Definition at line 54 of file IgProfService.h.

Referenced by IgProfService(), and postBeginJob().

Definition at line 56 of file IgProfService.h.

Referenced by IgProfService(), and postBeginLumi().

Definition at line 55 of file IgProfService.h.

Referenced by IgProfService(), and postBeginRun().

Definition at line 66 of file IgProfService.h.

Referenced by IgProfService(), and postCloseFile().

Definition at line 63 of file IgProfService.h.

Referenced by IgProfService(), and postEndJob().

Definition at line 61 of file IgProfService.h.

Referenced by IgProfService(), and postEndLumi().

Definition at line 62 of file IgProfService.h.

Referenced by IgProfService(), and postEndRun().

Definition at line 59 of file IgProfService.h.

Referenced by IgProfService(), and postEvent().

Definition at line 65 of file IgProfService.h.

Referenced by IgProfService(), and postOpenFile().

Definition at line 58 of file IgProfService.h.

Referenced by IgProfService(), and preEvent().

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

Definition at line 52 of file IgProfService.h.

Referenced by IgProfService(), and makeDump().

Definition at line 68 of file IgProfService.h.

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

Definition at line 71 of file IgProfService.h.

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

Definition at line 75 of file IgProfService.h.

Referenced by makeDump(), and postCloseFile().

Definition at line 74 of file IgProfService.h.

Referenced by makeDump(), and postOpenFile().

Definition at line 73 of file IgProfService.h.

Referenced by makeDump(), and postBeginLumi().

Definition at line 70 of file IgProfService.h.

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

Definition at line 72 of file IgProfService.h.

Referenced by makeDump(), and postBeginRun().

Definition at line 69 of file IgProfService.h.

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