DecrepitRelicInputSourceImplementation.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_DecrepitRelicInputSourceImplementation_h
2 #define art_Framework_Core_DecrepitRelicInputSourceImplementation_h
3 // vim: set sw=2 expandtab :
4 
5 //
6 // This is the relic we inherited from CMS, which is not an interface.
7 // The remaining comments are left over from that.
8 //
9 // InputSource: Abstract interface for all input sources. Input
10 // sources are responsible for creating an EventPrincipal, using data
11 // controlled by the source, and external to the EventPrincipal itself.
12 //
13 // The InputSource is also responsible for dealing with the "process
14 // name list" contained within the EventPrincipal. Each InputSource has
15 // to know what "process" (HLT, PROD, USER, USER1, etc.) the program is
16 // part of. The InputSource is repsonsible for pushing this process name
17 // onto the end of the process name list.
18 //
19 // For now, we specify this process name to the constructor of the
20 // InputSource. This should be improved.
21 //
22 // Some questions about this remain:
23 //
24 // 1. What should happen if we "rerun" a process? i.e., if "USER1" is
25 // already last in our input file, and we run again a job which claims
26 // to be "USER1", what should happen? For now, we just quietly add
27 // this to the history.
28 //
29 // 2. Do we need to detect a problem with a history like:
30 // HLT PROD USER1 PROD
31 // or is it up to the user not to do something silly? Right now, there
32 // is no protection against such sillyness.
33 //
34 // Some examples of InputSource subclasses may be:
35 //
36 // 1) EmptyEvent: creates EventPrincipals which contain no EDProducts.
37 // 2) RootInput: creates EventPrincipals which "contain" the data
38 // read from a root file. This source should provide for delayed loading
39 // of data, thus the quotation marks around contain.
40 // 3) DAQInputSource: creats EventPrincipals which contain raw data, as
41 // delivered by the L1 trigger and event builder.
42 //
43 
49 #include "cetlib/exempt_ptr.h"
50 #include "fhiclcpp/types/Atom.h"
52 
53 #include <memory>
54 #include <string>
55 
56 namespace art {
57 
59 
60  public: // CONFIGURATION
61  struct Config {
62 
63  ~Config();
64  Config();
65  Config(Config const&) = delete;
66  Config(Config&&) = delete;
67  Config& operator=(Config const&) = delete;
68  Config& operator=(Config&&) = delete;
69 
70  static char const* defaultMode();
71 
77  };
78 
79  public: // MEMBER FUNCTIONS -- Special Member Functions
81  ModuleDescription const&);
82 
83  // Prevent concrete instances of this class even though we don't
84  // have any (other) pure virtual functions.
85  virtual ~DecrepitRelicInputSourceImplementation() noexcept = 0;
86 
89 
92 
95 
96  public: // MEMBER FUNCTIONS -- Serial Access Interface
97  // Inform subclasses that they're going to be told to close the file
98  // for non-exceptional reasons (such as hitting the event limit).
99  virtual void
101  {}
102 
103  virtual input::ItemType nextItemType() override;
104 
105  // Close current file
106  virtual void closeFile() override;
107 
108  /// Read next file
109  std::unique_ptr<FileBlock> readFile() override;
110 
111  // Read next run.
112  virtual std::unique_ptr<RunPrincipal> readRun() override;
113 
114  // Read next subRun
115  virtual std::unique_ptr<SubRunPrincipal> readSubRun(
117 
118  // Read next event
119  // Indicate inability to get a new event by returning a null unique_ptr.
120  virtual std::unique_ptr<EventPrincipal> readEvent(
122 
123  // Not implemented.
124  // virtual
125  // std::unique_ptr<RangeSetHandler>
126  // runRangeSetHandler() = 0;
127 
128  // Not implemented.
129  // virtual
130  // std::unique_ptr<RangeSetHandler>
131  // subRunRangeSetHandler() = 0;
132 
133  public: // MEMBER FUNCTIONS -- Job Interface
134  // Called by framework at beginning of job
135  virtual void doBeginJob() override;
136 
137  // Called by framework at end of job
138  virtual void doEndJob() override;
139 
140  public: // MEMBER FUNCTIONS -- Random Access Interface
141  // Skip the number of events specified.
142  // Offset may be negative.
143  virtual void skipEvents(int offset) override;
144 
145  // Begin again at the first event
146  virtual void rewind() override;
147 
148  public: // MEMBER FUNCTIONS -- DecrepitRelicInputSourceImplementation specific
149  // interface
150  // RunsSubRunsAndEvents (default), RunsAndSubRuns, or Runs.
152 
153  // Accessor for maximum number of events to be read.
154  // -1 is used for unlimited.
155  int maxEvents() const;
156 
157  // Accessor for remaining number of events to be read.
158  // -1 is used for unlimited.
159  int remainingEvents() const;
160 
161  // Accessor for maximum number of subRuns to be read.
162  // -1 is used for unlimited.
163  int maxSubRuns() const;
164 
165  // Accessor for remaining number of subRuns to be read.
166  // -1 is used for unlimited.
167  int remainingSubRuns() const;
168 
169  public: // MEMBER FUNCTIONS -- DecrepitRelicInputSourceImplementation specific
170  // interface
171  // Reset the remaining number of events/subRuns to the maximum number.
172  void repeat_();
173 
174  // issue an event report
175  void issueReports(EventID const& eventID);
176 
177  protected: // MEMBER FUNCTIONS -- Utility Functions for Subclasses
178  input::ItemType state() const;
179 
181 
182  void reset();
183 
184  private: // MEMBER FUNCTIONS -- Required Interface for Subclasses
185  virtual input::ItemType getNextItemType() = 0;
186 
187  virtual std::unique_ptr<RunPrincipal> readRun_() = 0;
188 
189  virtual std::unique_ptr<SubRunPrincipal> readSubRun_(
191 
192  virtual std::unique_ptr<EventPrincipal> readEvent_() = 0;
193 
194  private: // MEMBER FUNCTIONS -- Optional Serial Interface for Subclasses
195  virtual std::unique_ptr<FileBlock> readFile_();
196 
197  virtual void closeFile_();
198 
199  private: // MEMBER FUNCTIONS -- Optional Job Interface for Subclasses
200  virtual void beginJob();
201 
202  virtual void endJob();
203 
204  private
205  : // MEMBER FUNCTIONS -- Optional Random Access Interface for Subclasses
206  virtual void skip(int);
207 
208  virtual void rewind_();
209 
210  private: // MEMBER DATA
214  int const reportFrequency_;
219  };
220 
221 } // namespace art
222 
223 #endif /* art_Framework_Core_DecrepitRelicInputSourceImplementation_h */
224 
225 // Local Variables:
226 // mode: c++
227 // End:
virtual std::unique_ptr< SubRunPrincipal > readSubRun_(cet::exempt_ptr< RunPrincipal const >)=0
virtual std::unique_ptr< RunPrincipal > readRun() override
virtual std::unique_ptr< EventPrincipal > readEvent_()=0
virtual input::ItemType getNextItemType()=0
virtual std::unique_ptr< RunPrincipal > readRun_()=0
DecrepitRelicInputSourceImplementation(fhicl::TableFragment< Config > const &, ModuleDescription const &)
virtual std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
virtual std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
virtual ~DecrepitRelicInputSourceImplementation() noexcept=0
std::unique_ptr< FileBlock > readFile() override
Read next file.