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
erhic/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_
VirtualEvent.h
erhic::EventFromAsciiFactory::mLine
std::string mLine
Definition: erhic/EventFactory.h:117
erhic
Definition: EventDis.cxx:14
erhic::EventFromAsciiFactory
Creates events from an input plain text file containing appropriately formatted data.
Definition: erhic/EventFactory.h:86
EventPythia.h
erhic::VirtualEventFactory::EventName
virtual std::string EventName() const =0
Returns a string with the full (including namespace) class name of the event type produced.
erhic::VirtualEvent
Abstract base class for a physics event.
Definition: VirtualEvent.h:25
erhic::EventFromAsciiFactory::EventName
virtual std::string EventName() const
Returns the name of the event class created by this factory.
Definition: EventFactory.cxx:178
functions.h
erhic::EventFromAsciiFactory::AtEndOfEvent
bool AtEndOfEvent() const
Returns true when an end-of-event marker is encountered in the input stream.
Definition: EventFactory.cxx:35
erhic::EventFromAsciiFactory::EventFromAsciiFactory
EventFromAsciiFactory()
Constructor.
Definition: erhic/EventFactory.h:91
erhic::VirtualEventFactory
Abstract base class for event builders.
Definition: erhic/EventFactory.h:35
erhic::EventFromAsciiFactory::AddParticle
bool AddParticle()
Create a new particle from the last data read from the input stream.
Definition: EventFactory.cxx:157
EventSmear.h
erhic::EventFromAsciiFactory::~EventFromAsciiFactory
virtual ~EventFromAsciiFactory()
Destructor.
Definition: erhic/EventFactory.h:96
erhic::VirtualEventFactory::Create
virtual VirtualEvent * Create()=0
Returns a new event instance.
erhic::VirtualEventFactory::Branch
virtual TBranch * Branch(TTree &, const std::string &)
Add a branch named "name" for the event type generated by this factory to a ROOT TTree.
Definition: erhic/EventFactory.h:65
erhic::EventFromAsciiFactory::FinishEvent
Int_t FinishEvent()
Perform end-of-event operations.
Definition: EventFactory.cxx:116
erhic::EventFromAsciiFactory::Create
virtual T * Create()
Returns a new event instance.
Definition: EventFactory.cxx:57
erhic::VirtualEventFactory::GetEvBufferPtr
virtual VirtualEvent * GetEvBufferPtr()
Returns a pointer to the event buffer.
Definition: erhic/EventFactory.h:50
erhic::EventFromAsciiFactory::EventFromAsciiFactory
EventFromAsciiFactory(std::istream &is)
Initialise the factory from an input stream.
Definition: erhic/EventFactory.h:101
erhic::VirtualEventFactory::Fill
virtual void Fill(TBranch &)
Calls Create() to generate an event and fills the provided branch with that event.
Definition: erhic/EventFactory.h:73
erhic::EventFromAsciiFactory::mEvent
std::auto_ptr< T > mEvent
Definition: erhic/EventFactory.h:118
erhic::EventFromAsciiFactory::mInput
std::istream * mInput
Definition: erhic/EventFactory.h:116
erhic::VirtualEventFactory::~VirtualEventFactory
virtual ~VirtualEventFactory()
Destructor.
Definition: erhic/EventFactory.h:40