OfflineROOTFile.h
Go to the documentation of this file.
1 #ifndef _OfflineROOTFile_h_
2 #define _OfflineROOTFile_h_
3 
4 #include <io/VROOTFile.h>
5 #include <io/StreamerSwitch.h>
6 
7 
8 class TBranch;
9 
10 namespace evt {
11  class Event;
12 }
13 
14 namespace utl {
15  class Branch;
16 }
17 
18 namespace io {
19 
20  class Event_ROOT;
21  class Config_ROOT;
22 
23 
32  class OfflineROOTFile : public VROOTFile {
33 
34  private:
35  // set default switch (constructed with all streamers on)
37 
38  public:
39  OfflineROOTFile() = default;
40 
41  OfflineROOTFile(const std::string& filename, const Mode mode = eRead,
42  utl::Branch* const b = nullptr,
43  const io::StreamerSwitch& streamerSwitch = fgDefaultSwitch);
44 
45  virtual ~OfflineROOTFile();
46 
47  void Open(const std::string& filename, const Mode mode, utl::Branch* const b = nullptr) override;
48 
49  void Close() override;
50 
51  void Write(const evt::Event& event) override;
52 
54  Status Read(evt::Event& event) override;
55 
57  Status FindEvent(const unsigned int eventId) override;
58 
59  Status GotoPosition(const unsigned int evNo) override;
60 
61  int GetNEvents() override;
62 
64 
67  std::string GetConfig();
68 
69  static const std::string kOfflineTreeName;
70  static const std::string kOfflineBranchName;
71  static const std::string kConfigBranchName;
72 
73  private:
75 
76  unsigned int fCurEventNo = 0;
77 
78  TBranch* fBranch = nullptr;
79  TBranch* fConfigBranch = nullptr;
83 
84  std::ofstream* fConfigOut = nullptr;
85  };
86 
87 }
88 
89 
90 #endif
std::string GetConfig()
Return a string with the configuration corresponding to the run.
int GetNEvents() override
std::ofstream * fConfigOut
ROOT streamer for top level offline format.
switches to allow excluding certain parts of Event from streaming
Holds the run configuration data from CentralConfig.
Definition: Config_ROOT.h:19
Status GotoPosition(const unsigned int evNo) override
goto by position in the file
Mode
Available open modes.
Definition: IoCodes.h:16
unsigned int fCurEventNo
OfflineROOTFile()=default
Event Class being actually streamed when using ROOT IO.
Definition: Event_ROOT.h:33
io::StreamerSwitch fStreamerSwitch
Class representing a document branch.
Definition: Branch.h:107
Status
Return code for seek operation.
Definition: IoCodes.h:24
void Write(const evt::Event &event) override
void Close() override
static const std::string kConfigBranchName
void Open(const std::string &filename, const Mode mode, utl::Branch *const b=nullptr) override
static const std::string kOfflineTreeName
Status FindEvent(const unsigned int eventId) override
On success returns event number in the file.
static const std::string kOfflineBranchName
io::Event_ROOT * fCurEvent
io::Config_ROOT * fConfig
char * filename
Definition: dump1090.h:266
static const io::StreamerSwitch fgDefaultSwitch
Status Read(evt::Event &event) override
Returns -1 if End Of File.

, generated on Tue Sep 26 2023.