eic-smear  1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
EventFactory.h
Go to the documentation of this file.
1 
10 #ifndef INCLUDE_EICSMEAR_ERHIC_EVENTFACTORY_H_
11 #define INCLUDE_EICSMEAR_ERHIC_EVENTFACTORY_H_
12 
13 #include <iostream>
14 #include <memory>
15 #include <string>
16 
17 #include <TBranch.h>
18 #include <TTree.h>
19 
20 #include "eicsmear/functions.h"
24 
25 namespace erhic {
26 
27 class ParticleMC;
28 
35 class VirtualEventFactory : public TObject {
36  public:
40  virtual ~VirtualEventFactory() { }
41 
45  virtual VirtualEvent* Create() = 0;
46 
50  virtual VirtualEvent* GetEvBufferPtr() { return 0; }
51 
58  virtual std::string EventName() const = 0;
59 
65  virtual TBranch* Branch(TTree&, const std::string&) {
66  return NULL;
67  }
73  virtual void Fill(TBranch&) { }
74 
75  ClassDef(VirtualEventFactory, 1)
76 };
77 
85 template<typename T>
87  public:
92 
96  virtual ~EventFromAsciiFactory() { }
97 
101  explicit EventFromAsciiFactory(std::istream& is)
102  : mInput(&is)
103  , mEvent(NULL) {
104  }
105 
109  virtual T* Create();
110 
114  virtual std::string EventName() const;
115 
116  std::istream* mInput;
117  std::string mLine;
118  std::auto_ptr<T> mEvent;
119 
120  protected:
124  bool AtEndOfEvent() const;
125 
129  Int_t FinishEvent();
130 
134  bool AddParticle();
135 
136  // Warning: explicitly putting the erhic:: namespace before the class
137  // name doesn't seen to work for template classes.
138  ClassDef(EventFromAsciiFactory, 1)
139 };
140 
141 } // namespace erhic
142 
143 #endif // INCLUDE_EICSMEAR_ERHIC_EVENTFACTORY_H_
virtual VirtualEvent * Create()=0
virtual TBranch * Branch(TTree &, const std::string &)
Definition: EventFactory.h:65
virtual void Fill(TBranch &)
Definition: EventFactory.h:73
EventFromAsciiFactory(std::istream &is)
Definition: EventFactory.h:101
virtual VirtualEvent * GetEvBufferPtr()
Definition: EventFactory.h:50
Abstract base class for a physics event.
Definition: VirtualEvent.h:25
virtual std::string EventName() const
virtual std::string EventName() const =0