Public Member Functions | Private Attributes | List of all members
arttest::ToyRawInputTester Class Reference
Inheritance diagram for arttest::ToyRawInputTester:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 ToyRawInputTester (fhicl::ParameterSet const &p)
 
void respondToOpenInputFile (art::FileBlock const &fb) override
 
void beginRun (art::Run const &r) override
 
void beginSubRun (art::SubRun const &sr) override
 
void analyze (art::Event const &e) override
 
void endJob () override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

size_t numEventsSeen_ {}
 
size_t numEventsExpected_ {}
 
size_t numSubRunsSeen_ {}
 
size_t numSubRunsExpected_ {}
 
size_t numRunsSeen_ {}
 
size_t numRunsExpected_ {}
 
size_t numFilesSeen_ {}
 
size_t numFilesExpected_ {}
 
strings fileNames_
 
fhicl::ParameterSet pset_
 
ostringstream messages_ {}
 
string expectedMessage_ {}
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 

Detailed Description

Definition at line 29 of file ToyRawInputTester_module.cc.

Constructor & Destructor Documentation

arttest::ToyRawInputTester::ToyRawInputTester ( fhicl::ParameterSet const &  p)
inlineexplicit

Definition at line 31 of file ToyRawInputTester_module.cc.

32  : art::EDAnalyzer{p}, fileNames_{p.get<strings>("fileNames")}, pset_{p}
33  {
35  ostringstream expected;
36  for (size_t i = 0; i != numFilesExpected_; ++i) {
37  expected << "open " << fileNames_[i] << '\n';
38 
39  std::vector<std::tuple<int, int, int>> tokens;
40  try { // Assume it's a real filename
41  fhicl::intermediate_table raw_config;
42  cet::filepath_lookup_after1 lookupPolicy(".:");
43  fhicl::parse_document(fileNames_[i], lookupPolicy, raw_config);
44  fhicl::ParameterSet file_pset;
45  make_ParameterSet(raw_config, file_pset);
46  assert(file_pset.get_if_present("data", tokens));
47  }
48  catch (...) { // Attempt to read the parameter set by that name instead.
49  assert(p.get_if_present(fileNames_[i], tokens));
50  }
51  RunNumber_t currentRun = -1;
52  SubRunNumber_t currentSubRun = -1;
53  for (auto const& token : tokens) {
54  int newRun, newSubRun, newEvent;
55  std::tie(newRun, newSubRun, newEvent) = token;
56  if (newRun != -1) {
58  currentRun = newRun;
59  expected << "begin " << RunID(currentRun) << '\n';
60  }
61  if (newSubRun != -1) {
63  currentSubRun = newSubRun;
64  expected << "begin " << SubRunID(currentRun, currentSubRun) << '\n';
65  }
66  if (newEvent != -1) {
68  expected << "event " << EventID(currentRun, currentSubRun, newEvent)
69  << '\n';
70  }
71  }
72  }
73  expectedMessage_ = expected.str();
74  }
std::vector< std::string > strings
const char expected[]
Definition: Exception_t.cc:22
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
p
Definition: test.py:228
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
Definition: parse.cc:856
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Function Documentation

void arttest::ToyRawInputTester::analyze ( art::Event const &  e)
inlineoverridevirtual

Implements art::EDAnalyzer.

Definition at line 98 of file ToyRawInputTester_module.cc.

99  {
100  ++numEventsSeen_;
101  messages_ << "event " << e.id() << '\n';
102  }
const double e
void arttest::ToyRawInputTester::beginRun ( art::Run const &  r)
inlineoverridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 84 of file ToyRawInputTester_module.cc.

85  {
86  ++numRunsSeen_;
87  messages_ << "begin " << r.id() << '\n';
88  }
void arttest::ToyRawInputTester::beginSubRun ( art::SubRun const &  sr)
inlineoverridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 91 of file ToyRawInputTester_module.cc.

92  {
94  messages_ << "begin " << sr.id() << '\n';
95  }
static const double sr
Definition: Units.h:167
void arttest::ToyRawInputTester::endJob ( )
inlineoverridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 105 of file ToyRawInputTester_module.cc.

106  {
107  cet::HorizontalRule constexpr rule{72};
108  std::cerr << rule('-') << '\n'
109  << expectedMessage_ << rule('-') << '\n'
110  << rule('+') << '\n'
111  << messages_.str() << rule('+') << '\n';
112  assert(numFilesSeen_ == numFilesExpected_);
113  assert(numRunsSeen_ == numRunsExpected_);
116  assert(expectedMessage_ == messages_.str());
117  }
void arttest::ToyRawInputTester::respondToOpenInputFile ( art::FileBlock const &  fb)
inlineoverridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 77 of file ToyRawInputTester_module.cc.

78  {
79  ++numFilesSeen_;
80  messages_ << "open " << fb.fileName() << '\n';
81  }

Member Data Documentation

string arttest::ToyRawInputTester::expectedMessage_ {}
private

Definition at line 131 of file ToyRawInputTester_module.cc.

strings arttest::ToyRawInputTester::fileNames_
private

Definition at line 128 of file ToyRawInputTester_module.cc.

ostringstream arttest::ToyRawInputTester::messages_ {}
private

Definition at line 130 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numEventsExpected_ {}
private

Definition at line 121 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numEventsSeen_ {}
private

Definition at line 120 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numFilesExpected_ {}
private

Definition at line 127 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numFilesSeen_ {}
private

Definition at line 126 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numRunsExpected_ {}
private

Definition at line 125 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numRunsSeen_ {}
private

Definition at line 124 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numSubRunsExpected_ {}
private

Definition at line 123 of file ToyRawInputTester_module.cc.

size_t arttest::ToyRawInputTester::numSubRunsSeen_ {}
private

Definition at line 122 of file ToyRawInputTester_module.cc.

fhicl::ParameterSet arttest::ToyRawInputTester::pset_
private

Definition at line 129 of file ToyRawInputTester_module.cc.


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