CMS 3D CMS Logo

JobReport.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 //
5 // 10/23/07 mf In an attempt to get clues about (or ene) the
6 // does-not-output-branches behavior, changed the
7 // generic os<< lines in JobReport::JobReportImpl::writeOutputFile
8 // to direct use of LogInfo.
9 //
10 // 4/8/08 mf Encase the logdesc for in <CDATA> ... </CDATA>
11 //
12 // 6/19/08 mf reportMessageInfo()
13 //
14 // 24 June 2008 ewv Correct format for CDATA and for second instance of reportError
15 
16 //
17 // Original Author: Marc Paterno
18 //
19 
23 
24 // The part of tinyxml used in JobReport was reviewed and
25 // determined to be threadsafe.
26 #include "tinyxml2.h"
27 #include <fstream>
28 #include <iomanip>
29 #include <ostream>
30 #include <sstream>
31 
32 namespace edm {
33  /*
34  * Note that output formatting is spattered across these classes
35  * If something outside these classes requires access to the
36  * same formatting then we need to refactor it into a common library
37  */
38 
39  template <typename S, typename T>
40  S& formatFile(T const& f, S& os) {
41  tinyxml2::XMLDocument doc;
42  if(f.fileHasBeenClosed) {
43  os << "\n<State Value=\"closed\"/>";
44  } else {
45  os << "\n<State Value=\"open\"/>";
46  }
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>";
52  os << "\n<Branches>";
53  for(auto const& branch : f.branchNames) {
54  os << "\n <Branch>" << doc.NewText(branch.c_str())->Value() << "</Branch>";
55  doc.DeleteChildren();
56  }
57  os << "\n</Branches>";
58  return os;
59  }
60  /*
61  * Note that output formatting is spattered across these classes
62  * If something outside these classes requires access to the
63  * same formatting then we need to refactor it into a common library
64  */
65  template <typename S>
66  S& print(S& os, JobReport::InputFile const& f) {
67  tinyxml2::XMLDocument doc;
68  os << "\n<InputFile>";
69  formatFile(f, os);
70  os << "\n<InputType>" << f.inputType << "</InputType>";
71  os << "\n<InputSourceClass>" << doc.NewText(f.inputSourceClassName.c_str())->Value()
72  << "</InputSourceClass>";
73  os << "\n<EventsRead>" << f.numEventsRead << "</EventsRead>";
74  return os;
75  }
76 
77  template <typename S>
78  S& print(S& os, JobReport::OutputFile const& f) {
79  tinyxml2::XMLDocument doc;
80  formatFile(f, os);
81  os << "\n<OutputModuleClass>"
82  << doc.NewText(f.outputModuleClassName.c_str())->Value()
83  << "</OutputModuleClass>";
84  os << "\n<TotalEvents>"
85  << f.numEventsWritten
86  << "</TotalEvents>\n";
87  os << "\n<DataType>"
88  << doc.NewText(f.dataType.c_str())->Value()
89  << "</DataType>\n";
90  os << "\n<BranchHash>"
91  << doc.NewText(f.branchHash.c_str())->Value()
92  << "</BranchHash>\n";
93  return os;
94  }
95 
96  template <typename S>
97  S& print(S& os,
98  JobReport::RunReport const& rep) {
99  os << "\n<Run ID=\""
100  << rep.runNumber
101  << "\">\n";
102 
103  for(auto const& il : rep.lumiSectionsToNEvents) {
104  if(std::numeric_limits<unsigned long>::max() == il.second) {
105  os << " <LumiSection ID=\"" << il.first << "\"/>\n";
106 
107  } else {
108  os << " <LumiSection ID=\"" << il.first << "\" NEvents=\""<<il.second<< "\"/>\n";
109  }
110  }
111  os << "</Run>\n";
112  return os;
113  }
114 
115  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f) {
116  return print(os,f);
117  }
118  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f) {
119  return print(os,f);
120  }
121  std::ostream& operator<< (std::ostream& os, JobReport::RunReport const& f) {
122  return print(os,f);
123  }
124 
126 
127  InputFile* inputFile = nullptr;
128  if(inputType == InputType::SecondarySource) {
129  if(t >= inputFilesSecSource_.size()) {
131  << "Access reported for secondary source input file with token "
132  << t
133  << " but no matching input file is found\n";
134  }
135  inputFile = &inputFilesSecSource_[t];
136  } else {
137  if(t >= inputFiles_.size()) {
139  << "Access reported for input file with token "
140  << t
141  << " but no matching input file is found\n";
142  }
143  inputFile = &inputFiles_[t];
144  }
145  if(inputFile->fileHasBeenClosed) {
147  << "Access reported for input file with token "
148  << t
149  << " after this file has been closed.\n"
150  << "File record follows:\n"
151  << *inputFile
152  << '\n';
153  }
154  return *inputFile;
155  }
156 
158  if(t >= outputFiles_.size()) {
160  << "Access reported for output file with token "
161  << t
162  << " but no matching output file is found\n";
163  }
164  if(outputFiles_[t].fileHasBeenClosed) {
166  << "Access reported for output file with token "
167  << t
168  << " after this file has been closed.\n"
169  << "File record follows:\n"
170  << outputFiles_[t]
171  << '\n';
172  }
173  return outputFiles_[t];
174  }
175 
176  /*
177  * Add the input file token provided to every output
178  * file currently available.
179  * Used whenever a new input file is opened, it's token
180  * is added to all open output files as a contributor
181  */
183  for(auto & outputFile : outputFiles_) {
184  if(!outputFile.fileHasBeenClosed) {
185  if(inputType == InputType::SecondarySource) {
186  outputFile.contributingInputsSecSource.push_back(t);
187  } else {
188  outputFile.contributingInputs.push_back(t);
189  }
190  }
191  }
192  }
193 
194  /*
195  * Write anJobReport::InputFile object to the Logger
196  * Generate XML string forJobReport::InputFile instance and dispatch to
197  * job report via MessageLogger
198  */
200  if(ost_) {
201  *ost_ << f ;
202  *ost_ << "\n<Runs>";
203  for(auto const& runReport : f.runReports) {
204  *ost_ << runReport.second;
205  }
206  *ost_ << "\n</Runs>\n";
207  *ost_ << "</InputFile>\n";
208  *ost_ << std::flush;
209  }
210  }
211 
212  /*
213  * Write an OutputFile object to the Logger
214  * Generate an XML string for the OutputFile provided and
215  * dispatch it to the logger
216  * Contributing input tokens are resolved to the input LFN and PFN
217  *
218  * TODO: We have not yet addressed the issue where we cleanup not
219  * contributing input files.
220  * Also, it is possible to get fake input to output file mappings
221  * if an input file is open already when a new output file is opened
222  * but the input gets closed without contributing events to the
223  * output file due to filtering etc.
224  *
225  */
227  tinyxml2::XMLDocument doc;
228  if(ost_) {
229  *ost_ << "\n<File>";
230  *ost_ << f;
231 
232  *ost_ << "\n<Runs>";
233  for(auto const& runReport : f.runReports) {
234  *ost_ << runReport.second;
235  }
236  *ost_ << "\n</Runs>\n";
237 
238  *ost_ << "\n<Inputs>";
239  for(auto token : f.contributingInputs) {
240  JobReport::InputFile inpFile = inputFiles_.at(token);
241  *ost_ << "\n<Input>";
242  *ost_ << "\n <LFN>" << doc.NewText(inpFile.logicalFileName.c_str())->Value() << "</LFN>";
243  *ost_ << "\n <PFN>" << doc.NewText(inpFile.physicalFileName.c_str())->Value() << "</PFN>";
244  *ost_ << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
245  *ost_ << "\n</Input>";
246  doc.DeleteChildren();
247  }
248  for(auto token : f.contributingInputsSecSource) {
249  JobReport::InputFile inpFile = inputFilesSecSource_.at(token);
250  *ost_ << "\n<Input>";
251  *ost_ << "\n <LFN>" << doc.NewText(inpFile.logicalFileName.c_str())->Value() << "</LFN>";
252  *ost_ << "\n <PFN>" << doc.NewText(inpFile.physicalFileName.c_str())->Value() << "</PFN>";
253  *ost_ << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
254  *ost_ << "\n</Input>";
255  doc.DeleteChildren();
256  }
257  *ost_ << "\n</Inputs>";
258  *ost_ << "\n</File>\n";
259  }
260  }
261 
262  /*
263  * Flush all open files to logger in event of a problem.
264  * Called from JobReport dtor to flush any remaining open files
265  */
267  for(auto const& inputFile : inputFiles_) {
268  if(!(inputFile.fileHasBeenClosed)) {
270  }
271  }
272  for(auto const& inputFile : inputFilesSecSource_) {
273  if(!(inputFile.fileHasBeenClosed)) {
275  }
276  }
277  for(auto const& outputFile : outputFiles_) {
278  if(!(outputFile.fileHasBeenClosed)) {
280  }
281  }
282  }
283 
285  auto& theMap = outputFiles_.at(token).runReports;
286  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
287  if(iter == theMap.end() || runNumber < iter->first) { // not found
288  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {}}); // insert it
289  }
290  }
291 
293  for(auto& inputFile : inputFiles_) {
294  if(!inputFile.fileHasBeenClosed) {
295  std::map<RunNumber, RunReport>& theMap = inputFile.runReports;
296  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
297  if(iter == theMap.end() || runNumber < iter->first) { // not found
298  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {}}); // insert it
299  }
300  }
301  }
302  }
303 
304  void JobReport::JobReportImpl::associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSect, unsigned long nEvents) {
305  auto& theMap = outputFiles_.at(token).runReports;
306  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
307  if(iter == theMap.end() || runNumber < iter->first) { // not found
308  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{{lumiSect,nEvents}}}}); // insert it
309  } else {
310  iter->second.lumiSectionsToNEvents[lumiSect]+=nEvents;
311  }
312  }
313 
314  void JobReport::JobReportImpl::associateInputLumiSection(unsigned int runNumber, unsigned int lumiSect) {
315  for(auto& inputFile : inputFiles_) {
316  if(!inputFile.fileHasBeenClosed) {
317  std::map<RunNumber, RunReport>& theMap = inputFile.runReports;
318  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
319  if(iter == theMap.end() || runNumber < iter->first) { // not found
320  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{lumiSect,std::numeric_limits<unsigned long>::max()}}}); // insert it
321  } else {
322  iter->second.lumiSectionsToNEvents[lumiSect]=std::numeric_limits<unsigned long>::max();
323  }
324  }
325  }
326  }
327 
329  impl_->flushFiles();
330  if(impl_->ost_) {
331  *(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
332  }
333  }
334 
336  impl_(new JobReportImpl(nullptr)) {
337  }
338 
339  JobReport::JobReport(std::ostream* iOstream) : impl_(new JobReportImpl(iOstream)) {
340  if(impl_->ost_) {
341  *(impl_->ost_) << "<FrameworkJobReport>\n";
342  }
343  }
344 
346  JobReport::inputFileOpened(std::string const& physicalFileName,
347  std::string const& logicalFileName,
348  std::string const& catalog,
349  std::string const& inputType,
350  std::string const& inputSourceClassName,
351  std::string const& moduleLabel,
352  std::string const& guid,
353  std::vector<std::string> const& branchNames) {
354 
355  InputType theInputType = InputType::Primary;
356  InputFile* newFile = nullptr;
357  JobReport::Token newToken = 0;
358 
359  if (inputType == "mixingFiles") {
360  theInputType = InputType::SecondarySource;
361  auto itr = impl_->inputFilesSecSource_.push_back(InputFile());
362  newFile = &(*itr);
363  newToken = itr - impl_->inputFilesSecSource_.begin();
364  } else {
365  if (inputType == "secondaryFiles") {
366  theInputType = InputType::SecondaryFile;
367  }
368  impl_->inputFiles_.emplace_back();
369  newFile = &impl_->inputFiles_.back();
370  newToken = impl_->inputFiles_.size() - 1;
371  }
372 
373  if(theInputType == InputType::Primary) {
374  impl_->lastOpenedPrimaryInputFile_ = impl_->inputFiles_.size() - 1;
375  }
376  newFile->logicalFileName = logicalFileName;
377  newFile->physicalFileName = physicalFileName;
378  newFile->catalog = catalog;
379  newFile->inputType = inputType;
380  newFile->inputSourceClassName = inputSourceClassName;
381  newFile->moduleLabel = moduleLabel;
382  newFile->guid = guid;
383  newFile->numEventsRead = 0;
384  newFile->branchNames = branchNames;
385  newFile->fileHasBeenClosed = false;
386 
387  // Add the new input file token to all output files
388  // currently open.
389  impl_->insertInputForOutputs(theInputType, newToken);
390  return newToken;
391  }
392 
393  void
395  JobReport::InputFile& f = impl_->getInputFileForToken(inputType, fileToken);
396  ++f.numEventsRead;
397  }
398 
399  void
401  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
402  f.dataType = dataType;
403  }
404 
405  void
407  JobReport::InputFile& f = impl_->getInputFileForToken(inputType, fileToken);
408  f.fileHasBeenClosed = true;
409  if(inputType == InputType::Primary) {
410  impl_->writeInputFile(f);
411  } else {
412  {
413  std::lock_guard<std::mutex> lock(write_mutex);
414  impl_->writeInputFile(f);
415  }
416  }
417  }
418 
420  JobReport::outputFileOpened(std::string const& physicalFileName,
421  std::string const& logicalFileName,
422  std::string const& catalog,
423  std::string const& outputModuleClassName,
424  std::string const& moduleLabel,
425  std::string const& guid,
426  std::string const& dataType,
427  std::string const& branchHash,
428  std::vector<std::string> const& branchNames) {
429  auto itr = impl_->outputFiles_.emplace_back();
430  JobReport::OutputFile& r = *itr;
431 
432  r.logicalFileName = logicalFileName;
433  r.physicalFileName = physicalFileName;
434  r.catalog = catalog;
435  r.outputModuleClassName = outputModuleClassName;
436  r.moduleLabel = moduleLabel;
437  r.guid = guid;
438  r.dataType = dataType;
439  r.branchHash = branchHash;
440  r.numEventsWritten = 0;
441  r.branchNames = branchNames;
442  r.fileHasBeenClosed = false;
443  //
444  // Init list of contributors to list of open input file Tokens
445  //
446  for(std::vector<Token>::size_type i = 0, iEnd = impl_->inputFiles_.size(); i < iEnd; ++i) {
447  if(!impl_->inputFiles_[i].fileHasBeenClosed) {
448  r.contributingInputs.push_back(i);
449  }
450  }
451  for(tbb::concurrent_vector<Token>::size_type i = 0, iEnd = impl_->inputFilesSecSource_.size(); i < iEnd; ++i) {
452  if(!impl_->inputFilesSecSource_[i].fileHasBeenClosed) {
453  r.contributingInputsSecSource.push_back(i);
454  }
455  }
456  return itr - impl_->outputFiles_.begin();
457  }
458 
459  void
461  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
462  ++f.numEventsWritten;
463  }
464 
465  void
467  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
468  f.fileHasBeenClosed = true;
469  impl_->writeOutputFile(f);
470  }
471 
472  void
474  if(impl_->ost_) {
475  std::ostream& msg = *(impl_->ost_);
476  {
477  std::lock_guard<std::mutex> lock(write_mutex);
478  msg << "<SkippedEvent Run=\"" << run << "\"";
479  msg << " Event=\"" << event << "\" />\n";
480  msg << std::flush;
481  }
482  }
483  }
484 
485  void
487  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
488  f.fastCopyingInputs.insert(std::make_pair(inputFileName, fastCopying));
489  }
490 
491  void
492  JobReport::reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents) {
493  impl_->associateLumiSection(token, run, lumiSectId,nEvents);
494  }
495 
496  void
497  JobReport::reportInputLumiSection(unsigned int run, unsigned int lumiSectId) {
498  impl_->associateInputLumiSection(run, lumiSectId);
499  }
500 
501  void
503  impl_->associateRun(token, run);
504  }
505 
506  void
508  impl_->associateInputRun(run);
509  }
510 
511  void
512  JobReport::reportAnalysisFile(std::string const& fileName, std::map<std::string, std::string> const& fileData) {
513  tinyxml2::XMLDocument doc;
514  if(impl_->ost_) {
515  std::ostream& msg = *(impl_->ost_);
516  {
517  std::lock_guard<std::mutex> lock(write_mutex);
518  msg << "<AnalysisFile>\n"
519  << " <FileName>" << doc.NewText(fileName.c_str())->Value() << "</FileName>\n";
520 
521  typedef std::map<std::string, std::string>::const_iterator const_iterator;
522  for(const_iterator pos = fileData.begin(), posEnd = fileData.end(); pos != posEnd; ++pos) {
523  msg << " <" << pos->first
524  << " Value=\"" << pos->second << "\" />"
525  << "\n";
526  }
527  msg << "</AnalysisFile>\n";
528  msg << std::flush;
529  }
530  }
531  }
532 
533  void
535  std::string const& longDesc,
536  int const& exitCode) {
537  if(impl_->ost_) {
538  {
539  std::lock_guard<std::mutex> lock(write_mutex);
540  std::ostream& msg = *(impl_->ost_);
541  msg << "<FrameworkError ExitStatus=\""<< exitCode
542  << "\" Type=\"" << shortDesc << "\" >\n";
543  msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
544  msg << "</FrameworkError>\n";
545  msg << std::flush;
546  }
547  }
548  }
549 
550  void
552  std::string const& lfn) {
553  if(impl_->ost_) {
554  std::ostream& msg = *(impl_->ost_);
555  tinyxml2::XMLDocument doc;
556  tinyxml2::XMLPrinter printer;
557  tinyxml2::XMLElement * skipped = doc.NewElement("SkippedFile");
558  skipped->SetAttribute("Pfn", pfn.c_str());
559  skipped->SetAttribute("Lfn", lfn.c_str());
560  {
561  std::lock_guard<std::mutex> lock(write_mutex);
562  skipped->Accept(&printer);
563  msg << printer.CStr() ;
564  msg << std::flush;
565  }
566  }
567  }
568 
569  void
571  if(impl_->ost_) {
572  std::ostream& msg = *(impl_->ost_);
573  tinyxml2::XMLDocument doc;
574  tinyxml2::XMLPrinter printer;
575  tinyxml2::XMLElement * fallback = doc.NewElement("FallbackAttempt");
576  fallback->SetAttribute("Pfn", pfn.c_str());
577  fallback->SetAttribute("Lfn", lfn.c_str());
578  {
579  std::lock_guard<std::mutex> lock(write_mutex);
580  fallback->Accept(&printer);
581  msg << printer.CStr() ;
582  msg << "<![CDATA[\n" << err << "\n]]>\n";
583  msg << std::flush;
584  }
585  }
586  }
587 
588  void
589  JobReport::reportMemoryInfo(std::vector<std::string> const& memoryData) {
590  if(impl_->ost_) {
591  std::ostream& msg = *(impl_->ost_);
592  msg << "<MemoryService>\n";
593 
594  typedef std::vector<std::string>::const_iterator const_iterator;
595  for(const_iterator pos = memoryData.begin(), posEnd = memoryData.end(); pos != posEnd; ++pos) {
596  msg << *pos << "\n";
597  }
598  msg << "</MemoryService>\n";
599  msg << std::flush;
600  }
601  }
602 
603  void
604  JobReport::reportMessageInfo(std::map<std::string, double> const& messageData) {
605  if(impl_->ost_) {
606  std::ostream& msg = *(impl_->ost_);
607  msg << "<MessageSummary>\n";
608  typedef std::map<std::string, double>::const_iterator const_iterator;
609  for(const_iterator pos = messageData.begin(), posEnd = messageData.end(); pos != posEnd; ++pos) {
610  msg << " <" << pos->first
611  << " Value=\"" << pos->second << "\" />"
612  << "\n";
613  }
614  msg << "</MessageSummary>\n";
615  msg << std::flush;
616  }
617  }
618 
619  void
621  if(impl_->printedReadBranches_) return;
622  impl_->printedReadBranches_ = true;
623  if(impl_->ost_) {
624  std::ostream& ost = *(impl_->ost_);
625  ost << "<ReadBranches>\n";
626  tinyxml2::XMLDocument doc;
627  tinyxml2::XMLPrinter printer;
628  for(auto const& iBranch : impl_->readBranches_) {
629  tinyxml2::XMLElement * branch = doc.NewElement("Branch");
630  branch->SetAttribute("Name", iBranch.first.c_str());
631  branch->SetAttribute("ReadCount", int64_t(iBranch.second));
632  branch->Accept(&printer);
633  ost << printer.CStr();
634  printer.ClearBuffer();
635  }
636  for(auto const& iBranch : impl_->readBranchesSecFile_) {
637  tinyxml2::XMLElement * branch = doc.NewElement("Branch");
638  branch->SetAttribute("Name", iBranch.first.c_str());
639  branch->SetAttribute("ReadCount", int64_t(iBranch.second));
640  branch->Accept(&printer);
641  ost << printer.CStr();
642  printer.ClearBuffer();
643  }
644  ost << "</ReadBranches>\n";
645  if(!impl_->readBranchesSecSource_.empty()) {
646  ost << "<SecondarySourceReadBranches>\n";
647  for(auto const& iBranch : impl_->readBranchesSecSource_) {
648  tinyxml2::XMLElement * branch = doc.NewElement("Branch");
649  branch->SetAttribute("Name", iBranch.first.c_str());
650  branch->SetAttribute("ReadCount", int64_t(iBranch.second.value().load()));
651  branch->Accept(&printer);
652  ost << printer.CStr();
653  printer.ClearBuffer();
654  }
655  ost << "</SecondarySourceReadBranches>\n";
656  }
657  ost << std::flush;
658  }
659  }
660 
661  void
663  if(inputType == InputType::Primary) {
664  // Fast cloned branches have already been reported.
665  std::set<std::string> const& clonedBranches = impl_->inputFiles_.at(impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
666  if(clonedBranches.find(branchName) == clonedBranches.end()) {
667  ++impl_->readBranches_[branchName];
668  }
669  } else if (inputType == InputType::SecondaryFile) {
670  ++impl_->readBranchesSecFile_[branchName];
671  } else if (inputType == InputType::SecondarySource) {
672  ++impl_->readBranchesSecSource_[branchName].value();
673  }
674  }
675 
676  void
677  JobReport::reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents) {
678  std::set<std::string>& clonedBranches = impl_->inputFiles_.at(impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
679  for(std::set<std::string>::const_iterator it = fastClonedBranches.begin(), itEnd = fastClonedBranches.end();
680  it != itEnd; ++it) {
681  if(clonedBranches.insert(*it).second) {
682  impl_->readBranches_[*it] += nEvents;
683  }
684  }
685  }
686 
688  tinyxml2::XMLDocument doc;
689  if(impl_->ost_) {
690  std::ostream& msg = *(impl_->ost_);
691  {
692  std::lock_guard<std::mutex> lock(write_mutex);
693  msg << "<RandomServiceStateFile>\n"
694  << doc.NewText(name.c_str())->Value() << "\n"
695  << "</RandomServiceStateFile>\n";
696  msg << std::flush;
697  }
698  }
699  }
700 
701  void
703  std::map<std::string, std::string> const& metrics) {
704  if(impl_->ost_) {
705  std::ostream& msg = *(impl_->ost_);
706  msg << "<PerformanceReport>\n"
707  << " <PerformanceSummary Metric=\"" << metricClass << "\">\n";
708 
709  typedef std::map<std::string, std::string>::const_iterator const_iterator;
710  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
711  msg << " <Metric Name=\"" << iter->first << "\" "
712  << "Value=\"" << iter->second << "\"/>\n";
713  }
714 
715  msg << " </PerformanceSummary>\n"
716  << "</PerformanceReport>\n";
717  msg << std::flush;
718  //LogInfo("FwkJob") << msg.str();
719  }
720  }
721 
722  void
724  std::string const& moduleName,
725  std::map<std::string, std::string> const& metrics) {
726  if(impl_->ost_) {
727  std::ostream& msg = *(impl_->ost_);
728  msg << "<PerformanceReport>\n"
729  << " <PerformanceModule Metric=\"" << metricClass << "\" "
730  << " Module=\"" << moduleName << "\" >\n";
731 
732  typedef std::map<std::string, std::string>::const_iterator const_iterator;
733  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
734  msg << " <Metric Name=\"" << iter->first << "\" "
735  << "Value=\"" << iter->second << "\"/>\n";
736  }
737 
738  msg << " </PerformanceModule>\n"
739  << "</PerformanceReport>\n";
740  msg << std::flush;
741  //LogInfo("FwkJob") << msg.str();
742  }
743  }
744 
747  std::ostringstream msg;
748 
749  tinyxml2::XMLDocument doc;
750  for(auto const& f :impl_->outputFiles_) {
751 
752  msg << "\n<File>";
753  msg << f;
754 
755  msg << "\n<LumiSections>";
756  msg << "\n<Inputs>";
757  typedef std::vector<JobReport::Token>::iterator iterator;
758  for(auto const& iInput : f.contributingInputs) {
759  auto const& inpFile = impl_->inputFiles_[iInput];
760  msg << "\n<Input>";
761  msg << "\n <LFN>" << doc.NewText(inpFile.logicalFileName.c_str())->Value() << "</LFN>";
762  msg << "\n <PFN>" << doc.NewText(inpFile.physicalFileName.c_str())->Value() << "</PFN>";
763  msg << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
764  msg << "\n</Input>";
765  doc.DeleteChildren();
766  }
767  msg << "\n</Inputs>";
768  msg << "\n</File>";
769 
770  }
771  return msg.str();
772  }
773 
774 } //namspace edm
InputType
Definition: InputType.h:5
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:551
std::string inputSourceClassName
Definition: JobReport.h:130
std::string outputModuleClassName
Definition: JobReport.h:156
std::string physicalFileName
Definition: JobReport.h:154
void associateRun(JobReport::Token token, unsigned int runNumber)
Definition: JobReport.cc:284
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:589
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:507
void eventReadFromFile(InputType inputType, Token fileToken)
Definition: JobReport.cc:394
std::mutex write_mutex
Definition: JobReport.h:435
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:570
std::string logicalFileName
Definition: JobReport.h:126
unsigned long long EventNumber_t
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:165
std::string logicalFileName
Definition: JobReport.h:153
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:486
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:502
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:687
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
#define nullptr
uint16_t size_type
edm::propagate_const< std::unique_ptr< JobReportImpl > > impl_
Definition: JobReport.h:434
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)
Definition: JobReport.cc:346
std::vector< InputFile > inputFiles_
Definition: JobReport.h:251
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:723
std::vector< Token > contributingInputs
Definition: JobReport.h:163
std::string physicalFileName
Definition: JobReport.h:127
void reportSkippedEvent(RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:473
void insertInputForOutputs(InputType inputType, Token t)
Definition: JobReport.cc:182
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::size_t numEventsRead
Definition: JobReport.h:133
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:199
StringVector branchNames
Definition: JobReport.h:162
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:497
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:702
reco::JetExtendedAssociation::JetExtendedData Value
double f[11][100]
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)
Definition: JobReport.cc:420
edm::propagate_const< std::ostream * > ost_
Definition: JobReport.h:259
rep
Definition: cuy.py:1190
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
Definition: JobReport.cc:534
std::size_t Token
Definition: JobReport.h:107
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:292
S & formatFile(T const &f, S &os)
Definition: JobReport.cc:40
void reportReadBranch(InputType inputType, std::string const &branchName)
Inform the job report that a branch has been read.
Definition: JobReport.cc:662
std::size_t numEventsWritten
Definition: JobReport.h:161
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:677
Value const & findOrDefault(std::map< Key, Value > const &m, Key const &k, Value const &defaultValue)
Definition: Map.h:28
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:460
tbb::concurrent_vector< InputFile > inputFilesSecSource_
Definition: JobReport.h:252
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:604
tuple msg
Definition: mps_check.py:278
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection, unsigned long nEvents)
Definition: JobReport.cc:304
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:746
HLT enums.
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:512
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:466
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:226
std::map< unsigned int, unsigned long > lumiSectionsToNEvents
Definition: JobReport.h:111
unsigned int RunNumber_t
InputFile & getInputFileForToken(InputType inputType, Token t)
Definition: JobReport.cc:125
tbb::concurrent_vector< OutputFile > outputFiles_
Definition: JobReport.h:253
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:400
UInt_t nEvents
Definition: hcalCalib.cc:42
tbb::concurrent_vector< Token > contributingInputsSecSource
Definition: JobReport.h:164
StringVector branchNames
Definition: JobReport.h:134
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
void inputFileClosed(InputType inputType, Token fileToken)
Definition: JobReport.cc:406
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:314
Definition: event.py:1
void reportReadBranches()
Definition: JobReport.cc:620
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:157
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
Definition: JobReport.cc:492