Loading...
Searching...
No Matches
Functions
load_gdml.cc File Reference

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

#include <vector>
#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4TransportationManager.hh"
#include "G01PrimaryGeneratorAction.hh"
#include "G01DetectorConstruction.hh"
#include "G01ActionInitialization.hh"
#include "FTFP_BERT.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4GDMLParser.hh"

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

◆ print_aux()

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

Definition at line 59 of file load_gdml.cc.

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file load_gdml.cc.

78{
79 G4cout << G4endl;
80 G4cout << "Usage: load_gdml <intput_gdml_file:mandatory>"
81 << " <output_gdml_file:optional>" << G4endl;
82 G4cout << G4endl;
83
84 if (argc<2)
85 {
86 G4cout << "Error! Mandatory input file is not specified!" << G4endl;
87 G4cout << G4endl;
88 return -1;
89 }
90
91 G4GDMLParser parser;
92
93// Uncomment the following if wish to avoid names stripping
94// parser.SetStripFlag(false);
95
96// Uncomment the following and set a string with proper absolute path and
97// schema filename if wishing to use alternative schema for parsing validation
98// parser.SetImportSchema("");
99
100 parser.SetOverlapCheck(true);
101 parser.Read(argv[1]);
102
103 if (argc>4)
104 {
105 G4cout << "Error! Too many arguments!" << G4endl;
106 G4cout << G4endl;
107 return -1;
108 }
109
110 auto* runManager = G4RunManagerFactory::CreateRunManager();
111
112 runManager->SetUserInitialization(new G01DetectorConstruction(
113 parser.GetWorldVolume()));
114 runManager->SetUserInitialization(new FTFP_BERT);
115 runManager->SetUserInitialization(new G01ActionInitialization());
116
117 runManager->Initialize();
118
119 // Initialize visualization
120 G4VisManager* visManager = new G4VisExecutive;
121 visManager->Initialize();
122
123 // Get the pointer to the User Interface manager
124 G4UImanager* UImanager = G4UImanager::GetUIpointer();
125
126 ///////////////////////////////////////////////////////////////////////
127 //
128 // Example how to retrieve Auxiliary Information
129 //
130
131 G4cout << std::endl;
132
133 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
134 std::vector<G4LogicalVolume*>::const_iterator lvciter;
135 for( lvciter = lvs->begin(); lvciter != lvs->end(); lvciter++ )
136 {
137 G4GDMLAuxListType auxInfo = parser.GetVolumeAuxiliaryInformation(*lvciter);
138
139 if (auxInfo.size()>0)
140 G4cout << "Auxiliary Information is found for Logical Volume : "
141 << (*lvciter)->GetName() << G4endl;
142
143 print_aux(&auxInfo);
144 }
145
146 // now the 'global' auxiliary info
147 G4cout << std::endl;
148 G4cout << "Global auxiliary info:" << std::endl;
149 G4cout << std::endl;
150
151 print_aux(parser.GetAuxList());
152
153 G4cout << std::endl;
154
155 //
156 // End of Auxiliary Information block
157 //
158 ////////////////////////////////////////////////////////////////////////
159
160
161 runManager->BeamOn(0);
162
163 // example of writing out
164
165 if (argc>=3)
166 {
167/*
168 G4GDMLAuxStructType mysubaux = {"mysubtype", "mysubvalue", "mysubunit", 0};
169 G4GDMLAuxListType* myauxlist = new G4GDMLAuxListType();
170 myauxlist->push_back(mysubaux);
171
172 G4GDMLAuxStructType myaux = {"mytype", "myvalue", "myunit", myauxlist};
173 parser.AddAuxiliary(myaux);
174
175
176 // example of setting auxiliary info for world volume
177 // (can be set for any volume)
178
179 G4GDMLAuxStructType mylocalaux = {"sometype", "somevalue", "someunit", 0};
180
181 parser.AddVolumeAuxiliary(mylocalaux,
182 G4TransportationManager::GetTransportationManager()
183 ->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume());
184*/
185
186 parser.SetRegionExport(true);
187 // parser.SetEnergyCutsExport(true);
188 // parser.SetOutputFileOverwrite(true);
189 parser.Write(argv[2], G4TransportationManager::GetTransportationManager()
190 ->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume());
191 }
192
193
194 if (argc==4) // batch mode
195 {
196 G4String command = "/control/execute ";
197 G4String fileName = argv[3];
198 UImanager->ApplyCommand(command+fileName);
199 }
200 else // interactive mode
201 {
202 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
203 UImanager->ApplyCommand("/control/execute vis.mac");
204 ui->SessionStart();
205 delete ui;
206 }
207
208 delete visManager;
209 delete runManager;
210
211 return 0;
212}
Action initialization class.
Detector construction allowing to use the geometry read from the GDML file.

Applications | User Support | Publications | Collaboration