Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
art::TFileService Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/art/v2_13_00/source/art/Framework/Services/Optional/TFileService.h"

Inheritance diagram for art::TFileService:
art::TFileDirectory

Classes

struct  Config
 

Public Types

using Parameters = ServiceTable< Config >
 
using Callback_t = TFileDirectory::Callback_t
 

Public Member Functions

 TFileService (ServiceTable< Config > const &config, art::ActivityRegistry &r)
 
 ~TFileService ()
 
void registerFileSwitchCallback (Callback_t c)
 
template<typename T >
void registerFileSwitchCallback (T *provider, void(T::*)())
 
TFile & file () const
 
template<typename T , typename... ARGS>
Tmake (ARGS...args) const
 
template<typename T , typename... ARGS>
TmakeAndRegister (char const *name, char const *title, ARGS...args) const
 
template<typename T , typename... ARGS>
TmakeAndRegister (std::string const &name, std::string const &title, ARGS...args) const
 
TFileDirectory mkdir (std::string const &dir, std::string const &descr="")
 

Static Public Attributes

static constexpr const char * default_tmpDir = "<parent-path-of-filename>"
 

Protected Member Functions

void invokeCallbacks ()
 
void registerCallback (Callback_t)
 
std::string fullPath () const
 

Protected Attributes

TFile * file_
 
std::string dir_
 
std::string descr_
 
bool requireCallback_ {false}
 

Private Member Functions

 TFileService (TFileService const &)=delete
 
TFileService operator= (TFileService const &)=delete
 
void setDirectoryName_ (art::ModuleDescription const &desc)
 
void openFile_ ()
 
void closeFile_ ()
 
void maybeSwitchFiles_ ()
 
bool requestsToCloseFile_ ()
 
std::string fileNameAtOpen_ ()
 
std::string fileNameAtClose_ (std::string const &)
 

Private Attributes

bool const closeFileFast_
 
FileStatsCollector fstats_
 
PostCloseFileRenamer fRenamer_ {fstats_}
 
std::string filePattern_
 
std::string uniqueFilename_
 
std::string tmpDir_
 
std::string lastClosedFile_ {}
 
Granularity currentGranularity_ {Granularity::Unset}
 
std::chrono::steady_clock::time_point beginTime_ {}
 
ClosingCriteria fileSwitchCriteria_ {ClosingCriteria::Config{}}
 
OutputFileStatus status_ {OutputFileStatus::Closed}
 
FileProperties fp_ {}
 

Detailed Description

Definition at line 31 of file TFileService.h.

Member Typedef Documentation

Definition at line 54 of file TFileService.h.

Definition at line 48 of file TFileService.h.

Constructor & Destructor Documentation

art::TFileService::TFileService ( TFileService const &  )
privatedelete
TFileService::TFileService ( ServiceTable< Config > const &  config,
art::ActivityRegistry r 
)

Definition at line 37 of file TFileService_service.cc.

References closeFileFast_, gen_hdf5record::config, currentGranularity_, e, art::Granularity::Event, plotROC::fileName, filePattern_, fileSwitchCriteria_, fp_, fstats_, art::Run::id(), art::SubRun::id(), art::Event::id(), art::Granularity::InputFile, maybeSwitchFiles_(), openFile_(), r(), art::FileStatsCollector::recordEvent(), art::FileStatsCollector::recordInputFile(), art::FileStatsCollector::recordRun(), art::FileStatsCollector::recordSubRun(), requestsToCloseFile_(), art::TFileDirectory::requireCallback_, art::Granularity::Run, setDirectoryName_(), sr, status_, string, art::Granularity::SubRun, tmpDir_, art::FileProperties::update(), and art::detail::validateFileNamePattern().

39  : TFileDirectory{"", "", nullptr, ""}
40  , closeFileFast_{config().closeFileFast()}
41  , fstats_{config.get_PSet().get<std::string>("service_type"),
42  ServiceHandle<TriggerNamesService const>{}->getProcessName()}
43  , filePattern_{config().fileName()}
44  , tmpDir_{config().tmpDir()}
45 {
46  ClosingCriteria::Config fpConfig;
47  requireCallback_ = config().fileProperties(fpConfig);
48  if (requireCallback_) {
50  fileSwitchCriteria_ = ClosingCriteria{fpConfig};
51  }
52  openFile_();
53 
54  // Activities to monitor in order to set the proper directory.
55  r.sPostOpenFile.watch(
56  [this](std::string const& fileName) { fstats_.recordInputFile(fileName); });
57 
60 
70 
73 
76 
78 
79  // Activities to monitor to keep track of events, subruns and runs seen.
80  r.sPostProcessEvent.watch([this](Event const& e) {
83  fstats_.recordEvent(e.id());
84  if (requestsToCloseFile_()) {
86  }
87  });
88  r.sPostEndSubRun.watch([this](SubRun const& sr) {
91  fstats_.recordSubRun(sr.id());
92  if (requestsToCloseFile_()) {
94  }
95  });
96  r.sPostEndRun.watch([this](Run const& r) {
99  fstats_.recordRun(r.id());
100  if (requestsToCloseFile_()) {
102  }
103  });
104  r.sPostCloseFile.watch([this] {
107  if (requestsToCloseFile_()) {
109  }
110  });
111 }
fileName
Definition: plotROC.py:78
std::string tmpDir_
Definition: TFileService.h:74
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleConstruction
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleEndSubRun
void recordRun(RunID const &id)
void validateFileNamePattern(bool do_check, std::string const &pattern)
void recordEvent(EventID const &id)
Definition: config.py:1
bool const closeFileFast_
Definition: TFileService.h:69
FileStatsCollector fstats_
Definition: TFileService.h:70
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleBeginSubRun
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleBeginJob
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleRespondToOpenInputFile
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleBeginRun
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleEndRun
ClosingCriteria fileSwitchCriteria_
Definition: TFileService.h:83
void recordSubRun(SubRunID const &id)
Granularity currentGranularity_
Definition: TFileService.h:78
caf::StandardRecord * sr
void recordInputFile(std::string const &inputFileName)
std::string filePattern_
Definition: TFileService.h:72
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleEndJob
void setDirectoryName_(art::ModuleDescription const &desc)
GlobalSignal< detail::SignalResponseType::LIFO, void(Run const &)> sPostEndRun
std::enable_if_t< B!=Granularity::InputFile > update(OutputFileStatus const status)
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleRespondToOpenOutputFiles
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModule
OutputFileStatus status_
Definition: TFileService.h:84
GlobalSignal< detail::SignalResponseType::LIFO, void(std::string const &)> sPostOpenFile
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &)> sPostProcessEvent
Float_t e
Definition: plot.C:35
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleRespondToCloseOutputFiles
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleRespondToCloseInputFile
FileProperties fp_
Definition: TFileService.h:85
GlobalSignal< detail::SignalResponseType::LIFO, void(SubRun const &)> sPostEndSubRun
TFileDirectory(std::string const &dir, std::string const &descr, TFile *file, std::string const &path)
Create a new TFileDirectory object.
enum BeamMode string
TFileService::~TFileService ( )

Definition at line 113 of file TFileService_service.cc.

References closeFile_().

114 {
115  closeFile_();
116 }

Member Function Documentation

void TFileService::closeFile_ ( )
private

Definition at line 165 of file TFileService_service.cc.

References art::Closed, closeFileFast_, art::TFileDirectory::file_, fileNameAtClose_(), fstats_, lastClosedFile_, art::FileStatsCollector::recordFileClose(), status_, and uniqueFilename_.

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

166 {
167  file_->Write();
168  if (closeFileFast_) {
169  gROOT->GetListOfFiles()->Remove(file_);
170  }
171  file_->Close();
172  delete file_;
173  file_ = nullptr;
177 }
std::string lastClosedFile_
Definition: TFileService.h:77
bool const closeFileFast_
Definition: TFileService.h:69
FileStatsCollector fstats_
Definition: TFileService.h:70
std::string uniqueFilename_
Definition: TFileService.h:73
OutputFileStatus status_
Definition: TFileService.h:84
std::string fileNameAtClose_(std::string const &)
TFile& art::TFileService::file ( ) const
inline

Definition at line 63 of file TFileService.h.

Referenced by calib::BetheBlochFit::endJob(), and chaninfo::BadChanValidate::endSubRun().

64  {
65  return *file_;
66  }
std::string TFileService::fileNameAtClose_ ( std::string const &  filename)
private

Definition at line 146 of file TFileService_service.cc.

References filePattern_, fRenamer_, and art::PostCloseFileRenamer::maybeRenameFile().

Referenced by closeFile_().

147 {
148  return filePattern_ == dev_null ?
149  dev_null :
151 }
string filename
Definition: shutoffs.py:106
PostCloseFileRenamer fRenamer_
Definition: TFileService.h:71
std::string filePattern_
Definition: TFileService.h:72
std::string maybeRenameFile(std::string const &inPath, std::string const &toPattern)
std::string TFileService::fileNameAtOpen_ ( )
private

Definition at line 136 of file TFileService_service.cc.

References default_tmpDir, filePattern_, art::parent_path(), string, tmpDir_, and art::unique_filename().

Referenced by openFile_().

137 {
138  if (filePattern_ == dev_null)
139  return dev_null;
140  return unique_filename(
142  "/TFileService");
143 }
std::string tmpDir_
Definition: TFileService.h:74
std::string unique_filename(std::string stem, std::string extension=".root")
static constexpr const char * default_tmpDir
Definition: TFileService.h:37
std::string filePattern_
Definition: TFileService.h:72
std::string parent_path(std::string const &path)
std::string art::TFileDirectory::fullPath ( ) const
protectedinherited

Return the full pathname of the current directory, formed from appending 'dir' to the end of 'path'.

void art::TFileDirectory::invokeCallbacks ( )
protectedinherited

Referenced by maybeSwitchFiles_().

template<typename T , typename... ARGS>
T * art::TFileDirectory::make ( ARGS...  args) const
inherited

make new ROOT object of type T, using constructor parameters args. It will be made in the 'current directory', as established with a call to 'cd'.

Definition at line 82 of file TFileDirectory.h.

References make_syst_table_plots::args, art::TFileDirectory::cd(), and T.

Referenced by calib::ADCShapeFitAna::analyze(), slicer::S4DParamCalc::analyze(), beamlinereco::EventWaveformDump::analyze(), tbana::DSToFAna::AnalyzeDSToF2Signals(), comi::ChanOcc::beginJob(), highe::HighEnergyAna::beginJob(), qeef::QeFinderVal::beginJob(), rsim::RecordNoiseSpectrumFile::beginJob(), tut::TutAnalyzer::beginJob(), cheat::TestTrackIds::beginJob(), novaddt::SingletonRejectionAna::beginJob(), util::RemoveBeamSpills::beginJob(), ve::VertexEva::beginJob(), util::RemoveTBSpills::beginJob(), calhit::CalHitAna::beginJob(), calib::FindOutliers::beginJob(), remid::ReMIdValidate::beginJob(), calib::AbsCalib::beginJob(), util::RemoveBeamSpillsPrecise::beginJob(), calib::ParticleCorrections::beginJob(), novaddt::TriCellTriggerAna::beginJob(), rsim::MakeNoiseSpectrumFile::beginJob(), air::AirShower::beginJob(), validation::ValidateDAQ2RawDigit::beginJob(), jmshower::RecoJMShowerAna::beginJob(), ddt::SMMADC::beginJob(), lem::AlignLibToVtx::beginJob(), cheat::RecoCheckAna::beginJob(), air::AirTree::beginJob(), calib::ResizeDetector::beginJob(), novaddt::ClusterAna::beginJob(), calib::TestParticleCorrections::beginJob(), febstat::FEBShutoff::beginJob(), valid::CellHitValidation::beginJob(), valid::FluxValidation::beginJob(), comi::CosmicMetrics::beginJob(), DataCheck::HardwareStatusCheck::beginJob(), calib::BetheBlochFit::beginJob(), valid::RecoHitValidation::beginJob(), mmc::Validation::beginJob(), dq::DAQHeaderSummaryAna::beginJob(), jmshower::JMTrackMerge::beginJob(), demo::DemoModule::beginJob(), remid::ReMIdTrain::beginJob(), calib::AssessCalib::beginJob(), beamlinereco::ToFSingleCounterAnalysis::beginJob(), BeamlineAna::beginJob(), supernova::SimAna::beginJob(), supernova::SnovaAna::beginJob(), zcl::SMMTriggerAna::beginJob(), tut::yn2020::FancyScience::beginJob(), febstat::EventFEBStatus::beginJob(), calib::FiberCalibration::beginJob(), novaddt::ActivityTriggerAna::beginJob(), comi::Cana::beginJob(), mcchk::MonopoleAna::beginJob(), mcchk::ShowerAnaCheck::beginJob(), earms::ElasticArmsHS::beginJob(), air::CosmicTrackRate::beginJob(), beamlinereco::ToFRecoAnalysis::beginJob(), tut::yn2017::AnalysisModule::beginJob(), slicer::S4DParamCalc::beginJob(), pa::ClusterEva::beginJob(), pa::HitEva::beginJob(), mcchk::RockAna::beginJob(), comi::DataCheck::beginJob(), tut::RecoValidationTutorial::beginJob(), mcchk::NeutrinoAna::beginJob(), murem::MuonRemoveAna::beginJob(), airshower::AirSlicer::beginJob(), tut::yn2017::DebugThis::beginJob(), zcl::MMCheater::beginJob(), align::SplitTracks::beginJob(), beamlinereco::WCTrackReco::beginJob(), numue::NumuEAna::beginJob(), novatb::TOFTimingResolution::beginJob(), cmf::CovarianceMatrixMaker::beginJob(), sn::SNSlicerAna::beginJob(), vf::TrackEva::beginJob(), calib::TimingCalibration::beginJob(), vdt::VertexDT::beginJob(), bpfit::BPFdEdxHistoMaker::beginJob(), mono::DataCheckMonopole::beginJob(), testbeam::TestBeamCommissioning::beginJob(), zcl::SMMCluster::beginJob(), lem::MakeLibrary::beginJob(), bpfit::BPFEnergyAna::beginJob(), calib::HitEfficiency::beginJob(), jmshower::JMClusterMerge::beginJob(), CerenkovSelection::beginJob(), comi::Leana::beginJob(), dt::DiscreteTracker::beginJob(), sn::SupernovaMCCluster::beginJob(), nnbar::SigVsBkgSimCompare::beginJob(), zcl::FmmTriggerAna::beginJob(), bsf::BremShowerFilter::beginJob(), calib::EnergyStandardCandles::beginJob(), remid::ReMIdDedx::beginJob(), novaddt::HorizontalMuonAna::beginJob(), chaninfo::FindSwappedChannels::beginJob(), comi::NumiFilteringAna::beginJob(), trk::KalmanTrackAna::beginJob(), beamlinereco::EventWaveformDump::beginJob(), ddt::DataSliceEva::beginJob(), calib::MuondEdx::beginJob(), zcl::FmmTrackerAna::beginJob(), zcl::FmmTrackerValidation::beginJob(), cmf::RandomUniverses::beginJob(), novaddt::Calibration::beginJob(), calib::DetRespDrift::beginJob(), hough::HoughValidate::beginJob(), ddt::SlicerEva::beginJob(), tbem::TBRecoAna::beginJob(), calib::PEResponse::beginJob(), cvn::CVNEventDump::beginJob(), trigmon::LongReadoutAnalyzer::beginJob(), cvn::CVNCosmicEventDump::beginJob(), showere::ShowerEnergyAna::beginJob(), jmshower::NueSel::beginJob(), bpfit::BreakPointAna::beginJob(), earms::ElasticArmsValidate::beginJob(), showere::ShowerEnergyFilterMC::beginJob(), mcchk::DetSimAna::beginJob(), rockmuon::NDRockMuon::beginJob(), mono::SlowMonopoleAna::beginJob(), cvn::CVNEventProngDump::beginJob(), cmf::FitFeldmanCousinsPoint::beginJob(), novaddt::UpMuAna::beginJob(), mono::Monopole::beginJob(), calib::MuonTrackHits::beginJob(), slicer::SlicerAna::beginJob(), comi::NearlineAna::beginJob(), ncid::NCNNKeras::beginJob(), ncid::NCNNKerasVal::beginJob(), tbana::SpillStreamAna::beginJob(), zcl::FastMMStudy::beginJob(), cheat::MCCheater::beginJob(), remid::ReMIdDedxRock::beginJob(), beamlinereco::ToFAnalysisMini::beginJob(), fuzz::FuzzyKValidate::beginJob(), remid::ReMIdDedxFD::beginJob(), remid::ReMIdDedxStudies::beginJob(), ncpi0::TwoProngBDTAna::beginJob(), tbana::DetectorRateShutOff::beginJob(), bpfit::BPFTmvaTrainer::beginJob(), nnbar::ShowerMuonCoincidence::beginJob(), bpf::BPFCVNAna::beginJob(), bpfit::DimuonFitter::beginJob(), bpfit::BreakPointProtonAna::beginJob(), air::AirKalmanAna::beginJob(), skim::SkimmerAna::beginJob(), ncs::Xbeam::beginJob(), ncs::GenieTruth::beginJob(), ncs::Xeff::beginJob(), skim::CellHitSkimmer::beginJob(), ncs::ROCKMRE::beginJob(), skim::CosmicBeamComparison::beginJob(), ddt::SuperDDTEva::beginJob(), moonshadowana::MoonShadowAna::beginJob(), calib::CalibAna::beginJob(), slid::LIDTraining::beginJob(), ncs::NCAna::beginJob(), moonshadowana::MoonShadowAnaHough::beginJob(), upmuana::UpMuRecoAna::beginJob(), upmuana::UpMuAnalysis::beginJob(), calib::MuondEdxAna::beginJob(), trident::DimuonSliceFilter::beginJob(), nnbar::RecoAnalysis::beginJob(), beamlinereco::ToFPositionRecoAnalysis::beginJob(), sn::SNMichelAnalyzer::beginJob(), htk::HoughTrack::beginJob(), comi::FEBFlash::beginJob(), trk::CosmicTrackAna::beginJob(), red::EWCosmics::beginJob(), calib::ThresholdAna::beginRun(), chaninfo::CosmicEff::beginRun(), mcchk::CloseInTime::beginRun(), dprf::ChannelPlots::beginRun(), mcchk::DetAna::beginRun(), calib::CosmicCalib::beginRun(), dprf::TrackPlots::beginRun(), mcchk::CosmicAna::beginRun(), mcchk::NeutrinoAna::beginRun(), evgen::IsoGen::beginRun(), calib::MakeAttenuationProfiles::beginRun(), mcchk::LeptonAna::beginRun(), calib::PEResponse::beginRun(), calib::StopperThreshold::beginRun(), photrans::ImprovedTransport::beginRun(), rsim::ReadoutSim::beginRun(), calib::CosmicTrends::beginRun(), comi::DataCheck::beginSubRun(), chaninfo::BadChanValidate::beginSubRun(), ifdb::MIN::beginSubRun(), cmf::CMFDecorrelator::CMFDecorrelator(), g4n::FLSHitListAction::ComputeCerenkovPhotons(), LightLevels::CreateHistos(), CerenkovResponse::CreateHistos(), bpfit::BreakPoint::DebugFitList(), bpfit::BreakPoint::DebugHitList(), bpfit::BreakPoint::DebugScatSurf(), rsim::ReadoutSim::DrawASICOutput(), tbana::DSToFAna::DSToFAna(), red::MatterProbe::ECalc(), calib::SystematicUncertaintyScaleAna::endJob(), mcchk::POTAna::endJob(), novaddt::RateMonitor::endJob(), chaninfo::CosmicEff::endJob(), dprf::TrackPlots::endJob(), calib::CosmicCalib::endJob(), calib::MakeAttenuationProfiles::endJob(), lem::MakeLibrary::endJob(), rockmuon::NDRockMuon::endJob(), calib::DCMTimingOffset::endJob(), ncs::Xeff::endJob(), ncs::ROCKMRE::endJob(), calib::CalibAna::endJob(), ncs::NCAna::endJob(), beamlinereco::ToFPositionRecoAnalysis::endJob(), calib::DriftResponseCalc::endRun(), calib::MuondEdx::endRun(), calib::MuonTrackHits::endRun(), calib::MuondEdxAna::endRun(), skim::EvaluatorNumuCCpi::EvaluatorNumuCCpi(), rsim::IFPGAAlgorithm::FetchThresholds(), bpfit::BreakPoint::FillExceptNt(), bpfit::BreakPoint::FillTrackNt(), G4MismatchAna::G4MismatchAna(), align::Alignment::GetChannelHists(), moonshadowana::MoonShadowAna::GetHisto(), moonshadowana::MoonShadowAnaHough::GetHisto(), novaddt::HitsAna::HitsAna(), testbeam::BeamlineRecoValidation::initializeHists(), novaddt::HorizontalMuonAna::IsHorzMuonTrack(), bpfit::BreakPoint::LogResiduals(), cmf::PlotUtilities::Make1DPlot(), trk::CosmicTrackAna::Make1DRecoHistograms(), trk::CosmicTrackAna::Make1DTruthHistograms(), cmf::PlotUtilities::Make2DContours(), trk::CosmicTrackAna::Make2DRecoHistograms(), trk::CosmicTrackAna::Make2DTruthHistograms(), highe::HighEnergyAna::make_histo(), novaddt::SNAna::make_histo(), mono::SlowMonopoleAna::make_histo(), cmf::FitFeldmanCousinsPoint::MakeCanvases(), cmf::PlotUtilities::MakeCLHeatMaps(), cmf::CovarianceFitHelper::MakeCovarianceMatrixHistogram(), cmf::CovarianceFitHelper::MakeDataMCCanv(), cmf::PlotUtilities::MakeEnergySpectraFromBins(), cmf::PlotUtilities::MakeGeneric2DHist(), MakeHist(), cmf::CovarianceFitHelper::MakeIterationGraphs(), novaddt::Calibration::MakeNoiseHisto(), cmf::PlotUtilities::MakeSpectrumHistogram(), airshower::AirSlicer::MakeTrackSlices(), mix::MixSimEvents::MixSimEvents(), calib::EnergyStandardCandles::PrepareMichelENtuple(), rwgt::MakeGENIEReweightTable::produce(), dprf::RawFebPlots::RawFebPlots(), calib::DriftCorrection::respondToCloseOutputFiles(), rwgt::RwgtTest::RwgtTest(), cmf::CMFCappedEventList::Serialize(), supernova::sliceAna::sliceAna(), sn::SupernovaAna::SupernovaAna(), geo::GeometryTest::testCellPos(), beamlinerecoana::WCTrackRecoAnalysis::WCTrackRecoAnalysis(), hough::HoughT::WriteHoughHistos(), hough::MultiHoughT::WriteHoughHistos(), cvn::CVNEventDump::WriteMapTH2(), cvn::CVNCosmicEventDump::WriteMapTH2(), and cvn::CVNEventProngDump::WriteMapTH2().

83  {
84  detail::RootDirectorySentry sentry;
85  cd();
86  return new T(args...);
87  }
double T
Definition: Xdiff_gwt.C:5
void cd() const
template<typename T , typename... ARGS>
T * art::TFileDirectory::makeAndRegister ( char const *  name,
char const *  title,
ARGS...  args 
) const
inherited

make and register a new ROOT object of type T, giving it the specified name and title, using constructor parameters 'args'. The type must be registerable, and must support naming and titling.

Definition at line 91 of file TFileDirectory.h.

References make_syst_table_plots::args, art::TFileDirectory::cd(), and T.

Referenced by tbana::DetectorRateShutOff::beginJob(), tbana::DSToFAna::DSToFAna(), cmf::PlotUtilities::Make1DPlot(), cmf::PlotUtilities::Make2DContours(), art::TFileDirectory::makeAndRegister(), cmf::ContourFromLibrary::MakeAndStorePlots(), and cmf::ContourFromGrid::MakeAndStorePlots().

94  {
95  detail::RootDirectorySentry sentry;
96  cd();
97  T* p = new T(args...);
98  p->SetName(name);
99  p->SetTitle(title);
100  gDirectory->Append(p);
101  return p;
102  }
const XML_Char * name
Definition: expat.h:151
const char * p
Definition: xmltok.h:285
double T
Definition: Xdiff_gwt.C:5
void cd() const
template<typename T , typename... ARGS>
T * art::TFileDirectory::makeAndRegister ( std::string const &  name,
std::string const &  title,
ARGS...  args 
) const
inherited

Definition at line 106 of file TFileDirectory.h.

References make_syst_table_plots::args, and art::TFileDirectory::makeAndRegister().

109  {
110  return makeAndRegister(name.c_str(), title.c_str(), args...);
111  }
const XML_Char * name
Definition: expat.h:151
T * makeAndRegister(char const *name, char const *title, ARGS...args) const
void TFileService::maybeSwitchFiles_ ( )
private

Definition at line 180 of file TFileService_service.cc.

References closeFile_(), currentGranularity_, filePattern_, fileSwitchCriteria_, fp_, art::ClosingCriteria::granularity(), art::TFileDirectory::invokeCallbacks(), lastClosedFile_, art::detail::logFileAction(), openFile_(), status_, and art::Switching.

Referenced by TFileService().

181 {
182  // FIXME: Should maybe include the granularity check in
183  // requestsToCloseFile_().
185  return;
186 
188  closeFile_();
189  detail::logFileAction("Closed TFileService file ", lastClosedFile_);
190  detail::logFileAction("Switching to new TFileService file with pattern ",
191  filePattern_);
192  fp_ = FileProperties{};
193  openFile_();
194  invokeCallbacks();
195 }
std::string lastClosedFile_
Definition: TFileService.h:77
void logFileAction(const char *msg, std::string const &file)
ClosingCriteria fileSwitchCriteria_
Definition: TFileService.h:83
auto granularity() const
Granularity currentGranularity_
Definition: TFileService.h:78
std::string filePattern_
Definition: TFileService.h:72
OutputFileStatus status_
Definition: TFileService.h:84
FileProperties fp_
Definition: TFileService.h:85
TFileDirectory art::TFileDirectory::mkdir ( std::string const &  dir,
std::string const &  descr = "" 
)
inherited
void TFileService::openFile_ ( )
private

Definition at line 154 of file TFileService_service.cc.

References ana::assert(), beginTime_, art::TFileDirectory::file_, fileNameAtOpen_(), fstats_, recentWatchdog::now, art::Open, art::FileStatsCollector::recordFileOpen(), status_, and uniqueFilename_.

Referenced by maybeSwitchFiles_(), and TFileService().

155 {
157  assert(file_ == nullptr && "TFile pointer should always be zero here!");
159  file_ = new TFile{uniqueFilename_.c_str(), "RECREATE"};
162 }
FileStatsCollector fstats_
Definition: TFileService.h:70
std::string uniqueFilename_
Definition: TFileService.h:73
std::chrono::steady_clock::time_point beginTime_
Definition: TFileService.h:79
OutputFileStatus status_
Definition: TFileService.h:84
assert(nhit_max >=nhit_nbins)
std::string fileNameAtOpen_()
TFileService art::TFileService::operator= ( TFileService const &  )
privatedelete
void art::TFileDirectory::registerCallback ( Callback_t  )
protectedinherited
void TFileService::registerFileSwitchCallback ( Callback_t  c)

Definition at line 119 of file TFileService_service.cc.

References art::TFileDirectory::registerCallback().

120 {
121  registerCallback(cb);
122 }
void registerCallback(Callback_t)
template<typename T >
void art::TFileService::registerFileSwitchCallback ( T provider,
void(T::*)()  f 
)

Definition at line 102 of file TFileService.h.

References DECLARE_ART_SERVICE, MakeMiniprodValidationCuts::f, and art::LEGACY.

103 {
104  auto cb = [provider, f] { return (provider->*f)(); };
106 }
void registerFileSwitchCallback(Callback_t c)
bool TFileService::requestsToCloseFile_ ( )
private

Definition at line 198 of file TFileService_service.cc.

References beginTime_, DEFINE_ART_SERVICE, art::TFileDirectory::file_, fileSwitchCriteria_, fp_, recentWatchdog::now, art::ClosingCriteria::should_close(), submit_hadd::u, art::FileProperties::updateAge(), and art::FileProperties::updateSize().

Referenced by TFileService().

199 {
200  using namespace std::chrono;
201  unsigned int constexpr oneK{1024u};
202  fp_.updateSize(file_->GetSize() / oneK);
203  fp_.updateAge(duration_cast<seconds>(steady_clock::now() - beginTime_));
205 }
ClosingCriteria fileSwitchCriteria_
Definition: TFileService.h:83
bool should_close(FileProperties const &) const
void updateAge(std::chrono::seconds const age)
std::chrono::steady_clock::time_point beginTime_
Definition: TFileService.h:79
void updateSize(unsigned const size)
FileProperties fp_
Definition: TFileService.h:85
void TFileService::setDirectoryName_ ( art::ModuleDescription const &  desc)
private

Definition at line 125 of file TFileService_service.cc.

References CET_ASSERT_ONLY_ONE_THREAD, art::TFileDirectory::descr_, art::TFileDirectory::dir_, art::ModuleDescription::moduleLabel(), art::ModuleDescription::moduleName(), and string.

Referenced by TFileService().

126 {
128  dir_ = desc.moduleLabel();
129  descr_ = dir_;
130  descr_ += " (";
131  descr_ += desc.moduleName();
132  descr_ += ") folder";
133 }
#define CET_ASSERT_ONLY_ONE_THREAD()

Member Data Documentation

std::chrono::steady_clock::time_point art::TFileService::beginTime_ {}
private

Definition at line 79 of file TFileService.h.

Referenced by openFile_(), and requestsToCloseFile_().

bool const art::TFileService::closeFileFast_
private

Definition at line 69 of file TFileService.h.

Referenced by closeFile_(), and TFileService().

Granularity art::TFileService::currentGranularity_ {Granularity::Unset}
private

Definition at line 78 of file TFileService.h.

Referenced by maybeSwitchFiles_(), and TFileService().

constexpr const char* art::TFileService::default_tmpDir = "<parent-path-of-filename>"
static

Definition at line 37 of file TFileService.h.

Referenced by fileNameAtOpen_().

std::string art::TFileDirectory::descr_
protectedinherited

Definition at line 69 of file TFileDirectory.h.

Referenced by setDirectoryName_().

std::string art::TFileDirectory::dir_
protectedinherited

Definition at line 68 of file TFileDirectory.h.

Referenced by setDirectoryName_().

TFile* art::TFileDirectory::file_
protectedinherited

Definition at line 67 of file TFileDirectory.h.

Referenced by closeFile_(), openFile_(), and requestsToCloseFile_().

std::string art::TFileService::filePattern_
private

Definition at line 72 of file TFileService.h.

Referenced by fileNameAtClose_(), fileNameAtOpen_(), maybeSwitchFiles_(), and TFileService().

ClosingCriteria art::TFileService::fileSwitchCriteria_ {ClosingCriteria::Config{}}
private

Definition at line 83 of file TFileService.h.

Referenced by maybeSwitchFiles_(), requestsToCloseFile_(), and TFileService().

FileProperties art::TFileService::fp_ {}
private

Definition at line 85 of file TFileService.h.

Referenced by maybeSwitchFiles_(), requestsToCloseFile_(), and TFileService().

PostCloseFileRenamer art::TFileService::fRenamer_ {fstats_}
private

Definition at line 71 of file TFileService.h.

Referenced by fileNameAtClose_().

FileStatsCollector art::TFileService::fstats_
private

Definition at line 70 of file TFileService.h.

Referenced by closeFile_(), openFile_(), and TFileService().

std::string art::TFileService::lastClosedFile_ {}
private

Definition at line 77 of file TFileService.h.

Referenced by closeFile_(), and maybeSwitchFiles_().

bool art::TFileDirectory::requireCallback_ {false}
protectedinherited

Definition at line 70 of file TFileDirectory.h.

Referenced by TFileService().

OutputFileStatus art::TFileService::status_ {OutputFileStatus::Closed}
private

Definition at line 84 of file TFileService.h.

Referenced by closeFile_(), maybeSwitchFiles_(), openFile_(), and TFileService().

std::string art::TFileService::tmpDir_
private

Definition at line 74 of file TFileService.h.

Referenced by fileNameAtOpen_(), and TFileService().

std::string art::TFileService::uniqueFilename_
private

Definition at line 73 of file TFileService.h.

Referenced by closeFile_(), and openFile_().


The documentation for this class was generated from the following files: