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/TestEm8/TestEm8.cc << 27 /// \brief Main program of the electromagnetic << 28 // 23 // >> 24 // $Id: TestEm8.cc,v 1.5 2005/05/03 10:21:16 allison Exp $ >> 25 // GEANT4 tag $Name: geant4-07-01 $ 29 // 26 // 30 //....oooOO0OOooo........oooOO0OOooo........oo << 27 // 31 //....oooOO0OOooo........oooOO0OOooo........oo << 28 // -------------------------------------------------------------- 32 << 29 // GEANT 4 - TestEm8 33 #include "ActionInitialization.hh" << 30 // 34 #include "DetectorConstruction.hh" << 31 // -------------------------------------------------------------- 35 #include "PhysicsList.hh" << 32 // Comments >> 33 // >> 34 // >> 35 // -------------------------------------------------------------- 36 36 37 #include "G4RunManagerFactory.hh" << 37 #include "G4RunManager.hh" 38 #include "G4UIExecutive.hh" << 39 #include "G4UIcommand.hh" << 40 #include "G4UImanager.hh" 38 #include "G4UImanager.hh" >> 39 #include "G4UIterminal.hh" >> 40 #include "Randomize.hh" >> 41 >> 42 #ifdef G4VIS_USE 41 #include "G4VisExecutive.hh" 43 #include "G4VisExecutive.hh" >> 44 #endif 42 45 43 //....oooOO0OOooo........oooOO0OOooo........oo << 46 #include "Em8DetectorConstruction.hh" >> 47 #include "PhysicsList.hh" >> 48 #include "Em8PrimaryGeneratorAction.hh" >> 49 #include "Em8RunAction.hh" >> 50 #include "Em8EventAction.hh" >> 51 #include "Em8SteppingAction.hh" >> 52 #include "Em8SteppingVerbose.hh" 44 53 45 int main(int argc, char** argv) << 54 int main(int argc,char** argv) 46 { 55 { 47 // detect interactive mode (if no arguments) << 48 G4UIExecutive* ui = nullptr; << 49 if (argc == 1) { << 50 ui = new G4UIExecutive(argc, argv); << 51 } << 52 56 53 auto* runManager = G4RunManagerFactory::Crea << 57 //choose the Random engine 54 // Number of threads can be defined via 3rd << 58 55 G4int nThreads = 2; << 59 HepRandom::setTheEngine(new RanecuEngine); 56 if (argc == 3) { << 60 57 if (G4String(argv[2]) == "NMAX") { << 61 //my Verbose output class 58 nThreads = G4Threading::G4GetNumberOfCor << 62 59 } << 63 G4VSteppingVerbose::SetInstance(new Em8SteppingVerbose); 60 else { << 64 61 nThreads = G4UIcommand::ConvertToInt(arg << 65 // Construct the default run manager 62 } << 66 63 } << 67 G4RunManager * runManager = new G4RunManager; 64 else if (argc == 1) { << 65 nThreads = 1; << 66 } << 67 if (nThreads > 0) { << 68 runManager->SetNumberOfThreads(nThreads); << 69 } << 70 68 71 // set mandatory initialization classes 69 // set mandatory initialization classes 72 DetectorConstruction* det = new DetectorCons << 73 runManager->SetUserInitialization(det); << 74 runManager->SetUserInitialization(new Physic << 75 70 >> 71 Em8DetectorConstruction* detector; >> 72 detector = new Em8DetectorConstruction; >> 73 runManager->SetUserInitialization(detector); >> 74 runManager->SetUserInitialization(new PhysicsList); >> 75 >> 76 #ifdef G4VIS_USE >> 77 >> 78 // visualization manager >> 79 >> 80 G4VisManager* visManager = new G4VisExecutive; >> 81 visManager->Initialize(); >> 82 >> 83 #endif >> 84 76 // set user action classes 85 // set user action classes 77 runManager->SetUserInitialization(new Action << 78 86 79 // initialize visualization << 87 runManager->SetUserAction(new Em8PrimaryGeneratorAction(detector)); 80 G4VisManager* visManager = nullptr; << 81 88 82 // get the pointer to the User Interface man << 89 Em8RunAction* runAction = new Em8RunAction; 83 G4UImanager* UImanager = G4UImanager::GetUIp << 84 90 85 if (ui) { << 91 runManager->SetUserAction(runAction); 86 // interactive mode << 92 87 visManager = new G4VisExecutive(); << 93 Em8EventAction* eventAction = new Em8EventAction(runAction); 88 visManager->Initialize(); << 89 ui->SessionStart(); << 90 delete ui; << 91 } << 92 else { << 93 // batch mode << 94 G4String command = "/control/execute "; << 95 G4String fileName = argv[1]; << 96 UImanager->ApplyCommand(command + fileName << 97 } << 98 94 >> 95 runManager->SetUserAction(eventAction); >> 96 >> 97 Em8SteppingAction* steppingAction = new Em8SteppingAction(detector, >> 98 eventAction, >> 99 runAction); >> 100 runManager->SetUserAction(steppingAction); >> 101 >> 102 //Initialize G4 kernel, physics tables may be here ???... >> 103 >> 104 // runManager->Initialize(); >> 105 >> 106 // get the pointer to the User Interface manager >> 107 >> 108 G4UImanager* UI = G4UImanager::GetUIpointer(); >> 109 >> 110 if (argc==1) // Define UI terminal for interactive mode >> 111 { >> 112 G4UIsession * session = new G4UIterminal; >> 113 UI->ApplyCommand("/control/execute init.mac"); >> 114 session->SessionStart(); >> 115 delete session; >> 116 } >> 117 else // Batch mode >> 118 { >> 119 G4String command = "/control/execute "; >> 120 G4String fileName = argv[1]; >> 121 UI->ApplyCommand(command+fileName); >> 122 } >> 123 99 // job termination 124 // job termination >> 125 >> 126 #ifdef G4VIS_USE 100 delete visManager; 127 delete visManager; >> 128 #endif 101 delete runManager; 129 delete runManager; >> 130 >> 131 return 0; 102 } 132 } 103 133 104 //....oooOO0OOooo........oooOO0OOooo........oo << 105 134