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 exoticphysics/monopole/monopole.cc << 26 // $Id: monopole.cc,v 1.1 2007/08/16 10:32:04 vnivanch Exp $ 27 /// \brief Main program of the exoticphysics/m << 27 // GEANT4 tag $Name: geant4-09-02 $ 28 // << 29 // 28 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 31 33 #include "ActionInitialization.hh" << 32 #include "G4RunManager.hh" 34 #include "DetectorConstruction.hh" << 35 << 36 #include "G4MonopolePhysics.hh" << 37 #include "G4PhysListFactory.hh" << 38 #include "G4RunManagerFactory.hh" << 39 #include "G4Types.hh" << 40 #include "G4UIExecutive.hh" << 41 #include "G4UImanager.hh" 33 #include "G4UImanager.hh" 42 #include "G4VModularPhysicsList.hh" << 34 #include "G4UIterminal.hh" 43 #include "G4VisExecutive.hh" << 35 #include "G4UItcsh.hh" 44 #include "Randomize.hh" 36 #include "Randomize.hh" 45 #include "globals.hh" << 46 37 47 //....oooOO0OOooo........oooOO0OOooo........oo << 38 #include "DetectorConstruction.hh" >> 39 #include "G4MonopolePhysics.hh" >> 40 #include "QGSP.hh" >> 41 #include "PrimaryGeneratorAction.hh" 48 42 49 namespace << 43 #include "RunAction.hh" 50 { << 44 #include "EventAction.hh" 51 void PrintUsage() << 45 #include "TrackingAction.hh" 52 { << 46 #include "SteppingAction.hh" 53 G4cerr << " Usage: " << G4endl << " monopole << 47 54 << G4endl << " Note: " << G4endl << 48 #ifdef G4VIS_USE 55 << " -s should be followed by a co << 49 #include "G4VisExecutive.hh" 56 << " -t option is for multi-thread << 50 #endif 57 } << 58 } // namespace << 59 51 60 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 53 62 int main(int argc, char** argv) << 54 int main(int argc,char** argv) { 63 { << 64 // Evaluate arguments << 65 // << 66 if (argc > 7) { << 67 PrintUsage(); << 68 return 1; << 69 } << 70 << 71 G4String macro; << 72 G4String setupMonopole; << 73 G4int nThreads = 1; << 74 for (G4int i = 1; i < argc; i = i + 2) { << 75 if (G4String(argv[i]) == "-m") << 76 macro = argv[i + 1]; << 77 else if (G4String(argv[i]) == "-s") << 78 setupMonopole = argv[i + 1]; << 79 else if (G4String(argv[i]) == "-t") { << 80 nThreads = G4UIcommand::ConvertToInt(arg << 81 } << 82 else { << 83 PrintUsage(); << 84 return 1; << 85 } << 86 } << 87 55 88 // Construct the default run manager << 56 //choose the Random engine 89 auto* runManager = G4RunManagerFactory::Crea << 57 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); 90 if (nThreads > 0) { << 91 runManager->SetNumberOfThreads(nThreads); << 92 } << 93 G4cout << "===== Example is started with " < << 94 << " threads =====" << G4endl; << 95 << 96 // Instantiate G4UIExecutive if interactive << 97 G4UIExecutive* ui = nullptr; << 98 if (macro.empty()) { << 99 ui = new G4UIExecutive(argc, argv); << 100 } << 101 << 102 // get the pointer to the User Interface man << 103 G4UImanager* UImanager = G4UImanager::GetUIp << 104 << 105 // create physicsList << 106 // Physics List is defined via environment << 107 G4PhysListFactory factory; << 108 G4VModularPhysicsList* phys = factory.GetRef << 109 << 110 // monopole physics is added << 111 G4MonopolePhysics* theMonopole = new G4Monop << 112 << 113 // Setup monopole << 114 if (setupMonopole.size()) { << 115 UImanager->ApplyCommand("/control/verbose << 116 UImanager->ApplyCommand("/monopole/setup " << 117 } << 118 58 119 // regsiter monopole physics << 59 //Construct the default run manager 120 phys->RegisterPhysics(theMonopole); << 60 G4RunManager * runManager = new G4RunManager; 121 61 122 runManager->SetUserInitialization(phys); << 62 //set mandatory initialization classes >> 63 DetectorConstruction* det; 123 64 124 // visualization manager << 65 //ceate physicsList 125 G4VisManager* visManager = nullptr; << 66 QGSP* phys = new QGSP(); >> 67 G4MonopolePhysics * theMonopole = new G4MonopolePhysics; >> 68 phys->RegisterPhysics(theMonopole); 126 69 127 // set detector construction << 70 PrimaryGeneratorAction* kin; 128 DetectorConstruction* det = new DetectorCons << 71 runManager->SetUserInitialization(det = new DetectorConstruction); 129 runManager->SetUserInitialization(det); << 72 runManager->SetUserInitialization(phys); 130 << 73 runManager->SetUserAction(kin = new PrimaryGeneratorAction(det)); 131 // set user action classes << 74 132 runManager->SetUserInitialization(new Action << 75 #ifdef G4VIS_USE 133 << 76 //visualization manager 134 // Process macro or start UI session << 77 G4VisManager* visManager = 0; 135 // << 78 #endif 136 if (macro.size()) { << 79 137 // batch mode << 80 //set user action classes 138 G4String command = "/control/execute "; << 81 RunAction* run; 139 UImanager->ApplyCommand(command + macro); << 82 140 } << 83 runManager->SetUserAction(run = new RunAction(det, kin)); 141 else { << 84 runManager->SetUserAction(new EventAction); 142 // interactive mode : define UI session << 85 runManager->SetUserAction(new TrackingAction(run)); 143 visManager = new G4VisExecutive(); << 86 runManager->SetUserAction(new SteppingAction(det, run)); 144 visManager->Initialize(); << 87 145 UImanager->ApplyCommand("/control/execute << 88 //get the pointer to the User Interface manager 146 ui->SessionStart(); << 89 G4UImanager* UI = G4UImanager::GetUIpointer(); 147 delete ui; << 90 G4cout << "User actions are instantiated" << G4endl; 148 } << 91 >> 92 if (argc == 1) // Define UI terminal for interactive mode >> 93 { >> 94 visManager = new G4VisExecutive(); >> 95 visManager->Initialize(); >> 96 G4UIsession* session = 0; >> 97 #ifdef G4UI_USE_TCSH >> 98 session = new G4UIterminal(new G4UItcsh); >> 99 #else >> 100 session = new G4UIterminal(); >> 101 #endif >> 102 session->SessionStart(); >> 103 delete session; >> 104 } >> 105 else // Batch mode >> 106 { >> 107 G4String command = "/control/execute "; >> 108 G4String fileName = argv[1]; >> 109 UI->ApplyCommand(command+fileName); >> 110 } 149 111 >> 112 //job termination >> 113 #ifdef G4VIS_USE 150 delete visManager; 114 delete visManager; 151 << 115 #endif 152 // job termination << 116 153 delete runManager; 117 delete runManager; 154 118 155 return 0; 119 return 0; 156 } 120 } 157 121 158 //....oooOO0OOooo........oooOO0OOooo........oo << 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 123