CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InputFile.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 Holder for an input TFile.
3 ----------------------------------------------------------------------*/
4 #include "InputFile.h"
5 
9 
10 #include <iomanip>
11 
12 namespace edm {
13  InputFile::InputFile(char const* fileName, char const* msg) : file_(), fileName_(fileName), reportToken_(0) {
14  logFileAction(msg, fileName);
15  file_.reset(TFile::Open(fileName));
16  if(!file_) {
17  return;
18  }
19  if(file_->IsZombie()) {
20  file_.reset();
21  return;
22  }
23  logFileAction(" Successfully opened file ", fileName);
24  }
25 
27  Close();
28  }
29 
30  void
31  InputFile::inputFileOpened(std::string const& logicalFileName,
32  std::string const& inputType,
33  std::string const& moduleName,
34  std::string const& label,
35  std::string const& fid,
36  std::vector<std::string> const& branchNames) {
37  Service<JobReport> reportSvc;
38  reportToken_ = reportSvc->inputFileOpened(fileName_,
39  logicalFileName,
40  std::string(),
41  inputType,
42  moduleName,
43  label,
44  fid,
45  branchNames);
46  }
47 
48  void
49  InputFile::eventReadFromFile(unsigned int run, unsigned int event) const {
50  Service<JobReport> reportSvc;
51  reportSvc->eventReadFromFile(reportToken_, run, event);
52  }
53 
54  void
55  InputFile::reportInputRunNumber(unsigned int run) const {
56  Service<JobReport> reportSvc;
57  reportSvc->reportInputRunNumber(run);
58  }
59 
60  void
61  InputFile::reportInputLumiSection(unsigned int run, unsigned int lumi) const {
62  Service<JobReport> reportSvc;
63  reportSvc->reportInputLumiSection(run, lumi);
64  }
65 
66  void
68  Service<JobReport> reportSvc;
69  reportSvc->reportSkippedFile(fileName, logicalFileName);
70  }
71 
72  void
73  InputFile::reportFallbackAttempt(std::string const& pfn, std::string const& logicalFileName, std::string const& errorMessage) {
74  Service<JobReport> reportSvc;
75  reportSvc->reportFallbackAttempt(pfn, logicalFileName, errorMessage);
76  }
77 
78  void
80  if(file_->IsOpen()) {
81  file_->Close();
82  try {
83  logFileAction(" Closed file ", fileName_.c_str());
84  Service<JobReport> reportSvc;
85  reportSvc->inputFileClosed(reportToken_);
86  } catch(std::exception) {
87  // If Close() called in a destructor after an exception throw, the services may no longer be active.
88  // Therefore, we catch any reasonable new exception.
89  }
90  }
91  }
92 
93  void
94  InputFile::logFileAction(char const* msg, char const* fileName) const {
95  LogAbsolute("fileAction") << std::setprecision(0) << TimeOfDay() << msg << fileName;
97  }
98 
99  void
101  Service<JobReport> reportSvc;
102  reportSvc->reportReadBranches();
103  }
104 
105  void
107  Service<JobReport> reportSvc;
108  reportSvc->reportReadBranch(branchName);
109  }
110 }
list pfn
Definition: dbtoconf.py:76
void reportInputLumiSection(unsigned int run, unsigned int lumi) const
Definition: InputFile.cc:61
void FlushMessageLog()
JobReport::Token reportToken_
Definition: InputFile.h:51
tuple lumi
Definition: fjr2json.py:35
void inputFileOpened(std::string const &logicalFileName, std::string const &inputType, std::string const &moduleName, std::string const &label, std::string const &fid, std::vector< std::string > const &branchNames)
Definition: InputFile.cc:31
void logFileAction(char const *msg, char const *fileName) const
Definition: InputFile.cc:94
static void reportSkippedFile(std::string const &fileName, std::string const &logicalFileName)
Definition: InputFile.cc:67
static void reportFallbackAttempt(std::string const &pfn, std::string const &logicalFileName, std::string const &errorMessage)
Definition: InputFile.cc:73
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
std::unique_ptr< TFile > file_
Definition: InputFile.h:49
std::string fileName_
Definition: InputFile.h:50
static void reportReadBranch(std::string const &branchname)
Definition: InputFile.cc:106
static void reportReadBranches()
Definition: InputFile.cc:100
void Close()
Definition: InputFile.cc:79
InputFile(char const *fileName, char const *msg)
Definition: InputFile.cc:13
list fid
Definition: NewTree.py:51
void eventReadFromFile(unsigned int run, unsigned int event) const
Definition: InputFile.cc:49
void reportInputRunNumber(unsigned int run) const
Definition: InputFile.cc:55