Warning, file /geant4/examples/advanced/hadrontherapy/hadrontherapy.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #include "G4RunManager.hh"
0062 #include "G4UImanager.hh"
0063 #include "G4PhysListFactory.hh"
0064 #include "G4VModularPhysicsList.hh"
0065 #include "HadrontherapyEventAction.hh"
0066 #include "HadrontherapyPhysicsList.hh"
0067 #include "HadrontherapyDetectorSD.hh"
0068 #include "HadrontherapyPrimaryGeneratorAction.hh"
0069 #include "HadrontherapyRunAction.hh"
0070 #include "HadrontherapyMatrix.hh"
0071 #include "Randomize.hh"
0072
0073 #include "G4UImessenger.hh"
0074 #include "globals.hh"
0075 #include "HadrontherapySteppingAction.hh"
0076 #include "HadrontherapyGeometryController.hh"
0077 #include "HadrontherapyGeometryMessenger.hh"
0078 #include "HadrontherapyInteractionParameters.hh"
0079 #include "HadrontherapyLet.hh"
0080
0081 #include "G4ScoringManager.hh"
0082 #include "G4ParallelWorldPhysics.hh"
0083 #include <time.h>
0084 #include "G4Timer.hh"
0085 #include "G4RunManagerFactory.hh"
0086 #include "HadrontherapyActionInitialization.hh"
0087
0088 #include "G4VisExecutive.hh"
0089 #include "G4UIExecutive.hh"
0090
0091 #include "QBBC.hh"
0092
0093
0094 int main(int argc ,char ** argv)
0095 {
0096
0097
0098 G4UIExecutive* ui = nullptr;
0099 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
0100
0101
0102
0103 G4Timer* theTimer = new G4Timer();
0104
0105 theTimer->Start();
0106
0107
0108
0109
0110 CLHEP::RanluxEngine defaultEngine( 1234567, 4 );
0111 G4Random::setTheEngine( &defaultEngine );
0112 G4int seed = (G4int) time( NULL );
0113 G4Random::setTheSeed( seed );
0114
0115
0116
0117 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0118
0119
0120 G4int nThreads = 4;
0121 runManager->SetNumberOfThreads(nThreads);
0122
0123
0124
0125 HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController();
0126
0127
0128
0129 HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
0130
0131 G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager();
0132 scoringManager->SetVerboseLevel(1);
0133
0134
0135 geometryController->SetGeometry("default");
0136
0137
0138 G4PhysListFactory factory;
0139 G4VModularPhysicsList* physicsList = 0;
0140 physicsList = new HadrontherapyPhysicsList();
0141
0142 if (physicsList)
0143 {
0144 G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
0145 physicsList -> RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
0146 }
0147
0148
0149 runManager->SetUserInitialization(physicsList);
0150
0151
0152 runManager->SetUserInitialization(new HadrontherapyActionInitialization);
0153
0154
0155 G4ScoringManager::GetScoringManager();
0156
0157
0158
0159 HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters(true);
0160
0161
0162
0163 HadrontherapyAnalysis* analysis = HadrontherapyAnalysis::GetInstance();
0164
0165
0166
0167
0168 auto visManager = new G4VisExecutive(argc, argv);
0169 visManager -> Initialize();
0170
0171
0172
0173 auto UImanager = G4UImanager::GetUIpointer();
0174
0175 if ( !ui ) {
0176
0177 G4String command = "/control/execute ";
0178 G4String fileName = argv[1];
0179 UImanager->ApplyCommand(command+fileName);
0180 }
0181
0182 else {
0183 UImanager -> ApplyCommand("/control/macroPath macro");
0184 UImanager -> ApplyCommand("/control/execute macro/defaultMacro.mac");
0185 ui -> SessionStart();
0186 delete ui;
0187 }
0188 delete visManager;
0189
0190
0191 theTimer->Stop();
0192
0193 G4cout << "The simulation took: " << theTimer->GetRealElapsed() << " s to run (real time)"
0194 << G4endl;
0195
0196
0197
0198
0199
0200
0201
0202 if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
0203 {
0204
0205 pMatrix -> StoreDoseFluenceAscii();
0206
0207 }
0208
0209 if (HadrontherapyLet *let = HadrontherapyLet::GetInstance())
0210 if(let -> doCalculation)
0211 {
0212 let -> LetOutput();
0213 let -> StoreLetAscii();
0214 }
0215
0216 delete geometryMessenger;
0217 delete geometryController;
0218 delete pInteraction;
0219 delete runManager;
0220 delete analysis;
0221 return 0;
0222
0223 }