hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EventFile.cxx
Go to the documentation of this file.
1
8#include "EventFile.h"
9#include "TProcessID.h"
10
11EventFile::EventFile(const std::string ifilename, const std::string& ofilename) {
12
13 // Open the input LCIO file. If the input file can't be opened, throw an
14 // exception.
15 lc_reader_->open(ifilename);
16
17 // Open the output ROOT file
18 ofile_ = new TFile(ofilename.c_str(), "recreate");
19}
20
22
23// Close out the previous event before moving on.
25 if (entry_ > 0) {
26 event_->getTree()->Fill();
27 }
28 TProcessID::SetObjectCount(objNumRoot_);
29}
30
32
33 // Read the next event. If it doesn't exist, stop processing events.
34 if ((lc_event_ = lc_reader_->readNextEvent()) == 0) return false;
35
38 ++entry_;
39
40 objNumRoot_ = TProcessID::GetObjectCount();
41
42 return true;
43}
44
46 event_ = static_cast<Event*> (ievent);
47 entry_ = 0;
48}
49
53
55
56 // Close the LCIO file that was being processed
57 lc_reader_->close();
58
59 // Write the ROOT tree to disk
60 ofile_->cd();
61 event_->getTree()->Write();
62
63 // Close the ROOT file
64 ofile_->Close();
65}
Class for managing io files.
int entry_
description
Definition EventFile.h:93
virtual ~EventFile()
Definition EventFile.cxx:21
IO::LCReader * lc_reader_
Definition EventFile.h:91
void close()
Definition EventFile.cxx:54
TFile * ofile_
Definition EventFile.h:79
int objNumRoot_
Definition EventFile.h:96
EventFile(const std::string ifilename, const std::string &ofilename)
Constructor.
Definition EventFile.cxx:11
virtual bool nextEvent()
Load the next event in the file.
Definition EventFile.cxx:31
EVENT::LCEvent * lc_event_
Definition EventFile.h:88
Event * event_
Definition EventFile.h:85
void resetOutputFileDir()
Definition EventFile.cxx:50
virtual void FillEvent()
Persists the event.
Definition EventFile.cxx:24
void setupEvent(IEvent *ievent)
Setup the event object that will be used by this file.
Definition EventFile.cxx:45
Definition Event.h:35
void setEntry(const int entry)
Definition Event.h:118
void setLCEvent(EVENT::LCEvent *lc_event)
Definition Event.h:96
TTree * getTree()
Definition Event.h:93
Definition IEvent.h:7