Go to the documentation of this file.00001
00002
00003
00004
00005 #include "InputFile.h"
00006
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "FWCore/Utilities/interface/TimeOfDay.h"
00010
00011 #include <iomanip>
00012
00013 namespace edm {
00014 InputFile::InputFile(char const* fileName, char const* msg) : file_(), fileName_(fileName), reportToken_(0) {
00015 logFileAction(msg, fileName);
00016 file_.reset(TFile::Open(fileName));
00017 if(!file_) {
00018 return;
00019 }
00020 if(file_->IsZombie()) {
00021 file_.reset();
00022 return;
00023 }
00024 logFileAction(" Successfully opened file ", fileName);
00025 }
00026
00027 InputFile::~InputFile() {
00028 Close();
00029 }
00030
00031 void
00032 InputFile::inputFileOpened(std::string const& logicalFileName,
00033 std::string const& inputType,
00034 std::string const& moduleName,
00035 std::string const& label,
00036 std::string const& fid,
00037 std::vector<std::string> const& branchNames) {
00038 Service<JobReport> reportSvc;
00039 reportToken_ = reportSvc->inputFileOpened(fileName_,
00040 logicalFileName,
00041 std::string(),
00042 inputType,
00043 moduleName,
00044 label,
00045 fid,
00046 branchNames);
00047 }
00048
00049 void
00050 InputFile::eventReadFromFile(unsigned int run, unsigned int event) const {
00051 Service<JobReport> reportSvc;
00052 reportSvc->eventReadFromFile(reportToken_, run, event);
00053 }
00054
00055 void
00056 InputFile::reportInputRunNumber(unsigned int run) const {
00057 Service<JobReport> reportSvc;
00058 reportSvc->reportInputRunNumber(run);
00059 }
00060
00061 void
00062 InputFile::reportInputLumiSection(unsigned int run, unsigned int lumi) const {
00063 Service<JobReport> reportSvc;
00064 reportSvc->reportInputLumiSection(run, lumi);
00065 }
00066
00067 void
00068 InputFile::Close() {
00069 if(file_->IsOpen()) {
00070 file_->Close();
00071 try {
00072 logFileAction(" Closed file ", fileName_.c_str());
00073 Service<JobReport> reportSvc;
00074 reportSvc->inputFileClosed(reportToken_);
00075 } catch(...) {
00076
00077
00078 }
00079 }
00080 }
00081
00082 void
00083 InputFile::logFileAction(char const* msg, char const* fileName) const {
00084 LogAbsolute("fileAction") << std::setprecision(0) << TimeOfDay() << msg << fileName;
00085 FlushMessageLog();
00086 }
00087 }