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