CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.
27 
28 #include <fstream>
29 #include <iomanip>
30 #include <ostream>
31 #include <sstream>
32 
33 namespace edm {
34  /*
35  * Note that output formatting is spattered across these classes
36  * If something outside these classes requires access to the
37  * same formatting then we need to refactor it into a common library
38  */
39  template <typename S, typename T>
40  S& formatFile(T const& f, S& os) {
41 
42  if(f.fileHasBeenClosed) {
43  os << "\n<State Value=\"closed\"/>";
44  } else {
45  os << "\n<State Value=\"open\"/>";
46  }
47 
48  os << "\n<LFN>" << TiXmlText(f.logicalFileName) << "</LFN>";
49  os << "\n<PFN>" << TiXmlText(f.physicalFileName) << "</PFN>";
50  os << "\n<Catalog>" << TiXmlText(f.catalog) << "</Catalog>";
51  os << "\n<ModuleLabel>" << TiXmlText(f.moduleLabel) << "</ModuleLabel>";
52  os << "\n<GUID>" << f.guid << "</GUID>";
53  os << "\n<Branches>";
54  for(auto const& branch : f.branchNames) {
55  os << "\n <Branch>" << TiXmlText(branch) << "</Branch>";
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 
68  os << "\n<InputFile>";
69  formatFile(f, os);
70  os << "\n<InputType>" << f.inputType << "</InputType>";
71  os << "\n<InputSourceClass>" << TiXmlText(f.inputSourceClassName)
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  formatFile(f, os);
80  os << "\n<OutputModuleClass>"
82  << "</OutputModuleClass>";
83  os << "\n<TotalEvents>"
84  << f.numEventsWritten
85  << "</TotalEvents>\n";
86  os << "\n<DataType>"
87  << TiXmlText(f.dataType)
88  << "</DataType>\n";
89  os << "\n<BranchHash>"
90  << TiXmlText(f.branchHash)
91  << "</BranchHash>\n";
92  return os;
93  }
94 
95  template <typename S>
96  S& print(S& os,
97  JobReport::RunReport const& rep) {
98  os << "\n<Run ID=\""
99  << rep.runNumber
100  << "\">\n";
101 
102  for(auto const& il : rep.lumiSectionsToNEvents) {
103  if(std::numeric_limits<unsigned long>::max() == il.second) {
104  os << " <LumiSection ID=\"" << il.first << "\"/>\n";
105 
106  } else {
107  os << " <LumiSection ID=\"" << il.first << "\" NEvents=\""<<il.second<< "\"/>\n";
108  }
109  }
110  os << "</Run>\n";
111  return os;
112  }
113 
114  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f) {
115  return print(os,f);
116  }
117  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f) {
118  return print(os,f);
119  }
120  std::ostream& operator<< (std::ostream& os, JobReport::RunReport const& f) {
121  return print(os,f);
122  }
123 
125 
126  InputFile* inputFile = nullptr;
127  if(inputType == InputType::SecondarySource) {
128  if(t >= inputFilesSecSource_.size()) {
130  << "Access reported for secondary source input file with token "
131  << t
132  << " but no matching input file is found\n";
133  }
134  inputFile = &inputFilesSecSource_[t];
135  } else {
136  if(t >= inputFiles_.size()) {
138  << "Access reported for input file with token "
139  << t
140  << " but no matching input file is found\n";
141  }
142  inputFile = &inputFiles_[t];
143  }
144  if(inputFile->fileHasBeenClosed) {
146  << "Access reported for input file with token "
147  << t
148  << " after this file has been closed.\n"
149  << "File record follows:\n"
150  << *inputFile
151  << '\n';
152  }
153  return *inputFile;
154  }
155 
157  if(t >= outputFiles_.size()) {
159  << "Access reported for output file with token "
160  << t
161  << " but no matching output file is found\n";
162  }
163  if(outputFiles_[t].fileHasBeenClosed) {
165  << "Access reported for output file with token "
166  << t
167  << " after this file has been closed.\n"
168  << "File record follows:\n"
169  << outputFiles_[t]
170  << '\n';
171  }
172  return outputFiles_[t];
173  }
174 
175  /*
176  * Add the input file token provided to every output
177  * file currently available.
178  * Used whenever a new input file is opened, it's token
179  * is added to all open output files as a contributor
180  */
182  for(auto & outputFile : outputFiles_) {
183  if(!outputFile.fileHasBeenClosed) {
184  if(inputType == InputType::SecondarySource) {
185  outputFile.contributingInputsSecSource.push_back(t);
186  } else {
187  outputFile.contributingInputs.push_back(t);
188  }
189  }
190  }
191  }
192 
193  /*
194  * Write anJobReport::InputFile object to the Logger
195  * Generate XML string forJobReport::InputFile instance and dispatch to
196  * job report via MessageLogger
197  */
199  if(ost_) {
200  *ost_ << f ;
201  *ost_ << "\n<Runs>";
202  for(auto const& runReport : f.runReports) {
203  *ost_ << runReport.second;
204  }
205  *ost_ << "\n</Runs>\n";
206  *ost_ << "</InputFile>\n";
207  *ost_ << std::flush;
208  }
209  }
210 
211  /*
212  * Write an OutputFile object to the Logger
213  * Generate an XML string for the OutputFile provided and
214  * dispatch it to the logger
215  * Contributing input tokens are resolved to the input LFN and PFN
216  *
217  * TODO: We have not yet addressed the issue where we cleanup not
218  * contributing input files.
219  * Also, it is possible to get fake input to output file mappings
220  * if an input file is open already when a new output file is opened
221  * but the input gets closed without contributing events to the
222  * output file due to filtering etc.
223  *
224  */
226  if(ost_) {
227  *ost_ << "\n<File>";
228  *ost_ << f;
229 
230  *ost_ << "\n<Runs>";
231  for(auto const& runReport : f.runReports) {
232  *ost_ << runReport.second;
233  }
234  *ost_ << "\n</Runs>\n";
235 
236  *ost_ << "\n<Inputs>";
237  for(auto token : f.contributingInputs) {
238  JobReport::InputFile inpFile = inputFiles_.at(token);
239  *ost_ << "\n<Input>";
240  *ost_ << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
241  *ost_ << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
242  *ost_ << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
243  *ost_ << "\n</Input>";
244  }
245  for(auto token : f.contributingInputsSecSource) {
246  JobReport::InputFile inpFile = inputFilesSecSource_.at(token);
247  *ost_ << "\n<Input>";
248  *ost_ << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
249  *ost_ << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
250  *ost_ << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
251  *ost_ << "\n</Input>";
252  }
253  *ost_ << "\n</Inputs>";
254  *ost_ << "\n</File>\n";
255  }
256  }
257 
258  /*
259  * Flush all open files to logger in event of a problem.
260  * Called from JobReport dtor to flush any remaining open files
261  */
263  for(auto const& inputFile : inputFiles_) {
264  if(!(inputFile.fileHasBeenClosed)) {
265  writeInputFile(inputFile);
266  }
267  }
268  for(auto const& inputFile : inputFilesSecSource_) {
269  if(!(inputFile.fileHasBeenClosed)) {
270  writeInputFile(inputFile);
271  }
272  }
273  for(auto const& outputFile : outputFiles_) {
274  if(!(outputFile.fileHasBeenClosed)) {
275  writeOutputFile(outputFile);
276  }
277  }
278  }
279 
281  std::map<RunNumber, RunReport>& theMap = outputFiles_.at(token).runReports;
282  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
283  if(iter == theMap.end() || runNumber < iter->first) { // not found
284  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {}}); // insert it
285  }
286  }
287 
289  for(auto& inputFile : inputFiles_) {
290  if(!inputFile.fileHasBeenClosed) {
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) { // not found
294  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {}}); // insert it
295  }
296  }
297  }
298  }
299 
300  void JobReport::JobReportImpl::associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSect, unsigned long nEvents) {
301  std::map<RunNumber, RunReport>& theMap = outputFiles_.at(token).runReports;
302  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
303  if(iter == theMap.end() || runNumber < iter->first) { // not found
304  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{{lumiSect,nEvents}}}}); // insert it
305  } else {
306  iter->second.lumiSectionsToNEvents[lumiSect]+=nEvents;
307  }
308  }
309 
310  void JobReport::JobReportImpl::associateInputLumiSection(unsigned int runNumber, unsigned int lumiSect) {
311  for(auto& inputFile : inputFiles_) {
312  if(!inputFile.fileHasBeenClosed) {
313  std::map<RunNumber, RunReport>& theMap = inputFile.runReports;
314  std::map<RunNumber, RunReport>::iterator iter(theMap.lower_bound(runNumber));
315  if(iter == theMap.end() || runNumber < iter->first) { // not found
316  theMap.emplace_hint(iter, runNumber, JobReport::RunReport{ runNumber, {{lumiSect,std::numeric_limits<unsigned long>::max()}}}); // insert it
317  } else {
318  iter->second.lumiSectionsToNEvents[lumiSect]=std::numeric_limits<unsigned long>::max();
319  }
320  }
321  }
322  }
323 
325  impl_->flushFiles();
326  if(impl_->ost_) {
327  *(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
328  }
329  }
330 
332  impl_(new JobReportImpl(0)) {
333  }
334 
335  JobReport::JobReport(std::ostream* iOstream) : impl_(new JobReportImpl(iOstream)) {
336  if(impl_->ost_) {
337  *(impl_->ost_) << "<FrameworkJobReport>\n";
338  }
339  }
340 
341  namespace {
342  void
343  toFileName(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren, std::ostringstream& ofilename) {
344  char filler = ofilename.fill();
345  unsigned int numberOfDigitsInIndex = 0U;
346  while (numberOfChildren != 0) {
347  ++numberOfDigitsInIndex;
348  numberOfChildren /= 10;
349  }
350  if(numberOfDigitsInIndex == 0) {
351  numberOfDigitsInIndex = 3; // Protect against zero numberOfChildren
352  }
353  std::string::size_type offset = jobReportFile.rfind('.');
354  if(offset == std::string::npos) {
355  ofilename << jobReportFile;
356  ofilename << '_' << std::setw(numberOfDigitsInIndex) << std::setfill('0') << childIndex << std::setfill(filler);
357  } else {
358  ofilename << jobReportFile.substr(0, offset);
359  ofilename << '_' << std::setw(numberOfDigitsInIndex) << std::setfill('0') << childIndex << std::setfill(filler);
360  ofilename << jobReportFile.substr(offset);
361  }
362  }
363  }
364 
365  void
366  JobReport::parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren) {
367  if(impl_->ost_) {
368  *(impl_->ost_) << "<ChildProcessFiles>\n";
369  for(unsigned int i = 0; i < numberOfChildren; ++i) {
370  std::ostringstream ofilename;
371  toFileName(jobReportFile, i, numberOfChildren, ofilename);
372  *(impl_->ost_) << " <ChildProcessFile>" << ofilename.str() << "</ChildProcessFile>\n";
373  }
374  *(impl_->ost_) << "</ChildProcessFiles>\n";
375  *(impl_->ost_) << "</FrameworkJobReport>\n";
376  std::ofstream* p = dynamic_cast<std::ofstream *>(impl_->ost_);
377  if(p) {
378  p->close();
379  }
380  }
381  }
382 
383  void
384  JobReport::parentAfterFork(std::string const& /*jobReportFile*/) {
385  }
386 
387  void
388  JobReport::childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren) {
389  std::ofstream* p = dynamic_cast<std::ofstream*>(impl_->ost_);
390  if(!p) return;
391  std::ostringstream ofilename;
392  toFileName(jobReportFile, childIndex, numberOfChildren, ofilename);
393  p->open(ofilename.str().c_str());
394  *p << "<FrameworkJobReport>\n";
395  }
396 
398  JobReport::inputFileOpened(std::string const& physicalFileName,
399  std::string const& logicalFileName,
400  std::string const& catalog,
401  std::string const& inputType,
402  std::string const& inputSourceClassName,
403  std::string const& moduleLabel,
404  std::string const& guid,
405  std::vector<std::string> const& branchNames) {
406 
407  InputType theInputType = InputType::Primary;
408  InputFile* newFile = nullptr;
409  JobReport::Token newToken = 0;
410 
411  if (inputType == "mixingFiles") {
412  theInputType = InputType::SecondarySource;
413  impl_->inputFilesSecSource_.push_back(InputFile());
414  newFile = &impl_->inputFilesSecSource_.back();
415  newToken = impl_->inputFilesSecSource_.size() - 1;
416  } else {
417  if (inputType == "secondaryFiles") {
418  theInputType = InputType::SecondaryFile;
419  }
420  impl_->inputFiles_.emplace_back();
421  newFile = &impl_->inputFiles_.back();
422  newToken = impl_->inputFiles_.size() - 1;
423  }
424 
425  if(theInputType == InputType::Primary) {
426  impl_->lastOpenedPrimaryInputFile_ = impl_->inputFiles_.size() - 1;
427  }
428  newFile->logicalFileName = logicalFileName;
429  newFile->physicalFileName = physicalFileName;
430  newFile->catalog = catalog;
431  newFile->inputType = inputType;
432  newFile->inputSourceClassName = inputSourceClassName;
433  newFile->moduleLabel = moduleLabel;
434  newFile->guid = guid;
435  newFile->numEventsRead = 0;
436  newFile->branchNames = branchNames;
437  newFile->fileHasBeenClosed = false;
438 
439  // Add the new input file token to all output files
440  // currently open.
441  impl_->insertInputForOutputs(theInputType, newToken);
442  return newToken;
443  }
444 
445  void
447  JobReport::InputFile& f = impl_->getInputFileForToken(inputType, fileToken);
448  ++f.numEventsRead;
449  }
450 
451  void
453  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
454  f.dataType = dataType;
455  }
456 
457  void
459  JobReport::InputFile& f = impl_->getInputFileForToken(inputType, fileToken);
460  f.fileHasBeenClosed = true;
461  if(inputType == InputType::Primary) {
462  impl_->writeInputFile(f);
463  } else {
464  {
465  std::lock_guard<std::mutex> lock(write_mutex);
466  impl_->writeInputFile(f);
467  }
468  }
469  }
470 
472  JobReport::outputFileOpened(std::string const& physicalFileName,
473  std::string const& logicalFileName,
474  std::string const& catalog,
475  std::string const& outputModuleClassName,
476  std::string const& moduleLabel,
477  std::string const& guid,
478  std::string const& dataType,
479  std::string const& branchHash,
480  std::vector<std::string> const& branchNames) {
481  impl_->outputFiles_.emplace_back();
482  JobReport::OutputFile& r = impl_->outputFiles_.back();
483 
484  r.logicalFileName = logicalFileName;
485  r.physicalFileName = physicalFileName;
486  r.catalog = catalog;
487  r.outputModuleClassName = outputModuleClassName;
488  r.moduleLabel = moduleLabel;
489  r.guid = guid;
490  r.dataType = dataType;
491  r.branchHash = branchHash;
492  r.numEventsWritten = 0;
493  r.branchNames = branchNames;
494  r.fileHasBeenClosed = false;
495  //
496  // Init list of contributors to list of open input file Tokens
497  //
498  for(std::vector<Token>::size_type i = 0, iEnd = impl_->inputFiles_.size(); i < iEnd; ++i) {
499  if(!impl_->inputFiles_[i].fileHasBeenClosed) {
500  r.contributingInputs.push_back(i);
501  }
502  }
503  for(tbb::concurrent_vector<Token>::size_type i = 0, iEnd = impl_->inputFilesSecSource_.size(); i < iEnd; ++i) {
504  if(!impl_->inputFilesSecSource_[i].fileHasBeenClosed) {
505  r.contributingInputsSecSource.push_back(i);
506  }
507  }
508  return impl_->outputFiles_.size()-1;
509  }
510 
511  void
512  JobReport::eventWrittenToFile(JobReport::Token fileToken, unsigned int /*run*/, unsigned int) {
513  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
514  ++f.numEventsWritten;
515  }
516 
517  void
519  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
520  f.fileHasBeenClosed = true;
521  impl_->writeOutputFile(f);
522  }
523 
524  void
525  JobReport::reportSkippedEvent(unsigned int run, unsigned int event) {
526  if(impl_->ost_) {
527  std::ostream& msg = *(impl_->ost_);
528  {
529  std::lock_guard<std::mutex> lock(write_mutex);
530  msg << "<SkippedEvent Run=\"" << run << "\"";
531  msg << " Event=\"" << event << "\" />\n";
532  msg << std::flush;
533  }
534  }
535  }
536 
537  void
539  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
540  f.fastCopyingInputs.insert(std::make_pair(inputFileName, fastCopying));
541  }
542 
543  void
544  JobReport::reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents) {
545  impl_->associateLumiSection(token, run, lumiSectId,nEvents);
546  }
547 
548  void
549  JobReport::reportInputLumiSection(unsigned int run, unsigned int lumiSectId) {
550  impl_->associateInputLumiSection(run, lumiSectId);
551  }
552 
553  void
555  impl_->associateRun(token, run);
556  }
557 
558  void
560  impl_->associateInputRun(run);
561  }
562 
563  void
564  JobReport::reportAnalysisFile(std::string const& fileName, std::map<std::string, std::string> const& fileData) {
565  if(impl_->ost_) {
566  std::ostream& msg = *(impl_->ost_);
567  {
568  std::lock_guard<std::mutex> lock(write_mutex);
569  msg << "<AnalysisFile>\n"
570  << " <FileName>" << TiXmlText(fileName) << "</FileName>\n";
571 
572  typedef std::map<std::string, std::string>::const_iterator const_iterator;
573  for(const_iterator pos = fileData.begin(), posEnd = fileData.end(); pos != posEnd; ++pos) {
574  msg << " <" << pos->first
575  << " Value=\"" << pos->second << "\" />"
576  << "\n";
577  }
578  msg << "</AnalysisFile>\n";
579  msg << std::flush;
580  }
581  }
582  }
583 
584  void
586  std::string const& longDesc,
587  int const& exitCode) {
588  if(impl_->ost_) {
589  {
590  std::lock_guard<std::mutex> lock(write_mutex);
591  std::ostream& msg = *(impl_->ost_);
592  msg << "<FrameworkError ExitStatus=\""<< exitCode
593  << "\" Type=\"" << shortDesc << "\" >\n";
594  msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
595  msg << "</FrameworkError>\n";
596  msg << std::flush;
597  }
598  }
599  }
600 
601  void
603  std::string const& lfn) {
604  if(impl_->ost_) {
605  std::ostream& msg = *(impl_->ost_);
606  TiXmlElement skipped("SkippedFile");
607  skipped.SetAttribute("Pfn", pfn);
608  skipped.SetAttribute("Lfn", lfn);
609  {
610  std::lock_guard<std::mutex> lock(write_mutex);
611  msg << skipped << "\n";
612  msg << std::flush;
613  }
614  }
615  }
616 
617  void
619  if(impl_->ost_) {
620  std::ostream& msg = *(impl_->ost_);
621  TiXmlElement fallback("FallbackAttempt");
622  fallback.SetAttribute("Pfn", pfn);
623  fallback.SetAttribute("Lfn", lfn);
624  {
625  std::lock_guard<std::mutex> lock(write_mutex);
626  msg << fallback << "\n";
627  msg << "<![CDATA[\n" << err << "\n]]>\n";
628  msg << std::flush;
629  }
630  }
631  }
632 
633  void
634  JobReport::reportMemoryInfo(std::vector<std::string> const& memoryData) {
635  if(impl_->ost_) {
636  std::ostream& msg = *(impl_->ost_);
637  msg << "<MemoryService>\n";
638 
639  typedef std::vector<std::string>::const_iterator const_iterator;
640  for(const_iterator pos = memoryData.begin(), posEnd = memoryData.end(); pos != posEnd; ++pos) {
641  msg << *pos << "\n";
642  }
643  msg << "</MemoryService>\n";
644  msg << std::flush;
645  }
646  }
647 
648  void
649  JobReport::reportMessageInfo(std::map<std::string, double> const& messageData) {
650  if(impl_->ost_) {
651  std::ostream& msg = *(impl_->ost_);
652  msg << "<MessageSummary>\n";
653  typedef std::map<std::string, double>::const_iterator const_iterator;
654  for(const_iterator pos = messageData.begin(), posEnd = messageData.end(); pos != posEnd; ++pos) {
655  msg << " <" << pos->first
656  << " Value=\"" << pos->second << "\" />"
657  << "\n";
658  }
659  msg << "</MessageSummary>\n";
660  msg << std::flush;
661  }
662  }
663 
664  void
666  if(impl_->printedReadBranches_) return;
667  impl_->printedReadBranches_ = true;
668  if(impl_->ost_) {
669  std::ostream& ost = *(impl_->ost_);
670  ost << "<ReadBranches>\n";
671  for(auto const& iBranch : impl_->readBranches_) {
672  TiXmlElement branch("Branch");
673  branch.SetAttribute("Name", iBranch.first);
674  branch.SetAttribute("ReadCount", iBranch.second);
675  ost << branch << "\n";
676  }
677  for(auto const& iBranch : impl_->readBranchesSecFile_) {
678  TiXmlElement branch("Branch");
679  branch.SetAttribute("Name", iBranch.first);
680  branch.SetAttribute("ReadCount", iBranch.second);
681  ost << branch << "\n";
682  }
683  ost << "</ReadBranches>\n";
684  if(!impl_->readBranchesSecSource_.empty()) {
685  ost << "<SecondarySourceReadBranches>\n";
686  for(auto const& iBranch : impl_->readBranchesSecSource_) {
687  TiXmlElement branch("Branch");
688  branch.SetAttribute("Name", iBranch.first);
689  branch.SetAttribute("ReadCount", iBranch.second.value().load());
690  ost << branch << "\n";
691  }
692  ost << "</SecondarySourceReadBranches>\n";
693  }
694  ost << std::flush;
695  }
696  }
697 
698  void
699  JobReport::reportReadBranch(InputType inputType, std::string const& branchName) {
700  if(inputType == InputType::Primary) {
701  // Fast cloned branches have already been reported.
702  std::set<std::string> const& clonedBranches = impl_->inputFiles_.at(impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
703  if(clonedBranches.find(branchName) == clonedBranches.end()) {
704  ++impl_->readBranches_[branchName];
705  }
706  } else if (inputType == InputType::SecondaryFile) {
707  ++impl_->readBranchesSecFile_[branchName];
708  } else if (inputType == InputType::SecondarySource) {
709  ++impl_->readBranchesSecSource_[branchName].value();
710  }
711  }
712 
713  void
714  JobReport::reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents) {
715  std::set<std::string>& clonedBranches = impl_->inputFiles_.at(impl_->lastOpenedPrimaryInputFile_).fastClonedBranches;
716  for(std::set<std::string>::const_iterator it = fastClonedBranches.begin(), itEnd = fastClonedBranches.end();
717  it != itEnd; ++it) {
718  if(clonedBranches.insert(*it).second) {
719  impl_->readBranches_[*it] += nEvents;
720  }
721  }
722  }
723 
725  if(impl_->ost_) {
726  std::ostream& msg = *(impl_->ost_);
727  {
728  std::lock_guard<std::mutex> lock(write_mutex);
729  msg << "<RandomServiceStateFile>\n"
730  << TiXmlText(name) << "\n"
731  << "</RandomServiceStateFile>\n";
732  msg << std::flush;
733  }
734  }
735  }
736 
737  void
739  std::map<std::string, std::string> const& metrics) {
740  if(impl_->ost_) {
741  std::ostream& msg = *(impl_->ost_);
742  msg << "<PerformanceReport>\n"
743  << " <PerformanceSummary Metric=\"" << metricClass << "\">\n";
744 
745  typedef std::map<std::string, std::string>::const_iterator const_iterator;
746  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
747  msg << " <Metric Name=\"" << iter->first << "\" "
748  << "Value=\"" << iter->second << "\"/>\n";
749  }
750 
751  msg << " </PerformanceSummary>\n"
752  << "</PerformanceReport>\n";
753  msg << std::flush;
754  //LogInfo("FwkJob") << msg.str();
755  }
756  }
757 
758  void
760  std::string const& moduleName,
761  std::map<std::string, std::string> const& metrics) {
762  if(impl_->ost_) {
763  std::ostream& msg = *(impl_->ost_);
764  msg << "<PerformanceReport>\n"
765  << " <PerformanceModule Metric=\"" << metricClass << "\" "
766  << " Module=\"" << moduleName << "\" >\n";
767 
768  typedef std::map<std::string, std::string>::const_iterator const_iterator;
769  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
770  msg << " <Metric Name=\"" << iter->first << "\" "
771  << "Value=\"" << iter->second << "\"/>\n";
772  }
773 
774  msg << " </PerformanceModule>\n"
775  << "</PerformanceReport>\n";
776  msg << std::flush;
777  //LogInfo("FwkJob") << msg.str();
778  }
779  }
780 
783  std::ostringstream msg;
784 
785  typedef std::vector<JobReport::OutputFile>::iterator iterator;
786 
787  for(iterator f = impl_->outputFiles_.begin(), fEnd = impl_->outputFiles_.end(); f != fEnd; ++f) {
788 
789  msg << "\n<File>";
790  msg << *f;
791 
792  msg << "\n<LumiSections>";
793  msg << "\n<Inputs>";
794  typedef std::vector<JobReport::Token>::iterator iterator;
795  for(iterator iInput = f->contributingInputs.begin(),
796  iInputEnd = f->contributingInputs.end();
797  iInput != iInputEnd; ++iInput) {
798  JobReport::InputFile inpFile = impl_->inputFiles_[*iInput];
799  msg << "\n<Input>";
800  msg << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
801  msg << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
802  msg << "\n <FastCopying>" << findOrDefault(f->fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
803  msg << "\n</Input>";
804  }
805  msg << "\n</Inputs>";
806  msg << "\n</File>";
807 
808  }
809  return msg.str();
810  }
811 
812 } //namspace edm
int i
Definition: DBlmapReader.cc:9
string rep
Definition: cuy.py:1188
InputType
Definition: InputType.h:5
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:602
std::string inputSourceClassName
Definition: JobReport.h:128
list pfn
Definition: dbtoconf.py:76
std::string outputModuleClassName
Definition: JobReport.h:154
std::string physicalFileName
Definition: JobReport.h:152
void associateRun(JobReport::Token token, unsigned int runNumber)
Definition: JobReport.cc:280
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:634
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:559
void eventReadFromFile(InputType inputType, Token fileToken)
Definition: JobReport.cc:446
std::mutex write_mutex
Definition: JobReport.h:437
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:618
std::string logicalFileName
Definition: JobReport.h:124
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:163
std::string logicalFileName
Definition: JobReport.h:151
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:538
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:554
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:724
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
uint16_t size_type
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:398
std::vector< InputFile > inputFiles_
Definition: JobReport.h:246
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:759
std::vector< Token > contributingInputs
Definition: JobReport.h:161
tuple InputFile
Open Root file and provide MEs ############.
std::string physicalFileName
Definition: JobReport.h:125
void insertInputForOutputs(InputType inputType, Token t)
Definition: JobReport.cc:181
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::size_t numEventsRead
Definition: JobReport.h:131
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:198
StringVector branchNames
Definition: JobReport.h:160
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:549
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:738
void childAfterFork(std::string const &jobReportFile, unsigned int childIndex, unsigned int numberOfChildren)
New output file for child.
Definition: JobReport.cc:388
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:472
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
Definition: JobReport.cc:585
std::size_t Token
Definition: JobReport.h:105
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:288
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:699
std::size_t numEventsWritten
Definition: JobReport.h:159
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:714
boost::scoped_ptr< JobReportImpl > impl_
Definition: JobReport.h:436
Value const & findOrDefault(std::map< Key, Value > const &m, Key const &k, Value const &defaultValue)
Definition: Map.h:28
tbb::concurrent_vector< InputFile > inputFilesSecSource_
Definition: JobReport.h:247
void parentAfterFork(std::string const &jobReportFile)
Definition: JobReport.cc:384
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:649
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection, unsigned long nEvents)
Definition: JobReport.cc:300
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:782
void parentBeforeFork(std::string const &jobReportFile, unsigned int numberOfChildren)
Definition: JobReport.cc:366
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:564
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:518
void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event)
Definition: JobReport.cc:512
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:225
std::map< unsigned int, unsigned long > lumiSectionsToNEvents
Definition: JobReport.h:109
InputFile & getInputFileForToken(InputType inputType, Token t)
Definition: JobReport.cc:124
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:452
UInt_t nEvents
Definition: hcalCalib.cc:42
tbb::concurrent_vector< Token > contributingInputsSecSource
Definition: JobReport.h:162
StringVector branchNames
Definition: JobReport.h:132
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:458
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:310
void reportSkippedEvent(unsigned int run, unsigned int event)
Definition: JobReport.cc:525
void reportReadBranches()
Definition: JobReport.cc:665
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:156
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
Definition: JobReport.cc:544