GEMC  2.3
Geant4 Monte-Carlo Framework
outputFactory.h
Go to the documentation of this file.
1 #ifndef OUTPUT_FACTORY_H
10 #define OUTPUT_FACTORY_H 1
11 
12 // gemc headers
13 #include "gbank.h"
14 #include "options.h"
16 
17 // EVIO headers
18 #include "evioUtil.hxx"
19 #include "evioFileChannel.hxx"
20 using namespace evio;
21 
22 // geant4 headers
23 #include "G4ThreeVector.hh"
24 
25 
31 // This information is relevant to ONE hit only
32 class hitOutput
33 {
34  private:
35 
36  // geant4 integrated (over the hit) information.
37  // DISABLED by default
38  map<string, double> raws;
39 
40  // digitized information coming from raws
41  // ENABLED by default
42  // key is variable name
43  map<string, double> dgtz;
44 
45  // geant4 step by step information.
46  // DISABLED by default
47  map< string, vector <double> > allRaws;
48 
49  // treated Volt signal as a function of time
50  // DISABLED by default
51  map< double, double > signalVT;
52 
53  // quantized signal as a function of time bunch
54  // DISABLED by default
55  map< int, int > quantumS;
56 
57 
58  // multi - digitized information from step by step
59  // DISABLED by default
60  map< string, vector <int> > multiDgt;
61 
62  public:
63 
64  void setRaws (map<string, double> r) {raws = r;}
65  void setDgtz (map<string, double> d) {dgtz = d;}
66  void setAllRaws (map< string, vector <double> > r) {allRaws = r;}
67  void setSignal (map< double, double > s) {signalVT = s;}
68  void setQuantumS (map< int, int > s) {quantumS = s;}
69  void setMultiDgt (map< string, vector <int> > d) {multiDgt = d;}
70 
71  void setOneRaw (string s, double d) {raws[s] = d;}
72  void setOneRaw (string s, int i) {raws[s] = (double) i;}
73 
74  void setOneDgt (string s, double d) {dgtz[s] = d;}
75  void setOneDgt (string s, int i) {dgtz[s] = (double) i;}
76 
77 
78  // may want to insert verbosity here?
79  map<string, double> getRaws() {return raws;}
80  map<string, double> getDgtz() {return dgtz;}
81  map< string, vector <double> > getAllRaws() {return allRaws;}
82  map< double, double > getSignalVT() {return signalVT;}
83  map< int, int > getQuantumS() {return quantumS;}
84  map< string, vector <int> > getMultiDgt() {return multiDgt;}
85 
86  double getIntRawVar(string s)
87  {
88  if(raws.find(s) != raws.end()) return raws[s];
89  return -99;
90  }
91  double getIntDgtVar(string s)
92  {
93  if(dgtz.find(s) != dgtz.end()) return dgtz[s];
94  return -99;
95  }
96 };
97 
98 
99 
110 {
111  public:
113  {
114  dname = detector;
115  stat = 0;
116  etot = 0;
117  t = -1; // initializing to negative for the first assignment
118  nphe = 0;
119  }
121 
122  string dname;
123  int stat;
124  double etot;
125  double t;
126  int nphe;
127 
128 };
129 
130 
131 
138 {
139  public:
141  {
142  pSum.clear();
143  }
145 
146  G4ThreeVector vertex;
147  G4ThreeVector momentum;
148  int PID;
149 
150  // adding summary information for each detector.
151  vector<summaryForParticle> pSum;
152 
153  int getVariableFromStringI(string);
154  double getVariableFromStringD(string);
155 };
156 
157 
158 
163 {
164  public:
166  ~outputContainer();
167 
169  string outType;
170  string outFile;
171 
172  ofstream *txtoutput;
173  evioFileChannel *pchan;
174 };
175 
180 
182 {
183  public:
184 
185  // record the simulation conditions on the file
186  virtual void recordSimConditions(outputContainer*, map<string, string>) = 0;
187 
188  // write event header
189  virtual void writeHeader(outputContainer*, map<string, double>, gBank) = 0;
190 
191  // write generated particles
192  virtual void writeGenerated(outputContainer*, vector<generatedParticle>, map<string, gBank> *banksMap) = 0;
193 
194  // write geant4 true integrated info
195  virtual void writeG4RawIntegrated(outputContainer*, vector<hitOutput>, string, map<string, gBank>*) = 0;
196 
197  // write geant4 true info for every step
198  virtual void writeG4RawAll(outputContainer*, vector<hitOutput>, string, map<string, gBank>*) = 0;
199 
200  // write geant4 raw integrated info
201  virtual void writeG4DgtIntegrated(outputContainer*, vector<hitOutput>, string, map<string, gBank>*) = 0;
202 
203  // write event and close stream if necessary
204  virtual void writeEvent(outputContainer*) = 0;
205 
206  string outputType;
207 
208  virtual ~outputFactory(){;}
209 };
210 
211 // Define outputFactory as a pointer to a function that returns a pointer to a outputFactory
212 typedef outputFactory *(*outputFactoryInMap)();
213 
214 // Instantiates the outputFactory
215 outputFactory *getOutputFactory(map<string, outputFactoryInMap>*, string);
216 
217 map<string, outputFactoryInMap> registerOutputFactories();
218 
219 
220 #endif
double getIntDgtVar(string s)
Definition: outputFactory.h:91
void setSignal(map< double, double > s)
Definition: outputFactory.h:67
map< int, int > getQuantumS()
Definition: outputFactory.h:83
map< string, vector< double > > getAllRaws()
Definition: outputFactory.h:81
void setQuantumS(map< int, int > s)
Definition: outputFactory.h:68
map< string, double > getRaws()
Definition: outputFactory.h:79
void setOneDgt(string s, double d)
Definition: outputFactory.h:74
void setMultiDgt(map< string, vector< int > > d)
Definition: outputFactory.h:69
void setOneRaw(string s, double d)
Definition: outputFactory.h:71
map< string, double > getDgtz()
Definition: outputFactory.h:80
void setOneDgt(string s, int i)
Definition: outputFactory.h:75
virtual ~outputFactory()
vector< summaryForParticle > pSum
ofstream * txtoutput
void setRaws(map< string, double > r)
Definition: outputFactory.h:64
summaryForParticle(string detector)
void setOneRaw(string s, int i)
Definition: outputFactory.h:72
double getIntRawVar(string s)
Definition: outputFactory.h:86
outputFactory * getOutputFactory(map< string, outputFactoryInMap > *, string)
void setDgtz(map< string, double > d)
Definition: outputFactory.h:65
map< string, outputFactoryInMap > registerOutputFactories()
map< double, double > getSignalVT()
Definition: outputFactory.h:82
void setAllRaws(map< string, vector< double > > r)
Definition: outputFactory.h:66
Definition: gbank.h:86
G4ThreeVector vertex
map< string, vector< int > > getMultiDgt()
Definition: outputFactory.h:84
G4ThreeVector momentum
evioFileChannel * pchan