GEMC  1.8
Geant4 Monte-Carlo Framework
usage.cc
Go to the documentation of this file.
1 // %%%%%%%%%%%%%
2 // gemc headers
3 // %%%%%%%%%%%%%
4 #include "usage.h"
5 #include "string_utilities.h"
6 
7 // %%%%%%%%%%%
8 // C++ headers
9 // %%%%%%%%%%%
10 #include <cstdio>
11 #include <set>
12 #include <cstdlib>
13 
15 {
16  // Initialize all the options in the map<string, "args"
17  //
18  // The "string" of the pair in the map is the argument name: -"name"=
19  // args = the string type argument
20  // arg = the numeric type argument
21  // help = Long explanation.
22  // name = Short description.
23  // type = 1 for argumenst that are strings, 0 for numbers.
24 
25  // #########
26  // Generator
27  // #########
28 
29  args["BEAM_P"].args = "e-, 11*GeV, 0*deg, 0*deg";
30  args["BEAM_P"].help = "Beam particle, momentum, angles (in respect of z-axis). \n";
31  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";
32  args["BEAM_P"].help += " Use -BEAM_P=\"show_all\" to print the list of G4 supported particles.\n";
33  args["BEAM_P"].name = "Beam particle, Energy, Theta, Phi";
34  args["BEAM_P"].type = 1;
35  args["BEAM_P"].ctgr = "generator";
36 
37  args["SPREAD_P"].args = "0*GeV, 0*deg, 0*deg";
38  args["SPREAD_P"].help = "Spread beam energy and angles (in respect of z-axis). \n";
39  args["SPREAD_P"].help += " Example: -SPREAD_P=\"0*GeV, 10*deg, 20*deg\" spreads 10 degrees in theta, 20 degrees in phi. \n";
40  args["SPREAD_P"].name = "delta_Energy, delta_Theta, delta_phi";
41  args["SPREAD_P"].type = 1;
42  args["SPREAD_P"].ctgr = "generator";
43 
44  args["ALIGN_ZAXIS"].args = "no";
45  args["ALIGN_ZAXIS"].help = "Align z axis to a custom direction. Options:\n";
46  args["ALIGN_ZAXIS"].help += " - \"beamp\" aligns z axis to the beam directions specified by BEAM_P.\n";
47  args["ALIGN_ZAXIS"].help += " - \"custom, theta*unit, phi*unit\" aligns z axis to a custom direction, changes BEAM_P reference frame.";
48  args["ALIGN_ZAXIS"].name = "Align z axis to a custom direction.";
49  args["ALIGN_ZAXIS"].type = 1;
50  args["ALIGN_ZAXIS"].ctgr = "generator";
51 
52  args["BEAM_V"].args = "(0, 0, 0) cm";
53  args["BEAM_V"].help = "Beam Vertex. Example: -BEAM_V=\"(0, 0, -20)cm\". ";
54  args["BEAM_V"].name = "Beam Vertex";
55  args["BEAM_V"].type = 1;
56  args["BEAM_V"].ctgr = "generator";
57 
58  args["SPREAD_V"].args = "(0, 0) cm";
59  args["SPREAD_V"].help = "Spread Beam Radius, Z position. Example: -SPREAD_V=\"(0.1, 10)cm\". ";
60  args["SPREAD_V"].name = "Vertex Spread";
61  args["SPREAD_V"].type = 1;
62  args["SPREAD_V"].ctgr = "generator";
63 
64  args["POLAR"].args = "0, 0*deg, 0*deg";
65  args["POLAR"].help = "Beam particle, polarization percentage and angles (in respect of z-axis). \n";
66  args["POLAR"].help += " Example: -POLAR=\"90, 90*deg, 270*deg\" sets 90% polarization 90 degrees in theta, 270 degrees in phi. \n";
67  args["POLAR"].help += " Use -POLAR=\"show_all\" to print the list of G4 supported particles.\n";
68  args["POLAR"].name = "Beam polarization in %, Theta, Phi";
69  args["POLAR"].type = 1;
70  args["POLAR"].ctgr = "generator";
71 
72  args["N"].arg = 0;
73  args["N"].help = "Number of events to be simulated.";
74  args["N"].name = "Number of events to be simulated";
75  args["N"].type = 0;
76  args["N"].ctgr = "generator";
77 
78  args["INPUT_GEN_FILE"].args = "gemc_internal";
79  args["INPUT_GEN_FILE"].help = "Generator Input. Current availables file formats:\n";
80  args["INPUT_GEN_FILE"].help += " LUND. \n";
81  args["INPUT_GEN_FILE"].help += " xample: -INPUT_GEN_FILE=\"LUND, input.dat\"\n";
82  args["INPUT_GEN_FILE"].name = "Generator Input File";
83  args["INPUT_GEN_FILE"].type = 1;
84  args["INPUT_GEN_FILE"].ctgr = "generator";
85 
86  args["NGENP"].arg = 10;
87  args["NGENP"].help = "Max Number of Generated Particles to save in the Output.";
88  args["NGENP"].name = "Max Number of Generated Particles to save in the Output";
89  args["NGENP"].type = 0;
90  args["NGENP"].ctgr = "generator";
91 
92 
93 
94 
95 
96 
97  // ###############
98  // Luminosity Beam
99  // ###############
100 
101  args["LUMI_P"].args = "e-, 11*GeV, 0*deg, 0*deg";
102  args["LUMI_P"].help = "Luminosity Beam particle, momentum, angles (in respect of z-axis). \n";
103  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";
104  args["LUMI_P"].help += " Use -LUMI_P=\"show_all\" to print the list of G4 supported particles.\n";
105  args["LUMI_P"].name = "Luminosity Beam particle, Energy, Theta, Phi";
106  args["LUMI_P"].type = 1;
107  args["LUMI_P"].ctgr = "luminosity";
108 
109  args["LUMI_V"].args = "(0, 0, -20) cm";
110  args["LUMI_V"].help = "Luminosity Beam Vertex. Example: -LUMI_V=\"(0, 0, -20)cm\". ";
111  args["LUMI_V"].name = "Luminosity Beam Vertex";
112  args["LUMI_V"].type = 1;
113  args["LUMI_V"].ctgr = "luminosity";
114 
115  args["LUMI_SPREAD_V"].args = "(0, 0) cm";
116  args["LUMI_SPREAD_V"].help = "Spread Luminosity Beam Radius, Z position. Example: -SPREAD_V=\"(0.1, 10)cm\". ";
117  args["LUMI_SPREAD_V"].name = "Luminosity Beam Vertex Spread";
118  args["LUMI_SPREAD_V"].type = 1;
119  args["LUMI_SPREAD_V"].ctgr = "luminosity";
120 
121  args["LUMI_EVENT"].args = "0, 0*ns, 2*ns";
122  args["LUMI_EVENT"].help = "Luminosity Beam Parameters: number of Particles/Event, Time Window, Time Between Bunches\n";
123  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";
124  args["LUMI_EVENT"].name = "Luminosity Beam Parameters";
125  args["LUMI_EVENT"].type = 1;
126  args["LUMI_EVENT"].ctgr = "luminosity";
127 
128  args["LUMI2_P"].args = "proton, 50*GeV, 175*deg, 180*deg";
129  args["LUMI2_P"].help = "Luminosity Beam Particle 2, momentum, angles (in respect of z-axis). \n";
130  args["LUMI2_P"].help += " Example: -LUMI2_P=\"proton, 1*GeV, 25*deg, 2*deg\" sets 1 GeV protons, 25 degrees in theta, 2 degrees in phi. \n";
131  args["LUMI2_P"].help += " Use -LUMI2_P=\"show_all\" to print the list of G4 supported particles.\n";
132  args["LUMI2_P"].name = "Luminosity Beam particle 2, Energy, Theta, Phi";
133  args["LUMI2_P"].type = 1;
134  args["LUMI2_P"].ctgr = "luminosity";
135 
136  args["LUMI2_V"].args = "(4, 0, 50) cm";
137  args["LUMI2_V"].help = "Luminosity Beam Particle 2 Vertex. Example: -LUMI2_V=\"(0, 0, -20)cm\". ";
138  args["LUMI2_V"].name = "Luminosity Beam Particle 2 Vertex";
139  args["LUMI2_V"].type = 1;
140  args["LUMI2_V"].ctgr = "luminosity";
141 
142  args["LUMI2_SPREAD_V"].args = "(0, 0) cm";
143  args["LUMI2_SPREAD_V"].help = "Spread Luminosity Beam 2 Radius, Z position. Example: -SPREAD_V=\"(0.1, 10)cm\". ";
144  args["LUMI2_SPREAD_V"].name = "Luminosity Beam Vertex 2 Spread";
145  args["LUMI2_SPREAD_V"].type = 1;
146  args["LUMI2_SPREAD_V"].ctgr = "luminosity";
147 
148  args["LUMI2_EVENT"].args = "0, 2*ns";
149  args["LUMI2_EVENT"].help = "Luminosity Beam 2 Parameters: number of Particles/Event, Time Between Bunches. The Time Window is specified with the LUMI_EVENT flag\n";
150  args["LUMI2_EVENT"].help += " Example: -LUMI2_EVENT=\"10000, 2*ns\" simulate 10K particles per event at 2ns intervals. \n";
151  args["LUMI2_EVENT"].name = "Luminosity Beam 2 Parameters";
152  args["LUMI2_EVENT"].type = 1;
153  args["LUMI2_EVENT"].ctgr = "luminosity";
154 
155 
156 
157 
158 
159 
160  // ##############
161  // MySQL Database
162  // ##############
163 
164  args["DBHOST"].args = "clasdb.jlab.org";
165  args["DBHOST"].help = "Select mysql server host name.";
166  args["DBHOST"].name = "Select mysql server host name";
167  args["DBHOST"].type = 1;
168  args["DBHOST"].ctgr = "mysql";
169 
170  args["DATABASE"].args = "clas12_geometry";
171  args["DATABASE"].help = "Select mysql Database.";
172  args["DATABASE"].name = "Select mysql Database";
173  args["DATABASE"].type = 1;
174  args["DATABASE"].ctgr = "mysql";
175 
176  args["BANK_DATABASE"].args = "clas12_banks";
177  args["BANK_DATABASE"].help = "Select mysql Bank Database.";
178  args["BANK_DATABASE"].name = "Select mysql Bank Database";
179  args["BANK_DATABASE"].type = 1;
180  args["BANK_DATABASE"].ctgr = "mysql";
181 
182  args["DBUSER"].args = "clasuser";
183  args["DBUSER"].help = "Select mysql user name";
184  args["DBUSER"].name = "Select mysql user name";
185  args["DBUSER"].type = 1;
186  args["DBUSER"].ctgr = "mysql";
187 
188  args["DBPSWD"].args = "";
189  args["DBPSWD"].help = "Select mysql password";
190  args["DBPSWD"].name = "Select mysql password";
191  args["DBPSWD"].type = 1;
192  args["DBPSWD"].ctgr = "mysql";
193 
194  args["GT"].args = "no";
195  args["GT"].help = "Selects Geometry table. This option is overwritten with the gemc read card.";
196  args["GT"].name = "Geometry table";
197  args["GT"].type = 1;
198  args["GT"].ctgr = "mysql";
199 
200 
201 
202 
203 
204 
205  // #########
206  // Verbosity
207  // #########
208 
209  args["G4P_VERBOSITY"].arg = 1;
210  args["G4P_VERBOSITY"].help = "Controls Physical Volumes Construction Log Output.";
211  args["G4P_VERBOSITY"].name = "Logical Volume Verbosity";
212  args["G4P_VERBOSITY"].type = 0;
213  args["G4P_VERBOSITY"].ctgr = "verbosity";
214 
215  args["GEO_VERBOSITY"].arg = 1;
216  args["GEO_VERBOSITY"].help = "Controls Geometry Construction Log Output.";
217  args["GEO_VERBOSITY"].name = "Geometry Verbosity";
218  args["GEO_VERBOSITY"].type = 0;
219  args["GEO_VERBOSITY"].ctgr = "verbosity";
220 
221  args["GUI_VERBOSITY"].arg = 1;
222  args["GUI_VERBOSITY"].help = "Controls GUI Construction Log Output.";
223  args["GUI_VERBOSITY"].name = "GUI Verbosity";
224  args["GUI_VERBOSITY"].type = 0;
225  args["GUI_VERBOSITY"].ctgr = "verbosity";
226 
227  args["HIT_VERBOSITY"].arg = 1;
228  args["HIT_VERBOSITY"].help = "Controls Hits Log Output. ";
229  args["HIT_VERBOSITY"].name = "Hit Verbosity";
230  args["HIT_VERBOSITY"].type = 0;
231  args["HIT_VERBOSITY"].ctgr = "verbosity";
232 
233  args["LOG_MSG"].args = " >>> gemc";
234  args["LOG_MSG"].help = "Log Messages Header.";
235  args["LOG_MSG"].name = "Log Messages Header";
236  args["LOG_MSG"].type = 1;
237  args["LOG_MSG"].ctgr = "verbosity";
238 
239  args["CATCH"].args = "Maurizio";
240  args["CATCH"].help = "Catch volumes matching the given string.";
241  args["CATCH"].name = "Volume catcher";
242  args["CATCH"].type = 1;
243  args["CATCH"].ctgr = "verbosity";
244 
245  args["MGN_VERBOSITY"].arg = 1;
246  args["MGN_VERBOSITY"].help = "Controls Magnetic Fields Log Output.";
247  args["MGN_VERBOSITY"].name = "Magnetic Fields Verbosity";
248  args["MGN_VERBOSITY"].type = 0;
249  args["MGN_VERBOSITY"].ctgr = "verbosity";
250 
251  args["PRINT_EVENT"].arg = 1000;
252  args["PRINT_EVENT"].help = "-PRINT_EVENT=N: Print Event Number every N events.";
253  args["PRINT_EVENT"].name = "Print Event Modulus";
254  args["PRINT_EVENT"].type = 0;
255  args["PRINT_EVENT"].ctgr = "verbosity";
256 
257  args["OUT_VERBOSITY"].arg = 1;
258  args["OUT_VERBOSITY"].help = "Controls Bank Log Output.";
259  args["OUT_VERBOSITY"].name = "Bank Output Verbosity";
260  args["OUT_VERBOSITY"].type = 0;
261  args["OUT_VERBOSITY"].ctgr = "verbosity";
262 
263  args["PHY_VERBOSITY"].arg = 1;
264  args["PHY_VERBOSITY"].help = "Controls Physics List Log Output.";
265  args["PHY_VERBOSITY"].name = "Physics List Verbosity";
266  args["PHY_VERBOSITY"].type = 0;
267  args["PHY_VERBOSITY"].ctgr = "verbosity";
268 
269  args["GEN_VERBOSITY"].arg = 0;
270  args["GEN_VERBOSITY"].help = "Controls Geant4 Generator Verbosity.";
271  args["GEN_VERBOSITY"].name = "Geant4 Generator Verbosity";
272  args["GEN_VERBOSITY"].type = 0;
273  args["GEN_VERBOSITY"].ctgr = "verbosity";
274 
275  args["G4TRACK_VERBOSITY"].arg = 0;
276  args["G4TRACK_VERBOSITY"].help = "Controls Geant4 Track Verbosity.";
277  args["G4TRACK_VERBOSITY"].name = "Geant4 Track Verbosity";
278  args["G4TRACK_VERBOSITY"].type = 0;
279  args["G4TRACK_VERBOSITY"].ctgr = "verbosity";
280 
281  args["MATERIAL_VERBOSITY"].arg = 0;
282  args["MATERIAL_VERBOSITY"].help = "Controls Geant4 Material Verbosity.";
283  args["MATERIAL_VERBOSITY"].name = "Geant4 Material Verbosity";
284  args["MATERIAL_VERBOSITY"].type = 0;
285  args["MATERIAL_VERBOSITY"].ctgr = "verbosity";
286 
287  args["PARAMETER_VERBOSITY"].arg = 0;
288  args["PARAMETER_VERBOSITY"].help = "Controls Parameters Verbosity.";
289  args["PARAMETER_VERBOSITY"].name = "Parameters Verbosity";
290  args["PARAMETER_VERBOSITY"].type = 0;
291  args["PARAMETER_VERBOSITY"].ctgr = "verbosity";
292 
293 
294 
295 
296 
297 
298  // ###########
299  // Run Control
300  // ###########
301 
302  args["EXEC_MACRO"].args = "no";
303  args["EXEC_MACRO"].help = "Executes commands in macro file.";
304  args["EXEC_MACRO"].name = "Executes commands in macro file";
305  args["EXEC_MACRO"].type = 1;
306  args["EXEC_MACRO"].ctgr = "control";
307 
308  args["CHECK_OVERLAPS"].arg = 0;
309  args["CHECK_OVERLAPS"].help = "Checks Overlapping Volumes:\n";
310  args["CHECK_OVERLAPS"].help += " 1. Check Overlaps at Construction Time\n";
311  args["CHECK_OVERLAPS"].help += " 2. Check Overlaps based on standard lines grid setup\n";
312  args["CHECK_OVERLAPS"].help += " 3. Check Overlaps by shooting lines according to a cylindrical pattern\n";
313  args["CHECK_OVERLAPS"].name = "Checks Overlapping Volumes";
314  args["CHECK_OVERLAPS"].type = 0;
315  args["CHECK_OVERLAPS"].ctgr = "control";
316 
317  args["USE_QT"].arg = 1;
318  args["USE_QT"].help = "QT GUI switch\n";
319  args["USE_QT"].help += " 0. Don't use the graphical interface\n";
320  args["USE_QT"].help += " 1. QT OpenGL Immediate mode (can interact with picture; sliders works well; slower than Stored mode)\n";
321  args["USE_QT"].help += " 2. OpenGL Stored mode (can't interact with picture; sliders works well)\n";
322  args["USE_QT"].help += " 3. OpenGL Immediate mode (can't interact with picture; sliders works well; slower than Stored mode)\n";
323  args["USE_QT"].help += " 4. QT OpenGL Stored mode (can interact with picture; sliders works but picture needs to be updated by clicking on it)\n";
324  args["USE_QT"].name = "QT Gui";
325  args["USE_QT"].type = 0;
326  args["USE_QT"].ctgr = "control";
327 
328  args["geometry"].args="600x600";
329  args["geometry"].help = "Specify the size of the QT display window. Default '600x600' ";
330  args["geometry"].name="geometry";
331  args["geometry"].type=1;
332  args["geometry"].ctgr = "control";
333 
334  args["QTSTYLE"].args = "no";
335  args["QTSTYLE"].name = "Sets the GUI Style";
336  args["QTSTYLE"].help = "Sets the GUI Style. Available options: \n";
337  args["QTSTYLE"].help += " - QCleanlooksStyle \n";
338  args["QTSTYLE"].help += " - QMacStyle \n";
339  args["QTSTYLE"].help += " - QPlastiqueStyle \n";
340  args["QTSTYLE"].help += " - QWindowsStyle \n";
341  args["QTSTYLE"].help += " - QMotifStyle";
342  args["QTSTYLE"].type = 1;
343  args["QTSTYLE"].ctgr = "control";
344 
345  args["RANDOM"].args = "TIME";
346  args["RANDOM"].help = "Random Engine Initialization. The argument (seed) can be an integer or the string TIME.";
347  args["RANDOM"].name = "Random Engine Initialization";
348  args["RANDOM"].type = 1;
349  args["RANDOM"].ctgr = "control";
350 
351  args["gcard"].args = "no";
352  args["gcard"].help = "gemc card file.";
353  args["gcard"].name = "gemc card file";
354  args["gcard"].type = 1;
355  args["gcard"].ctgr = "control";
356 
357  args["EVN"].arg = 1;
358  args["EVN"].help = "Initial Event Number.";
359  args["EVN"].name = "Initial Event Number";
360  args["EVN"].type = 0;
361  args["EVN"].ctgr = "control";
362 
363  args["ENERGY_CUT"].arg = -1.;
364  args["ENERGY_CUT"].help = "Set an energy cut in MeV below which no particle will be tracked further. -1. turns this off.";
365  args["ENERGY_CUT"].name = "Tracking Energy cut (in MeV)";
366  args["ENERGY_CUT"].type = 0;
367  args["ENERGY_CUT"].ctgr = "control";
368 
369  args["MAX_X_POS"].arg = 30000.;
370  args["MAX_X_POS"].help = "Max X Position in millimeters. Beyond this the track will be killed";
371  args["MAX_X_POS"].name = "Max X Position in millimeters. Beyond this the track will be killed";
372  args["MAX_X_POS"].type = 0;
373  args["MAX_X_POS"].ctgr = "control";
374 
375  args["MAX_Y_POS"].arg = 30000.;
376  args["MAX_Y_POS"].help = "Max Y Position in millimeters. Beyond this the track will be killed";
377  args["MAX_Y_POS"].name = "Max Y Position in millimeters. Beyond this the track will be killed";
378  args["MAX_Y_POS"].type = 0;
379  args["MAX_Y_POS"].ctgr = "control";
380 
381  args["MAX_Z_POS"].arg = 30000.;
382  args["MAX_Z_POS"].help = "Max Z Position in millimeters. Beyond this the track will be killed";
383  args["MAX_Z_POS"].name = "Max Z Position in millimeters. Beyond this the track will be killed";
384  args["MAX_Z_POS"].type = 0;
385  args["MAX_Z_POS"].ctgr = "control";
386 
387  args["DAWN_N"].arg = 0;
388  args["DAWN_N"].help = "Number of events to be displayed with the DAWN driver (also activate the DAWN driver).";
389  args["DAWN_N"].name = "Number of events to be displayed with the DAWN driver (also activate the DAWN driver)";
390  args["DAWN_N"].type = 0;
391  args["DAWN_N"].ctgr = "control";
392 
393  args["HIT_PROCESS_LIST"].args = "clas12";
394  args["HIT_PROCESS_LIST"].name = "Registers Hit Process Routines.";
395  args["HIT_PROCESS_LIST"].help = "Registers Hit Process Routines. Can register multiple experiments, separated by space, e.v. \"clas12 aprime\"\n";
396  args["HIT_PROCESS_LIST"].help += " clas12. CLAS12 hit process routines (default)\n";
397  args["HIT_PROCESS_LIST"].help += " aprime. aprime hit process routines\n";
398  args["HIT_PROCESS_LIST"].help += " gluex. GlueX hit process routines\n";
399  args["HIT_PROCESS_LIST"].type = 1;
400  args["HIT_PROCESS_LIST"].ctgr = "control";
401 
402  args["SAVE_ALL_MOTHERS"].arg = 0;
403  args["SAVE_ALL_MOTHERS"].name = "Set to 1 to save mother vertex and pid infos in output. High Memory Usage. Default is 0";
404  args["SAVE_ALL_MOTHERS"].help = "Set to 1 to save mother vertex and pid infos in output. High Memory Usage. Default is 0.\n";
405  args["SAVE_ALL_MOTHERS"].type = 0;
406  args["SAVE_ALL_MOTHERS"].ctgr = "control";
407 
408  args["HIGH_RES"].arg = 1;
409  args["HIGH_RES"].name = "Use High Resolution Graphics";
410  args["HIGH_RES"].help = "Use High Resolution Graphics\n";
411  args["HIGH_RES"].type = 0;
412  args["HIGH_RES"].ctgr = "control";
413 
414  args["RECORD_PASSBY"].arg = 0;
415  args["RECORD_PASSBY"].name = "Set to one if you want to save zero energy hits in the output. Default is 0.";
416  args["RECORD_PASSBY"].help = "Set to one if you want to save zero energy hits in the output. Default is 0.\n";
417  args["RECORD_PASSBY"].type = 0;
418  args["RECORD_PASSBY"].ctgr = "control";
419 
420  args["RECORD_MIRRORS"].arg = 0;
421  args["RECORD_MIRRORS"].name = "Set to one if you want to save mirror hits in the output. Default is 0.";
422  args["RECORD_MIRRORS"].help = "Set to one if you want to save mirror hits in the output. Default is 0.\n";
423  args["RECORD_MIRRORS"].type = 0;
424  args["RECORD_MIRRORS"].ctgr = "control";
425 
426  args["RUNNO"].arg = 1;
427  args["RUNNO"].name = "Run Number. Controls the geometry and calibration parameters.";
428  args["RUNNO"].help = "Run Number. Controls the geometry and calibration parameters.\n";
429  args["RUNNO"].type = 0;
430  args["RUNNO"].ctgr = "control";
431 
432  args["MERGE_FILE"].args = "no";
433  args["MERGE_FILE"].name = "Merge banks from filename.";
434  args["MERGE_FILE"].help = "Merge banks from filename. Format supported: \n";
435  args["MERGE_FILE"].help += " - EVIO";
436  args["MERGE_FILE"].type = 1;
437  args["MERGE_FILE"].ctgr = "control";
438 
439 
440 
441 
442 
443 
444  // ######
445  // Output
446  // ######
447 
448  args["OUTPUT"].args = "no, output";
449  args["OUTPUT"].help = "Type of output, output filename. Supported output: evio, txt. Example: -OUTPUT=\"evio, out.ev\"";
450  args["OUTPUT"].name = "Type of output, output filename. ";
451  args["OUTPUT"].type = 1;
452  args["OUTPUT"].ctgr = "output";
453 
454 
455 
456 
457 
458 
459  // #######
460  // Physics
461  // #######
462 
463  args["OPT_PH"].arg = 0;
464  args["OPT_PH"].help = "Activate Optical Physics Processes in gemc Physics List.";
465  args["OPT_PH"].name = "Optical Physics";
466  args["OPT_PH"].type = 0;
467  args["OPT_PH"].ctgr = "physics";
468 
469  args["USE_PHYSICSL"].args = "QGSC_BERT";
470  args["USE_PHYSICSL"].help = "Physics List. Avaliable choices: \n\n";
471  args["USE_PHYSICSL"].help += " * gemc: comprehensive physics list. Optical Physics may be activated with OPT_PH=1 \n\n";
472  args["USE_PHYSICSL"].help += " The following is a list of other physics lists. More infos can be found here:\n\n";
473  args["USE_PHYSICSL"].help += " http://geant4.cern.ch/support/proc_mod_catalog/physics_lists/referencePL.shtml\n\n";
474  args["USE_PHYSICSL"].help += " * LHEP: This is the main LHEP based physics list, using exclusively parameterised modeling. \n";
475  args["USE_PHYSICSL"].help += " * LHEP_BERT: Like LHEP, but using Geant4 Bertini cascade for primary protons, neutrons, \n";
476  args["USE_PHYSICSL"].help += " pions and Kaons below ~10GeV. \n";
477  args["USE_PHYSICSL"].help += " * LHEP_BERT_HP: Like LHEP_BERT with the addition to use the data driven high precision.\n";
478  args["USE_PHYSICSL"].help += " neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
479  args["USE_PHYSICSL"].help += " * QGSP: Quark-Gluon String model based physics list. \n";
480  args["USE_PHYSICSL"].help += " * QGSP_BERT: Like QGSP, but using Geant4 Bertini cascade for primary protons, neutrons, \n";
481  args["USE_PHYSICSL"].help += " pions and Kaons below ~10GeV. \n";
482  args["USE_PHYSICSL"].help += " * QGSP_BERT_HP: Like QGSP_BERT with the addition to use the data driven high precision.\n";
483  args["USE_PHYSICSL"].help += " neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
484  args["USE_PHYSICSL"].help += " * QGSP_BIC: Like QGSP, but using Geant4 Binary cascade for primary protons and neutrons \n";
485  args["USE_PHYSICSL"].help += " with energies below ~10GeV. \n";
486  args["USE_PHYSICSL"].help += " * QGSP_BIC_HP: Like QGSP_BIC with the addition to use the data driven high precision.\n";
487  args["USE_PHYSICSL"].help += " neutron package (NeutronHP) to transport neutrons below 20 MeV down to thermal energies.\n";
488  args["USE_PHYSICSL"].help += " * QGSC_BERT: The quark-gluon string (QGS) part handles the formation of strings in the initial\n";
489  args["USE_PHYSICSL"].help += " collision of a hadron with a nucleon in the nucleus. String fragmentation into hadrons is\n";
490  args["USE_PHYSICSL"].help += " handled by the Quark-Gluon String fragmentation model. The Chiral Invariant Phase Space (CHIPS)\n";
491  args["USE_PHYSICSL"].help += " part handles the de-excitation of the remnant nucleus. Uses Geant4 Bertini cascade for primary\n";
492  args["USE_PHYSICSL"].help += " protons, neutrons, pions and Kaons below ~10GeV. \n";
493  args["USE_PHYSICSL"].name = "Choice of Physics List";
494  args["USE_PHYSICSL"].type = 1;
495  args["USE_PHYSICSL"].ctgr = "physics";
496 
497  args["LOW_EM_PHYS"].arg = 0;
498  args["LOW_EM_PHYS"].help = "Turn on the low energy Electro-Magnetic physics, down to the X-rat scale.\n";
499  args["LOW_EM_PHYS"].help+= " Currently only implemented for gemc physics list. \n";
500  args["LOW_EM_PHYS"].help+= " 0 Turn off [default] \n";
501  args["LOW_EM_PHYS"].help+= " 1 Standard E&M down to X-rays ( ~1 kEV cutoff) \n";
502  args["LOW_EM_PHYS"].name = "Low Energy Physics";
503  args["LOW_EM_PHYS"].type = 0;
504  args["LOW_EM_PHYS"].ctgr = "physics";
505 
506  args["HALL_MATERIAL"].args = "Air";
507  args["HALL_MATERIAL"].help = "Composition of the Experimental Hall. \n";
508  args["HALL_MATERIAL"].help += " Air normal simulation\n";
509  args["HALL_MATERIAL"].help += " Air_Opt Simulation with Optical Physics (default)\n";
510  args["HALL_MATERIAL"].help += " Vacuum\n";
511  args["HALL_MATERIAL"].name = "Composition of the Experimental Hall";
512  args["HALL_MATERIAL"].type = 1;
513  args["HALL_MATERIAL"].ctgr = "physics";
514 
515  args["DEFAULT_MATERIAL"].args = "none";
516  args["DEFAULT_MATERIAL"].help = "Default material for missing material field.\n";
517  args["DEFAULT_MATERIAL"].name = "Default material for missing material field";
518  args["DEFAULT_MATERIAL"].type = 1;
519  args["DEFAULT_MATERIAL"].ctgr = "physics";
520 
521  args["HALL_FIELD"].args = "no";
522  args["HALL_FIELD"].help = "Magnetic Field of the Hall. \n";
523  args["HALL_FIELD"].name = "Magnetic Field of the Hall";
524  args["HALL_FIELD"].type = 1;
525  args["HALL_FIELD"].ctgr = "physics";
526 
527  args["FIELD_DIR"].args = "env";
528  args["FIELD_DIR"].help = "Magnetic Field Maps Location. \n";
529  args["FIELD_DIR"].name = "Magnetic Field Maps Location";
530  args["FIELD_DIR"].type = 1;
531  args["FIELD_DIR"].ctgr = "physics";
532 
533  args["NO_FIELD"].args = "none";
534  args["NO_FIELD"].help = "Sets Magnetic Field of a volume to zero. \"all\" means no magnetic field at all. \n";
535  args["NO_FIELD"].name = "Sets Magnetic Field of a volume to zero. \"all\" means no magnetic field at all ";
536  args["NO_FIELD"].type = 1;
537  args["NO_FIELD"].ctgr = "physics";
538 
539  args["MAX_FIELD_STEP"].arg = 0;
540  args["MAX_FIELD_STEP"].help = "Sets Maximum Acceptable Step in Magnetic Field (in mm).\n";
541  args["MAX_FIELD_STEP"].name = "Sets Maximum Acceptable Step in Magnetic Field (in mm) ";
542  args["MAX_FIELD_STEP"].type = 0;
543  args["MAX_FIELD_STEP"].ctgr = "physics";
544 
545  args["SCALE_FIELD"].args = "no, 1";
546  args["SCALE_FIELD"].help = "Scales Magnetic Field by a factor.\n";
547  args["SCALE_FIELD"].help += " Usage:\n";
548  args["SCALE_FIELD"].help += " -SCALE_FIELD=\"fieldname, scalefactor\"\n";
549  args["SCALE_FIELD"].help += " Example: -SCALE_FIELD=\"srr-solenoid, 0.5\"\n";
550  args["SCALE_FIELD"].name = "Scales Magnetic Field by a factor ";
551  args["SCALE_FIELD"].type = 1;
552  args["SCALE_FIELD"].ctgr = "physics";
553 
554  args["MATERIALSDB"].args = "CPP";
555  args["MATERIALSDB"].help = "Select Materials DB. \n";
556  args["MATERIALSDB"].help += " Available Databases: \n";
557  args["MATERIALSDB"].help += " * CPP: use the normal geant4 c++ constructor.\n";
558  args["MATERIALSDB"].help += " * MYSQL: use the mysql DB.\n";
559  args["MATERIALSDB"].name = "Select Materials DB. ";
560  args["MATERIALSDB"].type = 1;
561  args["MATERIALSDB"].ctgr = "physics";
562 
563 
564 
565 
566 
567 
568  // #######
569  // General
570  // #######
571 
572  args["PARAMETERSDB"].args = "MYSQL";
573  args["PARAMETERSDB"].help = "Select Parameters DB. \n";
574  args["PARAMETERSDB"].help += " Available Databases: \n";
575  args["PARAMETERSDB"].help += " * MYSQL: use the mysql DB.\n";
576  args["PARAMETERSDB"].name = "Select Parameters DB";
577  args["PARAMETERSDB"].type = 1;
578  args["PARAMETERSDB"].ctgr = "general";
579 
580  args["DC_MSTAG_R3"].arg = 0.0;
581  args["DC_MSTAG_R3"].help = "Mini Stagger for Region 3. Each layer will alternate +- |this value|";
582  args["DC_MSTAG_R3"].name = "Mini Stagger for Region 3. Each layer will alternate +- |this value|";
583  args["DC_MSTAG_R3"].type = 0;
584  args["DC_MSTAG_R3"].ctgr = "general";
585 
586  args["DC_MSTAG_R2"].arg = 0.0;
587  args["DC_MSTAG_R2"].help = "Mini Stagger for Region 2. Each layer will alternate +- |this value|";
588  args["DC_MSTAG_R2"].name = "Mini Stagger for Region 2. Each layer will alternate +- |this value|";
589  args["DC_MSTAG_R2"].type = 0;
590  args["DC_MSTAG_R2"].ctgr = "general";
591 
592 }
593 
595 
596 void gemc_opts::Scan_gcard(string file)
597 {
598  // If found, parse the <options> section of the file.
599  QDomDocument domDocument;
600 
601  cout << " >>> gemc Init: >> Parsing " << file << " for options: \n";
602 
603  QFile gcard(file.c_str());
604 
605  if( !gcard.exists() )
606  {
607  cout << " >>> gemc Init: >> gcard: " << file <<" not found. Exiting." << endl;
608  exit(0);
609  }
610 
611  if (!domDocument.setContent(&gcard))
612  {
613  gcard.close();
614  cout << " >>> gemc Init: >> gcard format is wrong - check XML syntax. Exiting." << endl;
615  exit(0);
616  }
617 
618  gcard.close();
619 
620  QDomElement docElem = domDocument.documentElement();
621  QDomNode n;
622 
623  map<string, int> count;
624  map<string,opts>::iterator itm;
625  for(itm = args.begin();itm != args.end(); itm++)
626  count[itm->first] = 0;
627 
628 
629  n = docElem.firstChild();
630  while(!n.isNull())
631  {
632  QDomElement e = n.toElement();
633  if(!e.isNull())
634  if(e.tagName().toStdString() == "option")
635  {
636  int found=0;
637  for(itm = args.begin();itm != args.end(); itm++)
638  {
639  // looking for a valid option. If a two instances of the same option exist
640  // the string __REPETITION__ will be appended
641  if(e.attributeNode("name").value().toStdString() == itm->first )
642  {
643  if(count[itm->first] == 0)
644  {
645 
646  itm->second.args = e.attributeNode("value").value().toStdString();
647  itm->second.arg = atof(e.attributeNode("value").value().toStdString().c_str());
648  cout << " >>> gemc Init: >> Options: " << itm->second.name << " set to: ";
649  if(itm->second.type) cout << itm->second.args;
650  else cout << itm->second.arg;
651  cout << endl;
652  }
653 
654  found = 1;
655  count[itm->first] += 1;
656 
657  if(count[itm->first]>1)
658  {
659  string new_opt = itm->first + "__REPETITION__" + stringify(count[itm->first] - 1);
660  args[new_opt].args = e.attributeNode("value").value().toStdString();
661  args[new_opt].arg = atof(e.attributeNode("value").value().toStdString().c_str());
662  args[new_opt].name = itm->second.name;
663  args[new_opt].help = itm->second.help;
664  args[new_opt].type = itm->second.type;
665  args[new_opt].ctgr = itm->second.ctgr;
666  cout << " >>> gemc Init: >> Options: " << itm->second.name << " set to: ";
667  if(itm->second.type) cout << itm->second.args;
668  else cout << itm->second.arg;
669  cout << endl;
670  }
671  break;
672  }
673  }
674  if( found == 0 )
675  {
676  cout << "The option in the gcard file " << e.attributeNode("name").value().toStdString()
677  << " is not known to this system. Please check your spelling. \n\n";
678  exit(3);
679  }
680  }
681 
682  // now looking for child arguments
683  QDomNode nn= e.firstChild();
684  while( !nn.isNull() && e.tagName().toStdString() == "option")
685  {
686  QDomElement ee = nn.toElement();
687  map<string,opts>::iterator itm;
688  int found=0;
689  for(itm = args.begin();itm != args.end(); itm++)
690  {
691  if(ee.tagName().toStdString() == itm->first )
692  {
693  itm->second.args= ee.attributeNode("value").value().toStdString();
694  itm->second.arg = atof(ee.attributeNode("value").value().toStdString().c_str());
695  cout << " >>> gemc Init: >> Options: " << itm->second.name << " set to:";
696  if(itm->second.type) cout << itm->second.args;
697  else cout << itm->second.arg;
698  cout << endl;
699  found = 1;
700  }
701  }
702  if( found == 0 )
703  {
704  cout << "The option in the gcard file " << e.attributeNode("name").value().toStdString()
705  << " is not known to this system. Please check your spelling. \n\n";
706  exit(3);
707  }
708  nn = nn.nextSibling();
709 
710  }
711  n = n.nextSibling();
712  }
713  gcard.close();
714 }
715 
716 
717 
718 int gemc_opts::Set(int argc, char **argv)
719 {
720  string arg;
721  string com;
722  string opt;
723  cout << endl;
724  string comp;
725 
726  map<string, opts>::iterator itm;
727 
728  set<string> category;
729 
730  // Check the command line for the -gcard=file option.
731  // Then call the parser for the gcard file that reads all the options.
732  // This must be done BEFORE the commandline is parsed, so that command line
733  // options override the options in the file.
734 
735  size_t pos;
736  string file;
737 
738  // Look for -gcard :
739  for(int i=1;i<argc;i++)
740  {
741  arg = argv[i];
742  if( (pos=arg.find("gcard="))!= string::npos)
743  {
744  file = arg.substr(pos+6);
745  Scan_gcard(file);
746  }
747  }
748 
749 
750  // Filling Categories
751  for(itm = args.begin(); itm != args.end(); itm++)
752  if(category.find(itm->second.ctgr) == category.end()) category.insert(itm->second.ctgr);
753 
754 
755  // -help-all
756  for(int i=1; i<argc; i++)
757  {
758  arg = argv[i];
759  com = "-help-all";
760  if(arg == com)
761  {
762  cout << " Usage: -Option=<option>" << endl << endl;
763  cout << " Options:" << endl << endl ;
764 
765  for(itm = args.begin(); itm != args.end(); itm++)
766  cout << " > Option " << itm->first << ": " << itm->second.help << endl;
767 
768  cout << endl << endl;
769  exit(0);
770  }
771  }
772 
773 
774  // -help
775  set<string> :: iterator itcat;
776  for(int i=1; i<argc; i++)
777  {
778  arg = argv[i];
779  com = "-help";
780  if(arg == com)
781  {
782  cout << endl << endl;
783  cout << " Help Options:" << endl << endl ;
784  cout << " > -help-all: all available options. " << endl << endl;
785  for(itcat = category.begin(); itcat != category.end(); itcat++)
786  {
787 
788  cout << " > -help-" << *itcat << " ";
789  cout.width(15);
790  cout << *itcat << " options." << endl;
791  }
792  cout << endl << endl;
793  exit(0);
794  }
795  }
796 
797 
798  // -help-option
799  for(int i=1; i<argc; i++)
800  {
801  arg = argv[i];
802  for(itcat = category.begin(); itcat != category.end(); itcat++)
803  {
804  com = "-help-" + *itcat;
805  if(arg == com)
806  {
807  cout << endl << endl << " ## " << *itcat << " ## " << endl << endl;
808  cout << " Usage: -Option=<option>" << endl << endl;
809  for(itm = args.begin(); itm != args.end(); itm++)
810  if(itm->second.ctgr == *itcat) cout << " > " << itm->first << ": " << itm->second.help << endl;
811  cout << endl << endl;
812  exit(0);
813  }
814  }
815  }
816 
817 
818  // -help-html
819  for(int i=1; i<argc; i++)
820  {
821  arg = argv[i];
822  for(itcat = category.begin(); itcat != category.end(); itcat++)
823  {
824  com = "-help-html";
825  if(arg == com)
826  {
827  ofstream hf;
828  hf.open("gemc_help.html");
829  hf << "<html>" << endl;
830  hf << " <STYLE TYPE=\"text/css\">" << endl;
831  hf << "<!--" << endl;
832  hf << ".pretty-table" << endl;
833  hf << "{" << endl;
834  hf << " padding: 0;" << endl;
835  hf << " margin: 0;" << endl;
836  hf << " border-collapse: collapse;" << endl;
837  hf << " border: 1px solid #333;" << endl;
838  hf << " font-family: \"Trebuchet MS\", Verdana, Arial, Helvetica, sans-serif;" << endl;
839  hf << " font-size: 0.8em;" << endl;
840  hf << " color: #000;" << endl;
841  hf << " background: #bcd0e4;" << endl;
842  hf << "}" << endl;
843  hf << ".pretty-table caption" << endl;
844  hf << "{" << endl;
845  hf << " caption-side: bottom;" << endl;
846  hf << " font-size: 0.9em;" << endl;
847  hf << " font-style: italic;" << endl;
848  hf << " text-align: right;" << endl;
849  hf << " padding: 0.5em 0;" << endl;
850  hf << "}" << endl;
851  hf << ".pretty-table th, .pretty-table td" << endl;
852  hf << "{" << endl;
853  hf << " border: 1px dotted #666;" << endl;
854  hf << " padding: 0.5em;" << endl;
855  hf << " text-align: left;" << endl;
856  hf << " color: #632a39;" << endl;
857  hf << "}" << endl;
858  hf << ".pretty-table th[scope=col]" << endl;
859  hf << "{" << endl;
860  hf << " color: #000;" << endl;
861  hf << " background-color: #8fadcc;" << endl;
862  hf << " text-transform: uppercase;" << endl;
863  hf << " font-size: 0.9em;" << endl;
864  hf << " border-bottom: 2px solid #333;" << endl;
865  hf << " border-right: 2px solid #333;" << endl;
866  hf << "}" << endl;
867  hf << ".pretty-table th+th[scope=col]" << endl;
868  hf << "{" << endl;
869  hf << " color: #009;" << endl;
870  hf << " background-color: #7d98b3;" << endl;
871  hf << " border-right: 1px dotted #666;" << endl;
872  hf << "}" << endl;
873  hf << ".pretty-table th[scope=row]" << endl;
874  hf << "{" << endl;
875  hf << " background-color: #b8cfe5;" << endl;
876  hf << " border-right: 2px solid #333;" << endl;
877  hf << "}" << endl;
878  hf << "pre{font-family:Helvetica;font-size:12pt}" << endl;
879 
880  hf << "--->" << endl;
881  hf << "</STYLE>" << endl;
882  hf << "</head>" << endl;
883  hf << "<body>" << endl;
884  hf << "<br><br>" << endl;
885  hf << "<center>" << endl;
886  hf << "<h1> GEMC options</h1>" << endl;
887  hf << "</center>" << endl;
888  hf << "<br><br><br>" << endl;
889  hf << "<table cellsize=20>" << endl;
890  hf << "<tr><td>" << endl;
891  hf << "<table class=\"pretty-table\">" << endl;
892  hf << "<caption>gemc options. This table is produced with the gemc option: gemc -help-html </caption>" << endl;
893  hf << "<tr><th scope=\"col\" >Category</th>" << endl;
894  hf << " <th scope=\"col\" >Option</th>" << endl;
895  hf << " <th scope=\"col\" >Help</th></tr>" << endl;
896  for(itcat = category.begin(); itcat != category.end(); itcat++)
897  for(itm = args.begin(); itm != args.end(); itm++)
898  if(itm->second.ctgr == *itcat)
899  {
900  hf << "<tr><th scope=\"row\">";
901  hf << *itcat ;
902 
903  hf << "</th> <td>";
904  hf << itm->first;
905  hf << "</td><td><pre>" << endl;
906  hf << itm->second.help;
907  hf << "</pre></td></tr>" << endl;
908  }
909 
910 
911  hf << "</table>" << endl;
912  hf << "</td>" << endl;
913  hf << "<td>" << endl;
914  hf << "</table>" << endl;
915  hf << " </body></html>";
916 
917  hf.close();
918  exit(0);
919  }
920  }
921  }
922 
923  map<string, int> count;
924  for(itm = args.begin();itm != args.end(); itm++)
925  count[itm->first] = 0;
926 
927  for(int i=1; i<argc; i++)
928  {
929  arg = argv[i];
930  int found=0;
931  for(itm = args.begin(); itm != args.end(); itm++)
932  {
933  com = "-" + itm->first + "=";
934  comp.assign(arg, 0, arg.find("=") + 1);
935  if(comp == com)
936  {
937  opt.assign(arg, com.size(), arg.size()-com.size());
938  if(count[itm->first] == 0)
939  {
940  itm->second.args = opt;
941  itm->second.arg = atof(opt.c_str());
942  cout << " >>> Options: " << itm->second.name << " set to: " ;
943  if(itm->second.type) cout << itm->second.args;
944  else cout << itm->second.arg ;
945  cout << endl;
946  }
947  found=1;
948  count[itm->first] += 1;
949  if(count[itm->first]>1)
950  {
951  string new_opt = itm->first + "__REPETITION__" + stringify(count[itm->first]-1);
952  args[new_opt].args = opt;
953  args[new_opt].arg = atof(opt.c_str());
954  args[new_opt].name = itm->second.name;
955  args[new_opt].help = itm->second.help;
956  args[new_opt].type = itm->second.type;
957  args[new_opt].ctgr = itm->second.ctgr;
958 
959  cout << " >>> Options: " << itm->second.name << " set to: " ;
960  if(itm->second.type) cout << args[new_opt].args;
961  else cout << args[new_opt].arg ;
962  cout << endl;
963  }
964  break;
965  }
966  }
967  //
968  // For MAC OS X, we want to ignore the -psn_# type argument. This argument is added by
969  // the system when launching an application as an "app", and # contains the process id.
970  //
971  if( found == 0 && strncmp(argv[i],"-psn_",4) !=0 )
972  {
973  cout << "The argument " << argv[i] << " is not known to this system. \n\n";
974  exit(2);
975  }
976  }
977 
978  cout << endl;
979 
980  return 1;
981 }
982 
983 vector<opts> gemc_opts::get_args(string opt)
984 {
985  map<string, opts>::iterator itm;
986  vector<opts> options;
987  map<string, int> count;
988  for(itm = args.begin();itm != args.end(); itm++)
989  {
990  if(itm->first.find(opt) != string::npos)
991  {
992  options.push_back(itm->second);
993  }
994  }
995 
996  return options;
997 }
998 
999 
1000 
1001 
1002 
1003 
1004 
1005 
1006 
1007 
1008 
1009 
1010 
1011 
1012 
gemc_opts()
Definition: usage.cc:14
~gemc_opts()
Definition: usage.cc:594
string stringify(double x)
map< string, opts > args
Options map.
Definition: usage.h:68
void Scan_gcard(string file)
Definition: usage.cc:596
vector< opts > get_args(string)
get a vector of arguments matching a string
Definition: usage.cc:983
int Set(int argc, char **args)
Sets map from command line arguments.
Definition: usage.cc:718