source: trunk/examples/novice/gemc/src/usage.cc

Last change on this file was 807, checked in by garnier, 16 years ago

update

File size: 14.8 KB
Line 
1// %%%%%%%%%%%%%
2// gemc headers
3// %%%%%%%%%%%%%
4#include "usage.h"
5
6// %%%%%%%%%%%
7// C++ headers
8// %%%%%%%%%%%
9#include <cstdio>
10#include <set>
11#include <cstdlib>
12
13gemc_opts::gemc_opts()
14{
15 // #########
16 // Generator
17 // #########
18
19 args["BEAM_P"].args  = "e-, 11*GeV, 0*deg, 0*deg";
20 args["BEAM_P"].help  = "Beam particle, momentum, angles (in respect of z-axis). \n";
21 args["BEAM_P"].help += "            Example: -BEAM_P=\"e-, 6*GeV, 15*deg, 20*deg\" sets 6 GeV electrons 15 degrees in theta, 20 degrees in phi. \n";
22 args["BEAM_P"].help += "            Use -BEAM_P=\"show_all\" to print the list of G4 supported particles.\n";
23 args["BEAM_P"].name  = "Beam particle, Energy, Theta, Phi";
24 args["BEAM_P"].type  = 1;
25 args["BEAM_P"].ctgr  = "generator";
26
27 args["SPREAD_P"].args  = "0*GeV, 0*deg, 0*deg";
28 args["SPREAD_P"].help  = "Spread beam energy and angles (in respect of z-axis). \n";
29 args["SPREAD_P"].help += "            Example: -SPREAD_P=\"0*GeV, 10*deg, 20*deg\" spreads 10 degrees in theta, 20 degrees in phi. \n";
30 args["SPREAD_P"].name  = "delta_Energy, delta_Theta, delta_phi";
31 args["SPREAD_P"].type  = 1;
32 args["SPREAD_P"].ctgr  = "generator";
33
34 args["BEAM_V"].args = "(0, 0, 0)cm";
35 args["BEAM_V"].help = "Beam Vertex. Example: -BEAM_V=\"(0, 0, -20)cm\". ";
36 args["BEAM_V"].name = "Beam Vertex";
37 args["BEAM_V"].type = 1;
38 args["BEAM_V"].ctgr = "generator";
39
40 args["SPREAD_V"].args = "(0, 0, 0)cm";
41 args["SPREAD_V"].help = "Spread Beam Vertex (cartesian coordinates). Example: -BEAM_V=\"(10, 10, 10)cm\". ";
42 args["SPREAD_V"].name = "Vertex Spread";
43 args["SPREAD_V"].type = 1;
44 args["SPREAD_V"].ctgr = "generator";
45
46 args["N"].arg  = 0;
47 args["N"].help = "Number of events to be simulated.";
48 args["N"].name = "Number of events to be simulated";
49 args["N"].type = 0;
50 args["N"].ctgr = "generator";
51
52 args["INPUT_GEN_FILE"].args = "gemc_internal";
53 args["INPUT_GEN_FILE"].help = "Generator Input. Current availables file formats:\n";
54 args["INPUT_GEN_FILE"].help += "           LUND. \n";
55 args["INPUT_GEN_FILE"].help += "           Example: -INPUT_GEN_FILE=\"LUND, input.dat\"\n";
56 args["INPUT_GEN_FILE"].name = "Generator Input File";
57 args["INPUT_GEN_FILE"].type = 1;
58 args["INPUT_GEN_FILE"].ctgr = "generator";
59
60 args["NGENP"].arg  = 1;
61 args["NGENP"].help = "Number of Generated Particles to save in the Output.";
62 args["NGENP"].name = "Number of Generated Particles to save in the Output";
63 args["NGENP"].type = 0;
64 args["NGENP"].ctgr = "generator";
65
66
67
68
69
70
71 // ###############
72 // Luminosity Beam
73 // ###############
74
75 args["LUMI_P"].args  = "e-, 11*GeV, 0*deg, 0*deg";
76 args["LUMI_P"].help  = "Luminosity Beam particle, momentum, angles (in respect of z-axis). \n";
77 args["LUMI_P"].help += "            Example: -LUMI_P=\"proton, 1*GeV, 25*deg, 2*deg\" sets 1 GeV protons, 25 degrees in theta, 2 degrees in phi. \n";
78 args["LUMI_P"].help += "            Use -LUMI_P=\"show_all\" to print the list of G4 supported particles.\n";
79 args["LUMI_P"].name  = "Luminosity Beam particle, Energy, Theta, Phi";
80 args["LUMI_P"].type  = 1;
81 args["LUMI_P"].ctgr = "luminosity";
82
83 args["LUMI_V"].args = "(0, 0, 0)cm";
84 args["LUMI_V"].help = "Luminosity Beam Vertex. Example: -LUMI_V=\"(0, 0, -20)cm\". ";
85 args["LUMI_V"].name = "Luminosity Beam Vertex";
86 args["LUMI_V"].type = 1;
87 args["LUMI_V"].ctgr = "luminosity";
88
89 args["LUMI_EVENT"].args = "0, 0*ns, 2*ns";
90 args["LUMI_EVENT"].help = "Luminosity Beam Parameters: number of Particles/Event, Time Window, Time Between Bunches\n";
91 args["LUMI_EVENT"].help += "            Example: -LUMI_EVENT=\"10000, 120*ns, 2*ns\" simulate 10K particles per event distributed over 120 ns, at 2ns intervals. \n";
92 args["LUMI_EVENT"].name = "Luminosity Beam Parameters";
93 args["LUMI_EVENT"].type = 1;
94 args["LUMI_EVENT"].ctgr = "luminosity";
95
96
97
98
99
100
101 // ##############
102 // MySQL Database
103 // ##############
104
105 args["DATABASE"].args = "clas12_geometry";
106 args["DATABASE"].help = "Select mysql Database.";
107 args["DATABASE"].name = "Select mysql Database";
108 args["DATABASE"].type = 1;
109 args["DATABASE"].ctgr = "mysql";
110
111 args["BANK_DATABASE"].args = "clas12_banks";
112 args["BANK_DATABASE"].help = "Select mysql Bank Database.";
113 args["BANK_DATABASE"].name = "Select mysql Bank Database";
114 args["BANK_DATABASE"].type = 1;
115 args["BANK_DATABASE"].ctgr = "mysql";
116
117 args["GT"].args = "BST";
118 args["GT"].help = "Selects Geometry table. This option is overwritten with the gemc read card.";
119 args["GT"].name = "Geometry table";
120 args["GT"].type = 1;
121 args["GT"].ctgr = "mysql";
122
123
124
125
126
127
128
129
130 // #########
131 // Verbosity
132 // #########
133
134 args["G4P_VERBOSITY"].arg  = 1;
135 args["G4P_VERBOSITY"].help = "Controls Physical Volumes Construction Log Output.";
136 args["G4P_VERBOSITY"].name = "Logical Volume Verbosity";
137 args["G4P_VERBOSITY"].type = 0;
138 args["G4P_VERBOSITY"].ctgr = "verbosity";
139
140 args["GEO_VERBOSITY"].arg  = 1;
141 args["GEO_VERBOSITY"].help = "Controls Geometry Construction Log Output.";
142 args["GEO_VERBOSITY"].name = "Geometry Verbosity";
143 args["GEO_VERBOSITY"].type = 0;
144 args["GEO_VERBOSITY"].ctgr = "verbosity";
145
146 args["GUI_VERBOSITY"].arg  = 1;
147 args["GUI_VERBOSITY"].help = "Controls GUI Construction Log Output.";
148 args["GUI_VERBOSITY"].name = "GUI Verbosity";
149 args["GUI_VERBOSITY"].type = 0;
150 args["GUI_VERBOSITY"].ctgr = "verbosity";
151
152 args["HIT_VERBOSITY"].arg  = 1;
153 args["HIT_VERBOSITY"].help = "Controls Hits Log Output. ";
154 args["HIT_VERBOSITY"].name = "Hit Verbosity";
155 args["HIT_VERBOSITY"].type = 0;
156 args["HIT_VERBOSITY"].ctgr = "verbosity";
157
158 args["LOG_MSG"].args = "  >>> gemc";
159 args["LOG_MSG"].help = "Log Messages Header.";
160 args["LOG_MSG"].name = "Log Messages Header";
161 args["LOG_MSG"].type = 1;
162 args["LOG_MSG"].ctgr = "verbosity";
163
164 args["CATCH"].args = "Maurizio";
165 args["CATCH"].help = "Catch volumes matching the given string.";
166 args["CATCH"].name = "Volume catcher";
167 args["CATCH"].type = 1;
168 args["CATCH"].ctgr = "verbosity";
169
170 args["MGN_VERBOSITY"].arg  = 1;
171 args["MGN_VERBOSITY"].help = "Controls Magnetic Fields Log Output.";
172 args["MGN_VERBOSITY"].name = "Magnetic Fields Verbosity";
173 args["MGN_VERBOSITY"].type = 0;
174 args["MGN_VERBOSITY"].ctgr = "verbosity";
175
176 args["PRINT_EVENT"].arg  = 1000;
177 args["PRINT_EVENT"].help = "-PRINT_EVENT=N: Print Event Number every N events.";
178 args["PRINT_EVENT"].name = "Print Event Modulus";
179 args["PRINT_EVENT"].type = 0;
180 args["PRINT_EVENT"].ctgr = "verbosity";
181
182 args["OUT_VERBOSITY"].arg  = 1;
183 args["OUT_VERBOSITY"].help = "Controls Bank Log Output.";
184 args["OUT_VERBOSITY"].name = "Bank Output Verbosity";
185 args["OUT_VERBOSITY"].type = 0;
186 args["OUT_VERBOSITY"].ctgr = "verbosity";
187
188 args["PHY_VERBOSITY"].arg  = 1;
189 args["PHY_VERBOSITY"].help = "Controls Physics List Log Output.";
190 args["PHY_VERBOSITY"].name = "Physics List Verbosity";
191 args["PHY_VERBOSITY"].type = 0;
192 args["PHY_VERBOSITY"].ctgr = "verbosity";
193
194 args["GEN_VERBOSITY"].arg  = 0;
195 args["GEN_VERBOSITY"].help = "Controls Geant4 Generator Verbosity.";
196 args["GEN_VERBOSITY"].name = "Geant4 Generator Verbosity";
197 args["GEN_VERBOSITY"].type = 0;
198 args["GEN_VERBOSITY"].ctgr = "verbosity";
199
200 args["G4TRACK_VERBOSITY"].arg  = 0;
201 args["G4TRACK_VERBOSITY"].help = "Controls Geant4 Track Verbosity.";
202 args["G4TRACK_VERBOSITY"].name = "Geant4 Track Verbosity";
203 args["G4TRACK_VERBOSITY"].type = 0;
204 args["G4TRACK_VERBOSITY"].ctgr = "verbosity";
205
206
207
208
209
210
211
212
213
214
215
216
217 // ###########
218 // Run Control
219 // ###########
220
221 args["EXEC_MACRO"].args = "no";
222 args["EXEC_MACRO"].help = "Executes commands in macro file.";
223 args["EXEC_MACRO"].name = "Executes commands in macro file";
224 args["EXEC_MACRO"].type = 1;
225 args["EXEC_MACRO"].ctgr = "control";
226
227 args["CHECK_OVERLAPS"].arg  = 0;
228 args["CHECK_OVERLAPS"].help = "Checks Overlapping Volumes at Construction time.";
229 args["CHECK_OVERLAPS"].name = "Checks Overlapping Volumes at Construction time";
230 args["CHECK_OVERLAPS"].type = 0;
231 args["CHECK_OVERLAPS"].ctgr = "control";
232
233 args["USE_QT"].arg  = 1;
234 args["USE_QT"].help = "Use/Don't Use the QT GUI. If set to 2, use OGLIX.";
235 args["USE_QT"].name = "QT Gui";
236 args["USE_QT"].type = 0;
237 args["USE_QT"].ctgr = "control";
238
239 args["RANDOM"].args = "TIME";
240 args["RANDOM"].help = "Random Engine Initialization. The argument (seed) can be an integer or the string TIME.";
241 args["RANDOM"].name = "Random Engine Initialization";
242 args["RANDOM"].type = 1;
243 args["RANDOM"].ctgr = "control";
244
245 args["gcard"].args = "no";
246 args["gcard"].help = "gemc card file.";
247 args["gcard"].name = "gemc card file";
248 args["gcard"].type = 1;
249 args["gcard"].ctgr = "control";
250
251 args["EVN"].arg  = 1;
252 args["EVN"].help = "Initial Event Number.";
253 args["EVN"].name = "Initial Event Number";
254 args["EVN"].type = 0;
255 args["EVN"].ctgr = "control";
256
257
258
259
260
261
262
263
264
265
266
267
268 // ######
269 // Output
270 // ######
271
272 args["OUTPUT"].args = "no, output";
273 args["OUTPUT"].help = "Type of output, output filename.";
274 args["OUTPUT"].name = "Type of output, output filename. Supported output: evio, txt. Example: -OUTPUT=\"evio, out.ev\"";
275 args["OUTPUT"].type = 1;
276 args["OUTPUT"].ctgr = "output";
277
278
279
280
281
282
283
284
285
286
287
288 // #######
289 // Physics
290 // #######
291
292 args["OPT_PH"].arg  = 0;
293 args["OPT_PH"].help = "Activate Optical Physics Processes in gemc Physics List.";
294 args["OPT_PH"].name = "Optical Physics";
295 args["OPT_PH"].type = 0;
296 args["OPT_PH"].ctgr = "physics";
297
298 args["USE_PHYSICSL"].args = "gemc";
299 args["USE_PHYSICSL"].help =  "Physics List. Avaliable choices: \n\n";
300 args["USE_PHYSICSL"].help += "            * gemc: comprehensive physics list. Optical Physics may be activated with OPT_PH=1 \n\n";
301 args["USE_PHYSICSL"].help += "            The following is a list of other physics lists. More infos can be found here:\n\n";
302 args["USE_PHYSICSL"].help += "            http://geant4.cern.ch/support/proc_mod_catalog/physics_lists/referencePL.shtml\n\n";
303 args["USE_PHYSICSL"].help += "            * LHEP: This is the main LHEP based physics list, using exclusively parameterised modeling. \n";
304 args["USE_PHYSICSL"].help += "            * LHEP_BERT: Like LHEP, but using Geant4 Bertini cascade for primary protons, neutrons, \n";
305 args["USE_PHYSICSL"].help += "               pions and Kaons below ~10GeV.  \n";
306 args["USE_PHYSICSL"].help += "            * LHEP_BERT_HP: Like LHEP_BERT with the addition to use the data driven high precision.\n";
307 args["USE_PHYSICSL"].help += "               neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
308 args["USE_PHYSICSL"].help += "            * QGSP:  String model based physics list. \n";
309 args["USE_PHYSICSL"].help += "            * QGSP_BERT: Like QGSP, but using Geant4 Bertini cascade for primary protons, neutrons, \n";
310 args["USE_PHYSICSL"].help += "               pions and Kaons below ~10GeV.  \n";
311 args["USE_PHYSICSL"].help += "            * QGSP_BERT_HP: Like QGSP_BERT with the addition to use the data driven high precision.\n";
312 args["USE_PHYSICSL"].help += "               neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
313 args["USE_PHYSICSL"].help += "            * QGSP_BIC: Like QGSP, but using Geant4 Binary cascade for primary protons and neutrons \n";
314 args["USE_PHYSICSL"].help += "               with energies below ~10GeV.  \n";
315 args["USE_PHYSICSL"].help += "            * QGSP_BIC_HP: Like QGSP_BIC with the addition to use the data driven high precision.\n";
316 args["USE_PHYSICSL"].help += "               neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
317 args["USE_PHYSICSL"].name = "Choice of Physics List";
318 args["USE_PHYSICSL"].type = 1;
319 args["USE_PHYSICSL"].ctgr = "physics";
320
321 args["HALL_MATERIAL"].args = "Vacuum";
322 args["HALL_MATERIAL"].help = "Composition of the Experimental Hall. \n";
323 args["HALL_MATERIAL"].help += "            Air normal simulation\n";
324 args["HALL_MATERIAL"].help += "            Air_Opt Simulation with Optical Physics (default)\n";
325 args["HALL_MATERIAL"].help += "            Vacuum\n";
326 args["HALL_MATERIAL"].name = "Composition of the Experimental Hall";
327 args["HALL_MATERIAL"].type = 1;
328 args["HALL_MATERIAL"].ctgr = "physics";
329
330 args["HALL_FIELD"].args = "no";
331 args["HALL_FIELD"].help = "Magnetic Field of the Hall. \n";
332 args["HALL_FIELD"].name = "Magnetic Field of the Hall";
333 args["HALL_FIELD"].type = 1;
334 args["HALL_FIELD"].ctgr = "physics";
335
336
337
338
339
340
341
342
343
344 // #######
345 // General
346 // #######
347
348 args["SERVICE"].arg  = 0;
349 args["SERVICE"].help = "Runs gemc as a service.";
350 args["SERVICE"].name = "Runs gemc as a service";
351 args["SERVICE"].type = 0;
352 args["SERVICE"].ctgr = "general";
353
354
355}
356
357gemc_opts::~gemc_opts(){}
358
359int gemc_opts::Set(int argc, char **argv)
360{
361 string arg;
362 string com;
363 string opt;
364 cout << endl;
365 string comp;
366
367 map<string, opts>::iterator itm;
368
369 set<string> category;
370
371 // Filling Categories
372 for(itm = args.begin(); itm != args.end(); itm++)
373    if(category.find(itm->second.ctgr) == category.end()) category.insert(itm->second.ctgr);
374
375
376
377 // -help-all
378 for(int i=1; i<argc; i++)
379 {
380    arg = argv[i];
381    com = "-help-all";
382    if(arg == com)
383    {
384       cout <<  "    Usage: -Option=<option>" << endl << endl;
385       cout <<  "    Options:" <<  endl << endl ;
386
387       for(itm = args.begin(); itm != args.end(); itm++)
388          cout <<  "   > Option " <<  itm->first << ": " << itm->second.help << endl;
389
390       cout << endl << endl;
391       exit(0);
392    }
393 }
394
395
396 // -help
397 set<string> :: iterator itcat;
398 for(int i=1; i<argc; i++)
399 {
400    arg = argv[i];
401    com = "-help";
402    if(arg == com)
403    {
404       cout <<  endl << endl;
405       cout <<  "    Help Options:" <<  endl << endl ;
406       cout <<  "   >  -help-all:  all available options. " <<  endl << endl;
407       for(itcat = category.begin(); itcat != category.end(); itcat++)
408       {
409
410          cout <<  "   >  -help-" << *itcat << "     ";
411          cout.width(15);
412          cout << *itcat << " options." << endl;
413       }
414       cout << endl << endl;
415       exit(0);
416    }
417 }
418
419
420 // -help-option
421 for(int i=1; i<argc; i++)
422 {
423    arg = argv[i];
424    for(itcat = category.begin(); itcat != category.end(); itcat++)
425    {
426       com = "-help-" + *itcat;
427       if(arg == com)
428       {
429          cout << endl << endl <<  "   ## " << *itcat << " ## " << endl << endl;
430          cout << "    Usage: -Option=<option>" << endl << endl;
431          for(itm = args.begin(); itm != args.end(); itm++)
432             if(itm->second.ctgr == *itcat) cout <<  "   > " <<  itm->first << ": " << itm->second.help << endl;
433          cout << endl << endl;
434          exit(0);
435       }
436    }
437 }
438
439
440 for(int i=1; i<argc; i++)
441 {
442    arg = argv[i];
443    map<string, opts>::iterator itm; 
444    for(itm = args.begin(); itm != args.end(); itm++)
445    {
446       com = "-" + itm->first + "=";
447       comp.assign(arg, 0, arg.find("=") + 1);
448       if(comp == com)
449       {
450          opt.assign(arg, com.size(), arg.size()-com.size());
451          itm->second.args = opt;
452          itm->second.arg  = atof(opt.c_str());
453          cout <<  " >>> Options: " << itm->second.name << " set to: " ;
454          if(itm->second.type) cout << itm->second.args;
455          else cout << itm->second.arg  ;
456          cout << endl;
457       }
458    }
459 }
460
461 cout << endl;
462
463 return 1;
464}
465
466
467
468
469
Note: See TracBrowser for help on using the repository browser.