Skip to content

Commit

Permalink
Event number 32 to 64 bits in IgProf
Browse files Browse the repository at this point in the history
  • Loading branch information
wddgit committed Oct 29, 2014
1 parent 6e5af50 commit 0fcf741
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
29 changes: 23 additions & 6 deletions IgTools/IgProf/plugins/IgProfModule.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
Expand Down Expand Up @@ -86,9 +87,9 @@ class IgProfModule : public edm::EDAnalyzer

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 = replaceU64(final, "%E", nevent_);
final = replaceU64(final, "%R", nrun_);
final = replaceU64(final, "%L", nlumi_);
final = replace(final, "%F", nfile_);
dump_(final.c_str());
}
Expand All @@ -109,6 +110,22 @@ class IgProfModule : public edm::EDAnalyzer
return result;
}

static std::string replaceU64(const std::string &s, const char *pat, unsigned long long val)
{
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, "%llu", val);
result.replace(pos, patlen, buf);
pos = pos - patlen + n;
}

return result;
}

void (*dump_)(const char *);
std::string atBeginJob_;
std::string atEndJob_;
Expand All @@ -120,9 +137,9 @@ class IgProfModule : public edm::EDAnalyzer
std::string atEvent_;
int prescale_;
int nrecord_;
int nevent_;
int nrun_;
int nlumi_;
edm::EventNumber_t nevent_;
edm::RunNumber_t nrun_;
edm::LuminosityBlockNumber_t nlumi_;
int nfile_;
};

Expand Down
22 changes: 19 additions & 3 deletions IgTools/IgProf/plugins/IgProfService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void IgProfService::makeDump(const std::string &format) {

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 = replaceU64(final, "%E", nevent_);
final = replaceU64(final, "%R", nrun_);
final = replaceU64(final, "%L", nlumi_);
final = replace(final, "%F", nfileopened_);
final = replace(final, "%C", nfileclosed_);
dump_(final.c_str());
Expand All @@ -178,5 +178,21 @@ IgProfService::replace(const std::string &s, const char *pat, int val) {
return result;
}

std::string
IgProfService::replaceU64(const std::string &s, const char *pat, unsigned long long val) {
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, "%llu", val);
result.replace(pos, patlen, buf);
pos = pos - patlen + n;
}

return result;
}

DEFINE_FWK_SERVICE(IgProfService);

9 changes: 6 additions & 3 deletions IgTools/IgProf/plugins/IgProfService.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Peter Elmer, Princeton University 18 Nov, 2008
//

#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"

Expand Down Expand Up @@ -51,6 +52,8 @@ namespace edm {
void makeDump(const std::string &format);
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);

void (*dump_)(const char *);

Expand All @@ -71,9 +74,9 @@ namespace edm {
int mineventrecord_;
int prescale_;
int nrecord_; // counter
int nevent_;
int nrun_;
int nlumi_;
edm::EventNumber_t nevent_;
edm::RunNumber_t nrun_;
edm::LuminosityBlockNumber_t nlumi_;
int nfileopened_; // counter of files opened thus far
int nfileclosed_; // counter of files closed thus far

Expand Down

0 comments on commit 0fcf741

Please sign in to comment.