Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // Please cite the following paper if you use << 26 // ------------------------------------------------------------------- 27 // Nucl.Instrum.Meth.B260:20-27, 2007 << 27 // $Id: Nanobeam.cc,v 1.8 2010-10-09 16:30:27 sincerti Exp $ 28 << 28 // ------------------------------------------------------------------- 29 #include "G4Types.hh" << 30 #include "G4RunManagerFactory.hh" << 31 29 >> 30 #include "G4RunManager.hh" 32 #include "G4UImanager.hh" 31 #include "G4UImanager.hh" >> 32 #include "Randomize.hh" >> 33 >> 34 #ifdef G4UI_USE >> 35 #include "G4UIExecutive.hh" >> 36 #endif 33 37 34 #include "ActionInitialization.hh" << 35 #include "DetectorConstruction.hh" 38 #include "DetectorConstruction.hh" 36 #include "PhysicsList.hh" 39 #include "PhysicsList.hh" 37 << 40 #include "PrimaryGeneratorAction.hh" 38 int main(int argc,char** argv) << 41 #include "RunAction.hh" 39 { << 42 #include "EventAction.hh" >> 43 #include "TrackingAction.hh" >> 44 #include "SteppingAction.hh" >> 45 #include "SteppingVerbose.hh" >> 46 #include "HistoManager.hh" >> 47 >> 48 int main(int argc,char** argv) { >> 49 >> 50 // Choose the Random engine >> 51 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 52 >> 53 // Verbose output class >> 54 G4VSteppingVerbose::SetInstance(new SteppingVerbose); >> 55 40 // Construct the default run manager 56 // Construct the default run manager 41 << 57 G4RunManager * runManager = new G4RunManager; 42 auto* runManager = G4RunManagerFactory::Crea << 43 G4int nThreads = 1; << 44 runManager->SetNumberOfThreads(nThreads); << 45 << 46 // Use only one thread for aberration coeffi << 47 // << 48 // For high statistics (no aberration coeffi << 49 // switch to more threads << 50 58 51 // Set mandatory initialization classes 59 // Set mandatory initialization classes 52 << 53 DetectorConstruction* detector = new Detecto 60 DetectorConstruction* detector = new DetectorConstruction; 54 << 55 runManager->SetUserInitialization(detector); 61 runManager->SetUserInitialization(detector); 56 << 57 runManager->SetUserInitialization(new Physic 62 runManager->SetUserInitialization(new PhysicsList); 58 << 63 59 // User action initialization << 64 PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector); 60 << 65 runManager->SetUserAction(primary); 61 runManager->SetUserInitialization(new Action << 66 62 << 67 HistoManager* histo = new HistoManager(); >> 68 >> 69 // Set user action classes >> 70 RunAction* RunAct = new RunAction(detector,primary,histo); >> 71 >> 72 runManager->SetUserAction(RunAct); >> 73 runManager->SetUserAction(new EventAction(RunAct)); >> 74 runManager->SetUserAction(new TrackingAction(RunAct)); >> 75 runManager->SetUserAction(new SteppingAction(RunAct,detector,primary,histo)); >> 76 63 // Initialize G4 kernel 77 // Initialize G4 kernel 64 << 65 runManager->Initialize(); 78 runManager->Initialize(); >> 79 >> 80 // Get the pointer to the User Interface manager >> 81 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 66 82 67 // Get the pointer to the User Interface man << 83 // 68 << 84 remove ("nanobeam.root"); 69 G4UImanager* UImanager = G4UImanager::GetUIp << 85 70 << 71 if (argc==1) // Define UI session for inte 86 if (argc==1) // Define UI session for interactive mode. 72 { << 87 { 73 UImanager->ApplyCommand("/control/execute << 88 #ifdef G4UI_USE >> 89 G4UIExecutive* ui = new G4UIExecutive(argc, argv); >> 90 UImanager->ApplyCommand("/control/execute default.mac"); >> 91 ui->SessionStart(); >> 92 delete ui; >> 93 #endif 74 } 94 } >> 95 75 else // Batch mode 96 else // Batch mode 76 { << 97 { 77 G4String command = "/control/execute "; 98 G4String command = "/control/execute "; 78 G4String fileName = argv[1]; 99 G4String fileName = argv[1]; 79 UImanager->ApplyCommand(command+fileName); 100 UImanager->ApplyCommand(command+fileName); 80 } 101 } 81 << 82 // << 83 102 84 delete runManager; 103 delete runManager; 85 104 86 return 0; 105 return 0; 87 } 106 } 88 107