LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
RootInputFileSequence.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Root_RootInputFileSequence_h
2 #define art_Framework_IO_Root_RootInputFileSequence_h
3 // vim: set sw=2:
4 
15 #include "cetlib/exempt_ptr.h"
16 #include "fhiclcpp/types/Atom.h"
20 #include "fhiclcpp/types/Table.h"
22 
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 namespace art {
28 
29  class DuplicateChecker;
30  class FileCatalogItem;
31  class FileIndex;
32  class InputFileCatalog;
33  class MasterProductRegistry;
34  class RootInputFile;
35 
37 
38  public: // TYPES
39  using RootInputFileSharedPtr = std::shared_ptr<RootInputFile>;
41 
42  public: // MEMBER FUNCTIONS
44 
46 
47  struct Config {
48 
49  using Name = fhicl::Name;
51  template <typename T>
53  template <typename T>
55  template <typename T>
57  template <typename T>
59  template <typename T>
61  template <typename T>
63 
65  Atom<EventNumber_t> skipEvents{Name("skipEvents"), 0};
66  Atom<bool> noEventSort{Name("noEventSort"), false};
67  Atom<bool> skipBadFiles{Name("skipBadFiles"), false};
68  Atom<unsigned> cacheSize{Name("cacheSize"), 0u};
69  Atom<std::int64_t> treeMaxVirtualSize{Name("treeMaxVirtualSize"), -1};
71  Name("saveMemoryObjectThreshold"),
72  -1};
73  Atom<bool> delayedReadEventProducts{Name("delayedReadEventProducts"),
74  true};
75  Atom<bool> delayedReadSubRunProducts{Name("delayedReadSubRunProducts"),
76  false};
77  Atom<bool> delayedReadRunProducts{Name("delayedReadRunProducts"), false};
79  std::vector<std::string>{"keep *"}};
81  Name("dropDescendantsOfDroppedBranches"),
82  true};
83  Atom<bool> readParameterSets{Name("readParameterSets"), true};
84 
85  struct SecondaryFile {
87  Sequence<std::string> b{Name("b"), std::vector<std::string>{}};
88  };
89 
91  Name("secondaryFileNames")};
97  Name("compactEventRanges"),
98  Comment(
99  "If users can guarantee that SubRuns do not span multiple input\n"
100  "files, the 'compactEventRanges' parameter can be set to 'true'\n"
101  "to ensure the most compact representation of event-ranges "
102  "associated\n"
103  "with all Runs and SubRuns stored in the input file.\n\n"
104  "WARNING: Enabling compact event ranges creates a history that can\n"
105  " cause file concatenation problems if a given SubRun spans\n"
106  " multiple input files. Use with care."),
107  false};
108  };
109 
115  ProcessConfiguration const&);
116  void endJob();
117 
118  std::unique_ptr<FileBlock> readFile_();
119 
120  std::unique_ptr<RootInputFile> openSecondaryFile(
121  std::string const& name,
122  cet::exempt_ptr<RootInputFile> primaryFile);
123 
124  void closeFile_();
125 
126  void skip(int offset);
127 
128  void rewind_();
129 
130  EventID seekToEvent(EventID const&, bool exact = false);
131 
132  EventID seekToEvent(off_t offset, bool exact = false);
133 
135 
136  std::unique_ptr<RunPrincipal> readIt(RunID const&);
137 
138  std::unique_ptr<RunPrincipal> readRun_();
139 
140  std::unique_ptr<SubRunPrincipal> readIt(SubRunID const&,
141  cet::exempt_ptr<RunPrincipal>);
142 
143  std::unique_ptr<SubRunPrincipal> readSubRun_(cet::exempt_ptr<RunPrincipal>);
144 
145  std::unique_ptr<EventPrincipal> readIt(EventID const&, bool exact = false);
146 
147  std::unique_ptr<EventPrincipal> readEvent_();
148 
151  {
153  }
154 
156  rootFile() const
157  {
158  return rootFile_;
159  }
160 
161  std::unique_ptr<RangeSetHandler> runRangeSetHandler();
162  std::unique_ptr<RangeSetHandler> subRunRangeSetHandler();
163 
164  std::vector<std::vector<std::string>> const&
166  {
167  return secondaryFileNames_;
168  }
169 
170  EventID
171  origEventID() const
172  {
173  return origEventID_;
174  }
175 
177  eventsToSkip() const
178  {
179  return eventsToSkip_;
180  }
181 
184  {
185  return fastCloningInfo_;
186  }
187 
188  unsigned int
190  {
191  return treeCacheSize_;
192  }
193 
194  int64_t
196  {
197  return treeMaxVirtualSize_;
198  }
199 
200  int64_t
202  {
204  };
205 
206  bool
208  {
210  }
211 
212  bool
214  {
216  }
217 
218  bool
220  {
222  }
223 
226  {
227  return processingMode_;
228  }
229 
230  void finish();
231 
232  private: // MEMBER FUNCTIONS
233  void initFile(bool skipBadFiles);
234 
235  bool nextFile();
236 
237  bool previousFile();
238 
239  void rewindFile();
240 
241  std::vector<FileCatalogItem> const& fileCatalogItems() const;
242 
244 
245  bool primary() const;
246 
247  private: // MEMBER DATA
249  bool firstFile_{true};
251  std::vector<std::shared_ptr<FileIndex>> fileIndexes_;
255  bool const noEventSort_;
256  bool const skipBadFiles_;
257  unsigned int const treeCacheSize_;
258  int64_t const treeMaxVirtualSize_;
266  std::shared_ptr<DuplicateChecker> duplicateChecker_{nullptr};
267  bool const dropDescendants_;
268  bool const readParameterSets_;
273  std::vector<std::vector<std::string>> secondaryFileNames_{};
275  bool pendingClose_{false};
276  };
277 
278 } // namespace art
279 
280 // Local Variables:
281 // mode: c++
282 // End:
283 #endif /* art_Framework_IO_Root_RootInputFileSequence_h */
OptionalAtom< EventNumber_t > hasFirstEvent
RootInputFileSharedPtr rootFile() const
std::unique_ptr< RangeSetHandler > runRangeSetHandler()
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
OptionalSequence< Table< SecondaryFile > > secondaryFileNames
ProcessConfiguration const & processConfiguration_
OptionalAtom< SubRunNumber_t > hasFirstSubRun
std::vector< FileCatalogItem > const & fileCatalogItems() const
RootInputFileSequence(RootInputFileSequence const &)=delete
std::unique_ptr< RangeSetHandler > subRunRangeSetHandler()
std::unique_ptr< RunPrincipal > readRun_()
std::unique_ptr< RootInputFile > openSecondaryFile(std::string const &name, cet::exempt_ptr< RootInputFile > primaryFile)
FastCloningInfoProvider const & fastCloningInfo() const
RootInputFileSharedPtr rootFileForLastReadEvent() const
ProcessConfiguration const & processConfiguration() const
std::shared_ptr< DuplicateChecker > duplicateChecker_
EventID seekToEvent(EventID const &, bool exact=false)
TableFragment< DuplicateChecker::Config > dc
std::vector< std::vector< std::string > > const & secondaryFileNames() const
OptionalAtom< RunNumber_t > setRunNumber
GroupSelectorRules groupSelectorRules_
std::unique_ptr< RunPrincipal > readIt(RunID const &)
Atom< std::int64_t > saveMemoryObjectThreshold
FastCloningInfoProvider fastCloningInfo_
OptionalAtom< RunNumber_t > hasFirstRun
RootInputFileSharedPtr rootFile_
EventNumber_t eventsToSkip() const
Long64_t EntryNumber
Definition: Inputfwd.h:46
unsigned int treeCacheSize() const
std::unique_ptr< FileBlock > readFile_()
std::vector< std::vector< std::string > > secondaryFileNames_
InputSource::ProcessingMode processingMode_
MasterProductRegistry & mpr_
std::unique_ptr< EventPrincipal > readEvent_()
void initFile(bool skipBadFiles)
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
std::shared_ptr< RootInputFile > RootInputFileSharedPtr
int64_t saveMemoryObjectThreshold() const
HLT enums.
InputSource::ProcessingMode const & processingMode()
std::unique_ptr< SubRunPrincipal > readSubRun_(cet::exempt_ptr< RunPrincipal >)
RootInputFileSharedPtr rootFileForLastReadEvent_
RootInputFileSequence & operator=(RootInputFileSequence const &)=delete
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119