Skip to content

Commit

Permalink
Merge pull request #17929 from Dr15Jones/nEventsPerLumiInJobReport_7_1
Browse files Browse the repository at this point in the history
Report # events per Lumi for output files in framework job report
  • Loading branch information
cmsbuild committed Mar 27, 2017
2 parents f263e7a + 6aafb77 commit 18de2a5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions FWCore/MessageLogger/interface/JobReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace edm {

struct RunReport {
RunNumber runNumber;
std::set<unsigned int> lumiSections;
std::map<unsigned int,unsigned long> lumiSectionsToNEvents;
};

/**\struct InputFile
Expand Down Expand Up @@ -195,7 +195,7 @@ namespace edm {
* Associate a Lumi Section to all open output files
*
*/
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection);
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection, unsigned long nEvents);

/*
* Associate a Lumi Section to all open input files
Expand Down Expand Up @@ -336,7 +336,7 @@ namespace edm {
/// for output files, call only if lumi section is written to
/// the output file
///
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId);
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0);

///
/// API for reporting a Lumi Section to the job report.
Expand Down
23 changes: 14 additions & 9 deletions FWCore/MessageLogger/src/JobReport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ namespace edm {
<< rep.runNumber
<< "\">\n";

for(auto il : rep.lumiSections) {
os << " <LumiSection ID=\"" << il << "\"/>\n";
for(auto const& il : rep.lumiSectionsToNEvents) {
if(std::numeric_limits<unsigned long>::max() == il.second) {
os << " <LumiSection ID=\"" << il.first << "\"/>\n";

} else {
os << " <LumiSection ID=\"" << il.first << "\" NEvents=\""<<il.second<< "\"/>\n";
}
}
os << "</Run>\n";
return os;
Expand Down Expand Up @@ -292,13 +297,13 @@ namespace edm {
}
}

void JobReport::JobReportImpl::associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSect) {
void JobReport::JobReportImpl::associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSect, unsigned long nEvents) {
std::map<RunNumber, RunReport>& theMap = outputFiles_.at(token).runReports;
std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
if(iter == theMap.end() || runNumber < iter->first) { // not found
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {lumiSect}}); // insert it
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{{lumiSect,nEvents}}}}); // insert it
} else {
iter->second.lumiSections.insert(lumiSect);
iter->second.lumiSectionsToNEvents[lumiSect]+=nEvents;
}
}

Expand All @@ -308,9 +313,9 @@ namespace edm {
std::map<RunNumber, RunReport>& theMap = inputFile.runReports;
std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
if(iter == theMap.end() || runNumber < iter->first) { // not found
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {lumiSect}}); // insert it
theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{lumiSect,std::numeric_limits<unsigned long>::max()}}}); // insert it
} else {
iter->second.lumiSections.insert(lumiSect);
iter->second.lumiSectionsToNEvents[lumiSect]=std::numeric_limits<unsigned long>::max();
}
}
}
Expand Down Expand Up @@ -536,8 +541,8 @@ namespace edm {
}

void
JobReport::reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId) {
impl_->associateLumiSection(token, run, lumiSectId);
JobReport::reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents) {
impl_->associateLumiSection(token, run, lumiSectId,nEvents);
}

void
Expand Down
4 changes: 2 additions & 2 deletions IOPool/Common/test/proper_RLfjr_output
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@

<Runs>
<Run ID="100">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="0"/>
</Run>

<Run ID="200">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="0"/>
</Run>

</Runs>
Expand Down
4 changes: 2 additions & 2 deletions IOPool/Common/test/proper_fjr_output
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@

<Runs>
<Run ID="100">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="10"/>
</Run>

<Run ID="200">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="15"/>
</Run>

</Runs>
Expand Down
4 changes: 2 additions & 2 deletions IOPool/Common/test/proper_fjrx_output
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@

<Runs>
<Run ID="100">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="10"/>
</Run>

<Run ID="200">
<LumiSection ID="1"/>
<LumiSection ID="1" NEvents="15"/>
</Run>

</Runs>
Expand Down
5 changes: 4 additions & 1 deletion IOPool/Output/src/RootOutputFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace edm {
lumiEntryNumber_(0LL),
runEntryNumber_(0LL),
indexIntoFile_(),
nEventsInLumi_(0),
metaDataTree_(nullptr),
parameterSetsTree_(nullptr),
parentageTree_(nullptr),
Expand Down Expand Up @@ -421,6 +422,7 @@ namespace edm {
// Report event written
Service<JobReport> reportSvc;
reportSvc->eventWrittenToFile(reportToken_, e.id().run(), e.id().event());
++nEventsInLumi_;
}

void RootOutputFile::writeLuminosityBlock(LuminosityBlockPrincipal const& lb, ModuleCallingContext const* mcc) {
Expand All @@ -440,7 +442,8 @@ namespace edm {
lumiTree_.optimizeBaskets(10ULL*1024*1024);

Service<JobReport> reportSvc;
reportSvc->reportLumiSection(reportToken_, lb.id().run(), lb.id().luminosityBlock());
reportSvc->reportLumiSection(reportToken_, lb.id().run(), lb.id().luminosityBlock(),nEventsInLumi_);
nEventsInLumi_ = 0;
}

void RootOutputFile::writeRun(RunPrincipal const& r, ModuleCallingContext const* mcc) {
Expand Down
1 change: 1 addition & 0 deletions IOPool/Output/src/RootOutputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ namespace edm {
IndexIntoFile::EntryNumber_t lumiEntryNumber_;
IndexIntoFile::EntryNumber_t runEntryNumber_;
IndexIntoFile indexIntoFile_;
unsigned long nEventsInLumi_;
TTree* metaDataTree_;
TTree* parameterSetsTree_;
TTree* parentageTree_;
Expand Down

0 comments on commit 18de2a5

Please sign in to comment.