File indexing completed on 2025-02-23 09:21:46
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
0038
0039
0040
0041
0042
0043
0044 #include "DicomActionInitialization.hh"
0045 #include "DicomNestedParamDetectorConstruction.hh"
0046 #include "DicomPartialDetectorConstruction.hh"
0047 #include "DicomRegularDetectorConstruction.hh"
0048
0049 #include "G4GenericPhysicsList.hh"
0050 #include "G4RunManagerFactory.hh"
0051 #include "G4Types.hh"
0052 #include "G4UImanager.hh"
0053 #include "Randomize.hh"
0054 #include "globals.hh"
0055
0056 #ifdef G4_DCMTK
0057 # include "DicomFileMgr.hh"
0058 #else
0059 # include "DicomHandler.hh"
0060 #endif
0061
0062 #include "DicomIntersectVolume.hh"
0063 #include "QGSP_BIC.hh"
0064 #include "Shielding.hh"
0065
0066 #include "G4UIExecutive.hh"
0067 #include "G4VisExecutive.hh"
0068 #include "G4tgrMessenger.hh"
0069
0070
0071
0072 int main(int argc, char** argv)
0073 {
0074
0075 G4UIExecutive* ui = nullptr;
0076 if (argc == 1) {
0077 ui = new G4UIExecutive(argc, argv);
0078 }
0079
0080 new G4tgrMessenger;
0081 char* part = std::getenv("DICOM_PARTIAL_PARAM");
0082 G4bool bPartial = FALSE;
0083 if (part && G4String(part) == "1") {
0084 bPartial = TRUE;
0085 }
0086
0087 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
0088 CLHEP::HepRandom::setTheSeed(G4long(24534575684783));
0089 G4long seeds[2];
0090 seeds[0] = G4long(534524575674523);
0091 seeds[1] = G4long(526345623452457);
0092 CLHEP::HepRandom::setTheSeeds(seeds);
0093
0094
0095 char* nthread_c = std::getenv("DICOM_NTHREADS");
0096
0097 unsigned nthreads = 4;
0098 unsigned env_threads = 0;
0099
0100 if (nthread_c) {
0101 env_threads = unsigned(G4UIcommand::ConvertToDouble(nthread_c));
0102 }
0103 if (env_threads > 0) {
0104 nthreads = env_threads;
0105 }
0106
0107 auto* runManager = G4RunManagerFactory::CreateRunManager();
0108 runManager->SetNumberOfThreads(nthreads);
0109
0110 DicomDetectorConstruction* theGeometry = 0;
0111
0112 #ifdef G4_DCMTK
0113 DicomFileMgr* theFileMgr = 0;
0114 #else
0115 DicomHandler* dcmHandler = 0;
0116 #endif
0117
0118 if (!bPartial) {
0119 #ifdef G4_DCMTK
0120
0121 theFileMgr = DicomFileMgr::GetInstance();
0122 theFileMgr->Convert("Data.dat");
0123
0124 #else
0125
0126 dcmHandler = DicomHandler::Instance();
0127 dcmHandler->CheckFileFormat();
0128 #endif
0129
0130
0131 char* nest = std::getenv("DICOM_NESTED_PARAM");
0132 if (nest && G4String(nest) == "1") {
0133 theGeometry = new DicomNestedParamDetectorConstruction();
0134 }
0135 else {
0136 theGeometry = new DicomRegularDetectorConstruction();
0137 }
0138 }
0139 else {
0140 theGeometry = new DicomPartialDetectorConstruction();
0141 }
0142 runManager->SetUserInitialization(theGeometry);
0143
0144
0145
0146
0147 G4VModularPhysicsList* phys = new Shielding();
0148 runManager->SetUserInitialization(phys);
0149
0150
0151 runManager->SetUserInitialization(new DicomActionInitialization());
0152
0153 runManager->Initialize();
0154
0155 new DicomIntersectVolume();
0156
0157
0158 G4VisManager* visManager = new G4VisExecutive;
0159 visManager->Initialize();
0160
0161 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0162
0163 if (ui) {
0164 UImanager->ApplyCommand("/control/execute vis.mac");
0165 ui->SessionStart();
0166 delete ui;
0167 }
0168 else {
0169 G4String command = "/control/execute ";
0170 G4String fileName = argv[1];
0171 UImanager->ApplyCommand(command + fileName);
0172 }
0173
0174 delete visManager;
0175 delete runManager;
0176
0177 if (!bPartial) {
0178 #ifdef G4_DCMTK
0179 delete theFileMgr;
0180 #endif
0181 }
0182
0183 return 0;
0184 }