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 // 23 // 27 /// \file field/field02/field02.cc << 24 // $Id: field02.cc,v 1.8 2005/12/06 14:01:03 gcosmo Exp $ 28 /// \brief Main program of the field/field02 e << 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 29 // 26 // 30 //....oooOO0OOooo........oooOO0OOooo........oo << 27 // 31 //....oooOO0OOooo........oooOO0OOooo........oo << 28 // -------------------------------------------------------------- 32 << 29 // GEANT 4 - TestF02 33 #include "G4Types.hh" << 30 // 34 << 31 // -------------------------------------------------------------- 35 #include "G4RunManagerFactory.hh" << 32 // Comments 36 #include "F02SteppingVerbose.hh" << 33 // 37 << 34 // 38 #include "F02ActionInitialization.hh" << 35 // -------------------------------------------------------------- 39 #include "F02DetectorConstruction.hh" << 40 #include "FTFP_BERT.hh" << 41 36 42 #include "G4StepLimiterPhysics.hh" << 37 #include "G4RunManager.hh" 43 #include "G4UIExecutive.hh" << 44 #include "G4UImanager.hh" 38 #include "G4UImanager.hh" 45 #include "G4VisExecutive.hh" << 39 #include "G4UIterminal.hh" 46 #include "Randomize.hh" 40 #include "Randomize.hh" 47 41 48 //....oooOO0OOooo........oooOO0OOooo........oo << 42 #ifdef G4VIS_USE >> 43 #include "G4VisExecutive.hh" >> 44 #endif >> 45 >> 46 #include "F02DetectorConstruction.hh" >> 47 #include "F02ElectricFieldSetup.hh" >> 48 #include "F02PhysicsList.hh" >> 49 #include "F02PrimaryGeneratorAction.hh" >> 50 #include "F02RunAction.hh" >> 51 #include "F02EventAction.hh" >> 52 #include "F02SteppingAction.hh" >> 53 #include "F02SteppingVerbose.hh" 49 54 50 int main(int argc, char** argv) << 55 int main(int argc,char** argv) 51 { 56 { 52 // Instantiate G4UIExecutive if there are no << 53 // << 54 G4UIExecutive* ui = nullptr; << 55 if (argc == 1) { << 56 ui = new G4UIExecutive(argc, argv); << 57 } << 58 57 59 // Setting the application-specific Stepping << 58 //choose the Random engine 60 // << 59 61 auto verbosity = new F02SteppingVerbose; << 60 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 61 >> 62 //my Verbose output class 62 63 >> 64 G4VSteppingVerbose::SetInstance(new F02SteppingVerbose); >> 65 63 // Construct the default run manager 66 // Construct the default run manager 64 // << 65 auto runManager = G4RunManagerFactory::Creat << 66 67 >> 68 G4RunManager * runManager = new G4RunManager; >> 69 >> 70 // Construct the helper class to manage the electric field & >> 71 // the parameters for the propagation of particles in it. >> 72 >> 73 F02ElectricFieldSetup* field = new F02ElectricFieldSetup() ; >> 74 67 // Set mandatory initialization classes 75 // Set mandatory initialization classes 68 // << 76 69 // Detector construction << 77 F02DetectorConstruction* detector; 70 auto detector = new F02DetectorConstruction( << 78 detector = new F02DetectorConstruction; 71 runManager->SetUserInitialization(detector); 79 runManager->SetUserInitialization(detector); 72 // Physics list << 80 runManager->SetUserInitialization(new F02PhysicsList(detector)); 73 G4VModularPhysicsList* physicsList = new FTF << 81 74 physicsList->RegisterPhysics(new G4StepLimit << 82 #ifdef G4VIS_USE 75 runManager->SetUserInitialization(physicsLis << 76 // User action initialization << 77 runManager->SetUserInitialization(new F02Act << 78 83 79 // Initialize G4 kernel << 84 // visualization manager 80 // << 81 runManager->Initialize(); << 82 85 83 // Initialize visualization << 84 // << 85 G4VisManager* visManager = new G4VisExecutiv 86 G4VisManager* visManager = new G4VisExecutive; 86 // G4VisExecutive can take a verbosity argum << 87 // G4VisManager* visManager = new G4VisExecu << 88 visManager->Initialize(); 87 visManager->Initialize(); 89 88 90 // Get the pointer to the User Interface man << 89 #endif 91 // << 90 92 G4UImanager* UImanager = G4UImanager::GetUIp << 91 // Set user action classes 93 << 92 94 if (!ui) // batch mode << 93 runManager->SetUserAction(new F02PrimaryGeneratorAction(detector)); 95 { << 94 96 G4String command = "/control/execute "; << 95 F02RunAction* runAction = new F02RunAction; 97 G4String fileName = argv[1]; << 96 98 UImanager->ApplyCommand(command + fileName << 97 runManager->SetUserAction(runAction); >> 98 >> 99 F02EventAction* eventAction = new F02EventAction(runAction); >> 100 >> 101 runManager->SetUserAction(eventAction); >> 102 >> 103 F02SteppingAction* steppingAction = new F02SteppingAction(); >> 104 runManager->SetUserAction(steppingAction); >> 105 >> 106 // Initialize G4 kernel, physics tables ... >> 107 >> 108 runManager->Initialize(); >> 109 >> 110 // get the pointer to the User Interface manager >> 111 >> 112 G4UImanager* UI = G4UImanager::GetUIpointer(); >> 113 >> 114 if (argc==1) // Define UI terminal for interactive mode >> 115 { >> 116 G4UIsession * session = new G4UIterminal; >> 117 session->SessionStart(); >> 118 delete session; 99 } 119 } 100 else { // interactive mode : define UI sess << 120 else // Batch mode 101 UImanager->ApplyCommand("/control/execute << 121 { 102 if (ui->IsGUI()) UImanager->ApplyCommand(" << 122 G4String command = "/control/execute "; 103 ui->SessionStart(); << 123 G4String fileName = argv[1]; 104 delete ui; << 124 UI->ApplyCommand(command+fileName); 105 } 125 } >> 126 >> 127 // job termination 106 128 107 // Job termination << 129 #ifdef G4VIS_USE 108 // Free the store: user actions, physics_lis << 109 // owned and deleted by the << 110 // be deleted in the main() << 111 << 112 delete verbosity; << 113 delete visManager; 130 delete visManager; >> 131 #endif >> 132 delete field; 114 delete runManager; 133 delete runManager; 115 134 116 return 0; 135 return 0; 117 } 136 } 118 137 119 //....oooOO0OOooo........oooOO0OOooo........oo << 120 138