Loading...
Searching...
No Matches
dicom2.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27/// \file dicom2.cc
28/// \brief Main program of the Dicom2 example
29
30#include "G4Types.hh"
31#include "G4RunManagerFactory.hh"
32#include "G4UImanager.hh"
33#include "G4GenericPhysicsList.hh"
34#include "G4tgrMessenger.hh"
35#include "G4VisExecutive.hh"
36#include "G4UIExecutive.hh"
37#include "G4Timer.hh"
38#include "globals.hh"
39#include "Randomize.hh"
40#include "Shielding.hh"
41#include "QGSP_BIC.hh"
42#include "QBBC.hh"
43
49#ifdef G4_DCMTK
50# include "DicomFileMgr.hh"
51#else
52# include "DicomHandler.hh"
53#endif
54
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58int main(int argc,char** argv)
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}
184
185//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Definition of the Dicom2ActionInitialization class.
Definition of the DicomHandler class.
Definition of the DicomIntersectVolume class.
Definition of the DicomNestedParamDetectorConstruction class.
Definition of the DicomPartialDetectorConstruction class.
Definition of the DicomRegularDetectorConstruction class.
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.
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration