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