EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventFactory.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventFactory.h
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 #include <vector>
17 #include <map>
18 
19 #include <TBranch.h>
20 #include <TTree.h>
21 
22 #include "eicsmear/functions.h"
27 
28 
29 namespace erhic {
30 
31 class ParticleMC;
32 
39 class VirtualEventFactory : public TObject {
40  public:
44  virtual ~VirtualEventFactory() { }
45 
49  virtual VirtualEvent* Create() = 0;
50 
54  virtual VirtualEvent* GetEvBufferPtr() { return 0; }
55 
62  virtual std::string EventName() const = 0;
63 
67  virtual void FindFirstEvent() {}
68 
74  virtual TBranch* Branch(TTree&, const std::string&) {
75  return NULL;
76  }
82  virtual void Fill(TBranch&) { }
83 
91  typedef std::pair <TString, TObject*> NamedObjects;
92  std::vector<NamedObjects> mObjectsToWriteAtTheEnd;
93 
97  std::map<std::string, std::string> mAdditionalInformation;
98 
99  ClassDef(VirtualEventFactory, 3)
100 };
101 
109 template<typename T>
111  public:
116 
121 
125  explicit EventFromAsciiFactory(std::istream& is)
126  : mInput(&is)
127  , mEvent(nullptr) {
128  }
129 
133  virtual T* Create();
134 
138  virtual std::string EventName() const;
139 
140  virtual void FindFirstEvent();
141 
142  protected:
143  std::istream* mInput;
144  std::string mLine;
145  std::unique_ptr<T> mEvent;
146 
150  bool AtEndOfEvent() const;
151 
155  Int_t FinishEvent();
156 
160  bool AddParticle();
161 
162  // Warning: explicitly putting the erhic:: namespace before the class
163  // name doesn't seen to work for template classes.
164  ClassDef(EventFromAsciiFactory, 2)
165 };
166 
176 } // namespace erhic
177 
178 #endif // INCLUDE_EICSMEAR_ERHIC_EVENTFACTORY_H_