Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file dicom2.cc 28 /// \brief Main program of the Dicom2 example 29 30 #include "Dicom2ActionInitialization.hh" 31 #include "DicomIntersectVolume.hh" 32 #include "DicomNestedParamDetectorConstruction 33 #include "DicomPartialDetectorConstruction.hh" 34 #include "DicomRegularDetectorConstruction.hh" 35 #include "QBBC.hh" 36 #include "QGSP_BIC.hh" 37 #include "Shielding.hh" 38 39 #include "G4GenericPhysicsList.hh" 40 #include "G4RunManagerFactory.hh" 41 #include "G4Timer.hh" 42 #include "G4Types.hh" 43 #include "G4UIExecutive.hh" 44 #include "G4UImanager.hh" 45 #include "G4VisExecutive.hh" 46 #include "G4tgrMessenger.hh" 47 #include "Randomize.hh" 48 #include "globals.hh" 49 #ifdef G4_DCMTK 50 # include "DicomFileMgr.hh" 51 #else 52 # include "DicomHandler.hh" 53 #endif 54 55 //....oooOO0OOooo........oooOO0OOooo........oo 56 57 int main(int argc, char** argv) 58 { 59 // Detect interactive mode (if no arguments) 60 // 61 G4UIExecutive* ui = 0; 62 if (argc == 1) ui = new G4UIExecutive(argc, 63 64 new G4tgrMessenger; 65 char* part = std::getenv("DICOM_PARTIAL_PARA 66 G4bool bPartial = (part && G4String(part) == 67 68 CLHEP::HepRandom::setTheEngine(new CLHEP::Mi 69 CLHEP::HepRandom::setTheSeed(G4long(24534575 70 G4long seeds[2]; 71 seeds[0] = G4long(534524575674523); 72 seeds[1] = G4long(526345623452457); 73 CLHEP::HepRandom::setTheSeeds(seeds); 74 75 // Construct the default run manager 76 G4int nthreads = G4GetEnv<G4int>("DICOM_NTHR 77 auto* runManager = G4RunManagerFactory::Crea 78 runManager->SetNumberOfThreads(nthreads); 79 80 G4cout << "\n\n\tDICOM2 running with " << ru 81 << G4endl; 82 83 DicomDetectorConstruction* theGeometry = 0; 84 85 #ifdef G4_DCMTK 86 DicomFileMgr* theFileMgr = 0; 87 #else 88 DicomHandler* dcmHandler = 0; 89 #endif 90 91 if (!bPartial) { 92 #ifdef G4_DCMTK 93 G4String inpfile = "Data.dat"; 94 char* env_inpfile = std::getenv("DICOM_INP 95 if (env_inpfile) inpfile = env_inpfile; 96 97 theFileMgr = DicomFileMgr::GetInstance(); 98 theFileMgr->Convert(inpfile); 99 #else 100 // Treatment of DICOM images before creati 101 dcmHandler = DicomHandler::Instance(); 102 dcmHandler->CheckFileFormat(); 103 #endif 104 105 // Initialisation of physics, geometry, pr 106 char* nest = std::getenv("DICOM_NESTED_PAR 107 if (nest && G4String(nest) == "1") { 108 theGeometry = new DicomNestedParamDetect 109 } 110 else { 111 theGeometry = new DicomRegularDetectorCo 112 } 113 } 114 else { 115 theGeometry = new DicomPartialDetectorCons 116 } 117 runManager->SetUserInitialization(theGeometr 118 119 // std::vector<G4String>* MyConstr = new 120 // MyConstr->push_back("G4EmStandardPhysi 121 // G4VModularPhysicsList* phys = new G4Ge 122 G4VModularPhysicsList* phys = new Shielding( 123 phys->SetDefaultCutValue(0.5 * CLHEP::mm); 124 runManager->SetUserInitialization(phys); 125 126 // User action initialization 127 runManager->SetUserInitialization(new Dicom2 128 129 runManager->Initialize(); 130 131 new DicomIntersectVolume(); 132 133 // Initialize visualization 134 // 135 G4VisManager* visManager = new G4VisExecutiv 136 // G4VisExecutive can take a verbosity argum 137 // G4VisManager* visManager = new G4VisExecu 138 visManager->Initialize(); 139 140 // Get the pointer to the User Interface man 141 G4UImanager* UImanager = G4UImanager::GetUIp 142 143 G4Timer t; 144 t.Start(); 145 146 // Process macro or start UI session 147 // 148 if (!ui) { 149 // batch mode 150 G4String command = "/control/execute "; 151 G4String fileName = argv[1]; 152 UImanager->ApplyCommand(command + fileName 153 } 154 else { 155 // interactive mode 156 UImanager->ApplyCommand("/control/execute 157 ui->SessionStart(); 158 delete ui; 159 } 160 161 t.Stop(); 162 163 // Job termination 164 // Free the store: user actions, physics_lis 165 // owned and deleted by the run manager, so 166 // in the main() program ! 167 168 delete visManager; 169 delete runManager; 170 171 if (!bPartial) { 172 #ifdef G4_DCMTK 173 delete theFileMgr; 174 #endif 175 } 176 177 G4cout << "\n[" << argv[0] << "] Primary exe 178 } 179 180 //....oooOO0OOooo........oooOO0OOooo........oo 181