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
Event.h
Go to the documentation of this file.
1
8#ifndef __EVENT_H__
9#define __EVENT_H__
10
11//----------------//
12// C++ StdLib //
13//----------------//
14#include <stdexcept>
15
16//----------//
17// LCIO //
18//----------//
19#include <EVENT/LCCollection.h>
20#include <EVENT/LCEvent.h>
21
22//----------//
23// ROOT //
24//----------//
25#include <TClonesArray.h>
26#include <TTree.h>
27
28//-----------//
29// hpstr //
30//-----------//
31#include "Collections.h"
32#include "IEvent.h"
33#include "EventHeader.h"
34
35class Event : public IEvent {
36
37 public:
38
40 Event();
41
43 ~Event();
44
48 virtual void add(const std::string name, TObject* object);
49
56 void addCollection(const std::string name, TClonesArray* collection);
57
61 template<typename T>
62 void addCollection(const std::string& name, std::vector<T*>* collection ){
63 branches_[name] = tree_->Branch(name.c_str(),&collection);};
64
70 TClonesArray* getCollection(const std::string name);
71
79 bool exists(const std::string name);
80
84 void Clear();
85
88
89 //TODO document
90 void setTree(TTree* tree) {tree_ = tree;};
91
93 TTree* getTree() { return tree_; }
94
96 void setLCEvent(EVENT::LCEvent* lc_event) { lc_event_ = lc_event; };
97
99 EVENT::LCEvent* getLCEvent() { return lc_event_; };
100
102 EVENT::LCCollection* getLCCollection(std::string name) {
103 return static_cast<EVENT::LCCollection*>(lc_event_->getCollection(name));
104 };
105
111 bool hasLCCollection(const std::string name);
112
118 void setEntry(const int entry) { entry_ = entry; };
119
120 private:
121
124
126 TTree* tree_{nullptr};
127
129 EVENT::LCEvent* lc_event_{nullptr};
130
132 std::map<std::string, TObject*> objects_;
133
135 std::map<std::string, TBranch*> branches_;
136
138 int entry_{0};
139
140}; // Event
141
142#endif // __EVENT_H__
143
144
Class used to encapsulate event information.
Definition Event.h:35
int entry_
Definition Event.h:138
EventHeader * event_header_
Definition Event.h:123
TClonesArray * getCollection(const std::string name)
Definition Event.cxx:57
bool exists(const std::string name)
Definition Event.cxx:73
std::map< std::string, TBranch * > branches_
Definition Event.h:135
TTree * tree_
Definition Event.h:126
void setEntry(const int entry)
Definition Event.h:118
Event()
Constructor.
Definition Event.cxx:15
EVENT::LCEvent * getLCEvent()
Definition Event.h:99
~Event()
Destructor.
Definition Event.cxx:24
EVENT::LCCollection * getLCCollection(std::string name)
Definition Event.h:102
std::map< std::string, TObject * > objects_
Definition Event.h:132
void Clear()
Definition Event.cxx:82
void setLCEvent(EVENT::LCEvent *lc_event)
Definition Event.h:96
virtual void add(const std::string name, TObject *object)
Definition Event.cxx:26
void addCollection(const std::string &name, std::vector< T * > *collection)
Definition Event.h:62
EVENT::LCEvent * lc_event_
Definition Event.h:129
bool hasLCCollection(const std::string name)
Definition Event.cxx:89
void setTree(TTree *tree)
Definition Event.h:90
void addCollection(const std::string name, TClonesArray *collection)
Definition Event.cxx:45
EventHeader & getEventHeaderMutable() const
Definition Event.h:87
TTree * getTree()
Definition Event.h:93
Definition IEvent.h:7