CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JobReport.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageLogger_JobReport_h
2 #define FWCore_MessageLogger_JobReport_h
3 // -*- C++ -*-
4 //
5 // Package: MessageLogger
6 // Class : JobReport
7 //
19 //
20 // Original Author: Marc Paterno
21 //
22 
23 /*
24 Changes Log 1: 2009/01/14 10:29:00, Natalia Garcia Nebot
25  Modified and added some methods to report CPU and memory information from /proc/cpuinfo
26  and /proc/meminfo files and Memory statistics
27 */
28 
29 #include <cstddef>
30 #include <string>
31 #include <ostream>
32 #include <set>
33 #include <map>
34 #include <vector>
35 
36 #include "boost/scoped_ptr.hpp"
37 
38 namespace edm {
39 
40  class JobReport {
41  public:
42  typedef unsigned int RunNumber;
43  typedef std::size_t Token;
44 
55  unsigned int runNumber;
56  unsigned int lumiSectionId;
63  };
64 
65  struct RunReport {
67  std::set<unsigned int> lumiSections;
68  };
69 
79  struct InputFile {
80  typedef std::vector<std::string> StringVector;
81 
82  std::string logicalFileName;
83  std::string physicalFileName;
84  std::string catalog;
85  std::string inputType; // primaryFiles, secondaryFiles, mixingFiles
86  std::string inputSourceClassName; // class which created the file
87  std::string moduleLabel; // name of class instance
88  std::string guid;
89  size_t numEventsRead;
91  std::map<RunNumber, RunReport> runReports;
93  std::set<std::string> fastClonedBranches;
94  };
95 
105  struct OutputFile {
106 
108 
109  std::string logicalFileName;
110  std::string physicalFileName;
111  std::string catalog;
113  std::string moduleLabel; // name of class instance
114  std::string guid;
115  std::string dataType;
116  std::string branchHash;
119  std::vector<Token> contributingInputs;
120  std::map<std::string, bool> fastCopyingInputs;
121  std::map<RunNumber, RunReport> runReports;
123  };
124 
125  struct JobReportImpl {
126  // Helper functions to be called from the xFileClosed functions,
127  // after the appropriate logging is done.
128  /*
129  * Note: We want to keep input files, so we can resolve tokens
130  * when we close output files
131  *
132  * Note2: Erasing the Output files on close invalidates the Tokens
133  * for existing output files since they are based on position in
134  * the vector, so I have left off implementing these methods for now
135  */
138 
141  /*
142  * Add the input file token provided to every output
143  * file currently available.
144  * Used whenever a new input file is opened, it's token
145  * is added to all open output files as a contributor
146  */
148 
149  /*
150  * get a vector of Tokens for all currently open
151  * input files.
152  * Used when a new output file is opened, all currently open
153  * input file tokens are used to initialise its list of contributors
154  */
155  void openInputFiles(std::vector<Token>& tokens);
156 
157  /*
158  * Get a vector of Tokens for all currently open output files
159  * Used to add lumi sections to open files
160  */
161  void openOutputFiles(std::vector<Token>& tokens);
162 
163  /*
164  * Associate a Lumi Section to all open output files
165  *
166  */
167  void associateLumiSection(unsigned int runNumber, unsigned int lumiSection);
168 
169 
170  /*
171  * Associate a Lumi Section to all open input files
172  *
173  */
174  void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
175  /*
176  * Associate a run to all open output files
177  */
178  void associateRun(unsigned int runNumber);
179  /*
180  * Associate a run to all open output files
181  */
182  void associateInputRun(unsigned int runNumber);
183 
184  /*
185  * Write an InputFile object to the Logger
186  * Generate XML string for InputFile instance and dispatch to
187  * job report via MessageLogger
188  */
189  void writeInputFile(InputFile const& f);
190  /*
191  * Write an OutputFile object to the Logger
192  * Generate an XML string for the OutputFile provided and
193  * dispatch it to the logger
194  * Contributing input tokens are resolved to the input LFN and PFN
195  *
196  * TODO: We have not yet addressed the issue where we cleanup not
197  * contributing input files.
198  * Also, it is possible to get fake input to output file mappings
199  * if an input file is open already when a new output file is opened
200  * but the input gets closed without contributing events to the
201  * output file due to filtering etc.
202  *
203  */
204  void writeOutputFile(OutputFile const& f);
205 
206  /*
207  * Add Generator info to the map of gen info stored in this
208  * instance.
209  */
210  void addGeneratorInfo(std::string const& name, std::string const& value);
211 
212  /*
213  * Write out generator info to the job report
214  */
215  void writeGeneratorInfo(void);
216 
217 
218  /*
219  * Flush all open files to logger in event of a problem.
220  */
221  void flushFiles(void);
222 
223  JobReportImpl(std::ostream* iOst): ost_(iOst) {}
224 
225  std::vector<InputFile> inputFiles_;
226  std::vector<OutputFile> outputFiles_;
227  std::map<std::string, std::string> generatorInfo_;
228  std::map<std::string, long long> readBranches_;
229  std::set<std::string>* fastClonedBranches_;
230  std::ostream* ost_;
231  };
232 
233  JobReport();
234  //Does not take ownership of pointer
235  JobReport(std::ostream* outputStream);
236 
237  ~JobReport();
238 
240  void childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren);
241 
242  void parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren);
243 
244  void parentAfterFork(std::string const& jobReportFile);
245 
249  Token inputFileOpened(std::string const& physicalFileName,
250  std::string const& logicalFileName,
251  std::string const& catalog,
252  std::string const& inputType,
253  std::string const& inputSourceClassName,
254  std::string const& moduleLabel,
255  std::string const& guid,
256  std::vector<std::string> const& branchNames);
257 
260  void eventReadFromFile(Token fileToken, unsigned int run, unsigned int event);
261 
266  void reportDataType(Token fileToken, std::string const& dataType);
267 
268 
272  void inputFileClosed(Token fileToken);
273 
277  Token outputFileOpened(std::string const& physicalFileName,
278  std::string const& logicalFileName,
279  std::string const& catalog,
280  std::string const& outputModuleClassName,
281  std::string const& moduleLabel,
282  std::string const& guid,
283  std::string const& dataType,
284  std::string const& branchHash,
285  std::vector<std::string> const& branchNames);
286 
289  void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event);
290 
294  void outputFileClosed(Token fileToken);
295 
301  void overrideEventsWritten(Token fileToken, int const eventsWritten);
307  void overrideEventsRead(Token fileToken, int const eventsRead);
308 
309  void reportSkippedEvent(unsigned int run, unsigned int event);
310 
316  void reportLumiSection(unsigned int run, unsigned int lumiSectId);
322  void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
323 
327  void reportRunNumber(unsigned int run);
331  void reportInputRunNumber(unsigned int run);
332 
338  void reportError(std::string const& shortDesc,
339  std::string const& longDesc);
340 
341  void reportError(std::string const& shortDesc,
342  std::string const& longDesc,
343  int const& exitCode);
344 
350  void reportSkippedFile(std::string const& pfn, std::string const& lfn);
351 
352  void reportFallbackAttempt(std::string const& pfn, std::string const& lfn, std::string const& err);
353 
354  void reportAnalysisFile(std::string const& fileName,
355  std::map<std::string, std::string> const& fileData) ;
356 
363  void reportMemoryInfo(std::vector<std::string> const& memoryData);
364 
371  void reportMessageInfo(std::map<std::string, double> const& messageData);
372 
379  void reportReadBranches();
380 
382  void reportReadBranch(std::string const& branchName);
383 
385  void reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents);
386 
389  void overrideContributingInputs(Token outputToken, std::vector<Token> const& inputTokens);
390 
394  void reportGeneratorInfo(std::string const& name, std::string const& value);
395 
399  void reportRandomStateFile(std::string const& name);
400 
405  void reportPSetHash(std::string const& hashValue);
406 
407  /*
408  * Report information about fast copying. Called for each open output file
409  * whenever an input file is opened.
410  */
411  void reportFastCopyingStatus(Token t, std::string const& inputFileName, bool fastCopying);
412 
420  void reportPerformanceSummary(std::string const& metricClass,
421  std::map<std::string, std::string> const& metrics);
422 
423  void reportPerformanceForModule(std::string const& metricClass,
424  std::string const& moduleName,
425  std::map<std::string, std::string> const& metrics);
426 
428  std::string dumpFiles(void);
429 
430  protected:
431  boost::scoped_ptr<JobReportImpl>& impl() {return impl_;}
432 
433  private:
434  boost::scoped_ptr<JobReportImpl> impl_;
435 
436  };
437 
438  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f);
439  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f);
440  std::ostream& operator<< (std::ostream& os, JobReport::LumiSectionReport const& rep);
441 
442 }
443 
444 #endif
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
void removeInputFileRecord_(Token t)
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::map< std::string, long long > readBranches_
Definition: JobReport.h:228
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
std::vector< std::string > StringVector
Definition: JobReport.h:80
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
InputFile::StringVector StringVector
Definition: JobReport.h:107
void removeOutputFileRecord_(Token t)
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:229
void inputFileClosed(Token fileToken)
Definition: JobReport.cc:550
StringVector branchNames
Definition: JobReport.h:118
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:121
std::map< std::string, std::string > generatorInfo_
Definition: JobReport.h:227
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
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
std::vector< OutputFile > outputFiles_
Definition: JobReport.h:226
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:667
unsigned int RunNumber
Definition: JobReport.h:42
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
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
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
boost::scoped_ptr< JobReportImpl > & impl()
Definition: JobReport.h:431
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
JobReportImpl(std::ostream *iOst)
Definition: JobReport.h:223
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.
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
std::set< std::string > * fastClonedBranches_
Definition: JobReport.h:229
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