LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DICOM.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 //
29 //
30 // The code was written by :
31 // *Louis Archambault louis.archambault@phy.ulaval.ca,
32 // *Luc Beaulieu beaulieu@phy.ulaval.ca
33 // +Vincent Hubert-Tremblay at tigre.2@sympatico.ca
34 //
35 //
36 // *Centre Hospitalier Universitaire de Quebec (CHUQ),
37 // Hotel-Dieu de Quebec, departement de Radio-oncologie
38 // 11 cote du palais. Quebec, QC, Canada, G1R 2J6
39 // tel (418) 525-4444 #6720
40 // fax (418) 691 5268
41 //
42 // + Universit� Laval, Qu�bec (QC) Canada
43 // *******************************************************
44 #include "G4Types.hh"
45 
46 #ifdef G4MULTITHREADED
47 #include "G4MTRunManager.hh"
48 #else
49 #include "G4RunManager.hh"
50 #endif
51 
52 #include "globals.hh"
53 #include "G4UImanager.hh"
54 #include "Randomize.hh"
55 
56 #include "G4GenericPhysicsList.hh"
57 
58 #include "DicomRegularDetectorConstruction.hh"
59 #include "DicomNestedParamDetectorConstruction.hh"
60 #include "DicomPartialDetectorConstruction.hh"
61 
62 #include "DicomActionInitialization.hh"
63 
64 #ifdef G4_DCMTK
65 # include "DicomFileMgr.hh"
66 #else
67 # include "DicomHandler.hh"
68 #endif
69 
70 #include "DicomIntersectVolume.hh"
71 #include "QGSP_BIC.hh"
72 #include "G4tgrMessenger.hh"
73 
74 #include "G4VisExecutive.hh"
75 #include "G4UIExecutive.hh"
76 
77 #include "Shielding.hh"
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
81 int main(int argc,char** argv)
82 {
83  // Instantiate G4UIExecutive if interactive mode
84  G4UIExecutive* ui = nullptr;
85  if ( argc == 1 ) {
86  ui = new G4UIExecutive(argc, argv);
87  }
88 
89  new G4tgrMessenger;
90  char* part = std::getenv( "DICOM_PARTIAL_PARAM" );
91  G4bool bPartial = FALSE;
92  if( part && G4String(part) == "1" ) {
93  bPartial = TRUE;
94  }
95 
96  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
97  CLHEP::HepRandom::setTheSeed(G4long(24534575684783));
98  G4long seeds[2];
99  seeds[0] = G4long(534524575674523);
100  seeds[1] = G4long(526345623452457);
101  CLHEP::HepRandom::setTheSeeds(seeds);
102 
103  // Construct the default run manager
104 #ifdef G4MULTITHREADED
105  char* nthread_c = std::getenv("DICOM_NTHREADS");
106 
107  unsigned nthreads = 4;
108  unsigned env_threads = 0;
109 
110  if(nthread_c) {env_threads=unsigned(G4UIcommand::ConvertToDouble(nthread_c));}
111  if(env_threads > 0) {nthreads=env_threads;}
112 
113  G4MTRunManager* runManager = new G4MTRunManager;
114  runManager->SetNumberOfThreads(nthreads);
115 
116  G4cout << "\n\n\tDICOM running in multithreaded mode with " << nthreads
117  << " threads\n\n" << G4endl;
118 
119 
120 #else
121  G4RunManager* runManager = new G4RunManager;
122  G4cout << "\n\n\tDICOM running in serial mode\n\n" << G4endl;
123 
124 #endif
125 
126  DicomDetectorConstruction* theGeometry = 0;
127 
128 #ifdef G4_DCMTK
129  DicomFileMgr* theFileMgr = 0;
130 #else
131  DicomHandler* dcmHandler = 0;
132 #endif
133 
134  if( !bPartial ){
135 #ifdef G4_DCMTK
136 
137  theFileMgr = DicomFileMgr::GetInstance();
138  theFileMgr->Convert("Data.dat");
139 
140 #else
141  // Treatment of DICOM images before creating the G4runManager
142  dcmHandler = DicomHandler::Instance();
143  dcmHandler->CheckFileFormat();
144 #endif
145 
146  // Initialisation of physics, geometry, primary particles ...
147  char* nest = std::getenv( "DICOM_NESTED_PARAM" );
148  if( nest && G4String(nest) == "1" ) {
149  theGeometry = new DicomNestedParamDetectorConstruction();
150  } else {
151  theGeometry = new DicomRegularDetectorConstruction();
152  }
153  } else {
154  theGeometry = new DicomPartialDetectorConstruction();
155  }
156  runManager->SetUserInitialization(theGeometry);
157 
158  // std::vector<G4String>* MyConstr = new std::vector<G4String>;
159  // MyConstr->push_back("G4EmStandardPhysics");
160  // G4VModularPhysicsList* phys = new G4GenericPhysicsList(MyConstr);
161  G4VModularPhysicsList* phys = new Shielding();
162  runManager->SetUserInitialization(phys);
163 
164  // Set user action classes
165  runManager->SetUserInitialization(new DicomActionInitialization());
166 
167  runManager->Initialize();
168 
169  new DicomIntersectVolume();
170 
171  // visualisation manager
172  G4VisManager* visManager = new G4VisExecutive;
173  visManager->Initialize();
174 
175  G4UImanager* UImanager = G4UImanager::GetUIpointer();
176 
177  if (ui)
178  {
179  UImanager->ApplyCommand("/control/execute vis.mac");
180  ui->SessionStart();
181  delete ui;
182  }
183  else
184  {
185  G4String command = "/control/execute ";
186  G4String fileName = argv[1];
187  UImanager->ApplyCommand(command+fileName);
188  }
189 
190  delete visManager;
191  delete runManager;
192 
193  if( !bPartial ) {
194 #ifdef G4_DCMTK
195  delete theFileMgr;
196 #endif
197  }
198 
199  return 0;
200 }
201 
TString part[npart]
Definition: Style.C:32
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:14
int main(int argc, char **argv)
Definition: DICOM.cc:81