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 // 26 /// \file electromagnetic/TestEm9/TestEm9.cc << 27 /// \brief Main program of the electromagnetic << 28 // << 29 // 23 // >> 24 // $Id: TestEm9.cc,v 1.6 2005/12/06 13:34:59 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 30 // 26 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 27 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 29 >> 30 #include "G4RunManager.hh" >> 31 #include "G4UImanager.hh" >> 32 #include "G4UIterminal.hh" >> 33 #include "G4UItcsh.hh" >> 34 #include "Randomize.hh" >> 35 34 #include "DetectorConstruction.hh" 36 #include "DetectorConstruction.hh" 35 #include "EventAction.hh" << 36 #include "PhysicsList.hh" 37 #include "PhysicsList.hh" 37 #include "PrimaryGeneratorAction.hh" 38 #include "PrimaryGeneratorAction.hh" >> 39 38 #include "RunAction.hh" 40 #include "RunAction.hh" >> 41 #include "EventAction.hh" 39 #include "SteppingAction.hh" 42 #include "SteppingAction.hh" 40 #include "TrackingAction.hh" 43 #include "TrackingAction.hh" 41 44 42 #include "G4RunManagerFactory.hh" << 45 #ifdef G4VIS_USE 43 #include "G4UIExecutive.hh" << 46 #include "G4VisExecutive.hh" 44 #include "G4UImanager.hh" << 47 #endif 45 #include "G4VisExecutive.hh" << 46 #include "Randomize.hh" << 47 48 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 50 50 int main(int argc, char** argv) << 51 int main(int argc,char** argv) { 51 { << 52 // detect interactive mode (if no arguments) << 53 G4UIExecutive* ui = nullptr; << 54 if (argc == 1) { << 55 ui = new G4UIExecutive(argc, argv); << 56 } << 57 52 58 // construct a serial run manager << 53 //choose the Random engine 59 auto* runManager = G4RunManagerFactory::Crea << 54 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); 60 55 61 // set mandatory initialization classes << 56 //Construct the default run manager >> 57 G4RunManager * runManager = new G4RunManager; >> 58 >> 59 //set mandatory initialization classes 62 DetectorConstruction* det = new DetectorCons 60 DetectorConstruction* det = new DetectorConstruction(); 63 PhysicsList* phys; 61 PhysicsList* phys; 64 PrimaryGeneratorAction* kin; 62 PrimaryGeneratorAction* kin; 65 runManager->SetUserInitialization(det); 63 runManager->SetUserInitialization(det); 66 runManager->SetUserInitialization(phys = new 64 runManager->SetUserInitialization(phys = new PhysicsList); 67 runManager->SetUserAction(kin = new PrimaryG 65 runManager->SetUserAction(kin = new PrimaryGeneratorAction(det)); 68 66 69 // set user action classes << 67 #ifdef G4VIS_USE 70 runManager->SetUserAction(new RunAction()); << 68 //visualization manager 71 runManager->SetUserAction(new EventAction()) << 69 G4VisManager* visManager = new G4VisExecutive; 72 runManager->SetUserAction(new TrackingAction << 70 visManager->Initialize(); 73 runManager->SetUserAction(new SteppingAction << 71 #endif 74 << 72 75 // initialize visualization << 73 //set user action classes 76 G4VisManager* visManager = nullptr; << 74 RunAction* run = new RunAction(); 77 << 75 EventAction* event = new EventAction(); 78 // get the pointer to the User Interface man << 76 TrackingAction* track = new TrackingAction(); 79 G4UImanager* UImanager = G4UImanager::GetUIp << 77 SteppingAction* step = new SteppingAction(); 80 << 78 81 if (ui) { << 79 runManager->SetUserAction(run); 82 // interactive mode << 80 runManager->SetUserAction(event); 83 visManager = new G4VisExecutive; << 81 runManager->SetUserAction(track); 84 visManager->Initialize(); << 82 runManager->SetUserAction(step); 85 ui->SessionStart(); << 83 86 delete ui; << 84 //get the pointer to the User Interface manager 87 } << 85 G4UImanager* UI = G4UImanager::GetUIpointer(); 88 else { << 86 89 // batch mode << 87 if (argc==1) // Define UI terminal for interactive mode 90 G4String command = "/control/execute "; << 88 { 91 G4String fileName = argv[1]; << 89 G4UIsession* session = 0; 92 UImanager->ApplyCommand(command + fileName << 90 #ifdef G4UI_USE_TCSH 93 } << 91 session = new G4UIterminal(new G4UItcsh); >> 92 #else >> 93 session = new G4UIterminal(); >> 94 #endif >> 95 session->SessionStart(); >> 96 delete session; >> 97 } >> 98 else // Batch mode >> 99 { >> 100 G4String command = "/control/execute "; >> 101 G4String fileName = argv[1]; >> 102 UI->ApplyCommand(command+fileName); >> 103 } 94 104 95 // job termination << 105 //job termination >> 106 #ifdef G4VIS_USE 96 delete visManager; 107 delete visManager; >> 108 #endif 97 delete runManager; 109 delete runManager; >> 110 >> 111 return 0; 98 } 112 } 99 113 100 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 101 115