artdaq  v2_03_00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
RawEventQueueReader.hh
1 #ifndef artdaq_ArtModules_detail_RawEventQueueReader_hh
2 #define artdaq_ArtModules_detail_RawEventQueueReader_hh
3 
4 #include "art/Framework/Core/Frameworkfwd.h"
5 
6 #include "art/Framework/Core/FileBlock.h"
7 #include "art/Framework/Core/ProductRegistryHelper.h"
8 #include "art/Framework/IO/Sources/SourceHelper.h"
9 #include "art/Framework/IO/Sources/SourceTraits.h"
10 #include "art/Framework/Principal/EventPrincipal.h"
11 #include "art/Framework/Principal/RunPrincipal.h"
12 #include "art/Framework/Principal/SubRunPrincipal.h"
13 #include "artdaq-core/Core/GlobalQueue.hh"
14 #include "fhiclcpp/ParameterSet.h"
15 
16 #include <string>
17 #include <map>
18 
19 namespace artdaq
20 {
21  namespace detail
22  {
27  {
32 
38 
39  art::SourceHelper const pmaker;
40  RawEventQueue& incoming_events;
41  artdaq::detail::seconds waiting_time;
43  std::string pretend_module_name;
47  size_t bytesRead;
48 
62  RawEventQueueReader(fhicl::ParameterSet const& ps,
63  art::ProductRegistryHelper& help,
64  art::SourceHelper const& pm);
65 
74  RawEventQueueReader(fhicl::ParameterSet const& ps,
75  art::ProductRegistryHelper& help,
76  art::SourceHelper const& pm,
77  art::MasterProductRegistry&) : RawEventQueueReader(ps, help, pm) {}
78 
82  void closeCurrentFile();
83 
88  void readFile(std::string const&, art::FileBlock*& fb);
89 
94  bool hasMoreData() const { return (!shutdownMsgReceived); }
95 
106  bool readNext(art::RunPrincipal* const & inR,
107  art::SubRunPrincipal* const & inSR,
108  art::RunPrincipal*& outR,
109  art::SubRunPrincipal*& outSR,
110  art::EventPrincipal*& outE);
111 
112  std::map<Fragment::type_t, std::string> fragment_type_map_;
113  unsigned readNext_calls_;
114  };
115  } // detail
116 } // artdaq
117 
118 namespace art
119 {
124  template <>
125  struct Source_generator<artdaq::detail::RawEventQueueReader>
126  {
127  static constexpr bool value = true;
128  };
129 }
130 
131 #endif /* artdaq_ArtModules_detail_RawEventQueueReader_hh */
std::string pretend_module_name
The module name to store data under.
bool readNext(art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
Dequeue a RawEvent and declare its Fragment contents to art, creating Run, SubRun, and EventPrincipal objects as necessary.
bool shutdownMsgReceived
Whether a shutdown message has been received.
bool hasMoreData() const
Whether more data is expected from the RawEventQueueReader.
RawEventQueueReader(RawEventQueueReader const &)=delete
Copy Constructor is deleted.
RawEventQueueReader & operator=(RawEventQueueReader const &)=delete
Copy Assignment operator is deleted.
The RawEventQueueReader is a class which implements the methods needed by art::Source.
std::string unidentified_instance_name
The name to use for unknown Fragment types.
void readFile(std::string const &, art::FileBlock *&fb)
Emulate opening a file.
RawEventQueueReader(fhicl::ParameterSet const &ps, art::ProductRegistryHelper &help, art::SourceHelper const &pm, art::MasterProductRegistry &)
RawEventQueueReader Constructor.
void closeCurrentFile()
Emulate closing a file. No-Op.
bool outputFileCloseNeeded
If an explicit output file close message is needed.
size_t bytesRead
running total of number of bytes dequeued
bool resume_after_timeout
Whether to resume if the dequeue action times out.
RawEventQueue & incoming_events
The events from the EventStore.
std::map< Fragment::type_t, std::string > fragment_type_map_
The Fragment type names that this RawEventQueueReader knows about.
artdaq::detail::seconds waiting_time
The amount of time to wait for an event from the queue.
unsigned readNext_calls_
The number of times readNext has been called.
art::SourceHelper const pmaker
An art::SourceHelper instance.