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

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

Detailed Description

Definition at line 21 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 
21  // ROOT's context management implicitly assumes that a file is opened and
22  // closed on the same thread. To avoid the problem, we declare a local
23  // TContext object; when it goes out of scope, its destructor unregisters
24  // the context, guaranteeing the context is unregistered in the same thread
25  // it was registered in. Fixes issue #15524.
26  TDirectory::TContext contextEraser;
27 
29  file_ = std::unique_ptr<TFile>(TFile::Open(fileName)); // propagate_const<T> has no reset() function
30  std::exception_ptr e = edm::threadLocalException::getException();
31  if(e != std::exception_ptr()) {
32  edm::threadLocalException::setException(std::exception_ptr());
33  std::rethrow_exception(e);
34  }
35  if(!file_) {
36  return;
37  }
38  if(file_->IsZombie()) {
39  file_ = nullptr; // propagate_const<T> has no reset() function
40  return;
41  }
42 
43  logFileAction(" Successfully opened file ", fileName);
44  }
JobReport::Token reportToken_
Definition: InputFile.h:53
InputType inputType_
Definition: InputFile.h:54
void logFileAction(char const *msg, char const *fileName) const
Definition: InputFile.cc:114
edm::propagate_const< std::unique_ptr< TFile > > file_
Definition: InputFile.h:51
std::string fileName_
Definition: InputFile.h:52
void setException(std::exception_ptr e)
std::exception_ptr getException()
InputFile::~InputFile ( )

Definition at line 46 of file InputFile.cc.

References Close().

46  {
47  Close();
48  }
void Close()
Definition: InputFile.cc:99
edm::InputFile::InputFile ( InputFile const &  )
delete

Member Function Documentation

void InputFile::Close ( )

Definition at line 99 of file InputFile.cc.

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

Referenced by ~InputFile().

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

Definition at line 69 of file InputFile.cc.

References inputType_, and reportToken_.

69  {
70  Service<JobReport> reportSvc;
71  reportSvc->eventReadFromFile(inputType_, reportToken_);
72  }
JobReport::Token reportToken_
Definition: InputFile.h:53
InputType inputType_
Definition: InputFile.h:54
TObject* edm::InputFile::Get ( char const *  name)
inline

Definition at line 46 of file InputFile.h.

References file_.

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

Definition at line 47 of file InputFile.h.

References file_.

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

47 {return file_->GetCacheRead();}
edm::propagate_const< std::unique_ptr< TFile > > file_
Definition: InputFile.h:51
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 51 of file InputFile.cc.

References fileName_, reportToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

56  {
57  Service<JobReport> reportSvc;
58  reportToken_ = reportSvc->inputFileOpened(fileName_,
59  logicalFileName,
60  std::string(),
61  inputType,
62  moduleName,
63  label,
64  fid,
65  branchNames);
66  }
JobReport::Token reportToken_
Definition: InputFile.h:53
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::string fileName_
Definition: InputFile.h:52
void InputFile::logFileAction ( char const *  msg,
char const *  fileName 
) const

Definition at line 114 of file InputFile.cc.

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

Referenced by Close(), and InputFile().

114  {
115  LogAbsolute("fileAction") << std::setprecision(0) << TimeOfDay() << msg << fileName;
116  FlushMessageLog();
117  }
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 93 of file InputFile.cc.

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

93  {
94  Service<JobReport> reportSvc;
95  reportSvc->reportFallbackAttempt(pfn, logicalFileName, errorMessage);
96  }
void InputFile::reportInputLumiSection ( unsigned int  run,
unsigned int  lumi 
) const

Definition at line 81 of file InputFile.cc.

81  {
82  Service<JobReport> reportSvc;
83  reportSvc->reportInputLumiSection(run, lumi);
84  }
tuple lumi
Definition: fjr2json.py:35
void InputFile::reportInputRunNumber ( unsigned int  run) const

Definition at line 75 of file InputFile.cc.

75  {
76  Service<JobReport> reportSvc;
77  reportSvc->reportInputRunNumber(run);
78  }
void InputFile::reportReadBranch ( InputType  inputType,
std::string const &  branchname 
)
static

Definition at line 126 of file InputFile.cc.

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

126  {
127  Service<JobReport> reportSvc;
128  reportSvc->reportReadBranch(inputType, branchName);
129  }
void InputFile::reportReadBranches ( )
static

Definition at line 120 of file InputFile.cc.

Referenced by edm::EmbeddedRootSource::endJob(), and edm::PoolSource::endJob().

120  {
121  Service<JobReport> reportSvc;
122  reportSvc->reportReadBranches();
123  }
void InputFile::reportSkippedFile ( std::string const &  fileName,
std::string const &  logicalFileName 
)
static

Definition at line 87 of file InputFile.cc.

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

87  {
88  Service<JobReport> reportSvc;
89  reportSvc->reportSkippedFile(fileName, logicalFileName);
90  }
void edm::InputFile::SetCacheRead ( TFileCacheRead *  tfcr)
inline

Definition at line 48 of file InputFile.h.

References file_, and NULL.

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

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

Member Data Documentation

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

Definition at line 51 of file InputFile.h.

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

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

Definition at line 52 of file InputFile.h.

Referenced by Close(), and inputFileOpened().

InputType edm::InputFile::inputType_
private

Definition at line 54 of file InputFile.h.

Referenced by Close(), and eventReadFromFile().

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

Definition at line 53 of file InputFile.h.

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