ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4HepRepMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4HepRepMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 #include "G4HepRepMessenger.hh"
28 
31 
34 {
36  return fpInstance;
37 }
38 
40  fileDir(""),
41  fileName("G4Data"),
42  overwrite(false),
43  cullInvisibles(false),
44  cylAsPolygons(false),
45  scale(1.),
46  suffix (""),
47  geometry(true),
48  pointAttributes(false),
49  solids(true),
50  invisibles(true) {
51 
52  heprepDirectory = new G4UIdirectory("/vis/heprep/");
53  heprepDirectory->SetGuidance("HepRep commands.");
54 
55  setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
56  setFileDirCommand->SetGuidance("Set directory for output.");
57  setFileDirCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
58  setFileDirCommand->SetParameterName("directory",false);
59  if ( std::getenv( "G4HEPREPFILE_DIR" ) == NULL ) {
61  } else {
62  setFileDirCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_DIR"));
63  fileDir = std::getenv("G4HEPREPFILE_DIR");
64  }
66 
67  setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
68  setFileNameCommand->SetGuidance("Set file name for output.");
69  setFileNameCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
70  setFileNameCommand->SetParameterName("directory",false);
71  if ( std::getenv( "G4HEPREPFILE_NAME" ) == NULL ) {
73  } else {
74  setFileNameCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_NAME"));
75  fileName = std::getenv("G4HEPREPFILE_NAME");
76  }
78 
79  setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
80  setOverwriteCommand->SetGuidance("Set true to write all output to exact same file name.");
81  setOverwriteCommand->SetGuidance("Set false to increment the file name for each new output.");
82  setOverwriteCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
84  if ( std::getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) {
86  } else {
87  setOverwriteCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_OVERWRITE"));
88  overwrite = setOverwriteCommand->ConvertToBool(std::getenv("G4HEPREPFILE_OVERWRITE"));
89  }
91 
92  setCullInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
93  setCullInvisiblesCommand->SetGuidance("Remove invisible objects from output file.");
94  setCullInvisiblesCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
96  if ( std::getenv( "G4HEPREPFILE_CULL" ) == NULL ) {
98  } else {
99  setCullInvisiblesCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_CULL"));
100  cullInvisibles = setCullInvisiblesCommand->ConvertToBool(std::getenv("G4HEPREPFILE_CULL"));
101  }
103 
104  renderCylAsPolygonsCommand = new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this);
105  renderCylAsPolygonsCommand->SetGuidance("Render cylinders and cones as polygons.");
106  renderCylAsPolygonsCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
110 
111  setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale",this);
112  setScaleCommand->SetGuidance("Re-Scale coordinates.");
113  setScaleCommand->SetParameterName("Scale",true);
115  setScaleCommand->SetRange("Scale > 0");
116 
117  setCenterCommand = new G4UIcmdWith3VectorAndUnit("/vis/heprep/center",this);
118  setCenterCommand->SetGuidance("Re-Center coordinates.");
119  setCenterCommand->SetParameterName("CenterX","CenterY","CenterZ",true);
122 
123  setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
124  setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
125  setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
126  setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
130 
131  appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
132  appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
133  appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
137 
138  addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
139  addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
140  addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
144 
145  useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
146  useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives.");
147  useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile..");
148  useSolidsCommand->SetParameterName("flag",false);
151 }
152 
154  delete setFileDirCommand;
155  delete setFileNameCommand;
156  delete setOverwriteCommand;
159  delete setScaleCommand;
160  delete setCenterCommand;
162  delete appendGeometryCommand;
164  delete useSolidsCommand;
165  delete heprepDirectory;
166 }
167 
169  if (command==setFileDirCommand) {
170  return fileDir;
171  } else if (command==setFileNameCommand) {
172  return fileName;
173  } else if (command==setOverwriteCommand) {
174  return overwrite;
175  } else if (command==setCullInvisiblesCommand) {
176  return cullInvisibles;
177  } else if (command==renderCylAsPolygonsCommand) {
179  } else if (command==setScaleCommand) {
181  } else if (command==setCenterCommand) {
183  } else if (command==setEventNumberSuffixCommand) {
184  return suffix;
185  } else if (command==appendGeometryCommand) {
187  } else if (command==addPointAttributesCommand) {
189  } else if (command==useSolidsCommand) {
191  } else {
192  return "";
193  }
194 }
195 
197  if (command==setFileDirCommand) {
198  fileDir = newValue;
199  } else if (command==setFileNameCommand) {
200  fileName = newValue;
201  } else if (command==setOverwriteCommand) {
203  } else if (command==setCullInvisiblesCommand) {
205  } else if (command==renderCylAsPolygonsCommand) {
207  } else if (command==setScaleCommand) {
209  } else if (command==setCenterCommand) {
211  } else if (command==setEventNumberSuffixCommand) {
212  suffix = newValue;
213  } else if (command==appendGeometryCommand) {
215  } else if (command==addPointAttributesCommand) {
217  } else if (command==useSolidsCommand) {
219  }
220 }
221 
223  return fileDir;
224 }
225 
227  return fileName;
228 }
229 
231  return overwrite;
232 }
233 
235  return cullInvisibles;
236 }
237 
239  return cylAsPolygons;
240 }
241 
243  return scale;
244 }
245 
247  return center;
248 }
249 
251  return suffix;
252 }
253 
255  return geometry;
256 }
257 
259  return pointAttributes;
260 }
261 
263  return solids;
264 }
265 
267  return invisibles;
268 }
269