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

Main program of the Dicom2 example. More...

#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4GenericPhysicsList.hh"
#include "G4tgrMessenger.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4Timer.hh"
#include "globals.hh"
#include "Randomize.hh"
#include "Shielding.hh"
#include "QGSP_BIC.hh"
#include "QBBC.hh"
#include "DicomRegularDetectorConstruction.hh"
#include "DicomNestedParamDetectorConstruction.hh"
#include "DicomPartialDetectorConstruction.hh"
#include "Dicom2ActionInitialization.hh"
#include "DicomIntersectVolume.hh"
#include "DicomHandler.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the Dicom2 example.

Definition in file dicom2.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 58 of file dicom2.cc.

59{
60 // Detect interactive mode (if no arguments) and define UI session
61 //
62 G4UIExecutive* ui = 0;
63 if (argc == 1)
64 ui = new G4UIExecutive(argc, argv);
65
67 char* part = std::getenv("DICOM_PARTIAL_PARAM");
68 G4bool bPartial = (part && G4String(part) == "1") ? true : false;
69
70 CLHEP::HepRandom::setTheEngine(new CLHEP::MixMaxRng);
71 CLHEP::HepRandom::setTheSeed(G4long(24534575684783));
72 G4long seeds[2];
73 seeds[0] = G4long(534524575674523);
74 seeds[1] = G4long(526345623452457);
75 CLHEP::HepRandom::setTheSeeds(seeds);
76
77 // Construct the default run manager
78 G4int nthreads = G4GetEnv<G4int>("DICOM_NTHREADS", G4Thread::hardware_concurrency());
79 auto* runManager = G4RunManagerFactory::CreateRunManager();
80 runManager->SetNumberOfThreads(nthreads);
81
82 G4cout << "\n\n\tDICOM2 running with "
83 << runManager->GetNumberOfThreads()
84 << " threads\n\n" << G4endl;
85
86 DicomDetectorConstruction* theGeometry = 0;
87
88#ifdef G4_DCMTK
89 DicomFileMgr* theFileMgr = 0;
90#else
91 DicomHandler* dcmHandler = 0;
92#endif
93
94 if( !bPartial )
95 {
96#ifdef G4_DCMTK
97 G4String inpfile = "Data.dat";
98 char* env_inpfile = std::getenv("DICOM_INPUT_FILE");
99 if(env_inpfile)
100 inpfile = env_inpfile;
101
102 theFileMgr = DicomFileMgr::GetInstance();
103 theFileMgr->Convert(inpfile);
104#else
105 // Treatment of DICOM images before creating the G4runManager
106 dcmHandler = DicomHandler::Instance();
107 dcmHandler->CheckFileFormat();
108#endif
109
110 // Initialisation of physics, geometry, primary particles ...
111 char* nest = std::getenv( "DICOM_NESTED_PARAM" );
112 if( nest && G4String(nest) == "1" ) {
113 theGeometry = new DicomNestedParamDetectorConstruction();
114 } else {
115 theGeometry = new DicomRegularDetectorConstruction();
116 }
117 } else {
118 theGeometry = new DicomPartialDetectorConstruction();
119 }
120 runManager->SetUserInitialization(theGeometry);
121
122 // std::vector<G4String>* MyConstr = new std::vector<G4String>;
123 // MyConstr->push_back("G4EmStandardPhysics");
124 // G4VModularPhysicsList* phys = new G4GenericPhysicsList(MyConstr);
125 G4VModularPhysicsList* phys = new Shielding();
126 phys->SetDefaultCutValue(0.5*CLHEP::mm);
127 runManager->SetUserInitialization(phys);
128
129 // User action initialization
130 runManager->SetUserInitialization(new Dicom2ActionInitialization());
131
132 runManager->Initialize();
133
135
136 // Initialize visualization
137 //
138 G4VisManager* visManager = new G4VisExecutive;
139 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
140 // G4VisManager* visManager = new G4VisExecutive("Quiet");
141 visManager->Initialize();
142
143 // Get the pointer to the User Interface manager
144 G4UImanager* UImanager = G4UImanager::GetUIpointer();
145
146 G4Timer t;
147 t.Start();
148
149 // Process macro or start UI session
150 //
151 if ( ! ui ) {
152 // batch mode
153 G4String command = "/control/execute ";
154 G4String fileName = argv[1];
155 UImanager->ApplyCommand(command+fileName);
156 }
157 else {
158 // interactive mode
159 UImanager->ApplyCommand("/control/execute vis.mac");
160 ui->SessionStart();
161 delete ui;
162 }
163
164 t.Stop();
165
166 // Job termination
167 // Free the store: user actions, physics_list and detector_description are
168 // owned and deleted by the run manager, so they should not be deleted
169 // in the main() program !
170
171 delete visManager;
172 delete runManager;
173
174 if( !bPartial )
175 {
176#ifdef G4_DCMTK
177 delete theFileMgr;
178#endif
179 }
180
181 G4cout << "\n[" << argv[0] << "] Primary execution time: " << t << "\n"
182 << G4endl;
183}
Action initialization class.
static DicomFileMgr * GetInstance()
void Convert(G4String fFileName)
static DicomHandler * Instance()
void CheckFileFormat()
Manages intersections of DICOM files with volumes.
Construct the phantom using DicomPhantomParameterisationColour.
Construct a DICOM Geant4 geometry produced from the intersetion of a DICOM file and a volume.
DicomRegularDetectorConstruction class.

Applications | User Support | Publications | Collaboration