File indexing completed on 2025-01-30 09:20:09
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
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 #include "G4RunManager.hh"
0067 #include "G4UImanager.hh"
0068 #include "G4PhysListFactory.hh"
0069 #include "G4VModularPhysicsList.hh"
0070 #include "HadrontherapyEventAction.hh"
0071 #include "HadrontherapyPhysicsList.hh"
0072 #include "HadrontherapyDetectorSD.hh"
0073 #include "HadrontherapyPrimaryGeneratorAction.hh"
0074 #include "HadrontherapyRunAction.hh"
0075 #include "HadrontherapyMatrix.hh"
0076 #include "Randomize.hh"
0077
0078 #include "G4UImessenger.hh"
0079 #include "globals.hh"
0080 #include "HadrontherapySteppingAction.hh"
0081 #include "HadrontherapyGeometryController.hh"
0082 #include "HadrontherapyGeometryMessenger.hh"
0083 #include "HadrontherapyInteractionParameters.hh"
0084 #include "HadrontherapyLet.hh"
0085
0086 #include "G4ScoringManager.hh"
0087 #include "G4ParallelWorldPhysics.hh"
0088 #include <time.h>
0089 #include "G4Timer.hh"
0090 #include "G4RunManagerFactory.hh"
0091 #include "HadrontherapyActionInitialization.hh"
0092
0093 #include "G4VisExecutive.hh"
0094 #include "G4UIExecutive.hh"
0095
0096
0097 int main(int argc ,char ** argv)
0098 {
0099 G4UIExecutive* ui = 0;
0100 if ( argc == 1 ) {
0101 ui = new G4UIExecutive(argc, argv);
0102 }
0103
0104
0105
0106 G4Timer* theTimer = new G4Timer();
0107
0108 theTimer->Start();
0109
0110
0111
0112
0113 CLHEP::RanluxEngine defaultEngine( 1234567, 4 );
0114 G4Random::setTheEngine( &defaultEngine );
0115 G4int seed = (G4int) time( NULL );
0116 G4Random::setTheSeed( seed );
0117
0118 auto* runManager = G4RunManagerFactory::CreateRunManager();
0119 G4int nThreads = 4;
0120 runManager->SetNumberOfThreads(nThreads);
0121
0122
0123
0124
0125 HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController();
0126
0127
0128 HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
0129
0130 G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager();
0131 scoringManager->SetVerboseLevel(1);
0132
0133
0134 geometryController->SetGeometry("default");
0135
0136
0137 G4PhysListFactory factory;
0138 G4VModularPhysicsList* phys = 0;
0139 G4String physName = "";
0140
0141
0142 char* path = std::getenv("PHYSLIST");
0143 if (path) { physName = G4String(path); }
0144
0145 if(physName != "" && factory.IsReferencePhysList(physName))
0146 {
0147 phys = factory.GetReferencePhysList(physName);
0148 }
0149 if (phys)
0150 {
0151 G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
0152 phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
0153 }
0154 else
0155 {
0156 G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
0157 phys = new HadrontherapyPhysicsList();
0158 }
0159
0160
0161 runManager->SetUserInitialization(phys);
0162
0163
0164 runManager->SetUserInitialization(new HadrontherapyActionInitialization);
0165
0166
0167 G4ScoringManager::GetScoringManager();
0168
0169
0170 HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters(true);
0171
0172
0173 HadrontherapyAnalysis* analysis = HadrontherapyAnalysis::GetInstance();
0174
0175
0176
0177
0178 G4VisManager* visManager = new G4VisExecutive;
0179 visManager -> Initialize();
0180
0181
0182 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0183
0184 if ( !ui ) {
0185
0186 G4String command = "/control/execute ";
0187 G4String fileName = argv[1];
0188 UImanager->ApplyCommand(command+fileName);
0189
0190 }
0191
0192 else {
0193
0194 UImanager -> ApplyCommand("/control/execute macro/defaultMacro.mac");
0195 ui -> SessionStart();
0196 delete ui;
0197 }
0198 delete visManager;
0199
0200
0201 theTimer->Stop();
0202
0203 G4cout << "The simulation took: " << theTimer->GetRealElapsed() << " s to run (real time)"
0204 << G4endl;
0205
0206
0207
0208
0209
0210
0211
0212 if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
0213 {
0214
0215 pMatrix -> StoreDoseFluenceAscii();
0216
0217 }
0218
0219 if (HadrontherapyLet *let = HadrontherapyLet::GetInstance())
0220 if(let -> doCalculation)
0221 {
0222 let -> LetOutput();
0223 let -> StoreLetAscii();
0224 }
0225
0226 delete geometryMessenger;
0227 delete geometryController;
0228 delete pInteraction;
0229 delete runManager;
0230 delete analysis;
0231 return 0;
0232
0233 }