LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
dicom2.cc File Reference

Main program of the Dicom2 example. More...

#include "G4Types.hh"
#include "G4RunManager.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

int main ( int  argc,
char **  argv 
)

Definition at line 62 of file dicom2.cc.

References part, and tca::seeds.

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