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