CMS 3D CMS Logo

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

#include <TFileService.h>

Inheritance diagram for TFileService:
TFileDirectory

Public Member Functions

void afterBeginJob ()
 Hook for writing info into JR. More...
 
TFile & file () const
 return opened TFile More...
 
 TFileService (const edm::ParameterSet &, edm::ActivityRegistry &)
 constructor More...
 
 ~TFileService ()
 destructor More...
 
- Public Member Functions inherited from TFileDirectory
bool cd () const
 
TDirectory * getBareDirectory (const std::string &subdir="") const
 
TH1 * getHist (const std::string &histname, const std::string &subdir="") const
 
template<typename T >
T * getObject (const std::string &objname, const std::string &subdir="")
 
template<typename T >
T * make () const
 make new ROOT object More...
 
template<typename T , typename Arg1 >
T * make (const Arg1 &a1) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 >
T * make (const Arg1 &a1, const Arg2 &a2) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 , typename Arg10 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9, const Arg10 &a10) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 , typename Arg10 , typename Arg11 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9, const Arg10 &a10, const Arg11 &a11) const
 make new ROOT object More...
 
template<typename T , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 , typename Arg5 , typename Arg6 , typename Arg7 , typename Arg8 , typename Arg9 , typename Arg10 , typename Arg11 , typename Arg12 >
T * make (const Arg1 &a1, const Arg2 &a2, const Arg3 &a3, const Arg4 &a4, const Arg5 &a5, const Arg6 &a6, const Arg7 &a7, const Arg8 &a8, const Arg9 &a9, const Arg10 &a10, const Arg11 &a11, const Arg12 &a12) const
 make new ROOT object More...
 
TFileDirectory mkdir (const std::string &dir, const std::string &descr="")
 create a new subdirectory More...
 
virtual ~TFileDirectory ()
 descructor More...
 

Private Member Functions

void setDirectoryName (const edm::ModuleDescription &desc)
 

Private Attributes

bool closeFileFast_
 
TFile * file_
 pointer to opened TFile More...
 
std::string fileName_
 
bool fileNameRecorded_
 

Detailed Description

Definition at line 16 of file TFileService.h.

Constructor & Destructor Documentation

TFileService::TFileService ( const edm::ParameterSet cfg,
edm::ActivityRegistry r 
)

constructor

Definition at line 13 of file TFileService.cc.

References afterBeginJob(), setDirectoryName(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPreModule(), edm::ActivityRegistry::watchPreModuleBeginJob(), edm::ActivityRegistry::watchPreModuleBeginLumi(), edm::ActivityRegistry::watchPreModuleBeginRun(), edm::ActivityRegistry::watchPreModuleConstruction(), edm::ActivityRegistry::watchPreModuleEndJob(), edm::ActivityRegistry::watchPreModuleEndLumi(), and edm::ActivityRegistry::watchPreModuleEndRun().

13  :
14  TFileDirectory("", "", TFile::Open(cfg.getParameter<string>("fileName").c_str() , "RECREATE"), ""),
16  fileName_(cfg.getParameter<string>("fileName")),
17  fileNameRecorded_(false),
18  closeFileFast_(cfg.getUntrackedParameter<bool>("closeFileFast", false))
19 {
20  // activities to monitor in order to set the proper directory
29  // delay writing into JobReport after BeginJob
31 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TFileDirectory(const std::string &dir, const std::string &descr, TFile *file, const std::string &path)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void watchPreModuleEndLumi(PreModuleEndLumi::slot_type const &iSlot)
TFile * file_
pointer to opened TFile
Definition: TFileService.h:30
void watchPreModule(PreModule::slot_type const &iSlot)
std::string fileName_
Definition: TFileService.h:31
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:40
void watchPreModuleEndRun(PreModuleEndRun::slot_type const &iSlot)
void watchPreModuleEndJob(PreModuleEndJob::slot_type const &iSlot)
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
bool fileNameRecorded_
Definition: TFileService.h:32
bool closeFileFast_
Definition: TFileService.h:33
void afterBeginJob()
Hook for writing info into JR.
Definition: TFileService.cc:45
void watchPreModuleBeginLumi(PreModuleBeginLumi::slot_type const &iSlot)
void watchPreModuleBeginRun(PreModuleBeginRun::slot_type const &iSlot)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
TFileService::~TFileService ( )

destructor

Definition at line 33 of file TFileService.cc.

References closeFileFast_, and file_.

33  {
34  file_->Write();
35  if(closeFileFast_) gROOT->GetListOfFiles()->Remove(file_);
36  file_->Close();
37  delete file_;
38 }
TFile * file_
pointer to opened TFile
Definition: TFileService.h:30
bool closeFileFast_
Definition: TFileService.h:33

Member Function Documentation

void TFileService::afterBeginJob ( )

Hook for writing info into JR.

Definition at line 45 of file TFileService.cc.

References fileName_, fileNameRecorded_, newFWLiteAna::fullName, and edm::JobReport::reportAnalysisFile().

Referenced by TFileService().

45  {
46 
47  if(!fileName_.empty()) {
48  if(!fileNameRecorded_) {
49  string fullName;
50  fullName.reserve(1024);
51  fullName = getcwd(&fullName[0],1024);
52  fullName += "/" + fileName_;
53 
54  map<string,string> fileData;
55  fileData.insert(make_pair("Source","TFileService"));
56 
57  Service<JobReport> reportSvc;
58  reportSvc->reportAnalysisFile(fullName,fileData);
59  fileNameRecorded_ = true;
60  }
61  }
62 }
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:652
std::string fileName_
Definition: TFileService.h:31
string fullName
bool fileNameRecorded_
Definition: TFileService.h:32
TFile& TFileService::file ( ) const
inline

return opened TFile

Definition at line 23 of file TFileService.h.

References file_.

Referenced by BTagPerformaceRootProducerFromSQLITE::analyze(), and MuonAlignmentFromReference::MuonAlignmentFromReference().

23 { return * file_; }
TFile * file_
pointer to opened TFile
Definition: TFileService.h:30
void TFileService::setDirectoryName ( const edm::ModuleDescription desc)
private

Definition at line 40 of file TFileService.cc.

References TFileDirectory::descr_, TFileDirectory::dir_, edm::ModuleDescription::moduleLabel(), and edm::ModuleDescription::moduleName().

Referenced by TFileService().

40  {
41  dir_ = desc.moduleLabel();
42  descr_ = (dir_ + " (" + desc.moduleName() + ") folder").c_str();
43 }
std::string const & moduleName() const
std::string const & moduleLabel() const
std::string dir_
std::string descr_

Member Data Documentation

bool TFileService::closeFileFast_
private

Definition at line 33 of file TFileService.h.

Referenced by ~TFileService().

TFile* TFileService::file_
private

pointer to opened TFile

Definition at line 30 of file TFileService.h.

Referenced by file(), and ~TFileService().

std::string TFileService::fileName_
private

Definition at line 31 of file TFileService.h.

Referenced by afterBeginJob().

bool TFileService::fileNameRecorded_
private

Definition at line 32 of file TFileService.h.

Referenced by afterBeginJob().