Public Member Functions | Protected Types | Protected Attributes | List of all members
art::test::SimpleSource Class Reference

Public Member Functions

 SimpleSource (fhicl::ParameterSet const &ps, art::ProductRegistryHelper &help, art::SourceHelper const &sHelper)
 
void closeCurrentFile ()
 
void readFile (std::string const &name, FileBlock *&fb)
 
bool readNext (RunPrincipal const *const inR, SubRunPrincipal const *const inSR, RunPrincipal *&outR, SubRunPrincipal *&outSR, EventPrincipal *&outE)
 

Protected Types

using eventNumbers_t = std::vector< std::tuple< int, int, int >>
 
using iter = eventNumbers_t::const_iterator
 

Protected Attributes

iter current_ {}
 
iter end_ {}
 
fhicl::ParameterSet data_
 
eventNumbers_t fileData_ {}
 
art::SourceHelper const & sHelper_
 
std::string currentFilename_ {}
 
RunID currentRunID_ {}
 
SubRunID currentSubRunID_ {}
 
EventID currentEventID_ {}
 
art::TypeLabel vtl_
 

Detailed Description

Definition at line 38 of file SimpleSource_source.cc.

Member Typedef Documentation

using art::test::SimpleSource::eventNumbers_t = std::vector<std::tuple<int, int, int>>
protected

Definition at line 55 of file SimpleSource_source.cc.

Definition at line 56 of file SimpleSource_source.cc.

Constructor & Destructor Documentation

art::test::SimpleSource::SimpleSource ( fhicl::ParameterSet const &  ps,
art::ProductRegistryHelper help,
art::SourceHelper const &  sHelper 
)

Definition at line 72 of file SimpleSource_source.cc.

75  : data_{ps}
76  , sHelper_{sHelper}
77  , vtl_{helper.reconstitutes<std::vector<double>, art::InEvent>("m3")}
78 {
79  helper.reconstitutes<int, art::InEvent>("m1");
80  helper.reconstitutes<double, art::InSubRun>("s1");
81  helper.reconstitutes<double, art::InRun>("r1");
82  helper.reconstitutes<bool, art::InEvent>("m2", "a");
83  helper.reconstitutes<bool, art::InEvent>("m2", "b");
84  helper.reconstitutes<art::Ptr<double>, art::InEvent>("m3");
85 }
fhicl::ParameterSet data_
static const double ps
Definition: Units.h:103
art::SourceHelper const & sHelper_

Member Function Documentation

void art::test::SimpleSource::closeCurrentFile ( )

Definition at line 88 of file SimpleSource_source.cc.

89 {
90  fileData_.clear();
91  current_ = iter{};
92  end_ = iter{};
93 }
eventNumbers_t::const_iterator iter
void art::test::SimpleSource::readFile ( std::string const &  name,
art::FileBlock *&  fb 
)

Definition at line 96 of file SimpleSource_source.cc.

97 {
100  << "ToyReader expects to find a parameter representing a file's\n"
101  << "contents whose name is " << name << "\n";
102  }
104  current_ = fileData_.begin();
105  end_ = fileData_.end();
106  fb = new art::FileBlock{art::FileFormatVersion{1, "SimpleSource 2017"},
108 }
fhicl::ParameterSet data_
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool art::test::SimpleSource::readNext ( RunPrincipal const *const  inR,
SubRunPrincipal const *const  inSR,
RunPrincipal *&  outR,
SubRunPrincipal *&  outSR,
EventPrincipal *&  outE 
)

Definition at line 111 of file SimpleSource_source.cc.

116 {
118  using std::make_unique;
119 
120  // Have we any more to read?
121  if (current_ == end_)
122  return false;
123 
124  int r, sr, e;
125  std::tie(r, sr, e) = *current_;
126  ++current_;
127 
128  if (r != -1) // New run
129  {
130  currentRunID_ = RunID{RunNumber_t(r)};
132  put_product_in_principal(make_unique<double>(76.5), *outR, "r1");
133  }
134  if (sr != -1) // New subrun
135  {
138  put_product_in_principal(make_unique<double>(7.0), *outSR, "s1");
139  }
140  if (e != -1) // New event
141  {
144  put_product_in_principal(make_unique<int>(26), *outE, "m1");
145  put_product_in_principal(make_unique<bool>(false), *outE, "m2", "a");
146  put_product_in_principal(make_unique<bool>(true), *outE, "m2", "b");
147  {
148  std::vector<double> nums{1.0, 3.7, 5.2};
150  make_unique<decltype(nums)>(std::move(nums)), *outE, "m3");
151  }
153  make_unique<art::Ptr<double>>(sHelper_.makePtr<double>(vtl_, *outE, 1)),
154  *outE,
155  "m3");
156  }
157  return true;
158 }
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
Definition: SourceHelper.cc:83
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:55
art::SourceHelper const & sHelper_
const double e
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
std::enable_if_t<(P::branch_type==InEvent)||(P::branch_type==InResults)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
static const double sr
Definition: Units.h:167
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120

Member Data Documentation

iter art::test::SimpleSource::current_ {}
protected

Definition at line 58 of file SimpleSource_source.cc.

EventID art::test::SimpleSource::currentEventID_ {}
protected

Definition at line 67 of file SimpleSource_source.cc.

std::string art::test::SimpleSource::currentFilename_ {}
protected

Definition at line 64 of file SimpleSource_source.cc.

RunID art::test::SimpleSource::currentRunID_ {}
protected

Definition at line 65 of file SimpleSource_source.cc.

SubRunID art::test::SimpleSource::currentSubRunID_ {}
protected

Definition at line 66 of file SimpleSource_source.cc.

fhicl::ParameterSet art::test::SimpleSource::data_
protected

Definition at line 60 of file SimpleSource_source.cc.

iter art::test::SimpleSource::end_ {}
protected

Definition at line 59 of file SimpleSource_source.cc.

eventNumbers_t art::test::SimpleSource::fileData_ {}
protected

Definition at line 61 of file SimpleSource_source.cc.

art::SourceHelper const& art::test::SimpleSource::sHelper_
protected

Definition at line 63 of file SimpleSource_source.cc.

art::TypeLabel art::test::SimpleSource::vtl_
protected

Definition at line 69 of file SimpleSource_source.cc.


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