Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
load_gdml.cc File Reference

Main program of the persistency/gdml/G01 example. More...

#include <vector>
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4TransportationManager.hh"
#include "G01PrimaryGeneratorAction.hh"
#include "G01DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4GDMLParser.hh"
Include dependency graph for load_gdml.cc:

Go to the source code of this file.

Functions

void print_aux (const G4GDMLAuxListType *auxInfoList, G4String prepend="|")
 
int main (int argc, char **argv)
 

Detailed Description

Main program of the persistency/gdml/G01 example.

Definition in file load_gdml.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 73 of file load_gdml.cc.

74 {
75  G4cout << G4endl;
76  G4cout << "Usage: load_gdml <intput_gdml_file:mandatory>"
77  << " <output_gdml_file:optional>" << G4endl;
78  G4cout << G4endl;
79 
80  if (argc<2)
81  {
82  G4cout << "Error! Mandatory input file is not specified!" << G4endl;
83  G4cout << G4endl;
84  return -1;
85  }
86 
88 
89 // Uncomment the following if wish to avoid names stripping
90 // parser.SetStripFlag(false);
91 
92  parser.Read(argv[1]);
93 
94  if (argc>4)
95  {
96  G4cout << "Error! Too many arguments!" << G4endl;
97  G4cout << G4endl;
98  return -1;
99  }
100 
101  G4RunManager* runManager = new G4RunManager;
102 
104  parser.GetWorldVolume()));
105  runManager->SetUserInitialization(new FTFP_BERT);
106  runManager->SetUserAction(new G01PrimaryGeneratorAction);
107 
108  runManager->Initialize();
109 
110  // Initialize visualization
111  G4VisManager* visManager = new G4VisExecutive;
112  visManager->Initialize();
113 
114  // Get the pointer to the User Interface manager
115  G4UImanager* UImanager = G4UImanager::GetUIpointer();
116 
118  //
119  // Example how to retrieve Auxiliary Information
120  //
121 
122  G4cout << std::endl;
123 
125  std::vector<G4LogicalVolume*>::const_iterator lvciter;
126  for( lvciter = lvs->begin(); lvciter != lvs->end(); lvciter++ )
127  {
128  G4GDMLAuxListType auxInfo = parser.GetVolumeAuxiliaryInformation(*lvciter);
129 
130  if (auxInfo.size()>0)
131  G4cout << "Auxiliary Information is found for Logical Volume : "
132  << (*lvciter)->GetName() << G4endl;
133 
134  print_aux(&auxInfo);
135  }
136 
137  // now the 'global' auxiliary info
138  G4cout << std::endl;
139  G4cout << "Global auxiliary info:" << std::endl;
140  G4cout << std::endl;
141 
142  print_aux(parser.GetAuxList());
143 
144  G4cout << std::endl;
145 
146  //
147  // End of Auxiliary Information block
148  //
150 
151  // example of writing out
152 
153  if (argc>=3)
154  {
155 /*
156  G4GDMLAuxStructType mysubaux = {"mysubtype", "mysubvalue", "mysubunit", 0};
157  G4GDMLAuxListType* myauxlist = new G4GDMLAuxListType();
158  myauxlist->push_back(mysubaux);
159 
160  G4GDMLAuxStructType myaux = {"mytype", "myvalue", "myunit", myauxlist};
161  parser.AddAuxiliary(myaux);
162 
163 
164  // example of setting auxiliary info for world volume
165  // (can be set for any volume)
166 
167  G4GDMLAuxStructType mylocalaux = {"sometype", "somevalue", "someunit", 0};
168 
169  parser.AddVolumeAuxiliary(mylocalaux,
170  G4TransportationManager::GetTransportationManager()
171  ->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume());
172 */
173  parser.SetRegionExport(true);
175  ->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume());
176  }
177 
178 
179  if (argc==4) // batch mode
180  {
181  G4String command = "/control/execute ";
182  G4String fileName = argv[3];
183  UImanager->ApplyCommand(command+fileName);
184  }
185  else // interactive mode
186  {
187  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
188  UImanager->ApplyCommand("/control/execute vis.mac");
189  ui->SessionStart();
190  delete ui;
191  }
192 
193  delete visManager;
194  delete runManager;
195 
196  return 0;
197 }
Minimal primary generator action to demonstrate the use of GDML geometries.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *lvol) const
Detector construction allowing to use the geometry read from the GDML file.
void SetRegionExport(G4bool)
const G4GDMLAuxListType * GetAuxList() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_SCHEMALOCATION)
CommandLineParser * parser(0)
void print_aux(const G4GDMLAuxListType *auxInfoList, G4String prepend="|")
Definition: load_gdml.cc:55
static G4TransportationManager * GetTransportationManager()
void Initialize()
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
void Read(const G4String &filename, G4bool Validate=true)
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

void print_aux ( const G4GDMLAuxListType auxInfoList,
G4String  prepend = "|" 
)

Definition at line 55 of file load_gdml.cc.

56 {
57  for(std::vector<G4GDMLAuxStructType>::const_iterator
58  iaux = auxInfoList->begin(); iaux != auxInfoList->end(); iaux++ )
59  {
60  G4String str=iaux->type;
61  G4String val=iaux->value;
62  G4String unit=iaux->unit;
63 
64  G4cout << prepend << str << " : " << val << " " << unit << G4endl;
65 
66  if (iaux->auxList) print_aux(iaux->auxList, prepend + "|");
67  }
68  return;
69 }
G4GLOB_DLL std::ostream G4cout
void print_aux(const G4GDMLAuxListType *auxInfoList, G4String prepend="|")
Definition: load_gdml.cc:55
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function: