CMS 3D CMS Logo

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

IgProfModule Class Reference

Inheritance diagram for IgProfModule:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginLuminosityBlock (const edm::LuminosityBlock &l, const edm::EventSetup &)
virtual void beginRun (const edm::Run &r, const edm::EventSetup &)
virtual void endJob (void)
virtual void endLuminosityBlock (const edm::LuminosityBlock &l, const edm::EventSetup &)
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 IgProfModule (const edm::ParameterSet &ps)
virtual void respondToOpenInputFile (const edm::FileBlock &)

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 atBeginJob_
std::string atBeginLumi_
std::string atBeginRun_
std::string atEndJob_
std::string atEndLumi_
std::string atEndRun_
std::string atEvent_
std::string atInputFile_
void(* dump_ )(const char *)
int nevent_
int nfile_
int nlumi_
int nrecord_
int nrun_
int prescale_

Detailed Description

Definition at line 16 of file IgProfModule.cc.


Constructor & Destructor Documentation

IgProfModule::IgProfModule ( const edm::ParameterSet ps) [inline]

Definition at line 19 of file IgProfModule.cc.

References atBeginJob_, atBeginLumi_, atEndJob_, atEndLumi_, atEvent_, atInputFile_, dump_, edm::ParameterSet::getUntrackedParameter(), and prescale_.

    : dump_(0),
      prescale_(0),
      nrecord_(0),
      nevent_(0),
      nrun_(0),
      nlumi_(0),
      nfile_(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";

      prescale_    = ps.getUntrackedParameter<int>("reportEventInterval", prescale_);
      atBeginJob_  = ps.getUntrackedParameter<std::string>("reportToFileAtBeginJob", atBeginJob_);
      atEndJob_    = ps.getUntrackedParameter<std::string>("reportToFileAtEndJob", atEndJob_);
      atBeginLumi_ = ps.getUntrackedParameter<std::string>("reportToFileAtBeginLumi", atBeginLumi_);
      atEndLumi_   = ps.getUntrackedParameter<std::string>("reportToFileAtEndLumi", atEndLumi_);
      atInputFile_ = ps.getUntrackedParameter<std::string>("reportToFileAtInputFile", atInputFile_);
      atEvent_     = ps.getUntrackedParameter<std::string>("reportToFileAtEvent", atEvent_);
    }

Member Function Documentation

virtual void IgProfModule::analyze ( const edm::Event e,
const edm::EventSetup  
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 59 of file IgProfModule.cc.

References atEvent_, edm::EventID::event(), edm::EventBase::id(), makeDump(), nevent_, nrecord_, and prescale_.

    {
      nevent_ = e.id().event();
      if (prescale_ > 0 && (++nrecord_ % prescale_) == 1)
        makeDump(atEvent_);
    }
virtual void IgProfModule::beginJob ( void  ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file IgProfModule.cc.

References atBeginJob_, and makeDump().

virtual void IgProfModule::beginLuminosityBlock ( const edm::LuminosityBlock l,
const edm::EventSetup  
) [inline, virtual]
virtual void IgProfModule::beginRun ( const edm::Run r,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 66 of file IgProfModule.cc.

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

    { nrun_ = r.run(); makeDump(atBeginRun_); }
virtual void IgProfModule::endJob ( void  ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file IgProfModule.cc.

References atEndJob_, and makeDump().

virtual void IgProfModule::endLuminosityBlock ( const edm::LuminosityBlock l,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 75 of file IgProfModule.cc.

References atEndLumi_, and makeDump().

virtual void IgProfModule::endRun ( const edm::Run ,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file IgProfModule.cc.

References atEndRun_, and makeDump().

void IgProfModule::makeDump ( const std::string &  format) [inline, private]

Definition at line 82 of file IgProfModule.cc.

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

Referenced by analyze(), beginJob(), beginLuminosityBlock(), beginRun(), endJob(), endLuminosityBlock(), endRun(), and respondToOpenInputFile().

    {
      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", nfile_);
      dump_(final.c_str());
    }
static std::string IgProfModule::replace ( const std::string &  s,
const char *  pat,
int  val 
) [inline, static, private]

Definition at line 96 of file IgProfModule.cc.

References n, pos, query::result, and asciidump::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;
    }
virtual void IgProfModule::respondToOpenInputFile ( const edm::FileBlock ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 78 of file IgProfModule.cc.

References atInputFile_, makeDump(), and nfile_.


Member Data Documentation

std::string IgProfModule::atBeginJob_ [private]

Definition at line 113 of file IgProfModule.cc.

Referenced by beginJob(), and IgProfModule().

std::string IgProfModule::atBeginLumi_ [private]

Definition at line 117 of file IgProfModule.cc.

Referenced by beginLuminosityBlock(), and IgProfModule().

std::string IgProfModule::atBeginRun_ [private]

Definition at line 115 of file IgProfModule.cc.

Referenced by beginRun().

std::string IgProfModule::atEndJob_ [private]

Definition at line 114 of file IgProfModule.cc.

Referenced by endJob(), and IgProfModule().

std::string IgProfModule::atEndLumi_ [private]

Definition at line 118 of file IgProfModule.cc.

Referenced by endLuminosityBlock(), and IgProfModule().

std::string IgProfModule::atEndRun_ [private]

Definition at line 116 of file IgProfModule.cc.

Referenced by endRun().

std::string IgProfModule::atEvent_ [private]

Definition at line 120 of file IgProfModule.cc.

Referenced by analyze(), and IgProfModule().

std::string IgProfModule::atInputFile_ [private]

Definition at line 119 of file IgProfModule.cc.

Referenced by IgProfModule(), and respondToOpenInputFile().

void(* IgProfModule::dump_)(const char *) [private]

Definition at line 112 of file IgProfModule.cc.

Referenced by IgProfModule(), and makeDump().

int IgProfModule::nevent_ [private]

Definition at line 123 of file IgProfModule.cc.

Referenced by analyze(), and makeDump().

int IgProfModule::nfile_ [private]

Definition at line 126 of file IgProfModule.cc.

Referenced by makeDump(), and respondToOpenInputFile().

int IgProfModule::nlumi_ [private]

Definition at line 125 of file IgProfModule.cc.

Referenced by beginLuminosityBlock(), and makeDump().

int IgProfModule::nrecord_ [private]

Definition at line 122 of file IgProfModule.cc.

Referenced by analyze(), and makeDump().

int IgProfModule::nrun_ [private]

Definition at line 124 of file IgProfModule.cc.

Referenced by beginRun(), and makeDump().

int IgProfModule::prescale_ [private]

Definition at line 121 of file IgProfModule.cc.

Referenced by analyze(), and IgProfModule().