Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // >> 24 // $Id: Brachy.cc >> 25 // GEANT4 tag $Name: geant4-08-00 $ >> 26 // 26 // ------------------------------------------- 27 // -------------------------------------------------------------- 27 // GEANT 4 - Brachytherapy exa 28 // GEANT 4 - Brachytherapy example 28 // ------------------------------------------- 29 // -------------------------------------------------------------- 29 // 30 // 30 // Code developed currently by: << 31 // Code developed by: 31 // S.Guatelli & D. Cutajar << 32 // S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano, S.Guatelli 32 33 33 // 34 // 34 // ******************************* 35 // ******************************* 35 // * * 36 // * * 36 // * Brachy.cc * 37 // * Brachy.cc * 37 // * * 38 // * * 38 // ******************************* 39 // ******************************* 39 // 40 // >> 41 // Brachytherapy simulates the energy deposition in a cubic (30*cm) >> 42 // >> 43 // brachytherapy source. 40 // 44 // 41 #include "G4Types.hh" << 45 // Simplified gamma generation is used. 42 #include "G4RunManagerFactory.hh" << 46 // Source axis is oriented along Z axis. The source is in the centre >> 47 //of the box. >> 48 >> 49 //default source Ir-192 >> 50 >> 51 #include "G4RunManager.hh" 43 #include "G4UImanager.hh" 52 #include "G4UImanager.hh" 44 #include "G4UIExecutive.hh" << 53 #include "G4UIterminal.hh" 45 #include "BrachyActionInitialization.hh" << 54 #include "G4UItcsh.hh" >> 55 #include "BrachyFactoryIr.hh" >> 56 #ifdef G4UI_USE_XM >> 57 #include "G4UIXm.hh" >> 58 #endif >> 59 >> 60 #ifdef G4VIS_USE 46 #include "G4VisExecutive.hh" 61 #include "G4VisExecutive.hh" >> 62 #endif >> 63 >> 64 #include "BrachyEventAction.hh" 47 #include "BrachyDetectorConstruction.hh" 65 #include "BrachyDetectorConstruction.hh" 48 #include "BrachyPhysicsList.hh" 66 #include "BrachyPhysicsList.hh" 49 #include "BrachyPrimaryGeneratorAction.hh" << 67 #include "BrachyPhantomSD.hh" >> 68 #include "BrachyPrimaryGeneratorActionIr.hh" 50 #include "G4SDManager.hh" 69 #include "G4SDManager.hh" 51 #include "Randomize.hh" << 70 #include "BrachyRunAction.hh" >> 71 #include "Randomize.hh" 52 #include "G4RunManager.hh" 72 #include "G4RunManager.hh" 53 #include "G4SDManager.hh" 73 #include "G4SDManager.hh" 54 #include "G4UImanager.hh" 74 #include "G4UImanager.hh" 55 #include "G4UImessenger.hh" 75 #include "G4UImessenger.hh" 56 76 57 #include "G4ScoringManager.hh" << 77 #ifdef G4ANALYSIS_USE 58 #include "G4UIExecutive.hh" << 78 #include "BrachyAnalysisManager.hh" 59 << 79 #endif 60 #include "G4ScoringManager.hh" << 61 #include "BrachyUserScoreWriter.hh" << 62 80 63 int main(int argc ,char ** argv) 81 int main(int argc ,char ** argv) 64 82 65 { 83 { 66 // Construct the default run manager << 84 G4RunManager* pRunManager = new G4RunManager; 67 // << 68 auto* pRunManager = G4RunManagerFactory::Cre << 69 G4int nThreads = 4; << 70 pRunManager->SetNumberOfThreads(nThreads); << 71 << 72 G4cout << "***********************" << G4end << 73 G4cout << "*** Seed: " << G4Random::getTheSe << 74 G4cout << "***********************" << G4end << 75 << 76 // Access to the Scoring Manager pointer << 77 << 78 G4ScoringManager* scoringManager = G4Scoring << 79 << 80 // Overwrite the default output file with us << 81 scoringManager->SetScoreWriter(new BrachyUse << 82 << 83 // Initialize the physics component << 84 pRunManager -> SetUserInitialization(new Bra << 85 << 86 // Initialize the detector component << 87 auto pDetectorConstruction = new BrachyDete << 88 pRunManager -> SetUserInitialization(pDetect << 89 85 90 // User action initialization << 86 G4String sensitiveDetectorName = "Phantom"; 91 87 92 auto actions = new BrachyActionInitialization << 88 BrachyDetectorConstruction *pDetectorConstruction = new BrachyDetectorConstruction(sensitiveDetectorName); 93 pRunManager->SetUserInitialization(actions); << 94 89 95 //Initialize G4 kernel << 90 pRunManager->SetUserInitialization(pDetectorConstruction); 96 // pRunManager -> Initialize(); << 91 pRunManager->SetUserInitialization(new BrachyPhysicsList); 97 92 98 // Visualization manager << 93 #ifdef G4VIS_USE >> 94 // visualization manager 99 G4VisManager* visManager = new G4VisExecutiv 95 G4VisManager* visManager = new G4VisExecutive; 100 visManager->Initialize(); 96 visManager->Initialize(); 101 << 97 #endif 102 // get the pointer to the User Interface man << 98 103 G4UImanager* UImanager = G4UImanager::GetUIp << 99 // output environment variables: >> 100 #ifdef G4ANALYSIS_USE >> 101 G4cout << G4endl << G4endl << G4endl >> 102 << " User Environment " << G4endl >> 103 << " Using AIDA 3.2.1 analysis " << G4endl; >> 104 # else >> 105 G4cout << G4endl << G4endl << G4endl >> 106 << " User Environment " << G4endl >> 107 << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS " >> 108 << G4endl; >> 109 #endif >> 110 >> 111 G4UIsession* session = 0; 104 if (argc == 1) // Define UI session for in 112 if (argc == 1) // Define UI session for interactive mode. 105 { 113 { 106 auto ui = new G4UIExecutive(argc, argv); << 114 session = new G4UIterminal(); >> 115 } >> 116 >> 117 BrachyEventAction *pEventAction = new BrachyEventAction(); >> 118 pRunManager -> SetUserAction(pEventAction ); >> 119 >> 120 BrachyRunAction *pRunAction = new BrachyRunAction(); >> 121 pRunManager -> SetUserAction(pRunAction); >> 122 >> 123 //Initialize G4 kernel >> 124 pRunManager -> Initialize(); >> 125 >> 126 // get the pointer to the User Interface manager >> 127 G4UImanager* UI = G4UImanager::GetUIpointer(); >> 128 if (session) // Define UI session for interactive mode. >> 129 { 107 G4cout << " UI session starts ..." << G4 130 G4cout << " UI session starts ..." << G4endl; 108 UImanager -> ApplyCommand("/control/exec << 131 UI -> ApplyCommand("/control/execute VisualisationMacro.mac"); 109 ui -> SessionStart(); << 132 session -> SessionStart(); 110 delete ui; << 133 delete session; 111 } 134 } 112 else // Batch mode 135 else // Batch mode 113 { << 136 { 114 G4String command = "/control/execute "; 137 G4String command = "/control/execute "; 115 G4String fileName = argv[1]; 138 G4String fileName = argv[1]; 116 UImanager -> ApplyCommand(command+fileNa << 139 UI -> ApplyCommand(command+fileName); 117 } << 140 } 118 141 >> 142 #ifdef G4ANALYSIS_USE >> 143 BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance(); >> 144 analysis -> finish(); >> 145 #endif >> 146 119 // Job termination 147 // Job termination 120 // Close the root file << 148 #ifdef G4VIS_USE 121 << 122 delete visManager; 149 delete visManager; >> 150 #endif >> 151 123 delete pRunManager; 152 delete pRunManager; 124 153 125 return 0; 154 return 0; 126 } 155 } 127 156