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 /// \file eventgenerator/HepMC/HepMCEx01/HepMC 26 /// \file eventgenerator/HepMC/HepMCEx01/HepMCEx01.cc 27 /// \brief Main program of the eventgenerator/ 27 /// \brief Main program of the eventgenerator/HepMC/HepMCEx01 example 28 // 28 // 29 // 29 // 30 // ------------------------------------------- 30 // -------------------------------------------------------------- 31 // GEANT 4 - example derived from novice 31 // GEANT 4 - example derived from novice exampleN04 32 // ------------------------------------------- 32 // -------------------------------------------------------------- 33 33 >> 34 #include "G4Types.hh" >> 35 >> 36 #include "FTFP_BERT.hh" >> 37 #include "G4RunManager.hh" >> 38 #include "G4UImanager.hh" >> 39 34 #include "ExN04DetectorConstruction.hh" 40 #include "ExN04DetectorConstruction.hh" 35 #include "ExN04EventAction.hh" 41 #include "ExN04EventAction.hh" 36 #include "ExN04PrimaryGeneratorAction.hh" 42 #include "ExN04PrimaryGeneratorAction.hh" 37 #include "ExN04RunAction.hh" 43 #include "ExN04RunAction.hh" 38 #include "ExN04StackingAction.hh" 44 #include "ExN04StackingAction.hh" 39 #include "ExN04SteppingAction.hh" 45 #include "ExN04SteppingAction.hh" 40 #include "ExN04SteppingVerbose.hh" 46 #include "ExN04SteppingVerbose.hh" 41 #include "ExN04TrackingAction.hh" 47 #include "ExN04TrackingAction.hh" 42 #include "FTFP_BERT.hh" << 43 48 44 #include "G4RunManagerFactory.hh" << 45 #include "G4Types.hh" << 46 #include "G4UIExecutive.hh" << 47 #include "G4UImanager.hh" << 48 #include "G4VisExecutive.hh" 49 #include "G4VisExecutive.hh" >> 50 #include "G4UIExecutive.hh" 49 51 50 int main(int argc, char** argv) << 52 int main(int argc,char** argv) 51 { 53 { 52 // Instantiate G4UIExecutive if there are no 54 // Instantiate G4UIExecutive if there are no arguments (interactive mode) 53 G4UIExecutive* ui = nullptr; 55 G4UIExecutive* ui = nullptr; 54 if (argc == 1) { << 56 if ( argc == 1 ) { 55 ui = new G4UIExecutive(argc, argv); 57 ui = new G4UIExecutive(argc, argv); 56 } 58 } 57 59 58 // User Verbose output class 60 // User Verbose output class 59 // 61 // 60 G4VSteppingVerbose* verbosity = new ExN04Ste 62 G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose; 61 G4VSteppingVerbose::SetInstance(verbosity); 63 G4VSteppingVerbose::SetInstance(verbosity); 62 64 63 // Serial only Run manager << 65 // Run manager 64 // 66 // 65 auto* runManager = G4RunManagerFactory::Crea << 67 G4RunManager* runManager = new G4RunManager; 66 68 67 // User Initialization classes (mandatory) 69 // User Initialization classes (mandatory) 68 // 70 // 69 G4VUserDetectorConstruction* detector = new 71 G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction; 70 runManager->SetUserInitialization(detector); 72 runManager->SetUserInitialization(detector); 71 // 73 // 72 G4VUserPhysicsList* physics = new FTFP_BERT; 74 G4VUserPhysicsList* physics = new FTFP_BERT; 73 runManager->SetUserInitialization(physics); 75 runManager->SetUserInitialization(physics); 74 76 75 runManager->Initialize(); 77 runManager->Initialize(); 76 78 77 // User Action classes 79 // User Action classes 78 // 80 // 79 G4VUserPrimaryGeneratorAction* gen_action = 81 G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction; 80 runManager->SetUserAction(gen_action); 82 runManager->SetUserAction(gen_action); 81 // 83 // 82 G4UserRunAction* run_action = new ExN04RunAc 84 G4UserRunAction* run_action = new ExN04RunAction; 83 runManager->SetUserAction(run_action); 85 runManager->SetUserAction(run_action); 84 // 86 // 85 G4UserEventAction* event_action = new ExN04E 87 G4UserEventAction* event_action = new ExN04EventAction; 86 runManager->SetUserAction(event_action); 88 runManager->SetUserAction(event_action); 87 // 89 // 88 G4UserStackingAction* stacking_action = new 90 G4UserStackingAction* stacking_action = new ExN04StackingAction; 89 runManager->SetUserAction(stacking_action); 91 runManager->SetUserAction(stacking_action); 90 // 92 // 91 G4UserTrackingAction* tracking_action = new 93 G4UserTrackingAction* tracking_action = new ExN04TrackingAction; 92 runManager->SetUserAction(tracking_action); 94 runManager->SetUserAction(tracking_action); 93 // 95 // 94 G4UserSteppingAction* stepping_action = new 96 G4UserSteppingAction* stepping_action = new ExN04SteppingAction; 95 runManager->SetUserAction(stepping_action); 97 runManager->SetUserAction(stepping_action); 96 98 97 G4VisManager* visManager = new G4VisExecutiv 99 G4VisManager* visManager = new G4VisExecutive; 98 visManager->Initialize(); 100 visManager->Initialize(); 99 101 100 // get the pointer to the User Interface man << 102 //get the pointer to the User Interface manager 101 G4UImanager* UImanager = G4UImanager::GetUIp 103 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 102 104 103 if (!ui) // batch mode << 105 if (!ui) // batch mode 104 { << 106 { 105 visManager->SetVerboseLevel("quiet"); << 107 visManager->SetVerboseLevel("quiet"); 106 G4String command = "/control/execute "; << 108 G4String command = "/control/execute "; 107 G4String fileName = argv[1]; << 109 G4String fileName = argv[1]; 108 UImanager->ApplyCommand(command + fileName << 110 UImanager->ApplyCommand(command+fileName); 109 } << 111 } 110 else { // interactive mode : define UI sess << 112 else 111 ui->SessionStart(); << 113 { // interactive mode : define UI session 112 delete ui; << 114 ui->SessionStart(); 113 } << 115 delete ui; >> 116 } 114 117 115 // Free the store: user actions, physics_lis 118 // Free the store: user actions, physics_list and detector_description are 116 // owned and deleted by the 119 // owned and deleted by the run manager, so they should not 117 // be deleted in the main() 120 // be deleted in the main() program ! 118 121 119 delete verbosity; << 120 delete visManager; 122 delete visManager; 121 delete runManager; 123 delete runManager; >> 124 delete verbosity; 122 } 125 } 123 126