LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ClosingCriteria.cc
Go to the documentation of this file.
3 
5 using seconds_t = std::chrono::seconds;
6 
7 namespace {
8  void
9  config_assert(bool const cond, std::string const& msg)
10  {
11  if (!cond)
12  throw art::Exception(art::errors::Configuration) << msg << '\n';
13  }
14 }
15 
17  unsigned const subRuns,
18  unsigned const runs,
19  unsigned const inputFiles,
20  unsigned const the_size,
21  seconds_t const the_age)
22  : counts_{{events, subRuns, runs, inputFiles}}, age_{the_age}, size_{the_size}
23 {}
24 
25 std::ostream&
26 art::operator<<(std::ostream& os, FileProperties const& fp)
27 {
28  os << "[nEvents: " << fp.nEvents() << ", nSubRuns: " << fp.nSubRuns()
29  << ", nRuns: " << fp.nRuns() << ", nInputFiles: " << fp.nInputFiles()
30  << ", size: " << fp.size() << ", age: " << fp.age().count() << "]";
31  return os;
32 }
33 
36  c.maxSubRuns(),
37  c.maxRuns(),
38  c.maxInputFiles(),
39  c.maxSize(),
40  seconds_t{c.maxAge()}},
41  c.granularity()}
42 {
43  auto const& cc = closingCriteria_;
44  config_assert(cc.nEvents() > 0, "maxEvents must be greater than 0.");
45  config_assert(cc.nSubRuns() > 0, "maxSubRuns must be greater than 0.");
46  config_assert(cc.nRuns() > 0, "maxRuns must be greater than 0.");
47  config_assert(cc.nInputFiles() > 0, "maxInputFiles must be greater than 0.");
48  config_assert(cc.size() > 0, "maxSize must be greater than 0 KiB.");
49  config_assert(cc.age() > decltype(cc.age())::zero(),
50  "maxAge must be greater than 0 seconds.");
51 }
52 
54  std::string const& granularity)
56 {}
57 
58 bool
60 {
61  return fp.size() >= closingCriteria_.size() ||
62  fp.nEvents() >= closingCriteria_.nEvents() ||
64  fp.nRuns() >= closingCriteria_.nRuns() ||
66  fp.age() >= closingCriteria_.age();
67 }
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
ClosingCriteria()=default
auto nSubRuns() const
auto nEvents() const
art::FileIndex::EntryNumber_t EntryNumber_t
FileProperties()=default
long long EntryNumber_t
Definition: FileIndex.h:43
static BT value(std::string const &spec)
std::chrono::seconds age_
bool should_close(FileProperties const &) const
auto granularity() const
auto nRuns() const
FILE * fp
Definition: plot.C:36
FileProperties closingCriteria_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
fhicl::Atom< std::string > granularity
auto size() const
std::chrono::seconds seconds_t
auto nInputFiles() const