39 template <
typename S,
typename T>
41 tinyxml2::XMLDocument
doc;
42 if (
f.fileHasBeenClosed) {
43 os <<
"\n<State Value=\"closed\"/>";
45 os <<
"\n<State Value=\"open\"/>";
47 os <<
"\n<LFN>" <<
doc.NewText(
f.logicalFileName.c_str())->
Value() <<
"</LFN>";
48 os <<
"\n<PFN>" <<
doc.NewText(
f.physicalFileName.c_str())->
Value() <<
"</PFN>";
49 os <<
"\n<Catalog>" <<
doc.NewText(
f.catalog.c_str())->
Value() <<
"</Catalog>";
50 os <<
"\n<ModuleLabel>" <<
doc.NewText(
f.moduleLabel.c_str())->
Value() <<
"</ModuleLabel>";
51 os <<
"\n<GUID>" <<
f.guid <<
"</GUID>";
53 for (
auto const&
branch :
f.branchNames) {
54 os <<
"\n <Branch>" <<
doc.NewText(
branch.c_str())->
Value() <<
"</Branch>";
57 os <<
"\n</Branches>";
67 tinyxml2::XMLDocument
doc;
68 os <<
"\n<InputFile>";
70 os <<
"\n<InputType>" <<
f.inputType <<
"</InputType>";
71 os <<
"\n<InputSourceClass>" <<
doc.NewText(
f.inputSourceClassName.c_str())->
Value() <<
"</InputSourceClass>";
72 os <<
"\n<EventsRead>" <<
f.numEventsRead <<
"</EventsRead>";
78 tinyxml2::XMLDocument
doc;
80 os <<
"\n<OutputModuleClass>" <<
doc.NewText(
f.outputModuleClassName.c_str())->
Value() <<
"</OutputModuleClass>";
81 os <<
"\n<TotalEvents>" <<
f.numEventsWritten <<
"</TotalEvents>\n";
82 os <<
"\n<DataType>" <<
doc.NewText(
f.dataType.c_str())->
Value() <<
"</DataType>\n";
83 os <<
"\n<BranchHash>" <<
doc.NewText(
f.branchHash.c_str())->
Value() <<
"</BranchHash>\n";
89 os <<
"\n<Run ID=\"" <<
rep.runNumber <<
"\">\n";
91 for (
auto const& il :
rep.lumiSectionsToNEvents) {
93 os <<
" <LumiSection ID=\"" << il.first <<
"\"/>\n";
96 os <<
" <LumiSection ID=\"" << il.first <<
"\" NEvents=\"" << il.second <<
"\"/>\n";
112 <<
t <<
" but no matching input file is found\n";
118 <<
"Access reported for input file with token " <<
t <<
" but no matching input file is found\n";
124 <<
"Access reported for input file with token " <<
t <<
" after this file has been closed.\n" 125 <<
"File record follows:\n" 132 if (
t >= outputFiles_.size()) {
134 <<
"Access reported for output file with token " <<
t <<
" but no matching output file is found\n";
136 if (outputFiles_[
t].fileHasBeenClosed) {
138 <<
"Access reported for output file with token " <<
t <<
" after this file has been closed.\n" 139 <<
"File record follows:\n" 140 << outputFiles_[
t] <<
'\n';
142 return outputFiles_[
t];
155 outputFile.contributingInputsSecSource.push_back(
t);
172 for (
auto const& runReport :
f.runReports) {
173 *ost_ << runReport.second;
175 *ost_ <<
"\n</Runs>\n";
176 *ost_ <<
"</InputFile>\n";
196 tinyxml2::XMLDocument
doc;
202 for (
auto const& runReport :
f.runReports) {
203 *ost_ << runReport.second;
205 *ost_ <<
"\n</Runs>\n";
207 *ost_ <<
"\n<Inputs>";
208 for (
auto token :
f.contributingInputs) {
210 *ost_ <<
"\n<Input>";
215 *ost_ <<
"\n</Input>";
216 doc.DeleteChildren();
218 for (
auto token :
f.contributingInputsSecSource) {
220 *ost_ <<
"\n<Input>";
225 *ost_ <<
"\n</Input>";
226 doc.DeleteChildren();
228 *ost_ <<
"\n</Inputs>";
229 *ost_ <<
"\n</File>\n";
238 for (
auto const&
inputFile : inputFiles_) {
243 for (
auto const&
inputFile : inputFilesSecSource_) {
256 auto& theMap = outputFiles_.at(
token).runReports;
257 std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(
runNumber));
258 if (iter == theMap.end() ||
runNumber < iter->first) {
266 std::map<RunNumber, RunReport>& theMap =
inputFile.runReports;
267 std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(
runNumber));
268 if (iter == theMap.end() ||
runNumber < iter->first) {
277 unsigned int lumiSect,
279 auto& theMap = outputFiles_.at(
token).runReports;
280 std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(
runNumber));
281 if (iter == theMap.end() ||
runNumber < iter->first) {
284 iter->second.lumiSectionsToNEvents[lumiSect] +=
nEvents;
291 std::map<RunNumber, RunReport>& theMap =
inputFile.runReports;
292 std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(
runNumber));
293 if (iter == theMap.end() ||
runNumber < iter->first) {
314 auto endpos =
impl_->ost_->tellp();
321 *(
impl_->ost_) <<
"<!--";
322 for (
int i = padding;
i > 0; --
i) {
323 (*
impl_->ost_) <<
' ';
325 *(
impl_->ost_) <<
"-->\n";
336 *(
impl_->ost_) <<
"<FrameworkError ExitStatus=\"8901\" Type=\"UnexpectedJobTermination\"/>\n";
349 *(
impl_->ost_) <<
"<FrameworkJobReport>\n";
366 if (inputType ==
"mixingFiles") {
370 newToken = itr -
impl_->inputFilesSecSource_.begin();
372 if (inputType ==
"secondaryFiles") {
375 impl_->inputFiles_.emplace_back();
376 newFile = &
impl_->inputFiles_.back();
377 newToken =
impl_->inputFiles_.size() - 1;
381 impl_->lastOpenedPrimaryInputFile_ =
impl_->inputFiles_.size() - 1;
389 newFile->
guid = guid;
396 impl_->insertInputForOutputs(theInputType, newToken);
412 f.fileHasBeenClosed =
true;
431 auto itr =
impl_->outputFiles_.emplace_back();
434 r.logicalFileName = logicalFileName;
435 r.physicalFileName = physicalFileName;
437 r.outputModuleClassName = outputModuleClassName;
441 r.branchHash = branchHash;
442 r.numEventsWritten = 0;
444 r.fileHasBeenClosed =
false;
449 if (!
impl_->inputFiles_[
i].fileHasBeenClosed) {
450 r.contributingInputs.push_back(
i);
455 if (!
impl_->inputFilesSecSource_[
i].fileHasBeenClosed) {
456 r.contributingInputsSecSource.push_back(
i);
459 return itr -
impl_->outputFiles_.begin();
464 ++
f.numEventsWritten;
469 f.fileHasBeenClosed =
true;
471 impl_->writeOutputFile(
f);
480 msg <<
"<SkippedEvent Run=\"" <<
run <<
"\"";
481 msg <<
" Event=\"" <<
event <<
"\" />\n";
491 f.fastCopyingInputs.insert(std::make_pair(
inputFileName, fastCopying));
496 unsigned int lumiSectId,
502 impl_->associateInputLumiSection(
run, lumiSectId);
510 tinyxml2::XMLDocument
doc;
515 msg <<
"<AnalysisFile>\n" 516 <<
" <FileName>" <<
doc.NewText(
fileName.c_str())->
Value() <<
"</FileName>\n";
518 typedef std::map<std::string, std::string>::const_iterator const_iterator;
519 for (const_iterator
pos = fileData.begin(), posEnd = fileData.end();
pos != posEnd; ++
pos) {
520 msg <<
" <" <<
pos->first <<
" Value=\"" <<
pos->second <<
"\" />" 523 msg <<
"</AnalysisFile>\n";
535 msg <<
"<FrameworkError ExitStatus=\"" << exitCode <<
"\" Type=\"" << shortDesc <<
"\" >\n";
536 msg <<
"<![CDATA[\n" << longDesc <<
"\n]]>\n";
537 msg <<
"</FrameworkError>\n";
548 msg <<
"<ShutdownSignal/>\n";
557 tinyxml2::XMLDocument
doc;
558 tinyxml2::XMLPrinter printer;
559 tinyxml2::XMLElement*
skipped =
doc.NewElement(
"SkippedFile");
560 skipped->SetAttribute(
"Pfn", pfn.c_str());
561 skipped->SetAttribute(
"Lfn", lfn.c_str());
565 msg << printer.CStr();
574 tinyxml2::XMLDocument
doc;
575 tinyxml2::XMLPrinter printer;
576 tinyxml2::XMLElement*
fallback =
doc.NewElement(
"FallbackAttempt");
577 fallback->SetAttribute(
"Pfn", pfn.c_str());
578 fallback->SetAttribute(
"Lfn", lfn.c_str());
582 msg << printer.CStr();
583 msg <<
"<![CDATA[\n" <<
err <<
"\n]]>\n";
593 msg <<
"<MemoryService>\n";
595 typedef std::vector<std::string>::const_iterator const_iterator;
596 for (const_iterator
pos = memoryData.begin(), posEnd = memoryData.end();
pos != posEnd; ++
pos) {
599 msg <<
"</MemoryService>\n";
608 msg <<
"<MessageSummary>\n";
609 typedef std::map<std::string, double>::const_iterator const_iterator;
610 for (const_iterator
pos = messageData.begin(), posEnd = messageData.end();
pos != posEnd; ++
pos) {
611 msg <<
" <" <<
pos->first <<
" Value=\"" <<
pos->second <<
"\" />" 614 msg <<
"</MessageSummary>\n";
620 bool expected =
false;
621 if (not
impl_->printedReadBranches_.compare_exchange_strong(expected,
true))
625 std::ostream& ost = *(
impl_->ost_);
626 ost <<
"<ReadBranches>\n";
627 tinyxml2::XMLDocument
doc;
628 tinyxml2::XMLPrinter printer;
629 for (
auto const& iBranch :
impl_->readBranches_) {
630 tinyxml2::XMLElement*
branch =
doc.NewElement(
"Branch");
631 branch->SetAttribute(
"Name", iBranch.first.c_str());
632 branch->SetAttribute(
"ReadCount", int64_t(iBranch.second));
634 ost << printer.CStr();
635 printer.ClearBuffer();
637 for (
auto const& iBranch :
impl_->readBranchesSecFile_) {
638 tinyxml2::XMLElement*
branch =
doc.NewElement(
"Branch");
639 branch->SetAttribute(
"Name", iBranch.first.c_str());
640 branch->SetAttribute(
"ReadCount", int64_t(iBranch.second));
642 ost << printer.CStr();
643 printer.ClearBuffer();
645 ost <<
"</ReadBranches>\n";
646 if (!
impl_->readBranchesSecSource_.empty()) {
647 ost <<
"<SecondarySourceReadBranches>\n";
648 for (
auto const& iBranch :
impl_->readBranchesSecSource_) {
649 tinyxml2::XMLElement*
branch =
doc.NewElement(
"Branch");
650 branch->SetAttribute(
"Name", iBranch.first.c_str());
651 branch->SetAttribute(
"ReadCount", int64_t(iBranch.second.value().load()));
653 ost << printer.CStr();
654 printer.ClearBuffer();
656 ost <<
"</SecondarySourceReadBranches>\n";
665 std::set<std::string>
const& clonedBranches =
666 impl_->inputFiles_.at(
impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
667 if (clonedBranches.find(
branchName) == clonedBranches.end()) {
678 std::set<std::string>& clonedBranches =
679 impl_->inputFiles_.at(
impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
680 for (std::set<std::string>::const_iterator
it = fastClonedBranches.begin(), itEnd = fastClonedBranches.end();
683 if (clonedBranches.insert(*it).second) {
690 tinyxml2::XMLDocument
doc;
695 msg <<
"<RandomServiceStateFile>\n" 697 <<
"</RandomServiceStateFile>\n";
704 std::map<std::string, std::string>
const&
metrics) {
707 msg <<
"<PerformanceReport>\n" 708 <<
" <PerformanceSummary Metric=\"" << metricClass <<
"\">\n";
710 typedef std::map<std::string, std::string>::const_iterator const_iterator;
711 for (const_iterator iter =
metrics.begin(), iterEnd =
metrics.end(); iter != iterEnd; ++iter) {
712 msg <<
" <Metric Name=\"" << iter->first <<
"\" " 713 <<
"Value=\"" << iter->second <<
"\"/>\n";
716 msg <<
" </PerformanceSummary>\n" 717 <<
"</PerformanceReport>\n";
724 std::map<std::string, std::string>
const&
metrics) {
727 msg <<
"<PerformanceReport>\n" 728 <<
" <PerformanceModule Metric=\"" << metricClass <<
"\" " 731 typedef std::map<std::string, std::string>::const_iterator const_iterator;
732 for (const_iterator iter =
metrics.begin(), iterEnd =
metrics.end(); iter != iterEnd; ++iter) {
733 msg <<
" <Metric Name=\"" << iter->first <<
"\" " 734 <<
"Value=\"" << iter->second <<
"\"/>\n";
737 msg <<
" </PerformanceModule>\n" 738 <<
"</PerformanceReport>\n";
744 std::ostringstream
msg;
746 tinyxml2::XMLDocument
doc;
747 for (
auto const&
f :
impl_->outputFiles_) {
751 msg <<
"\n<LumiSections>";
753 typedef std::vector<JobReport::Token>::iterator iterator;
754 for (
auto const& iInput :
f.contributingInputs) {
755 auto const& inpFile =
impl_->inputFiles_[iInput];
757 msg <<
"\n <LFN>" <<
doc.NewText(inpFile.logicalFileName.c_str())->
Value() <<
"</LFN>";
758 msg <<
"\n <PFN>" <<
doc.NewText(inpFile.physicalFileName.c_str())->
Value() <<
"</PFN>";
759 msg <<
"\n <FastCopying>" <<
findOrDefault(
f.fastCopyingInputs, inpFile.physicalFileName) <<
"</FastCopying>";
761 doc.DeleteChildren();
763 msg <<
"\n</Inputs>";
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
void associateRun(JobReport::Token token, unsigned int runNumber)
void reportMemoryInfo(std::vector< std::string > const &memoryData)
void reportInputRunNumber(unsigned int run)
void eventReadFromFile(InputType inputType, Token fileToken)
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
static constexpr std::string_view kJobReportEndElement
unsigned long long EventNumber_t
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
void temporarilyCloseXML()
void reportRunNumber(JobReport::Token token, unsigned int run)
void reportRandomStateFile(std::string const &name)
S & print(S &os, JobReport::InputFile const &f)
edm::propagate_const< std::unique_ptr< JobReportImpl > > impl_
static constexpr int kMinSizeOfComment
Token inputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &inputType, std::string const &inputSourceClassName, std::string const &moduleLabel, std::string const &guid, std::vector< std::string > const &branchNames)
std::vector< InputFile > inputFiles_
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
void reportSkippedEvent(RunNumber_t run, EventNumber_t event)
void insertInputForOutputs(InputType inputType, Token t)
void writeInputFile(InputFile const &f)
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
reco::JetExtendedAssociation::JetExtendedData Value
Token outputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &outputModuleClassName, std::string const &moduleLabel, std::string const &guid, std::string const &dataType, std::string const &branchHash, std::vector< std::string > const &branchNames)
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
void associateInputRun(unsigned int runNumber)
S & formatFile(T const &f, S &os)
void reportReadBranch(InputType inputType, std::string const &branchName)
Inform the job report that a branch has been read.
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
void reportShutdownSignal()
Value const & findOrDefault(std::map< Key, Value > const &m, Key const &k, Value const &defaultValue)
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
void reportMessageInfo(std::map< std::string, double > const &messageData)
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection, unsigned long nEvents)
std::string dumpFiles(void)
debug/test util
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
void outputFileClosed(Token fileToken)
void writeOutputFile(OutputFile const &f)
InputFile & getInputFileForToken(InputType inputType, Token t)
void reportDataType(Token fileToken, std::string const &dataType)
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
void inputFileClosed(InputType inputType, Token fileToken)
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
void reportReadBranches()
OutputFile & getOutputFileForToken(Token t)
oneapi::tbb::concurrent_vector< InputFile > inputFilesSecSource_
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)