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 #include "Dicom2ActionInitialization.hh"
0031 #include "DicomIntersectVolume.hh"
0032 #include "DicomNestedParamDetectorConstruction.hh"
0033 #include "DicomPartialDetectorConstruction.hh"
0034 #include "DicomRegularDetectorConstruction.hh"
0035 #include "QBBC.hh"
0036 #include "QGSP_BIC.hh"
0037 #include "Shielding.hh"
0038
0039 #include "G4GenericPhysicsList.hh"
0040 #include "G4RunManagerFactory.hh"
0041 #include "G4Timer.hh"
0042 #include "G4Types.hh"
0043 #include "G4UIExecutive.hh"
0044 #include "G4UImanager.hh"
0045 #include "G4VisExecutive.hh"
0046 #include "G4tgrMessenger.hh"
0047 #include "Randomize.hh"
0048 #include "globals.hh"
0049 #ifdef G4_DCMTK
0050 # include "DicomFileMgr.hh"
0051 #else
0052 # include "DicomHandler.hh"
0053 #endif
0054
0055
0056
0057 int main(int argc, char** argv)
0058 {
0059
0060
0061 G4UIExecutive* ui = 0;
0062 if (argc == 1) ui = new G4UIExecutive(argc, argv);
0063
0064 new G4tgrMessenger;
0065 char* part = std::getenv("DICOM_PARTIAL_PARAM");
0066 G4bool bPartial = (part && G4String(part) == "1") ? true : false;
0067
0068 CLHEP::HepRandom::setTheEngine(new CLHEP::MixMaxRng);
0069 CLHEP::HepRandom::setTheSeed(G4long(24534575684783));
0070 G4long seeds[2];
0071 seeds[0] = G4long(534524575674523);
0072 seeds[1] = G4long(526345623452457);
0073 CLHEP::HepRandom::setTheSeeds(seeds);
0074
0075
0076 G4int nthreads = G4GetEnv<G4int>("DICOM_NTHREADS", G4Thread::hardware_concurrency());
0077 auto* runManager = G4RunManagerFactory::CreateRunManager();
0078 runManager->SetNumberOfThreads(nthreads);
0079
0080 G4cout << "\n\n\tDICOM2 running with " << runManager->GetNumberOfThreads() << " threads\n\n"
0081 << G4endl;
0082
0083 DicomDetectorConstruction* theGeometry = 0;
0084
0085 #ifdef G4_DCMTK
0086 DicomFileMgr* theFileMgr = 0;
0087 #else
0088 DicomHandler* dcmHandler = 0;
0089 #endif
0090
0091 if (!bPartial) {
0092 #ifdef G4_DCMTK
0093 G4String inpfile = "Data.dat";
0094 char* env_inpfile = std::getenv("DICOM_INPUT_FILE");
0095 if (env_inpfile) inpfile = env_inpfile;
0096
0097 theFileMgr = DicomFileMgr::GetInstance();
0098 theFileMgr->Convert(inpfile);
0099 #else
0100
0101 dcmHandler = DicomHandler::Instance();
0102 dcmHandler->CheckFileFormat();
0103 #endif
0104
0105
0106 char* nest = std::getenv("DICOM_NESTED_PARAM");
0107 if (nest && G4String(nest) == "1") {
0108 theGeometry = new DicomNestedParamDetectorConstruction();
0109 }
0110 else {
0111 theGeometry = new DicomRegularDetectorConstruction();
0112 }
0113 }
0114 else {
0115 theGeometry = new DicomPartialDetectorConstruction();
0116 }
0117 runManager->SetUserInitialization(theGeometry);
0118
0119
0120
0121
0122 G4VModularPhysicsList* phys = new Shielding();
0123 phys->SetDefaultCutValue(0.5 * CLHEP::mm);
0124 runManager->SetUserInitialization(phys);
0125
0126
0127 runManager->SetUserInitialization(new Dicom2ActionInitialization());
0128
0129 runManager->Initialize();
0130
0131 new DicomIntersectVolume();
0132
0133
0134
0135 G4VisManager* visManager = new G4VisExecutive;
0136
0137
0138 visManager->Initialize();
0139
0140
0141 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0142
0143 G4Timer t;
0144 t.Start();
0145
0146
0147
0148 if (!ui) {
0149
0150 G4String command = "/control/execute ";
0151 G4String fileName = argv[1];
0152 UImanager->ApplyCommand(command + fileName);
0153 }
0154 else {
0155
0156 UImanager->ApplyCommand("/control/execute vis.mac");
0157 ui->SessionStart();
0158 delete ui;
0159 }
0160
0161 t.Stop();
0162
0163
0164
0165
0166
0167
0168 delete visManager;
0169 delete runManager;
0170
0171 if (!bPartial) {
0172 #ifdef G4_DCMTK
0173 delete theFileMgr;
0174 #endif
0175 }
0176
0177 G4cout << "\n[" << argv[0] << "] Primary execution time: " << t << "\n" << G4endl;
0178 }
0179
0180