LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::FileStatsCollector Class Reference

#include "FileStatsCollector.h"

Public Member Functions

 FileStatsCollector (std::string const &moduleLabel, std::string const &processName)
 
void recordFileOpen ()
 
void recordInputFile (std::string const &inputFileName)
 
void recordEvent (EventID const &id)
 
void recordRun (RunID const &id)
 
void recordSubRun (SubRunID const &id)
 
void recordFileClose ()
 
std::string const & moduleLabel () const
 
std::string const & processName () const
 
boost::posix_time::ptime outputFileOpenTime () const
 
boost::posix_time::ptime outputFileCloseTime () const
 
SubRunID const & lowestSubRunID () const
 
SubRunID const & highestSubRunID () const
 
EventID const & lowestEventID () const
 
EventID const & highestEventID () const
 
std::string const & lastOpenedInputFile () const
 
std::vector< std::string > parents (bool want_basename=true) const
 
bool fileCloseRecorded () const
 
std::size_t eventsThisFile () const
 
std::set< SubRunID > const & seenSubRuns () const
 

Private Member Functions

void resetStatistics_ ()
 

Private Attributes

std::string const moduleLabel_
 
std::string const processName_
 
SubRunID lowestSubRun_ {}
 
SubRunID highestSubRun_ {}
 
EventID lowestEventIDSeen_ {}
 
EventID highestEventIDSeen_ {}
 
boost::posix_time::ptime fo_ {}
 
boost::posix_time::ptime fc_ {}
 
bool fileCloseRecorded_ {false}
 
std::string lastOpenedInputFile_ {}
 
std::vector< std::string > inputFilesSeen_ {}
 
std::size_t nEvents_ {}
 
std::set< SubRunIDsubRunsSeen_ {}
 

Detailed Description

Definition at line 22 of file FileStatsCollector.h.

Constructor & Destructor Documentation

art::FileStatsCollector::FileStatsCollector ( std::string const &  moduleLabel,
std::string const &  processName 
)

Definition at line 7 of file FileStatsCollector.cc.

References processName(), and processName_.

10 {}
std::string const & processName() const
std::string const & moduleLabel() const
std::string const moduleLabel_
std::string const processName_

Member Function Documentation

std::size_t art::FileStatsCollector::eventsThisFile ( ) const
inline

Definition at line 127 of file FileStatsCollector.h.

References nEvents_.

Referenced by art::RootOutputFile::writeFileCatalogMetadata().

128 {
129  return nEvents_;
130 }
bool art::FileStatsCollector::fileCloseRecorded ( ) const
inline

Definition at line 121 of file FileStatsCollector.h.

References fileCloseRecorded_.

Referenced by art::PostCloseFileRenamer::applySubstitutions().

122 {
123  return fileCloseRecorded_;
124 }
art::EventID const & art::FileStatsCollector::highestEventID ( ) const
inline

Definition at line 109 of file FileStatsCollector.h.

References highestEventIDSeen_.

Referenced by art::RootOutputFile::writeFileCatalogMetadata().

110 {
111  return highestEventIDSeen_;
112 }
art::SubRunID const & art::FileStatsCollector::highestSubRunID ( ) const
inline

Definition at line 97 of file FileStatsCollector.h.

References highestSubRun_.

Referenced by art::PostCloseFileRenamer::subFilledNumericNoIndex_().

98 {
99  return highestSubRun_;
100 }
std::string const & art::FileStatsCollector::lastOpenedInputFile ( ) const
inline

Definition at line 115 of file FileStatsCollector.h.

References lastOpenedInputFile_.

Referenced by art::PostCloseFileRenamer::subInputFileName_().

116 {
117  return lastOpenedInputFile_;
118 }
art::EventID const & art::FileStatsCollector::lowestEventID ( ) const
inline

Definition at line 103 of file FileStatsCollector.h.

References lowestEventIDSeen_.

Referenced by art::RootOutputFile::writeFileCatalogMetadata().

104 {
105  return lowestEventIDSeen_;
106 }
art::SubRunID const & art::FileStatsCollector::lowestSubRunID ( ) const
inline

Definition at line 91 of file FileStatsCollector.h.

References lowestSubRun_.

Referenced by art::PostCloseFileRenamer::subFilledNumericNoIndex_().

92 {
93  return lowestSubRun_;
94 }
std::string const & art::FileStatsCollector::moduleLabel ( ) const
inline

Definition at line 67 of file FileStatsCollector.h.

References moduleLabel_.

Referenced by art::PostCloseFileRenamer::applySubstitutionsNoIndex_().

68 {
69  return moduleLabel_;
70 }
std::string const moduleLabel_
boost::posix_time::ptime art::FileStatsCollector::outputFileCloseTime ( ) const
inline

Definition at line 85 of file FileStatsCollector.h.

References fc_.

Referenced by art::PostCloseFileRenamer::subTimestamp_().

86 {
87  return fc_;
88 }
boost::posix_time::ptime fc_
boost::posix_time::ptime art::FileStatsCollector::outputFileOpenTime ( ) const
inline

Definition at line 79 of file FileStatsCollector.h.

References fo_.

Referenced by art::PostCloseFileRenamer::subTimestamp_(), and art::RootOutputFile::writeFileCatalogMetadata().

80 {
81  return fo_;
82 }
boost::posix_time::ptime fo_
std::vector< std::string > art::FileStatsCollector::parents ( bool  want_basename = true) const

Definition at line 85 of file FileStatsCollector.cc.

References inputFilesSeen_.

Referenced by art::RootOutputFile::writeFileCatalogMetadata().

86 {
87  std::vector<std::string> result;
88  if (want_basename) {
89  result.reserve(inputFilesSeen_.size());
90  for (auto const& ifile : inputFilesSeen_) {
91  boost::filesystem::path const ifp{ifile};
92  result.emplace_back(ifp.filename().native());
93  }
94  } else {
95  result = inputFilesSeen_;
96  }
97  return result;
98 }
std::vector< std::string > inputFilesSeen_
std::string const & art::FileStatsCollector::processName ( ) const
inline

Definition at line 73 of file FileStatsCollector.h.

References processName_.

Referenced by art::PostCloseFileRenamer::applySubstitutionsNoIndex_(), and FileStatsCollector().

74 {
75  return processName_;
76 }
std::string const processName_
void art::FileStatsCollector::recordEvent ( EventID const &  id)

Definition at line 33 of file FileStatsCollector.cc.

References highestEventIDSeen_, art::EventID::isValid(), lowestEventIDSeen_, nEvents_, and recordSubRun().

Referenced by art::TFileService::TFileService(), and art::RootOutput::write().

34 {
35  ++nEvents_;
36  // Actually saw a real event that we've been asked to write, so
37  // EventID should be valid.
39  lowestEventIDSeen_ = id;
40  }
41  if (id > highestEventIDSeen_) {
42  // Sort-invalid-first gives the correct answer.
44  }
45  // Record that we have seen this SubRunID too.
46  recordSubRun(id.subRunID());
47 }
bool isValid() const
Definition: EventID.h:123
void recordSubRun(SubRunID const &id)
void art::FileStatsCollector::recordFileClose ( )

Definition at line 78 of file FileStatsCollector.cc.

References fc_, and fileCloseRecorded_.

Referenced by art::TFileService::closeFile_(), and art::RootOutput::finishEndFile().

79 {
80  fc_ = boost::posix_time::second_clock::universal_time();
81  fileCloseRecorded_ = true;
82 }
boost::posix_time::ptime fc_
void art::FileStatsCollector::recordFileOpen ( )

Definition at line 13 of file FileStatsCollector.cc.

References fileCloseRecorded_, fo_, inputFilesSeen_, lastOpenedInputFile_, and resetStatistics_().

Referenced by art::RootOutput::doOpenFile(), and art::TFileService::openFile_().

14 {
16  if (!inputFilesSeen_.empty()) {
18  }
19  fo_ = boost::posix_time::second_clock::universal_time();
20  fileCloseRecorded_ = false;
21 }
boost::posix_time::ptime fo_
std::vector< std::string > inputFilesSeen_
void art::FileStatsCollector::recordInputFile ( std::string const &  inputFileName)

Definition at line 24 of file FileStatsCollector.cc.

References inputFilesSeen_, and lastOpenedInputFile_.

Referenced by art::RootOutput::respondToOpenInputFile(), and art::TFileService::TFileService().

25 {
26  if (!inputFileName.empty()) {
27  inputFilesSeen_.emplace_back(inputFileName);
28  }
29  lastOpenedInputFile_ = inputFileName;
30 }
std::vector< std::string > inputFilesSeen_
void art::FileStatsCollector::recordRun ( RunID const &  id)

Definition at line 50 of file FileStatsCollector.cc.

References highestSubRun_, art::SubRunID::invalidSubRun(), art::RunID::isValid(), lowestSubRun_, and art::SubRunID::runID().

Referenced by recordSubRun(), art::TFileService::TFileService(), and art::RootOutput::writeRun().

51 {
52  if ((!lowestSubRun_.runID().isValid()) || id < lowestSubRun_.runID()) {
54  }
55  if (id > highestSubRun_.runID()) {
56  // Sort-invalid-first gives the correct answer.
58  }
59 }
RunID const & runID() const
Definition: SubRunID.h:78
static SubRunID invalidSubRun(RunID const &rID)
Definition: SubRunID.h:164
bool isValid() const
Definition: RunID.h:69
void art::FileStatsCollector::recordSubRun ( SubRunID const &  id)

Definition at line 62 of file FileStatsCollector.cc.

References highestSubRun_, art::SubRunID::isValid(), lowestSubRun_, recordRun(), art::SubRunID::runID(), and subRunsSeen_.

Referenced by recordEvent(), art::TFileService::TFileService(), and art::RootOutput::writeSubRun().

63 {
64  recordRun(id.runID());
65  if (id.runID() == lowestSubRun_.runID() &&
66  (id.isValid() && ((!lowestSubRun_.isValid()) || // No valid subrun yet.
67  id < lowestSubRun_))) {
68  lowestSubRun_ = id;
69  }
70  if (id > highestSubRun_) {
71  // Sort-invalid-first gives the correct answer.
72  highestSubRun_ = id;
73  }
74  subRunsSeen_.emplace(id);
75 }
void recordRun(RunID const &id)
bool isValid() const
Definition: SubRunID.h:96
RunID const & runID() const
Definition: SubRunID.h:78
std::set< SubRunID > subRunsSeen_
void art::FileStatsCollector::resetStatistics_ ( )
private

Definition at line 101 of file FileStatsCollector.cc.

References fc_, fo_, highestSubRun_, inputFilesSeen_, lowestSubRun_, nEvents_, and subRunsSeen_.

Referenced by recordFileOpen().

102 {
103  fo_ = fc_ = boost::posix_time::ptime();
104  lowestSubRun_ = highestSubRun_ = SubRunID{};
105  inputFilesSeen_.clear();
106  nEvents_ = 0ul;
107  subRunsSeen_.clear();
108 }
boost::posix_time::ptime fo_
std::vector< std::string > inputFilesSeen_
boost::posix_time::ptime fc_
std::set< SubRunID > subRunsSeen_
std::set< art::SubRunID > const & art::FileStatsCollector::seenSubRuns ( ) const
inline

Definition at line 133 of file FileStatsCollector.h.

References subRunsSeen_.

Referenced by art::RootOutputFile::writeFileCatalogMetadata().

134 {
135  return subRunsSeen_;
136 }
std::set< SubRunID > subRunsSeen_

Member Data Documentation

boost::posix_time::ptime art::FileStatsCollector::fc_ {}
private

Definition at line 58 of file FileStatsCollector.h.

Referenced by outputFileCloseTime(), recordFileClose(), and resetStatistics_().

bool art::FileStatsCollector::fileCloseRecorded_ {false}
private

Definition at line 59 of file FileStatsCollector.h.

Referenced by fileCloseRecorded(), recordFileClose(), and recordFileOpen().

boost::posix_time::ptime art::FileStatsCollector::fo_ {}
private

Definition at line 57 of file FileStatsCollector.h.

Referenced by outputFileOpenTime(), recordFileOpen(), and resetStatistics_().

EventID art::FileStatsCollector::highestEventIDSeen_ {}
private

Definition at line 56 of file FileStatsCollector.h.

Referenced by highestEventID(), and recordEvent().

SubRunID art::FileStatsCollector::highestSubRun_ {}
private

Definition at line 54 of file FileStatsCollector.h.

Referenced by highestSubRunID(), recordRun(), recordSubRun(), and resetStatistics_().

std::vector<std::string> art::FileStatsCollector::inputFilesSeen_ {}
private

Definition at line 61 of file FileStatsCollector.h.

Referenced by parents(), recordFileOpen(), recordInputFile(), and resetStatistics_().

std::string art::FileStatsCollector::lastOpenedInputFile_ {}
private

Definition at line 60 of file FileStatsCollector.h.

Referenced by lastOpenedInputFile(), recordFileOpen(), and recordInputFile().

EventID art::FileStatsCollector::lowestEventIDSeen_ {}
private

Definition at line 55 of file FileStatsCollector.h.

Referenced by lowestEventID(), and recordEvent().

SubRunID art::FileStatsCollector::lowestSubRun_ {}
private

Definition at line 53 of file FileStatsCollector.h.

Referenced by lowestSubRunID(), recordRun(), recordSubRun(), and resetStatistics_().

std::string const art::FileStatsCollector::moduleLabel_
private

Definition at line 51 of file FileStatsCollector.h.

Referenced by moduleLabel().

std::size_t art::FileStatsCollector::nEvents_ {}
private

Definition at line 62 of file FileStatsCollector.h.

Referenced by eventsThisFile(), recordEvent(), and resetStatistics_().

std::string const art::FileStatsCollector::processName_
private

Definition at line 52 of file FileStatsCollector.h.

Referenced by FileStatsCollector(), and processName().

std::set<SubRunID> art::FileStatsCollector::subRunsSeen_ {}
private

Definition at line 63 of file FileStatsCollector.h.

Referenced by recordSubRun(), resetStatistics_(), and seenSubRuns().


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