00001 #ifndef FWCore_MessageLogger_JobReport_h
00002 #define FWCore_MessageLogger_JobReport_h
00003
00004
00005
00006
00007
00020
00021
00022
00023
00024
00025 #include <cstddef>
00026 #include <string>
00027 #include <ostream>
00028 #include <set>
00029 #include <map>
00030 #include <vector>
00031
00032
00033 #include "boost/scoped_ptr.hpp"
00034
00035 namespace edm {
00036
00037 class JobReport {
00038 public:
00039 typedef unsigned int RunNumber;
00040 typedef std::size_t Token;
00041
00042
00052 struct LumiSectionReport {
00053 unsigned int runNumber;
00054 unsigned int lumiSectionId;
00061
00062 };
00063
00064 struct RunReport {
00065 RunNumber runNumber;
00066 std::set<unsigned int> lumiSections;
00067
00068 };
00069
00079 struct InputFile {
00080 typedef std::vector<std::string> StringVector;
00081
00082 std::string logicalFileName;
00083 std::string physicalFileName;
00084 std::string catalog;
00085 std::string inputSourceClassName;
00086 std::string moduleLabel;
00087 std::string guid;
00088 size_t numEventsRead;
00089 StringVector branchNames;
00090 std::map<RunNumber, RunReport> runReports;
00091 bool fileHasBeenClosed;
00092 };
00093
00094
00105 struct OutputFile {
00106
00107 typedef InputFile::StringVector StringVector;
00108
00109 std::string logicalFileName;
00110 std::string physicalFileName;
00111 std::string catalog;
00112 std::string outputModuleClassName;
00113 std::string moduleLabel;
00114 std::string guid;
00115 std::string dataType;
00116 std::string branchHash;
00117 size_t numEventsWritten;
00118 StringVector branchNames;
00119 std::vector<Token> contributingInputs;
00120 std::map<RunNumber, RunReport> runReports;
00121 bool fileHasBeenClosed;
00122 };
00123
00124 struct JobReportImpl {
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 void removeInputFileRecord_(Token t);
00136 void removeOutputFileRecord_(Token t);
00137
00138 InputFile& getInputFileForToken(Token t);
00139 OutputFile& getOutputFileForToken(Token t);
00140
00141
00142
00143
00144
00145
00146 void insertInputForOutputs(Token t);
00147
00148
00149
00150
00151
00152
00153
00154 std::vector<Token> openInputFiles(void);
00155
00156
00157
00158
00159
00160 std::vector<Token> openOutputFiles(void);
00161
00162
00163
00164
00165
00166 void associateLumiSection(unsigned int runNumber, unsigned int lumiSection);
00167
00168
00169
00170
00171
00172
00173 void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
00174
00175
00176
00177 void associateRun(unsigned int runNumber);
00178
00179
00180
00181 void associateInputRun(unsigned int runNumber);
00182
00183
00184
00185
00186
00187
00188
00189 void writeInputFile(const InputFile & f);
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 void writeOutputFile(const OutputFile & f);
00205
00206
00207
00208
00209
00210
00211 void addGeneratorInfo(const std::string& name, const std::string& value);
00212
00213
00214
00215
00216 void writeGeneratorInfo(void);
00217
00218
00219
00220
00221
00222 void flushFiles(void);
00223
00224 JobReportImpl(std::ostream* iOst): ost_(iOst) {}
00225
00226 std::vector<InputFile> inputFiles_;
00227 std::vector<OutputFile> outputFiles_;
00228 std::map<std::string, std::string> generatorInfo_;
00229 std::ostream* ost_;
00230 };
00231
00232 JobReport();
00233
00234 JobReport(std::ostream* outputStream);
00235
00236 ~JobReport();
00237
00241 Token inputFileOpened(std::string const& physicalFileName,
00242 std::string const& logicalFileName,
00243 std::string const& catalog,
00244 std::string const& inputSourceClassName,
00245 std::string const& moduleLabel,
00246 std::string const& guid,
00247 std::vector<std::string> const& branchNames);
00248
00249 Token inputFileOpened(std::string const& physicalFileName,
00250 std::string const& logicalFileName,
00251 std::string const& catalog,
00252 std::string const& inputSourceClassName,
00253 std::string const& moduleLabel,
00254 std::vector<std::string> const& branchNames);
00257 void eventReadFromFile(Token fileToken, unsigned int run, unsigned int event);
00258
00263 void reportDataType(Token fileToken, std::string const& dataType);
00264
00265
00269 void inputFileClosed(Token fileToken);
00270
00274 Token outputFileOpened(std::string const& physicalFileName,
00275 std::string const& logicalFileName,
00276 std::string const& catalog,
00277 std::string const& outputModuleClassName,
00278 std::string const& moduleLabel,
00279 std::string const& guid,
00280 std::string const& dataType,
00281 std::string const& branchHash,
00282 std::vector<std::string> const& branchNames);
00283
00284 Token outputFileOpened(std::string const& physicalFileName,
00285 std::string const& logicalFileName,
00286 std::string const& catalog,
00287 std::string const& outputModuleClassName,
00288 std::string const& moduleLabel,
00289 std::string const& guid,
00290 std::string const& dataType,
00291 std::vector<std::string> const& branchNames);
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 Token outputFileOpened(std::string const& physicalFileName,
00303 std::string const& logicalFileName,
00304 std::string const& catalog,
00305 std::string const& outputModuleClassName,
00306 std::string const& moduleLabel,
00307 std::string const& guid,
00308 std::vector<std::string> const& branchNames);
00309
00310
00311 Token outputFileOpened(std::string const& physicalFileName,
00312 std::string const& logicalFileName,
00313 std::string const& catalog,
00314 std::string const& outputModuleClassName,
00315 std::string const& moduleLabel,
00316 std::vector<std::string> const& branchNames);
00317
00318
00319
00322 void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event);
00323
00327 void outputFileClosed(Token fileToken);
00328
00334 void overrideEventsWritten(Token fileToken, const int eventsWritten);
00340 void overrideEventsRead(Token fileToken, const int eventsRead);
00341
00342 void reportSkippedEvent(unsigned int run, unsigned int event);
00343
00344
00350 void reportLumiSection(unsigned int run, unsigned int lumiSectId);
00356 void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
00357
00361 void reportRunNumber(unsigned int run);
00365 void reportInputRunNumber(unsigned int run);
00366
00372 void reportError(std::string const& shortDesc,
00373 std::string const& longDesc);
00374
00375 void reportError(std::string const& shortDesc,
00376 std::string const& longDesc,
00377 int const& exitCode);
00378
00384 void reportSkippedFile(std::string const& pfn, std::string const& lfn);
00385
00386 void reportAnalysisFile(std::string const& fileName,
00387 std::map<std::string, std::string> const& fileData) ;
00393 void reportTimingInfo(std::map<std::string, double> const & timingData);
00394
00400 void reportMemoryInfo(std::map<std::string, double> const& memoryData);
00401
00408 void reportMemoryInfo(std::vector<std::string> const& memoryData);
00409
00416 void reportMessageInfo(std::map<std::string, double> const & messageData);
00417
00419 void reportStorageStats(std::string const & data);
00420
00423 void overrideContributingInputs(Token outputToken, std::vector<Token> const& inputTokens);
00424
00428 void reportGeneratorInfo(std::string const& name, std::string const& value);
00429
00433 void reportRandomStateFile(std::string const& name);
00434
00439 void reportPSetHash(std::string const& hashValue);
00440
00441
00449 void reportPerformanceSummary(std::string const& metricClass,
00450 std::map<std::string, std::string> const& metrics);
00451
00452 void reportPerformanceForModule(std::string const& metricClass,
00453 std::string const& moduleName,
00454 std::map<std::string, std::string> const& metrics);
00455
00456
00457
00459 std::string dumpFiles(void);
00460
00461 protected:
00462 boost::scoped_ptr<JobReportImpl>& impl() {return impl_;}
00463
00464 private:
00465 boost::scoped_ptr<JobReportImpl> impl_;
00466
00467 };
00468
00469 std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f);
00470 std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f);
00471 std::ostream& operator<< (std::ostream& os, JobReport::LumiSectionReport const& rep);
00472
00473
00474
00475
00476
00477
00478 template <typename S, typename T>
00479 S& formatFile(const T& f, S& os) {
00480
00481 if (f.fileHasBeenClosed) {
00482 os << "\n<State Value=\"closed\"/>";
00483 } else {
00484 os << "\n<State Value=\"open\"/>";
00485 }
00486 os << "\n<LFN>" << f.logicalFileName << "</LFN>";
00487 os << "\n<PFN>" << f.physicalFileName << "</PFN>";
00488 os << "\n<Catalog>" << f.catalog << "</Catalog>";
00489 os << "\n<ModuleLabel>" << f.moduleLabel << "</ModuleLabel>";
00490 os << "\n<GUID>" << f.guid << "</GUID>";
00491 os << "\n<Branches>";
00492 std::vector<std::string>::const_iterator iBranch;
00493 for (iBranch = f.branchNames.begin();
00494 iBranch != f.branchNames.end();
00495 iBranch++) {
00496 os << "\n <Branch>" << *iBranch << "</Branch>";
00497 }
00498 os << "\n</Branches>";
00499 return os;
00500 }
00501 }
00502
00503 #endif