CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::InputFile Class Reference

#include <InputFile.h>

Public Member Functions

void Close ()
 
void eventReadFromFile () const
 
TObject * Get (char const *name)
 
TFileCacheRead * GetCacheRead () const
 
 InputFile (char const *fileName, char const *msg, InputType inputType)
 
 InputFile (InputFile const &)=delete
 
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)
 
void logFileAction (char const *msg, char const *fileName) const
 
InputFileoperator= (InputFile const &)=delete
 
void reportInputLumiSection (unsigned int run, unsigned int lumi) const
 
void reportInputRunNumber (unsigned int run) const
 
void SetCacheRead (TFileCacheRead *tfcr)
 
 ~InputFile ()
 

Static Public Member Functions

static void reportFallbackAttempt (std::string const &pfn, std::string const &logicalFileName, std::string const &errorMessage)
 
static void reportReadBranch (InputType inputType, std::string const &branchname)
 
static void reportReadBranches ()
 
static void reportSkippedFile (std::string const &fileName, std::string const &logicalFileName)
 

Private Attributes

std::unique_ptr< TFile > file_
 
std::string fileName_
 
InputType inputType_
 
JobReport::Token reportToken_
 

Detailed Description

Definition at line 20 of file InputFile.h.

Constructor & Destructor Documentation

InputFile::InputFile ( char const *  fileName,
char const *  msg,
InputType  inputType 
)
explicit

Definition at line 18 of file InputFile.cc.

References alignCSCRings::e, file_, edm::threadLocalException::getException(), logFileAction(), and edm::threadLocalException::setException().

18  :
19  file_(), fileName_(fileName), reportToken_(0), inputType_(inputType) {
20 
22  file_.reset(TFile::Open(fileName));
23  std::exception_ptr e = edm::threadLocalException::getException();
24  if(e != std::exception_ptr()) {
25  edm::threadLocalException::setException(std::exception_ptr());
26  std::rethrow_exception(e);
27  }
28  if(!file_) {
29  return;
30  }
31  if(file_->IsZombie()) {
32  file_.reset();
33  return;
34  }
35 
36  logFileAction(" Successfully opened file ", fileName);
37  }
JobReport::Token reportToken_
Definition: InputFile.h:52
InputType inputType_
Definition: InputFile.h:53
void logFileAction(char const *msg, char const *fileName) const
Definition: InputFile.cc:107
std::unique_ptr< TFile > file_
Definition: InputFile.h:50
std::string fileName_
Definition: InputFile.h:51
void setException(std::exception_ptr e)
std::exception_ptr getException()
InputFile::~InputFile ( )

Definition at line 39 of file InputFile.cc.

References Close().

39  {
40  Close();
41  }
void Close()
Definition: InputFile.cc:92
edm::InputFile::InputFile ( InputFile const &  )
delete

Member Function Documentation

void InputFile::Close ( )

Definition at line 92 of file InputFile.cc.

References cppFunctionSkipper::exception, file_, fileName_, inputType_, logFileAction(), and reportToken_.

Referenced by ~InputFile().

92  {
93  if(file_->IsOpen()) {
94  file_->Close();
95  try {
96  logFileAction(" Closed file ", fileName_.c_str());
97  Service<JobReport> reportSvc;
98  reportSvc->inputFileClosed(inputType_, reportToken_);
99  } catch(std::exception) {
100  // If Close() called in a destructor after an exception throw, the services may no longer be active.
101  // Therefore, we catch any reasonable new exception.
102  }
103  }
104  }
JobReport::Token reportToken_
Definition: InputFile.h:52
InputType inputType_
Definition: InputFile.h:53
void logFileAction(char const *msg, char const *fileName) const
Definition: InputFile.cc:107
std::unique_ptr< TFile > file_
Definition: InputFile.h:50
std::string fileName_
Definition: InputFile.h:51
void InputFile::eventReadFromFile ( ) const

Definition at line 62 of file InputFile.cc.

References inputType_, and reportToken_.

62  {
63  Service<JobReport> reportSvc;
64  reportSvc->eventReadFromFile(inputType_, reportToken_);
65  }
JobReport::Token reportToken_
Definition: InputFile.h:52
InputType inputType_
Definition: InputFile.h:53
TObject* edm::InputFile::Get ( char const *  name)
inline

Definition at line 45 of file InputFile.h.

References file_.

45 {return file_->Get(name);}
std::unique_ptr< TFile > file_
Definition: InputFile.h:50
TFileCacheRead* edm::InputFile::GetCacheRead ( ) const
inline

Definition at line 46 of file InputFile.h.

References file_.

Referenced by edm::roottree::trainCache().

46 {return file_->GetCacheRead();}
std::unique_ptr< TFile > file_
Definition: InputFile.h:50
void InputFile::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 at line 44 of file InputFile.cc.

References fileName_, reportToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

49  {
50  Service<JobReport> reportSvc;
51  reportToken_ = reportSvc->inputFileOpened(fileName_,
52  logicalFileName,
53  std::string(),
54  inputType,
55  moduleName,
56  label,
57  fid,
58  branchNames);
59  }
JobReport::Token reportToken_
Definition: InputFile.h:52
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::string fileName_
Definition: InputFile.h:51
list fid
Definition: NewTree.py:51
void InputFile::logFileAction ( char const *  msg,
char const *  fileName 
) const

Definition at line 107 of file InputFile.cc.

References MillePedeFileConverter_cfg::fileName, and edm::FlushMessageLog().

Referenced by Close(), and InputFile().

107  {
108  LogAbsolute("fileAction") << std::setprecision(0) << TimeOfDay() << msg << fileName;
109  FlushMessageLog();
110  }
void FlushMessageLog()
InputFile& edm::InputFile::operator= ( InputFile const &  )
delete
void InputFile::reportFallbackAttempt ( std::string const &  pfn,
std::string const &  logicalFileName,
std::string const &  errorMessage 
)
static

Definition at line 86 of file InputFile.cc.

Referenced by edm::RootInputFileSequence::initFile().

86  {
87  Service<JobReport> reportSvc;
88  reportSvc->reportFallbackAttempt(pfn, logicalFileName, errorMessage);
89  }
list pfn
Definition: dbtoconf.py:76
void InputFile::reportInputLumiSection ( unsigned int  run,
unsigned int  lumi 
) const

Definition at line 74 of file InputFile.cc.

74  {
75  Service<JobReport> reportSvc;
76  reportSvc->reportInputLumiSection(run, lumi);
77  }
tuple lumi
Definition: fjr2json.py:35
void InputFile::reportInputRunNumber ( unsigned int  run) const

Definition at line 68 of file InputFile.cc.

68  {
69  Service<JobReport> reportSvc;
70  reportSvc->reportInputRunNumber(run);
71  }
void InputFile::reportReadBranch ( InputType  inputType,
std::string const &  branchname 
)
static

Definition at line 119 of file InputFile.cc.

Referenced by edm::RootDelayedReader::getProduct_().

119  {
120  Service<JobReport> reportSvc;
121  reportSvc->reportReadBranch(inputType, branchName);
122  }
void InputFile::reportReadBranches ( )
static

Definition at line 113 of file InputFile.cc.

Referenced by edm::PoolSource::endJob().

113  {
114  Service<JobReport> reportSvc;
115  reportSvc->reportReadBranches();
116  }
void InputFile::reportSkippedFile ( std::string const &  fileName,
std::string const &  logicalFileName 
)
static

Definition at line 80 of file InputFile.cc.

Referenced by edm::RootInputFileSequence::initFile().

80  {
81  Service<JobReport> reportSvc;
82  reportSvc->reportSkippedFile(fileName, logicalFileName);
83  }
void edm::InputFile::SetCacheRead ( TFileCacheRead *  tfcr)
inline

Definition at line 47 of file InputFile.h.

References file_, and NULL.

Referenced by edm::roottree::trainCache().

47 {file_->SetCacheRead(tfcr, NULL, TFile::kDoNotDisconnect);}
#define NULL
Definition: scimark2.h:8
std::unique_ptr< TFile > file_
Definition: InputFile.h:50

Member Data Documentation

std::unique_ptr<TFile> edm::InputFile::file_
private

Definition at line 50 of file InputFile.h.

Referenced by Close(), Get(), GetCacheRead(), InputFile(), and SetCacheRead().

std::string edm::InputFile::fileName_
private

Definition at line 51 of file InputFile.h.

Referenced by Close(), and inputFileOpened().

InputType edm::InputFile::inputType_
private

Definition at line 53 of file InputFile.h.

Referenced by Close(), and eventReadFromFile().

JobReport::Token edm::InputFile::reportToken_
private

Definition at line 52 of file InputFile.h.

Referenced by Close(), eventReadFromFile(), and inputFileOpened().