GEMC  1.8
Geant4 Monte-Carlo Framework
dmesg_init.cc
Go to the documentation of this file.
1 
6 // %%%%%%%%%%
7 // G4 headers
8 // %%%%%%%%%%
9 #include "G4RunManager.hh"
10 #include "G4VisExecutive.hh"
11 #include "G4TrajectoryDrawByParticleID.hh"
12 
13 // %%%%%%%%%%%%%
14 // gemc headers
15 // %%%%%%%%%%%%%
16 #include "usage.h"
17 
21 vector<string> init_dmesg(gemc_opts gemcOpt)
22 {
23  vector<string> commands;
24 
25  // Geant4 Process verbosity
26  double PHI_VERB = gemcOpt.args["PHY_VERBOSITY"].arg ;
27  int OVERL = (int) gemcOpt.args["CHECK_OVERLAPS"].arg ;
28  int DAWN_N = (int) gemcOpt.args["DAWN_N"].arg ;
29  int SAVE_ALL_MOTHERS = (int) gemcOpt.args["SAVE_ALL_MOTHERS"].arg ;
30 
31  char phi_verb[2];
32  sprintf(phi_verb, "%d", (int) PHI_VERB);
33  string proc_verb1 = "/process/setVerbose ";
34  string proc_verb2 = "/process/verbose ";
35  proc_verb1.append(phi_verb);
36  proc_verb1.append(" all");
37  proc_verb2.append(phi_verb);
38 
39 
40  // Geant4 Tracking Verbosity
41  double TRACK_VERB = gemcOpt.args["G4TRACK_VERBOSITY"].arg ;
42  char track_verb[2];
43  sprintf(track_verb, "%d", (int) TRACK_VERB);
44  string tra_verb = "/tracking/verbose ";
45  tra_verb.append(track_verb);
46  commands.push_back(tra_verb);
47 
48  // keep trajectories in the container if mother infos are required
49  if(SAVE_ALL_MOTHERS)
50  commands.push_back("/tracking/storeTrajectory 2");
51  else
52  commands.push_back("/tracking/storeTrajectory 0");
53 
54 
55  // sets all verbosity to zero
56  commands.push_back("/control/verbose 0");
57  commands.push_back("/geometry/navigator/verbose 0");
58  commands.push_back("/event/verbose 0");
59  commands.push_back("/run/verbose 0");
60  commands.push_back("/run/particle/verbose 0");
61  commands.push_back("/material/verbose 0");
62  commands.push_back(proc_verb1.c_str());
63  commands.push_back(proc_verb2.c_str());
64  commands.push_back("/process/eLoss/verbose 0");
65  commands.push_back("/vis/verbose 0");
66  commands.push_back("/vis/viewer/flush");
67  commands.push_back("/process/setVerbose 0");
68 
69 
70 
71 
72  if(OVERL>1)
73  commands.push_back("/geometry/test/grid_test 1");
74 
75  if(OVERL>2)
76  commands.push_back("/geometry/test/cylinder_test 1");
77 
78 
79  if(DAWN_N>0)
80  {
81  char dawn[10];
82  sprintf(dawn, "%d", DAWN_N);
83  string DN = "/run/beamOn ";
84  DN.append(dawn);
85 
86  commands.push_back("/vis/open DAWNFILE");
87  commands.push_back("/vis/drawVolume");
88  commands.push_back("/vis/scene/add/trajectories rich smooth");
89  commands.push_back("/vis/scene/add/hits");
90  commands.push_back("/vis/scene/endOfEventAction accumulate -1");
91  commands.push_back(DN);
92  }
93 
94 
95 
96  return commands;
97 }
98 
102 vector<string> init_dvmesg(gemc_opts gemcOpt, G4VisManager *VM)
103 {
104  vector<string> commands;
105  commands.push_back("/vis/scene/create Hall-B");
106  double use_qt = gemcOpt.args["USE_QT"].arg;
107  int HIGH_RES = (int) gemcOpt.args["HIGH_RES"].arg ;
108 
109  // OpenGL immediate mode
110  if(use_qt==1)
111  commands.push_back("/vis/open OGLI " + gemcOpt.args["geometry"].args);
112  // openGL stored mode
113  else if(use_qt==2)
114  commands.push_back("/vis/open OGLS " + gemcOpt.args["geometry"].args);
115 
116 
117  commands.push_back("/vis/viewer/set/autoRefresh 1");
118 // commands.push_back("/vis/viewer/set/culling global true");
119 // commands.push_back("/vis/viewer/set/culling coveredDaughters 1");
120 
121 
122  if(HIGH_RES==1)
123  {
124  commands.push_back("/vis/scene/add/trajectories rich smooth");
125  commands.push_back("/vis/viewer/set/background .8 .9 .98 1"); // 205, 230, 251 = CD, E6, FA
126  commands.push_back("/vis/scene/add/hits");
127  //commands.push_back("/vis/viewer/set/lineSegmentsPerCircle 100");
128  commands.push_back("/vis/scene/endOfEventAction accumulate -1");
129  }
130  else
131  {
132  commands.push_back("/vis/scene/add/trajectories");
133  commands.push_back("/vis/scene/add/hits");
134  commands.push_back("/vis/scene/endOfEventAction accumulate -1");
135  }
136 
137 
138 
139 // commands.push_back("/vis/viewer/zoom 1.0");
140 
141 
142  // tracks colors
143  // these steps come from the user manual chapter Trajectory Drawing Models
144  // Create and configure a drawByParticleID model named gemcColorIDModel
145  // positive particles: RED
146  // negative particles: GREEN
147  // specific colors below
148  G4TrajectoryDrawByParticleID* gemcColorIDModel = new G4TrajectoryDrawByParticleID("gemcColorIDModel");
149  gemcColorIDModel->SetDefault("gray");
150  gemcColorIDModel->Set("neutron", "black");
151  gemcColorIDModel->Set("gamma", "blue");
152  gemcColorIDModel->Set("e-", "cyan");
153  gemcColorIDModel->Set("pi+", "magenta");
154  gemcColorIDModel->Set("pi-", "yellow");
155  gemcColorIDModel->Set("proton", G4Colour(0.95, 0.6, 0.3)); // orange
156 
157  G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
158  for(int i=0; i<particleTable->entries(); i++)
159  {
160  string pname = particleTable->GetParticleName(i);
161  double charge = particleTable->FindParticle(pname)->GetPDGCharge();
162  string pcolor ;
163  if(pname != "neutron" &&
164  pname != "gamma" &&
165  pname != "e-" &&
166  pname != "pi+" &&
167  pname != "pi-" &&
168  pname != "proton" )
169  {
170  if(charge>0)
171  gemcColorIDModel->Set(pname, "red");
172  if(charge==0)
173  gemcColorIDModel->Set(pname, "white");
174  if(charge<0)
175  gemcColorIDModel->Set(pname, "green");
176  }
177  }
178 
179  VM->RegisterModel(gemcColorIDModel);
180  VM->SelectTrajectoryModel(gemcColorIDModel->Name());
181 
182  // Draw by Process - interesting! But not working yet?
183 // commands.push_back("/vis/modeling/trajectories/create/drawByAttribute gemcColorAttributeModel");
184 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/setAttribute CPN");
185 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/verbose true");
186 //
187 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/addValue brem_key eBrem");
188 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/addValue annihil_key annihil");
189 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/addValue decay_key Decay");
190 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/addValue muIon_key muIoni");
191 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/addValue eIon_key eIoni");
192 //
193 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/brem_key/setLineColour yellow");
194 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/annihil_key/setLineColour yellow");
195 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/decay_key/setLineColour yellow");
196 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/eIon_key/setLineColour yellow");
197 // commands.push_back("/vis/modeling/trajectories/gemcColorAttributeModel/muIon_key/setLineColour yellow");
198 
199  return commands;
200 }
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
vector< string > init_dmesg(gemc_opts gemcOpt)
General Initialization Routine.
Definition: dmesg_init.cc:21
vector< string > init_dvmesg(gemc_opts gemcOpt, G4VisManager *VM)
Initialization Routine for Visualization.
Definition: dmesg_init.cc:102
map< string, opts > args
Options map.
Definition: usage.h:68