#include <TFileService.h>
Public Member Functions | |
void | afterBeginJob () |
Hook for writing info into JR. | |
TFile & | file () const |
return opened TFile | |
TFileService (const edm::ParameterSet &, edm::ActivityRegistry &) | |
constructor | |
~TFileService () | |
destructor | |
Private Member Functions | |
void | setDirectoryName (const edm::ModuleDescription &desc) |
Private Attributes | |
bool | closeFileFast_ |
TFile * | file_ |
pointer to opened TFile | |
std::string | fileName_ |
bool | fileNameRecorded_ |
Definition at line 16 of file TFileService.h.
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().
: TFileDirectory("", "", TFile::Open(cfg.getParameter<string>("fileName").c_str() , "RECREATE"), ""), file_(TFileDirectory::file_), fileName_(cfg.getParameter<string>("fileName")), fileNameRecorded_(false), closeFileFast_(cfg.getUntrackedParameter<bool>("closeFileFast", false)) { // activities to monitor in order to set the proper directory r.watchPreModuleConstruction(this, & TFileService::setDirectoryName); r.watchPreModule(this, & TFileService::setDirectoryName); r.watchPreModuleBeginJob(this, & TFileService::setDirectoryName); r.watchPreModuleEndJob(this, & TFileService::setDirectoryName); r.watchPreModuleBeginRun(this, & TFileService::setDirectoryName); r.watchPreModuleEndRun(this, & TFileService::setDirectoryName); r.watchPreModuleBeginLumi(this, & TFileService::setDirectoryName); r.watchPreModuleEndLumi(this, & TFileService::setDirectoryName); // delay writing into JobReport after BeginJob r.watchPostBeginJob(this,&TFileService::afterBeginJob); }
TFileService::~TFileService | ( | ) |
destructor
Definition at line 33 of file TFileService.cc.
References closeFileFast_, and file_.
{ file_->Write(); if(closeFileFast_) gROOT->GetListOfFiles()->Remove(file_); file_->Close(); delete file_; }
void TFileService::afterBeginJob | ( | ) |
Hook for writing info into JR.
Definition at line 45 of file TFileService.cc.
References fileName_, fileNameRecorded_, and newFWLiteAna::fullName.
Referenced by TFileService().
{ if(!fileName_.empty()) { if(!fileNameRecorded_) { string fullName; fullName.reserve(1024); fullName = getcwd(&fullName[0],1024); fullName += "/" + fileName_; map<string,string> fileData; fileData.insert(make_pair("Source","TFileService")); Service<JobReport> reportSvc; reportSvc->reportAnalysisFile(fullName,fileData); fileNameRecorded_ = true; } } }
TFile& TFileService::file | ( | ) | const [inline] |
return opened TFile
Definition at line 23 of file TFileService.h.
References file_.
{ return * file_; }
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().
{ dir_ = desc.moduleLabel(); descr_ = (dir_ + " (" + desc.moduleName() + ") folder").c_str(); }
bool TFileService::closeFileFast_ [private] |
Definition at line 33 of file TFileService.h.
Referenced by ~TFileService().
TFile* TFileService::file_ [private] |
pointer to opened TFile
Reimplemented from TFileDirectory.
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().