File indexing completed on 2025-02-23 09:22:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include "FTFP_BERT.hh"
0038 #include "G01ActionInitialization.hh"
0039 #include "G01DetectorConstruction.hh"
0040 #include "G01PrimaryGeneratorAction.hh"
0041
0042 #include "G4GDMLParser.hh"
0043 #include "G4LogicalVolumeStore.hh"
0044 #include "G4RunManagerFactory.hh"
0045 #include "G4TransportationManager.hh"
0046 #include "G4Types.hh"
0047 #include "G4UIExecutive.hh"
0048 #include "G4UImanager.hh"
0049 #include "G4VisExecutive.hh"
0050
0051 #include <vector>
0052
0053 void print_aux(const G4GDMLAuxListType* auxInfoList, G4String prepend = "|")
0054 {
0055 for (std::vector<G4GDMLAuxStructType>::const_iterator iaux = auxInfoList->begin();
0056 iaux != auxInfoList->end(); iaux++)
0057 {
0058 G4String str = iaux->type;
0059 G4String val = iaux->value;
0060 G4String unit = iaux->unit;
0061
0062 G4cout << prepend << str << " : " << val << " " << unit << G4endl;
0063
0064 if (iaux->auxList) print_aux(iaux->auxList, prepend + "|");
0065 }
0066 return;
0067 }
0068
0069
0070
0071 int main(int argc, char** argv)
0072 {
0073 G4cout << G4endl;
0074 G4cout << "Usage: load_gdml <intput_gdml_file:mandatory>"
0075 << " <output_gdml_file:optional>" << G4endl;
0076 G4cout << G4endl;
0077
0078 if (argc < 2) {
0079 G4cout << "Error! Mandatory input file is not specified!" << G4endl;
0080 G4cout << G4endl;
0081 return -1;
0082 }
0083
0084 G4GDMLParser parser;
0085
0086
0087
0088
0089
0090
0091
0092
0093 parser.SetOverlapCheck(true);
0094 parser.Read(argv[1]);
0095
0096 if (argc > 4) {
0097 G4cout << "Error! Too many arguments!" << G4endl;
0098 G4cout << G4endl;
0099 return -1;
0100 }
0101
0102 auto* runManager = G4RunManagerFactory::CreateRunManager();
0103
0104 runManager->SetUserInitialization(new G01DetectorConstruction(parser.GetWorldVolume()));
0105 runManager->SetUserInitialization(new FTFP_BERT);
0106 runManager->SetUserInitialization(new G01ActionInitialization());
0107
0108 runManager->Initialize();
0109
0110
0111 G4VisManager* visManager = new G4VisExecutive;
0112 visManager->Initialize();
0113
0114
0115 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0116
0117
0118
0119
0120
0121
0122 G4cout << std::endl;
0123
0124 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
0125 std::vector<G4LogicalVolume*>::const_iterator lvciter;
0126 for (lvciter = lvs->begin(); lvciter != lvs->end(); lvciter++) {
0127 G4GDMLAuxListType auxInfo = parser.GetVolumeAuxiliaryInformation(*lvciter);
0128
0129 if (auxInfo.size() > 0)
0130 G4cout << "Auxiliary Information is found for Logical Volume : " << (*lvciter)->GetName()
0131 << G4endl;
0132
0133 print_aux(&auxInfo);
0134 }
0135
0136
0137 G4cout << std::endl;
0138 G4cout << "Global auxiliary info:" << std::endl;
0139 G4cout << std::endl;
0140
0141 print_aux(parser.GetAuxList());
0142
0143 G4cout << std::endl;
0144
0145
0146
0147
0148
0149
0150 runManager->BeamOn(0);
0151
0152
0153
0154 if (argc >= 3) {
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 parser.SetRegionExport(true);
0175
0176
0177 parser.Write(argv[2], G4TransportationManager::GetTransportationManager()
0178 ->GetNavigatorForTracking()
0179 ->GetWorldVolume()
0180 ->GetLogicalVolume());
0181 }
0182
0183 if (argc == 4)
0184 {
0185 G4String command = "/control/execute ";
0186 G4String fileName = argv[3];
0187 UImanager->ApplyCommand(command + fileName);
0188 }
0189 else
0190 {
0191 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0192 UImanager->ApplyCommand("/control/execute vis.mac");
0193 ui->SessionStart();
0194 delete ui;
0195 }
0196
0197 delete visManager;
0198 delete runManager;
0199
0200 return 0;
0201 }