LDMX Software
EventFile.h
1#ifndef FRAMEWORK_EVENT_EVENTFILE_H_
2#define FRAMEWORK_EVENT_EVENTFILE_H_
3
4//---< C++ >---//
5#include <map>
6#include <string>
7#include <vector>
8
9//---< Framework >---//
10#include "Framework/Configure/Parameters.h"
11#include "Framework/Event.h"
12
13//---< ROOT >---//
14#include "TFile.h"
15#include "TTree.h"
16
17namespace ldmx {
18class RunHeader;
19}
20
21namespace framework {
22
26class EventFile {
27 public:
43 const std::string &filename, EventFile *parent, bool isOutputFile,
44 bool isSingleOutput, bool isLoopable);
45
59 const std::string &fileName, bool isLoopable);
60
74 const std::string &fileName, EventFile *parent,
75 bool isSingleOutput = false);
76
89 const std::string &fileName);
90
96 ~EventFile();
97
116 bool isCorrupted() const;
117
157 void addDrop(const std::string &rule);
158
163 void setupEvent(Event *evt);
164
175 void updateParent(EventFile *parent);
176
181 Event *getEvent() { return event_; };
182
212 bool nextEvent(bool storeCurrentEvent = true);
213
218 int skipToEvent(int offset);
219
229 void writeRunHeader(ldmx::RunHeader &runHeader);
230
238 void writeRunTree();
239
246 ldmx::RunHeader *getRunHeaderPtr(int runNumber);
247
255 ldmx::RunHeader &getRunHeader(int runNumber);
256
258 const std::string &getFileName() { return fileName_; }
259
260 private:
277 void importRunHeaders();
278
279 private:
281 Long64_t entries_{-1};
282
284 Long64_t ientry_{-1};
285
287 std::string fileName_;
288
291
294
296 bool isLoopable_{false};
297
299 TFile *file_{nullptr};
300
302 TTree *tree_{nullptr};
303
306
308 Event *event_{nullptr};
309
316 std::vector<std::pair<std::string, bool>> preCloneRules_;
317
325 std::vector<std::string> reactivateRules_;
326
337 std::map<int, std::pair<bool, ldmx::RunHeader *>> runMap_;
338};
339} // namespace framework
340
341#endif // FRAMEWORK_EVENT_EVENTFILE_H
Class implementing an event buffer system for storing event data.
This class manages all ROOT file input/output operations.
Definition EventFile.h:26
void updateParent(EventFile *parent)
Change pointer to different parent file.
const std::string & getFileName()
Definition EventFile.h:258
bool isSingleOutput_
True if there is only one output file.
Definition EventFile.h:293
TFile * file_
The backing TFile for this EventFile.
Definition EventFile.h:299
void addDrop(const std::string &rule)
Add a rule for dropping collections from the output.
std::string fileName_
The file name.
Definition EventFile.h:287
bool isLoopable_
True if this is an input file with pileup overlay events *‍/.
Definition EventFile.h:296
std::map< int, std::pair< bool, ldmx::RunHeader * > > runMap_
Map of run numbers to RunHeader objects.
Definition EventFile.h:337
void setupEvent(Event *evt)
Set an Event object containing the event data to work with this file.
Long64_t entries_
The number of entries in the tree.
Definition EventFile.h:281
std::vector< std::string > reactivateRules_
Vector of drop rules that have been parsed and need to be used to reactivate these branches on the in...
Definition EventFile.h:325
std::vector< std::pair< std::string, bool > > preCloneRules_
Pre-clone rules.
Definition EventFile.h:316
void writeRunTree()
Write the map of run headers to the file as a TTree of RunHeader.
bool nextEvent(bool storeCurrentEvent=true)
Prepare the next event.
Event * getEvent()
Get the Event object containing the event data.
Definition EventFile.h:181
bool isOutputFile_
True if file is an output file being written to disk.
Definition EventFile.h:290
ldmx::RunHeader * getRunHeaderPtr(int runNumber)
Update the RunHeader for a given run, if it exists in the input file.
Long64_t ientry_
The current entry in the tree.
Definition EventFile.h:284
void writeRunHeader(ldmx::RunHeader &runHeader)
Write the run header into the run map.
~EventFile()
Destructor.
void importRunHeaders()
Fill the internal map of run numbers to RunHeader objects from the input file.
int skipToEvent(int offset)
Skip events using an offset.
ldmx::RunHeader & getRunHeader(int runNumber)
Get the RunHeader for a given run, if it exists in the input file.
EventFile * parent_
A parent file containing event data.
Definition EventFile.h:305
TTree * tree_
The tree with event data.
Definition EventFile.h:302
Event * event_
The object containing the actual event data (trees and branches).
Definition EventFile.h:308
bool isCorrupted() const
Check if the file we have is corrupted.
Implements an event buffer system for storing event data.
Definition Event.h:41
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:54
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45