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 Attributes | Private Member Functions | Private Attributes | Static Private Attributes
TFileService Class Reference

#include <TFileService.h>

Public Member Functions

void afterBeginJob ()
 Hook for writing info into JR. More...
 
bool cd () const
 
TFile & file () const
 return opened TFile More...
 
std::string fullPath () const
 return the full path of the stored histograms More...
 
TDirectory * getBareDirectory (const std::string &subdir="") const
 
template<typename T >
TgetObject (const std::string &objname, const std::string &subdir="")
 
template<typename T , typename... Args>
Tmake (const Args &...args) const
 make new ROOT object More...
 
TFileDirectory mkdir (const std::string &dir, const std::string &descr="")
 create a new subdirectory More...
 
TFileDirectorytFileDirectory ()
 
 TFileService (const edm::ParameterSet &, edm::ActivityRegistry &)
 constructor More...
 
 ~TFileService ()
 destructor More...
 

Static Public Attributes

static const std::string kSharedResource = "TFileService"
 

Private Member Functions

void postModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void postModuleGlobal (edm::GlobalContext const &, edm::ModuleCallingContext const &)
 
void preModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void preModuleGlobal (edm::GlobalContext const &, edm::ModuleCallingContext const &)
 
void setDirectoryName (const edm::ModuleDescription &desc)
 

Private Attributes

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

Static Private Attributes

static thread_local TFileDirectory tFileDirectory_
 

Detailed Description

Definition at line 30 of file TFileService.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 17 of file TFileService.cc.

References afterBeginJob(), file_, TFileDirectory::file_, fileName_, postModuleEvent(), postModuleGlobal(), preModuleEvent(), preModuleGlobal(), setDirectoryName(), tFileDirectory_, edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostModuleEvent(), edm::ActivityRegistry::watchPostModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPostModuleGlobalBeginRun(), edm::ActivityRegistry::watchPostModuleGlobalEndLumi(), edm::ActivityRegistry::watchPostModuleGlobalEndRun(), edm::ActivityRegistry::watchPreModuleBeginJob(), edm::ActivityRegistry::watchPreModuleConstruction(), edm::ActivityRegistry::watchPreModuleEndJob(), edm::ActivityRegistry::watchPreModuleEvent(), edm::ActivityRegistry::watchPreModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPreModuleGlobalBeginRun(), edm::ActivityRegistry::watchPreModuleGlobalEndLumi(), and edm::ActivityRegistry::watchPreModuleGlobalEndRun().

17  :
18  file_(nullptr),
19  fileName_(cfg.getParameter<std::string>("fileName")),
20  fileNameRecorded_(false),
21  closeFileFast_(cfg.getUntrackedParameter<bool>("closeFileFast", false))
22 {
24  "",
25  TFile::Open(fileName_.c_str(), "RECREATE"),
26  "");
28 
29  // activities to monitor in order to set the proper directory
35 
40 
45 
46  // delay writing into JobReport after BeginJob
48 }
void watchPostModuleGlobalEndLumi(PostModuleGlobalEndLumi::slot_type const &iSlot)
void postModuleGlobal(edm::GlobalContext const &, edm::ModuleCallingContext const &)
Definition: TFileService.cc:80
T getParameter(std::string const &) const
void watchPreModuleGlobalBeginRun(PreModuleGlobalBeginRun::slot_type const &iSlot)
T getUntrackedParameter(std::string const &, T const &) const
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
void watchPostModuleGlobalBeginLumi(PostModuleGlobalBeginLumi::slot_type const &iSlot)
TFile * file_
pointer to opened TFile
Definition: TFileService.h:81
void watchPreModuleGlobalEndRun(PreModuleGlobalEndRun::slot_type const &iSlot)
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
std::string fileName_
Definition: TFileService.h:82
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:57
void watchPreModuleEndJob(PreModuleEndJob::slot_type const &iSlot)
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
void watchPreModuleGlobalBeginLumi(PreModuleGlobalBeginLumi::slot_type const &iSlot)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
Definition: TFileService.cc:67
void watchPostModuleGlobalEndRun(PostModuleGlobalEndRun::slot_type const &iSlot)
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
Definition: TFileService.cc:63
bool fileNameRecorded_
Definition: TFileService.h:83
bool closeFileFast_
Definition: TFileService.h:84
void watchPostModuleGlobalBeginRun(PostModuleGlobalBeginRun::slot_type const &iSlot)
void afterBeginJob()
Hook for writing info into JR.
Definition: TFileService.cc:87
void preModuleGlobal(edm::GlobalContext const &, edm::ModuleCallingContext const &)
Definition: TFileService.cc:75
void watchPreModuleGlobalEndLumi(PreModuleGlobalEndLumi::slot_type const &iSlot)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
TFileService::~TFileService ( )

destructor

Definition at line 50 of file TFileService.cc.

References closeFileFast_, and file_.

50  {
51  file_->Write();
52  if(closeFileFast_) gROOT->GetListOfFiles()->Remove(file_);
53  file_->Close();
54  delete file_;
55 }
TFile * file_
pointer to opened TFile
Definition: TFileService.h:81
bool closeFileFast_
Definition: TFileService.h:84

Member Function Documentation

void TFileService::afterBeginJob ( )

Hook for writing info into JR.

Definition at line 87 of file TFileService.cc.

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

Referenced by TFileService().

87  {
88 
89  if(!fileName_.empty()) {
90  if(!fileNameRecorded_) {
92  fullName.reserve(1024);
93  fullName = getcwd(&fullName[0],1024);
94  fullName += "/" + fileName_;
95 
96  std::map<std::string, std::string> fileData;
97  fileData.insert(std::make_pair("Source","TFileService"));
98 
100  reportSvc->reportAnalysisFile(fullName,fileData);
101  fileNameRecorded_ = true;
102  }
103  }
104 }
std::string fileName_
Definition: TFileService.h:82
string fullName
bool fileNameRecorded_
Definition: TFileService.h:83
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:559
bool TFileService::cd ( ) const
inline
TFile& TFileService::file ( ) const
inline
std::string TFileService::fullPath ( ) const
inline

return the full path of the stored histograms

Definition at line 74 of file TFileService.h.

References TFileDirectory::fullPath(), and tFileDirectory_.

74 { return tFileDirectory_.fullPath(); }
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
std::string fullPath() const
return the full path of the stored histograms
TDirectory* TFileService::getBareDirectory ( const std::string &  subdir = "") const
inline

Definition at line 52 of file TFileService.h.

References TFileDirectory::getBareDirectory(), and tFileDirectory_.

Referenced by FFTJetImageRecorder::analyze(), and FFTJetPileupAnalyzer::analyze().

52  {
53  return tFileDirectory_.getBareDirectory(subdir);
54  }
TDirectory * getBareDirectory(const std::string &subdir="") const
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
template<typename T >
T* TFileService::getObject ( const std::string &  objname,
const std::string &  subdir = "" 
)
inline

Definition at line 57 of file TFileService.h.

References TFileDirectory::getObject(), and tFileDirectory_.

58  {
59  return tFileDirectory_.getObject<T>(objname, subdir);
60  }
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
T * getObject(const std::string &objname, const std::string &subdir="")
long double T
template<typename T , typename... Args>
T* TFileService::make ( const Args &...  args) const
inline

make new ROOT object

Definition at line 64 of file TFileService.h.

References TFileDirectory::make(), and tFileDirectory_.

Referenced by AlCaHOCalibProducer::AlCaHOCalibProducer(), SiStripGainFromCalibTree::algoEndJob(), AlignmentMonitorMuonSystemMap1D::AlignmentMonitorMuonSystemMap1D(), AlignmentMuonHIPTrajectorySelector::AlignmentMuonHIPTrajectorySelector(), AnaL1CaloCleaner::AnaL1CaloCleaner(), MuonAlignmentAnalyzer::analyze(), EcalMipGraphs::analyze(), EcalDisplaysByEvent::analyze(), AnaMuonCaloCleaner::AnaMuonCaloCleaner(), APVShotsAnalyzer::APVShotsAnalyzer(), tnp::BaseTreeFiller::BaseTreeFiller(), HypothesisAnalyzer::beginJob(), PatTauAnalyzer::beginJob(), PatZjetsElectronAnalyzer::beginJob(), PatZjetsJetAnalyzer::beginJob(), PatTriggerTagAndProbe::beginJob(), PatTriggerAnalyzer::beginJob(), PatBJetTagAnalyzer::beginJob(), PatMCMatchingExtended::beginJob(), PatMCMatching::beginJob(), myRawAna::beginJob(), PatTopSelectionAnalyzer::beginJob(), PatBasicAnalyzer::beginJob(), PatBTagAnalyzer::beginJob(), PatTrackAnalyzer::beginJob(), PatVertexAnalyzer::beginJob(), MCPhotonAnalyzer::beginJob(), PhotonsWithConversionsAnalyzer::beginJob(), ShallowTree::beginJob(), JetCorrectorDemo::beginJob(), FactorizedJetCorrectorDemo::beginJob(), ExampleMuonAnalyzer::beginJob(), PatBJetTrackAnalyzer::beginJob(), EmbeddingKineReweightNtupleProducer::beginJob(), WMuNuSelector::beginJob(), PatBJetVertexAnalyzer::beginJob(), ResolutionCreator::beginJob(), StudyHLT::beginJob(), MuonAlignmentAnalyzer::beginJob(), myJetAna::beginJob(), SiPixelDQMRocLevelAnalyzer::beginJob(), ContainmentCorrectionAnalyzer::beginJob(), HitEff::beginJob(), FFTJetImageRecorder::beginJob(), FFTJetPileupAnalyzer::beginJob(), HcalIsoTrkAnalyzer::beginJob(), CosmicSplitterValidation::beginJob(), IsoTrackCalib::beginJob(), IsoTrig::beginJob(), PrimaryVertexValidation::beginJob(), IsoTrackCalibration::beginJob(), ErsatzMEt::beginJob(), IsolatedTracksHcalScale::beginJob(), HcalRaddamMuon::beginJob(), HcalHBHEMuonAnalyzer::beginJob(), StudyHLT::beginRun(), HLTOfflineReproducibility::beginRun(), IsoTrackCalib::beginRun(), MaterialBudgetCastorHistos::book(), MaterialBudgetHcalHistos::book(), MaterialBudgetForward::book(), MaterialBudget::book(), IsolatedParticlesGeneratedJets::BookHistograms(), IsolatedGenParticles::BookHistograms(), IsolatedTracksNxN::BookHistograms(), MuonAlignmentFromReference::bookNtuple(), SVTagInfoValidationAnalyzer::bookRecoToSim(), SVTagInfoValidationAnalyzer::bookSimToReco(), IsolatedTracksCone::BuildTree(), calcTopMass::calcTopMass(), CalibratableTest::CalibratableTest(), CMSDAS11DijetAnalyzer::CMSDAS11DijetAnalyzer(), CMSDAS11DijetTestAnalyzer::CMSDAS11DijetTestAnalyzer(), CSCPairResidualsConstraint::configure(), CSCOverlapsAlignmentAlgorithm::CSCOverlapsAlignmentAlgorithm(), CSCOverlapsBeamSplashCut::CSCOverlapsBeamSplashCut(), DreamSD::DreamSD(), DuplicateRecHits::DuplicateRecHits(), EcalDisplaysByEvent::EcalDisplaysByEvent(), EcalMipGraphs::EcalMipGraphs(), ElectronStudy::ElectronStudy(), JetCorrectorDemo::endJob(), FactorizedJetCorrectorDemo::endJob(), IsoTrig::endJob(), IsoTrackCalib::endJob(), TrackerOfflineValidation::endJob(), TkLasBeamFitter::endRunProduce(), EopTreeWriter::EopTreeWriter(), G4StepStatistics::G4StepStatistics(), gamma_radiative_analyzer::gamma_radiative_analyzer(), HcalTB02Histo::HcalTB02Histo(), HcalTB04Histo::HcalTB04Histo(), HcalTB06Histo::HcalTB06Histo(), HcalTestHistoManager::HcalTestHistoManager(), HLTBitAnalyzer::HLTBitAnalyzer(), HLTCSCOverlapFilter::HLTCSCOverlapFilter(), HOCalibAnalyzer::HOCalibAnalyzer(), HSCPValidator::HSCPValidator(), HcalForwardAnalysis::init(), EcalMipGraphs::initHists(), EcalDisplaysByEvent::initHists(), HltComparator::initialise(), L1RCTRelValAnalyzer::L1RCTRelValAnalyzer(), L1RCTTestAnalyzer::L1RCTTestAnalyzer(), LHEAnalyzer::LHEAnalyzer(), SiStripHitEffFromCalibTree::makeHotColdMaps(), SiStripHitEffFromCalibTree::makeSummary(), MCVerticesAnalyzer::MCVerticesAnalyzer(), MCvsRecoVerticesAnalyzer::MCvsRecoVerticesAnalyzer(), MultiplicityCorrelatorHistogramMaker::MultiplicityCorrelatorHistogramMaker(), MuTriggerAnalyzer::MuTriggerAnalyzer(), OverlapProblemTPAnalyzer::OverlapProblemTPAnalyzer(), OverlapProblemTSOSAnalyzer::OverlapProblemTSOSAnalyzer(), PatJetAnalyzer::PatJetAnalyzer(), PatZToMuMuAnalyzer::PatZToMuMuAnalyzer(), CSCAlignmentCorrections::plot(), VariableNTupler::registerleaves(), AdHocNTupler::registerleaves(), StringBasedNTupler::registerleaves(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), EcalMipGraphs::selectDigi(), EcalDisplaysByEvent::selectDigi(), PatBTagCommonHistos::Set(), SiPixelQualityHistory::SiPixelQualityHistory(), SiStripBaselineAnalyzer::SiStripBaselineAnalyzer(), SiStripQualityHistory::SiStripQualityHistory(), SiStripGainFromCalibTree::storeOnTree(), SVTagInfoValidationAnalyzer::SVTagInfoValidationAnalyzer(), testAnalyzer::testAnalyzer(), TopElecAnalyzer::TopElecAnalyzer(), TopGenEventAnalyzer::TopGenEventAnalyzer(), TopJetAnalyzer::TopJetAnalyzer(), TopMuonAnalyzer::TopMuonAnalyzer(), TopTauAnalyzer::TopTauAnalyzer(), TrackCount::TrackCount(), MuonMillepedeAlgorithm::updateInfo(), ZMassHistogrammer::ZMassHistogrammer(), ZMuMu_efficiencyAnalyzer::ZMuMu_efficiencyAnalyzer(), ZMuMu_MCanalyzer::ZMuMu_MCanalyzer(), ZMuMu_Radiative_analyzer::ZMuMu_Radiative_analyzer(), ZMuMu_vtxAnalyzer::ZMuMu_vtxAnalyzer(), ZMuMuAnalyzer::ZMuMuAnalyzer(), ZMuMuAnalyzer_cynematics::ZMuMuAnalyzer_cynematics(), ZMuMuIsolationAnalyzer::ZMuMuIsolationAnalyzer(), ZMuMuPerformances::ZMuMuPerformances(), and ZMuMuSaMassHistogram::ZMuMuSaMassHistogram().

64  {
65  return tFileDirectory_.make<T>(args ...);
66  }
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
T * make(const Args &...args) const
make new ROOT object
long double T
TFileDirectory TFileService::mkdir ( const std::string &  dir,
const std::string &  descr = "" 
)
inline

create a new subdirectory

Definition at line 69 of file TFileService.h.

References TFileDirectory::mkdir(), and tFileDirectory_.

Referenced by AlignmentMonitorBase::AlignmentMonitorBase(), CentralityTableProducer::analyze(), SiStripBaselineAnalyzer::analyze(), GenMuonRadCorrAnalyzer::beginJob(), L1GctValidation::beginJob(), l1t::L1TGlobalAnalyzer::beginJob(), l1t::L1TStage2CaloAnalyzer::beginJob(), PrimaryVertexValidation::beginJob(), HLTOfflineReproducibility::beginRun(), BigEventsDebugger< T >::BigEventsDebugger(), BjetAnalysis::BjetAnalysis(), DigiInvestigatorHistogramMaker::book(), DigiVtxPosCorrHistogramMaker::book(), BeamSpotHistogramMaker::book(), DigiPileupCorrHistogramMaker::book(), DigiVertexCorrHistogramMaker::book(), DigiBXCorrHistogramMaker< T >::book(), VertexHistogramMaker::book(), DigiLumiCorrHistogramMaker::book(), BSvsPVHistogramMaker::book(), L1GtDataEmulAnalyzer::bookHistograms(), IsolatedGenParticles::BookHistograms(), IsolatedTracksNxN::BookHistograms(), CosmicGenFilterHelix::createHistsEnd(), CosmicGenFilterHelix::createHistsStart(), TrackerOfflineValidation::DirectoryWrapper::DirectoryWrapper(), PatBTagAnalyzer::endJob(), EWKSystUnc::EWKSystUnc(), MuonAlignmentFromReference::fitAndAlign(), GctErrorAnalyzer::GctErrorAnalyzer(), GlbMuQualityCutsAnalysis::GlbMuQualityCutsAnalysis(), HCalSD::HCalSD(), HFGflash::HFGflash(), HFShowerParam::HFShowerParam(), WMuNuValidator::init_histograms(), MultiplicityTimeCorrelations::MultiplicityTimeCorrelations(), batchmanager.BatchManager::PrepareJob(), TrackerDpgAnalysis::TrackerDpgAnalysis(), TrackerGeometryCompare::TrackerGeometryCompare(), TSOSHistogramMaker::TSOSHistogramMaker(), ZHistogrammer::ZHistogrammer(), ZLONLOHistogrammer::ZLONLOHistogrammer(), ZMCHistogrammer::ZMCHistogrammer(), ZMuMu_efficiencyAnalyzer::ZMuMu_efficiencyAnalyzer(), ZMuMuAnalyzer_cynematics::ZMuMuAnalyzer_cynematics(), ZMuMuEfficiency::ZMuMuEfficiency(), ZMuPtScaleAnalyzer::ZMuPtScaleAnalyzer(), and zPdfUnc::zPdfUnc().

69  {
70  return tFileDirectory_.mkdir(dir, descr);
71  }
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
dbl *** dir
Definition: mlp_gen.cc:35
void TFileService::postModuleEvent ( edm::StreamContext const &  ,
edm::ModuleCallingContext const &  mcc 
)
private

Definition at line 67 of file TFileService.cc.

References edm::ModuleCallingContext::moduleDescription(), edm::ModuleCallingContext::previousModuleOnThread(), and setDirectoryName().

Referenced by TFileService().

67  {
68  edm::ModuleCallingContext const* previous_mcc = mcc.previousModuleOnThread();
69  if(previous_mcc) {
70  setDirectoryName(*previous_mcc->moduleDescription());
71  }
72 }
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:57
ModuleDescription const * moduleDescription() const
ModuleCallingContext const * previousModuleOnThread() const
void TFileService::postModuleGlobal ( edm::GlobalContext const &  ,
edm::ModuleCallingContext const &  mcc 
)
private

Definition at line 80 of file TFileService.cc.

References edm::ModuleCallingContext::moduleDescription(), edm::ModuleCallingContext::previousModuleOnThread(), and setDirectoryName().

Referenced by TFileService().

80  {
81  edm::ModuleCallingContext const* previous_mcc = mcc.previousModuleOnThread();
82  if(previous_mcc) {
83  setDirectoryName(*previous_mcc->moduleDescription());
84  }
85 }
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:57
ModuleDescription const * moduleDescription() const
ModuleCallingContext const * previousModuleOnThread() const
void TFileService::preModuleEvent ( edm::StreamContext const &  ,
edm::ModuleCallingContext const &  mcc 
)
private

Definition at line 63 of file TFileService.cc.

References edm::ModuleCallingContext::moduleDescription(), and setDirectoryName().

Referenced by TFileService().

63  {
64  setDirectoryName(*mcc.moduleDescription());
65 }
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:57
void TFileService::preModuleGlobal ( edm::GlobalContext const &  ,
edm::ModuleCallingContext const &  mcc 
)
private

Definition at line 75 of file TFileService.cc.

References edm::ModuleCallingContext::moduleDescription(), and setDirectoryName().

Referenced by TFileService().

75  {
76  setDirectoryName(*mcc.moduleDescription());
77 }
void setDirectoryName(const edm::ModuleDescription &desc)
Definition: TFileService.cc:57
void TFileService::setDirectoryName ( const edm::ModuleDescription desc)
private

Definition at line 57 of file TFileService.cc.

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

Referenced by postModuleEvent(), postModuleGlobal(), preModuleEvent(), preModuleGlobal(), and TFileService().

57  {
60  tFileDirectory_.descr_ = (tFileDirectory_.dir_ + " (" + desc.moduleName() + ") folder").c_str();
61 }
std::string const & moduleName() const
TFile * file_
pointer to opened TFile
Definition: TFileService.h:81
std::string const & moduleLabel() const
static thread_local TFileDirectory tFileDirectory_
Definition: TFileService.h:79
std::string dir_
std::string descr_
TFileDirectory& TFileService::tFileDirectory ( )
inline

Member Data Documentation

bool TFileService::closeFileFast_
private

Definition at line 84 of file TFileService.h.

Referenced by ~TFileService().

TFile* TFileService::file_
private

pointer to opened TFile

Definition at line 81 of file TFileService.h.

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

std::string TFileService::fileName_
private

Definition at line 82 of file TFileService.h.

Referenced by afterBeginJob(), and TFileService().

bool TFileService::fileNameRecorded_
private

Definition at line 83 of file TFileService.h.

Referenced by afterBeginJob().

const std::string TFileService::kSharedResource = "TFileService"
static

Definition at line 76 of file TFileService.h.

thread_local TFileDirectory TFileService::tFileDirectory_
staticprivate