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 
24 
26 
27 #include <fstream>
28 #include <iomanip>
29 #include <iostream>
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(std::vector<std::string>::const_iterator iBranch = f.branchNames.begin(),
54  iBranchEnd = f.branchNames.end();
55  iBranch != iBranchEnd;
56  ++iBranch) {
57  os << "\n <Branch>" << TiXmlText(*iBranch) << "</Branch>";
58  }
59  os << "\n</Branches>";
60  return os;
61  }
62  /*
63  * Note that output formatting is spattered across these classes
64  * If something outside these classes requires access to the
65  * same formatting then we need to refactor it into a common library
66  */
67  template <typename S>
68  S&
69  print(S& os, JobReport::InputFile const& f) {
70 
71  os << "\n<InputFile>";
72  formatFile(f, os);
73  os << "\n<InputType>" << f.inputType << "</InputType>";
74  os << "\n<InputSourceClass>" << TiXmlText(f.inputSourceClassName)
75  << "</InputSourceClass>";
76  os << "\n<EventsRead>" << f.numEventsRead << "</EventsRead>";
77  return os;
78  }
79 
80  template <typename S>
81  S&
82  print(S& os, JobReport::OutputFile const& f) {
83  formatFile(f, os);
84  os << "\n<OutputModuleClass>"
86  << "</OutputModuleClass>";
87  os << "\n<TotalEvents>"
88  << f.numEventsWritten
89  << "</TotalEvents>\n";
90  os << "\n<DataType>"
91  << TiXmlText(f.dataType)
92  << "</DataType>\n";
93  os << "\n<BranchHash>"
94  << TiXmlText(f.branchHash)
95  << "</BranchHash>\n";
96 
97  return os;
98  }
99 
100  template <typename S>
101  S&
102  print(S& os,
103  JobReport::RunReport const& rep) {
104  os << "\n<Run ID=\""
105  << rep.runNumber
106  << "\">\n";
107 
108  typedef std::set<unsigned int>::iterator iterator;
109  for(iterator il = rep.lumiSections.begin(), ilEnd = rep.lumiSections.end(); il != ilEnd; ++il) {
110  os << " <LumiSection ID=\"" << *il << "\"/>\n";
111 
112  }
113  os << "</Run>\n";
114  return os;
115  }
116 
117  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f) {
118  return print(os,f);
119  }
120  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f) {
121  return print(os,f);
122  }
123 
124  std::ostream& operator<< (std::ostream& os, JobReport::RunReport const& f) {
125  return print(os,f);
126  }
127 
128  //To talk to MessageLogger directly
130  return print(os,f);
131  }
133  return print(os,f);
134  }
136  return print(os,f);
137  }
138 // edm::MessageSender& operator<< (edm::MessageSender& os, JobReport::LumiSectionReport const& rep) {
139 // return print(os,rep);
140 // }
141 //
142 
144  if(t >= inputFiles_.size()) {
146  << "Access reported for input file with token "
147  << t
148  << " but no matching input file is found\n";
149  }
150 
151  if(inputFiles_[t].fileHasBeenClosed) {
153  << "Access reported for input file with token "
154  << t
155  << " after this file has been closed.\n"
156  << "File record follows:\n"
157  << inputFiles_[t]
158  << '\n';
159  }
160 
161  return inputFiles_[t];
162  }
163 
165  if(t >= outputFiles_.size()) {
167  << "Access reported for output file with token "
168  << t
169  << " but no matching output file is found\n";
170  }
171  if(outputFiles_[t].fileHasBeenClosed) {
173  << "Access reported for output file with token "
174  << t
175  << " after this file has been closed.\n"
176  << "File record follows:\n"
177  << outputFiles_[t]
178  << '\n';
179  }
180  return outputFiles_[t];
181  }
182 
183  /*
184  * Add the input file token provided to every output
185  * file currently available.
186  * Used whenever a new input file is opened, it's token
187  * is added to all open output files as a contributor
188  */
190  typedef std::vector<JobReport::OutputFile>::iterator iterator;
191  for(iterator outFile = outputFiles_.begin(), outFileEnd = outputFiles_.end(); outFile != outFileEnd; ++outFile) {
192  outFile->contributingInputs.push_back(t);
193  }
194  }
195  /*
196  * get a vector of Tokens for all currently open
197  * input files.
198  * Used when a new output file is opened, all currently open
199  * input file tokens are used to initialize its list of contributors
200  */
201  void JobReport::JobReportImpl::openInputFiles(std::vector<JobReport::Token>& result) {
202  result.reserve(inputFiles_.size());
203  for(unsigned int i = 0; i < inputFiles_.size(); ++i) {
204  if(inputFiles_[i].fileHasBeenClosed == false) {
205  result.push_back(i);
206  }
207  }
208  }
209 
210  /*
211  * get a vector of Tokens for all currently open
212  * output files.
213  *
214  */
215  void JobReport::JobReportImpl::openOutputFiles(std::vector<JobReport::Token>& result) {
216  result.reserve(outputFiles_.size());
217  for(unsigned int i = 0; i < outputFiles_.size(); ++i) {
218  if(outputFiles_[i].fileHasBeenClosed == false) {
219  result.push_back(i);
220  }
221  }
222  }
223 
224  /*
225  * Write anJobReport::InputFile object to the Logger
226  * Generate XML string forJobReport::InputFile instance and dispatch to
227  * job report via MessageLogger
228  */
230  if(ost_) {
231  *ost_ << f ;
232  *ost_ << "\n<Runs>";
233  typedef std::map<JobReport::RunNumber, JobReport::RunReport>::const_iterator const_iterator;
234  for(const_iterator iRun = f.runReports.begin(), iRunEnd = f.runReports.end(); iRun != iRunEnd; ++iRun) {
235  *ost_ << iRun->second;
236  }
237  *ost_ << "\n</Runs>\n";
238  *ost_ << "</InputFile>\n";
239  *ost_ << std::flush;
240  }
241  //LogInfo("FwkJob") << f;
242  }
243 
244  /*
245  * Write an OutputFile object to the Logger
246  * Generate an XML string for the OutputFile provided and
247  * dispatch it to the logger
248  * Contributing input tokens are resolved to the input LFN and PFN
249  *
250  * TODO: We have not yet addressed the issue where we cleanup not
251  * contributing input files.
252  * Also, it is possible to get fake input to output file mappings
253  * if an input file is open already when a new output file is opened
254  * but the input gets closed without contributing events to the
255  * output file due to filtering etc.
256  *
257  */
259  if(ost_) {
260  *ost_ << "\n<File>";
261  *ost_ << f;
262 
263  *ost_ << "\n<Runs>";
264  typedef std::map<JobReport::RunNumber, JobReport::RunReport>::const_iterator const_iterator;
265  for(const_iterator iRun = f.runReports.begin(), iRunEnd = f.runReports.end(); iRun != iRunEnd; ++iRun) {
266  *ost_ << iRun->second;
267  }
268  *ost_ << "\n</Runs>\n";
269 
270  *ost_ << "\n<Inputs>";
271  for(std::vector<JobReport::Token>::const_iterator
272  iInput = f.contributingInputs.begin(),
273  iInputEnd = f.contributingInputs.end();
274  iInput != iInputEnd; ++iInput) {
275  JobReport::InputFile inpFile = inputFiles_[*iInput];
276  *ost_ << "\n<Input>";
277  *ost_ << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
278  *ost_ << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
279  *ost_ << "\n <FastCopying>" << findOrDefault(f.fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
280  *ost_ << "\n</Input>";
281  }
282  *ost_ << "\n</Inputs>";
283  *ost_ << "\n</File>\n";
284  }
285  }
286 
287  /*
288  * Flush all open files to logger in event of a problem.
289  * Called from JobReport dtor to flush any remaining open files
290  */
292  for(std::vector<JobReport::InputFile>::iterator ipos = inputFiles_.begin(), iposEnd = inputFiles_.end();
293  ipos != iposEnd; ++ipos) {
294  if(!(ipos->fileHasBeenClosed)) {
295  writeInputFile(*ipos);
296  }
297  }
298  for(std::vector<JobReport::OutputFile>::iterator opos = outputFiles_.begin(), oposEnd = outputFiles_.end();
299  opos != oposEnd; ++opos) {
300  if(!(opos->fileHasBeenClosed)) {
301  writeOutputFile(*opos);
302  }
303  }
304  }
305 
307  std::string const& value) {
308 
309  generatorInfo_[name] = value;
310  }
311 
313  if(ost_) {
314  *ost_ << "\n<GeneratorInfo>\n";
315  for(std::map<std::string, std::string>::iterator pos = generatorInfo_.begin(),
316  posEnd = generatorInfo_.end();
317  pos != posEnd; ++pos) {
318  std::ostringstream msg;
319  msg << "\n<Data Name=\"" << pos->first
320  << "\" Value=\"" << pos->second << "\"/>";
321  *ost_ << msg.str();
322  }
323  *ost_ << "</GeneratorInfo>\n";
324  }
325  }
326 
328  std::vector<Token> openFiles;
329  openOutputFiles(openFiles);
330  for(std::vector<Token>::iterator iToken = openFiles.begin(), iTokenEnd = openFiles.end(); iToken != iTokenEnd; ++iToken) {
331  JobReport::OutputFile& theFile = outputFiles_[*iToken];
332 
333  //
334  // check run is known to file
335  // if not, add a run report for that run
336  if(theFile.runReports.count(runNumber) == 0) {
338  newReport.runNumber = runNumber;
339  theFile.runReports.insert(
340  std::make_pair(runNumber, newReport)
341  );
342  }
343 
344  }
345  }
346 
348  std::vector<Token> openFiles;
349  openInputFiles(openFiles);
350  for(std::vector<Token>::iterator iToken = openFiles.begin(), iTokenEnd = openFiles.end(); iToken != iTokenEnd; ++iToken) {
351  JobReport::InputFile& theFile = inputFiles_[*iToken];
352 
353  //
354  // check run is known to file
355  // if not, add a run report for that run
356  if(theFile.runReports.count(runNumber) == 0) {
358  newReport.runNumber = runNumber;
359  theFile.runReports.insert(std::make_pair(runNumber, newReport));
360  }
361 
362  }
363  }
364 
365  void JobReport::JobReportImpl::associateLumiSection(unsigned int runNumber, unsigned int lumiSect) {
366  std::vector<Token> openFiles;
367  openOutputFiles(openFiles);
368  for(std::vector<Token>::iterator iToken = openFiles.begin(), iTokenEnd = openFiles.end(); iToken != iTokenEnd; ++iToken) {
369  //
370  // Loop over all open output files
371  //
372  JobReport::OutputFile& theFile = outputFiles_[*iToken];
373 
374  //
375  // check run is known to file
376  // if not, add a run report for that run
377  if(theFile.runReports.count(runNumber) == 0) {
379  newReport.runNumber = runNumber;
380  theFile.runReports.insert(std::make_pair(runNumber, newReport));
381  }
382 
383  //
384  // Get the run report for this run, now that it either was created
385  // or already existed
386  std::map<JobReport::RunNumber, JobReport::RunReport>::iterator finder;
387  finder = theFile.runReports.find(runNumber);
388 
389  //
390  // add the lumi section to the report, the lumi list is a Set
391  // so duplicates dont matter
392  (finder->second).lumiSections.insert(lumiSect);
393  }
394  }
395 
396  void JobReport::JobReportImpl::associateInputLumiSection(unsigned int runNumber, unsigned int lumiSect) {
397  std::vector<Token> openFiles;
398  openInputFiles(openFiles);
399  for(std::vector<Token>::iterator iToken = openFiles.begin(), iTokenEnd = openFiles.end(); iToken != iTokenEnd; ++iToken) {
400  //
401  // Loop over all open input files
402  //
403  JobReport::InputFile& theFile = inputFiles_[*iToken];
404 
405  //
406  // check run is known to file
407  // if not, add a run report for that run
408  if(theFile.runReports.count(runNumber) == 0) {
410  newReport.runNumber = runNumber;
411  theFile.runReports.insert(std::make_pair(runNumber, newReport));
412  }
413 
414  //
415  // Get the run report for this run, now that it either was created
416  // or already existed
417  std::map<JobReport::RunNumber, JobReport::RunReport>::iterator finder;
418  finder = theFile.runReports.find(runNumber);
419 
420  //
421  // add the lumi section to the report, the lumi list is a Set
422  // so duplicates dont matter
423  (finder->second).lumiSections.insert(lumiSect);
424  }
425  }
426 
428  impl_->writeGeneratorInfo();
429  impl_->flushFiles();
430  if(impl_->ost_) {
431  *(impl_->ost_) << "</FrameworkJobReport>\n" << std::flush;
432  }
433  }
434 
436  impl_(new JobReportImpl(0)) {
437  }
438 
439  JobReport::JobReport(std::ostream* iOstream) : impl_(new JobReportImpl(iOstream)) {
440  if(impl_->ost_) {
441  *(impl_->ost_) << "<FrameworkJobReport>\n";
442  }
443  }
444 
445  namespace {
446  void
447  toFileName(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren, std::ostringstream& ofilename) {
448  char filler = ofilename.fill();
449  unsigned int numberOfDigitsInIndex = 0U;
450  while (numberOfChildren != 0) {
451  ++numberOfDigitsInIndex;
452  numberOfChildren /= 10;
453  }
454  if(numberOfDigitsInIndex == 0) {
455  numberOfDigitsInIndex = 3; // Protect against zero numberOfChildren
456  }
457  std::string::size_type offset = jobReportFile.rfind('.');
458  if(offset == std::string::npos) {
459  ofilename << jobReportFile;
460  ofilename << '_' << std::setw(numberOfDigitsInIndex) << std::setfill('0') << childIndex << std::setfill(filler);
461  } else {
462  ofilename << jobReportFile.substr(0, offset);
463  ofilename << '_' << std::setw(numberOfDigitsInIndex) << std::setfill('0') << childIndex << std::setfill(filler);
464  ofilename << jobReportFile.substr(offset);
465  }
466  }
467  }
468 
469  void
470  JobReport::parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren) {
471  if(impl_->ost_) {
472  *(impl_->ost_) << "<ChildProcessFiles>\n";
473  for(unsigned int i = 0; i < numberOfChildren; ++i) {
474  std::ostringstream ofilename;
475  toFileName(jobReportFile, i, numberOfChildren, ofilename);
476  *(impl_->ost_) << " <ChildProcessFile>" << ofilename.str() << "</ChildProcessFile>\n";
477  }
478  *(impl_->ost_) << "</ChildProcessFiles>\n";
479  *(impl_->ost_) << "</FrameworkJobReport>\n";
480  std::ofstream* p = dynamic_cast<std::ofstream *>(impl_->ost_);
481  if(p) {
482  p->close();
483  }
484  }
485  }
486 
487  void
488  JobReport::parentAfterFork(std::string const& /*jobReportFile*/) {
489  }
490 
491  void
492  JobReport::childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren) {
493  std::ofstream* p = dynamic_cast<std::ofstream*>(impl_->ost_);
494  if(!p) return;
495  std::ostringstream ofilename;
496  toFileName(jobReportFile, childIndex, numberOfChildren, ofilename);
497  p->open(ofilename.str().c_str());
498  *p << "<FrameworkJobReport>\n";
499  }
500 
502  JobReport::inputFileOpened(std::string const& physicalFileName,
503  std::string const& logicalFileName,
504  std::string const& catalog,
505  std::string const& inputType,
506  std::string const& inputSourceClassName,
507  std::string const& moduleLabel,
508  std::string const& guid,
509  std::vector<std::string> const& branchNames) {
510  // Do we have to worry about thread safety here? Or is this
511  // service used in a way to make this safe?
512  impl_->inputFiles_.push_back(JobReport::InputFile());
513  JobReport::InputFile& r = impl_->inputFiles_.back();
514  impl_->fastClonedBranches_ = &r.fastClonedBranches;
515 
516  r.logicalFileName = logicalFileName;
517  r.physicalFileName = physicalFileName;
518  r.catalog = catalog;
519  r.inputType = inputType;
520  r.inputSourceClassName = inputSourceClassName;
521  r.moduleLabel = moduleLabel;
522  r.guid = guid;
523  // r.runsSeen is not modified
524  r.numEventsRead = 0;
525  r.branchNames = branchNames;
526  r.fileHasBeenClosed = false;
527 
528  JobReport::Token newToken = impl_->inputFiles_.size()-1;
529  //
530  // Add the new input file token to all output files
531  // currently open.
532  impl_->insertInputForOutputs(newToken);
533  return newToken;
534  }
535 
536  void
537  JobReport::eventReadFromFile(JobReport::Token fileToken, unsigned int /*run*/, unsigned int) {
538  JobReport::InputFile& f = impl_->getInputFileForToken(fileToken);
539  ++f.numEventsRead;
540  //f.runsSeen.insert(run);
541  }
542 
543  void
544  JobReport::reportDataType(Token fileToken, std::string const& dataType) {
545  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
546  f.dataType = dataType;
547  }
548 
549  void
551  JobReport::InputFile& f = impl_->getInputFileForToken(fileToken);
552  // Dump information to the MessageLogger's JobSummary
553  // about this file.
554  // After setting the file to 'closed', we will no longer be able
555  // to reference it by ID.
556  f.fileHasBeenClosed = true;
557  impl_->writeInputFile(f);
558  }
559 
561  JobReport::outputFileOpened(std::string const& physicalFileName,
562  std::string const& logicalFileName,
563  std::string const& catalog,
564  std::string const& outputModuleClassName,
565  std::string const& moduleLabel,
566  std::string const& guid,
567  std::string const& dataType,
568  std::string const& branchHash,
569  std::vector<std::string> const& branchNames) {
570  impl_->outputFiles_.push_back(JobReport::OutputFile());
571  JobReport::OutputFile& r = impl_->outputFiles_.back();
572 
573  r.logicalFileName = logicalFileName;
574  r.physicalFileName = physicalFileName;
575  r.catalog = catalog;
576  r.outputModuleClassName = outputModuleClassName;
577  r.moduleLabel = moduleLabel;
578  r.guid = guid;
579  r.dataType = dataType;
580  r.branchHash = branchHash;
581  // r.runsSeen is not modified
582  r.numEventsWritten = 0;
583  r.branchNames = branchNames;
584  r.fileHasBeenClosed = false;
585  //
586  // Init list of contributors to list of open input file Tokens
587  //
588  impl_->openInputFiles(r.contributingInputs);
589  return impl_->outputFiles_.size()-1;
590  }
591 
592  void
593  JobReport::eventWrittenToFile(JobReport::Token fileToken, unsigned int /*run*/, unsigned int) {
594  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
595  ++f.numEventsWritten;
596  //f.runsSeen.insert(run);
597  }
598 
599  void
601  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
602  // Dump information to the MessageLogger's JobSummary
603  // about this file.
604  // After setting the file to 'closed', we will no longer be able
605  // to reference it by ID.
606  f.fileHasBeenClosed = true;
607  impl_->writeOutputFile(f);
608  }
609 
610  void
611  JobReport:: reportFastCopyingStatus(JobReport::Token fileToken, std::string const& inputFileName, bool fastCopying) {
612  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
613  f.fastCopyingInputs.insert(std::make_pair(inputFileName, fastCopying));
614  }
615 
616  void
617  JobReport::overrideEventsWritten(Token fileToken, int const eventsWritten) {
618  // Get the required output file instance using the token
619  JobReport::OutputFile& f = impl_->getOutputFileForToken(fileToken);
620  // set the eventsWritten parameter to the provided value
621  f.numEventsWritten = eventsWritten;
622  }
623 
624  void
625  JobReport::overrideEventsRead(Token fileToken, int const eventsRead) {
626  // Get the required input file instance using the token
627  JobReport::InputFile& f = impl_->getInputFileForToken(fileToken);
628  // set the events read parameter to the provided value
629  f.numEventsRead = eventsRead;
630  }
631 
632  void
634  std::vector<Token> const& inputTokens) {
635  // Get the required output file instance using the token
636  JobReport::OutputFile& f = impl_->getOutputFileForToken(outputToken);
637  // override its contributing inputs data
638  f.contributingInputs = inputTokens;
639  }
640 
641  void
642  JobReport::reportSkippedEvent(unsigned int run, unsigned int event) {
643  if(impl_->ost_) {
644  std::ostream& msg = *(impl_->ost_);
645  msg << "<SkippedEvent Run=\"" << run << "\"";
646  msg << " Event=\"" << event << "\" />\n";
647  msg << std::flush;
648  //LogInfo("FwkJob") << msg.str();
649  }
650  }
651 
652  void
653  JobReport::reportLumiSection(unsigned int run, unsigned int lumiSectId) {
654  impl_->associateLumiSection(run, lumiSectId);
655  }
656 
657  void
658  JobReport::reportInputLumiSection(unsigned int run, unsigned int lumiSectId) {
659  impl_->associateInputLumiSection(run, lumiSectId);
660  }
661 
662  void
664  impl_->associateRun(run);
665  }
666  void
668  impl_->associateInputRun(run);
669  }
670 
671  void
672  JobReport::reportError(std::string const& shortDesc,
673  std::string const& longDesc) {
674  if(impl_->ost_) {
675  std::ostream& msg = *(impl_->ost_);
676  msg << "<FrameworkError ExitStatus=\"1\" Type=\"" << shortDesc << "\" >\n";
677  msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
678  msg << "</FrameworkError>\n";
679  //LogError("FwkJob") << msg.str();
680  msg << std::flush;
681  }
682  }
683 
684  void
685  JobReport::reportAnalysisFile(std::string const& fileName, std::map<std::string, std::string> const& fileData) {
686  if(impl_->ost_) {
687  std::ostream& msg = *(impl_->ost_);
688  //std::ostringstream msg;
689  msg << "<AnalysisFile>\n"
690  << " <FileName>" << TiXmlText(fileName) << "</FileName>\n";
691 
692  typedef std::map<std::string, std::string>::const_iterator const_iterator;
693  for(const_iterator pos = fileData.begin(), posEnd = fileData.end(); pos != posEnd; ++pos) {
694  msg << " <" << pos->first
695  << " Value=\"" << pos->second << "\" />"
696  << "\n";
697  }
698  msg << "</AnalysisFile>\n";
699  //LogError("FwkJob") << msg.str();
700  msg << std::flush;
701  }
702  }
703 
704  void
705  JobReport::reportError(std::string const& shortDesc,
706  std::string const& longDesc,
707  int const& exitCode) {
708  if(impl_->ost_) {
709  std::ostream& msg = *(impl_->ost_);
710  //std::ostringstream msg;
711  msg << "<FrameworkError ExitStatus=\""<< exitCode
712  << "\" Type=\"" << shortDesc << "\" >\n";
713  msg << "<![CDATA[\n" << longDesc << "\n]]>\n";
714  msg << "</FrameworkError>\n";
715  //LogError("FwkJob") << msg.str();
716  msg << std::flush;
717  }
718  }
719 
720  void
721  JobReport::reportSkippedFile(std::string const& pfn,
722  std::string const& lfn) {
723  if(impl_->ost_) {
724  std::ostream& msg = *(impl_->ost_);
725  TiXmlElement skipped("SkippedFile");
726  skipped.SetAttribute("Pfn", pfn);
727  skipped.SetAttribute("Lfn", lfn);
728  msg << skipped << "\n";
729  msg << std::flush;
730  //LogInfo("FwkJob") << msg.str();
731  }
732  }
733 
734  void
735  JobReport::reportFallbackAttempt(std::string const& pfn, std::string const& lfn, std::string const& err) {
736  if(impl_->ost_) {
737  std::ostream& msg = *(impl_->ost_);
738  TiXmlElement fallback("FallbackAttempt");
739  fallback.SetAttribute("Pfn", pfn);
740  fallback.SetAttribute("Lfn", lfn);
741  msg << fallback << "\n";
742  msg << "<![CDATA[\n" << err << "\n]]>\n";
743  msg << std::flush;
744  //LogInfo("FwkJob") << msg.str();
745  }
746  }
747 
748  void
749  JobReport::reportMemoryInfo(std::vector<std::string> const& memoryData) {
750  if(impl_->ost_) {
751  std::ostream& msg = *(impl_->ost_);
752  msg << "<MemoryService>\n";
753 
754  typedef std::vector<std::string>::const_iterator const_iterator;
755  for(const_iterator pos = memoryData.begin(), posEnd = memoryData.end(); pos != posEnd; ++pos) {
756  msg << *pos << "\n";
757  }
758  msg << "</MemoryService>\n";
759  msg << std::flush;
760  }
761  }
762 
763  void
764  JobReport::reportMessageInfo(std::map<std::string, double> const& messageData) {
765  if(impl_->ost_) {
766  std::ostream& msg = *(impl_->ost_);
767  msg << "<MessageSummary>\n";
768  typedef std::map<std::string, double>::const_iterator const_iterator;
769  for(const_iterator pos = messageData.begin(), posEnd = messageData.end(); pos != posEnd; ++pos) {
770  msg << " <" << pos->first
771  << " Value=\"" << pos->second << "\" />"
772  << "\n";
773  }
774  msg << "</MessageSummary>\n";
775  msg << std::flush;
776  }
777  }
778 
779  void
781  if(impl_->ost_) {
782  std::ostream& ost = *(impl_->ost_);
783  ost << "<ReadBranches>\n";
784  typedef std::map<std::string, long long>::const_iterator const_iterator;
785  for(const_iterator it = impl_->readBranches_.begin(), itEnd = impl_->readBranches_.end(); it != itEnd; ++it) {
786  TiXmlElement branch("Branch");
787  branch.SetAttribute("Name", it->first);
788  branch.SetAttribute("ReadCount", it->second);
789  ost << branch << "\n";
790  // ost << " <Branch Name=" << '"' << it->first << '"'<< " ReadCount=" << it->second << ">\n";
791  }
792  ost << "</ReadBranches>\n";
793  ost << std::flush;
794  }
795  }
796 
797  void
798  JobReport::reportReadBranch(std::string const& branchName) {
799  // Fast cloned branches have already been reported.
800  if(impl_->fastClonedBranches_->find(branchName) == impl_->fastClonedBranches_->end()) {
801  ++impl_->readBranches_[branchName];
802  }
803  }
804 
805  void
806  JobReport::reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents) {
807  for(std::set<std::string>::const_iterator it = fastClonedBranches.begin(), itEnd = fastClonedBranches.end();
808  it != itEnd; ++it) {
809  if(impl_->fastClonedBranches_->insert(*it).second) {
810  impl_->readBranches_[*it] += nEvents;
811  }
812  }
813  }
814 
815  void
816  JobReport::reportGeneratorInfo(std::string const& name, std::string const& value) {
817  impl_->addGeneratorInfo(name, value);
818  }
819 
820  void JobReport::reportRandomStateFile(std::string const& name) {
821  if(impl_->ost_) {
822  std::ostream& msg = *(impl_->ost_);
823  msg << "<RandomServiceStateFile>\n"
824  << TiXmlText(name) << "\n"
825  << "</RandomServiceStateFile>\n";
826  //LogInfo("FwkJob") << msg.str();
827  msg << std::flush;
828  }
829  }
830 
831  void
832  JobReport::reportPSetHash(std::string const& hashValue) {
833  if(impl_->ost_) {
834  std::ostream& msg = *(impl_->ost_);
835  msg << "<PSetHash>"
836  << hashValue
837  << "</PSetHash>\n";
838  //LogInfo("FwkJob") << msg.str();
839  msg << std::flush;
840  }
841  }
842 
843  void
844  JobReport::reportPerformanceSummary(std::string const& metricClass,
845  std::map<std::string, std::string> const& metrics) {
846  if(impl_->ost_) {
847  std::ostream& msg = *(impl_->ost_);
848  msg << "<PerformanceReport>\n"
849  << " <PerformanceSummary Metric=\"" << metricClass << "\">\n";
850 
851  typedef std::map<std::string, std::string>::const_iterator const_iterator;
852  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
853  msg << " <Metric Name=\"" << iter->first << "\" "
854  << "Value=\"" << iter->second << "\"/>\n";
855  }
856 
857  msg << " </PerformanceSummary>\n"
858  << "</PerformanceReport>\n";
859  msg << std::flush;
860  //LogInfo("FwkJob") << msg.str();
861  }
862  }
863 
864  void
865  JobReport::reportPerformanceForModule(std::string const& metricClass,
866  std::string const& moduleName,
867  std::map<std::string, std::string> const& metrics) {
868  if(impl_->ost_) {
869  std::ostream& msg = *(impl_->ost_);
870  msg << "<PerformanceReport>\n"
871  << " <PerformanceModule Metric=\"" << metricClass << "\" "
872  << " Module=\"" << moduleName << "\" >\n";
873 
874  typedef std::map<std::string, std::string>::const_iterator const_iterator;
875  for(const_iterator iter = metrics.begin(), iterEnd = metrics.end(); iter != iterEnd; ++iter) {
876  msg << " <Metric Name=\"" << iter->first << "\" "
877  << "Value=\"" << iter->second << "\"/>\n";
878  }
879 
880  msg << " </PerformanceModule>\n"
881  << "</PerformanceReport>\n";
882  msg << std::flush;
883  //LogInfo("FwkJob") << msg.str();
884  }
885  }
886 
887  std::string
889  std::ostringstream msg;
890 
891  typedef std::vector<JobReport::OutputFile>::iterator iterator;
892 
893  for(iterator f = impl_->outputFiles_.begin(), fEnd = impl_->outputFiles_.end(); f != fEnd; ++f) {
894 
895  msg << "\n<File>";
896  msg << *f;
897 
898  msg << "\n<LumiSections>";
899  //typedef std::vector<JobReport::LumiSectionReport>::iterator Iter;
900  //for(Iter iLumi = f->lumiSections.begin(),
901  // iLumiEnd = f->lumiSections.end();
902  // iLumi != iLumiEnd; ++iLumi) {
903  // msg << *iLumi;
904  //}
905  //msg << "\n</LumiSections>\n";
906  msg << "\n<Inputs>";
907  typedef std::vector<JobReport::Token>::iterator iterator;
908  for(iterator iInput = f->contributingInputs.begin(),
909  iInputEnd = f->contributingInputs.end();
910  iInput != iInputEnd; ++iInput) {
911  JobReport::InputFile inpFile = impl_->inputFiles_[*iInput];
912  msg << "\n<Input>";
913  msg << "\n <LFN>" << TiXmlText(inpFile.logicalFileName) << "</LFN>";
914  msg << "\n <PFN>" << TiXmlText(inpFile.physicalFileName) << "</PFN>";
915  msg << "\n <FastCopying>" << findOrDefault(f->fastCopyingInputs, inpFile.physicalFileName) << "</FastCopying>";
916  msg << "\n</Input>";
917  }
918  msg << "\n</Inputs>";
919  msg << "\n</File>";
920 
921  }
922  return msg.str();
923  }
924 
925 } //namspace edm
void openInputFiles(std::vector< Token > &tokens)
Definition: JobReport.cc:201
void reportReadBranch(std::string const &branchName)
Inform the job report that a branch has been read.
Definition: JobReport.cc:798
void associateRun(unsigned int runNumber)
Definition: JobReport.cc:327
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:561
int i
Definition: DBlmapReader.cc:9
std::string inputSourceClassName
Definition: JobReport.h:86
list pfn
Definition: dbtoconf.py:76
void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event)
Definition: JobReport.cc:593
std::string outputModuleClassName
Definition: JobReport.h:112
std::string physicalFileName
Definition: JobReport.h:110
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:611
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:735
std::string logicalFileName
Definition: JobReport.h:82
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:502
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:806
void overrideEventsWritten(Token fileToken, int const eventsWritten)
Definition: JobReport.cc:617
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:685
std::set< std::string > fastClonedBranches
Definition: JobReport.h:93
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:820
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:120
std::string logicalFileName
Definition: JobReport.h:109
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:544
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:69
uint16_t size_type
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:600
std::vector< InputFile > inputFiles_
Definition: JobReport.h:225
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:91
std::vector< Token > contributingInputs
Definition: JobReport.h:119
std::string physicalFileName
Definition: JobReport.h:83
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:229
void inputFileClosed(Token fileToken)
Definition: JobReport.cc:550
StringVector branchNames
Definition: JobReport.h:118
tuple result
Definition: query.py:137
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:121
std::set< unsigned int > lumiSections
Definition: JobReport.h:67
double f[11][100]
void parentAfterFork(std::string const &jobReportFile)
Definition: JobReport.cc:488
void reportSkippedEvent(unsigned int run, unsigned int event)
Definition: JobReport.cc:642
void openOutputFiles(std::vector< Token > &tokens)
Definition: JobReport.cc:215
unsigned int offset(bool)
void reportPSetHash(std::string const &hashValue)
Definition: JobReport.cc:832
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 eventReadFromFile(Token fileToken, unsigned int run, unsigned int event)
Definition: JobReport.cc:537
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:667
std::size_t Token
Definition: JobReport.h:43
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:347
InputFile & getInputFileForToken(Token t)
Definition: JobReport.cc:143
S & formatFile(T const &f, S &os)
Definition: JobReport.cc:39
void childAfterFork(std::string const &jobReportFile, unsigned int childIndex, unsigned int numberOfChildren)
New output file for child.
Definition: JobReport.cc:492
boost::scoped_ptr< JobReportImpl > impl_
Definition: JobReport.h:434
void reportGeneratorInfo(std::string const &name, std::string const &value)
Definition: JobReport.cc:816
void reportLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:653
Value const & findOrDefault(std::map< Key, Value > const &m, Key const &k, Value const &defaultValue)
Definition: Map.h:28
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:749
std::string moduleLabel
Definition: JobReport.h:87
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:888
void reportError(std::string const &shortDesc, std::string const &longDesc)
Definition: JobReport.cc:672
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:658
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:258
void overrideEventsRead(Token fileToken, int const eventsRead)
Definition: JobReport.cc:625
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:844
UInt_t nEvents
Definition: hcalCalib.cc:43
void insertInputForOutputs(Token t)
Definition: JobReport.cc:189
StringVector branchNames
Definition: JobReport.h:90
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
void parentBeforeFork(std::string const &jobReportFile, unsigned int numberOfChildren)
Definition: JobReport.cc:470
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:396
void addGeneratorInfo(std::string const &name, std::string const &value)
Definition: JobReport.cc:306
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:865
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:764
void overrideContributingInputs(Token outputToken, std::vector< Token > const &inputTokens)
Definition: JobReport.cc:633
void reportReadBranches()
Definition: JobReport.cc:780
void associateLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:365
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:164
void reportRunNumber(unsigned int run)
Definition: JobReport.cc:663
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:721