00001 #ifndef FWCore_MessageLogger_JobReport_h
00002 #define FWCore_MessageLogger_JobReport_h
00003
00004
00005
00006
00007
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <cstddef>
00030 #include <string>
00031 #include <ostream>
00032 #include <set>
00033 #include <map>
00034 #include <vector>
00035
00036 #include "boost/scoped_ptr.hpp"
00037 #include "FWCore/Utilities/interface/tinyxml.h"
00038
00039 namespace edm {
00040
00041 class JobReport {
00042 public:
00043 typedef unsigned int RunNumber;
00044 typedef std::size_t Token;
00045
00055 struct LumiSectionReport {
00056 unsigned int runNumber;
00057 unsigned int lumiSectionId;
00064 };
00065
00066 struct RunReport {
00067 RunNumber runNumber;
00068 std::set<unsigned int> lumiSections;
00069 };
00070
00080 struct InputFile {
00081 typedef std::vector<std::string> StringVector;
00082
00083 std::string logicalFileName;
00084 std::string physicalFileName;
00085 std::string catalog;
00086 std::string inputType;
00087 std::string inputSourceClassName;
00088 std::string moduleLabel;
00089 std::string guid;
00090 size_t numEventsRead;
00091 StringVector branchNames;
00092 std::map<RunNumber, RunReport> runReports;
00093 bool fileHasBeenClosed;
00094 };
00095
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<std::string, bool> fastCopyingInputs;
00121 std::map<RunNumber, RunReport> runReports;
00122 bool fileHasBeenClosed;
00123 };
00124
00125 struct JobReportImpl {
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 void removeInputFileRecord_(Token t);
00137 void removeOutputFileRecord_(Token t);
00138
00139 InputFile& getInputFileForToken(Token t);
00140 OutputFile& getOutputFileForToken(Token t);
00141
00142
00143
00144
00145
00146
00147 void insertInputForOutputs(Token t);
00148
00149
00150
00151
00152
00153
00154
00155 void openInputFiles(std::vector<Token>& tokens);
00156
00157
00158
00159
00160
00161 void openOutputFiles(std::vector<Token>& tokens);
00162
00163
00164
00165
00166
00167 void associateLumiSection(unsigned int runNumber, unsigned int lumiSection);
00168
00169
00170
00171
00172
00173
00174 void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
00175
00176
00177
00178 void associateRun(unsigned int runNumber);
00179
00180
00181
00182 void associateInputRun(unsigned int runNumber);
00183
00184
00185
00186
00187
00188
00189 void writeInputFile(InputFile const& f);
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 void writeOutputFile(OutputFile const& f);
00205
00206
00207
00208
00209
00210 void addGeneratorInfo(std::string const& name, std::string const& value);
00211
00212
00213
00214
00215 void writeGeneratorInfo(void);
00216
00217
00218
00219
00220
00221 void flushFiles(void);
00222
00223 JobReportImpl(std::ostream* iOst): ost_(iOst) {}
00224
00225 std::vector<InputFile> inputFiles_;
00226 std::vector<OutputFile> outputFiles_;
00227 std::map<std::string, std::string> generatorInfo_;
00228 std::ostream* ost_;
00229 };
00230
00231 JobReport();
00232
00233 JobReport(std::ostream* outputStream);
00234
00235 ~JobReport();
00236
00238 void childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren);
00239
00240 void parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren);
00241
00242 void parentAfterFork(std::string const& jobReportFile);
00243
00247 Token inputFileOpened(std::string const& physicalFileName,
00248 std::string const& logicalFileName,
00249 std::string const& catalog,
00250 std::string const& inputType,
00251 std::string const& inputSourceClassName,
00252 std::string const& moduleLabel,
00253 std::string const& guid,
00254 std::vector<std::string> const& branchNames);
00255
00258 void eventReadFromFile(Token fileToken, unsigned int run, unsigned int event);
00259
00264 void reportDataType(Token fileToken, std::string const& dataType);
00265
00266
00270 void inputFileClosed(Token fileToken);
00271
00275 Token outputFileOpened(std::string const& physicalFileName,
00276 std::string const& logicalFileName,
00277 std::string const& catalog,
00278 std::string const& outputModuleClassName,
00279 std::string const& moduleLabel,
00280 std::string const& guid,
00281 std::string const& dataType,
00282 std::string const& branchHash,
00283 std::vector<std::string> const& branchNames);
00284
00287 void eventWrittenToFile(Token fileToken, unsigned int run, unsigned int event);
00288
00292 void outputFileClosed(Token fileToken);
00293
00299 void overrideEventsWritten(Token fileToken, int const eventsWritten);
00305 void overrideEventsRead(Token fileToken, int const eventsRead);
00306
00307 void reportSkippedEvent(unsigned int run, unsigned int event);
00308
00314 void reportLumiSection(unsigned int run, unsigned int lumiSectId);
00320 void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
00321
00325 void reportRunNumber(unsigned int run);
00329 void reportInputRunNumber(unsigned int run);
00330
00336 void reportError(std::string const& shortDesc,
00337 std::string const& longDesc);
00338
00339 void reportError(std::string const& shortDesc,
00340 std::string const& longDesc,
00341 int const& exitCode);
00342
00348 void reportSkippedFile(std::string const& pfn, std::string const& lfn);
00349
00350 void reportAnalysisFile(std::string const& fileName,
00351 std::map<std::string, std::string> const& fileData) ;
00352
00359 void reportMemoryInfo(std::vector<std::string> const& memoryData);
00360
00367 void reportMessageInfo(std::map<std::string, double> const& messageData);
00368
00371 void overrideContributingInputs(Token outputToken, std::vector<Token> const& inputTokens);
00372
00376 void reportGeneratorInfo(std::string const& name, std::string const& value);
00377
00381 void reportRandomStateFile(std::string const& name);
00382
00387 void reportPSetHash(std::string const& hashValue);
00388
00389
00390
00391
00392
00393 void reportFastCopyingStatus(Token t, std::string const& inputFileName, bool fastCopying);
00394
00402 void reportPerformanceSummary(std::string const& metricClass,
00403 std::map<std::string, std::string> const& metrics);
00404
00405 void reportPerformanceForModule(std::string const& metricClass,
00406 std::string const& moduleName,
00407 std::map<std::string, std::string> const& metrics);
00408
00410 std::string dumpFiles(void);
00411
00412 protected:
00413 boost::scoped_ptr<JobReportImpl>& impl() {return impl_;}
00414
00415 private:
00416 boost::scoped_ptr<JobReportImpl> impl_;
00417
00418 };
00419
00420 std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f);
00421 std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f);
00422 std::ostream& operator<< (std::ostream& os, JobReport::LumiSectionReport const& rep);
00423
00424
00425
00426
00427
00428
00429 template <typename S, typename T>
00430 S& formatFile(T const& f, S& os) {
00431
00432 if (f.fileHasBeenClosed) {
00433 os << "\n<State Value=\"closed\"/>";
00434 } else {
00435 os << "\n<State Value=\"open\"/>";
00436 }
00437
00438 os << "\n<LFN>" << TiXmlText(f.logicalFileName) << "</LFN>";
00439 os << "\n<PFN>" << TiXmlText(f.physicalFileName) << "</PFN>";
00440 os << "\n<Catalog>" << TiXmlText(f.catalog) << "</Catalog>";
00441 os << "\n<ModuleLabel>" << TiXmlText(f.moduleLabel) << "</ModuleLabel>";
00442 os << "\n<GUID>" << f.guid << "</GUID>";
00443 os << "\n<Branches>";
00444 for (std::vector<std::string>::const_iterator iBranch = f.branchNames.begin(),
00445 iBranchEnd = f.branchNames.end();
00446 iBranch != iBranchEnd;
00447 ++iBranch) {
00448 os << "\n <Branch>" << TiXmlText(*iBranch) << "</Branch>";
00449 }
00450 os << "\n</Branches>";
00451 return os;
00452 }
00453 }
00454
00455 #endif