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 visualization/userVisAction/userVisA << 26 // 27 /// \brief Main program of the visualization/u << 27 // $Id: userVisAction.cc,v 1.2 2006/06/29 17:46:00 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-02 $ >> 29 // >> 30 // >> 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 28 33 29 #include "B1ActionInitialization.hh" << 34 #include "UVA_DetectorConstruction.hh" 30 #include "B1DetectorConstruction.hh" << 35 #include "UVA_PhysicsList.hh" 31 #include "QBBC.hh" << 36 #include "UVA_PrimaryGeneratorAction.hh" 32 #include "UVA_VisAction.hh" << 37 #include "UVA_RunAction.hh" >> 38 #include "UVA_EventAction.hh" >> 39 #include "UVA_SteppingAction.hh" >> 40 #include "UVA_SteppingVerbose.hh" 33 41 34 #include "G4RunManagerFactory.hh" << 42 #include "G4RunManager.hh" 35 #include "G4SystemOfUnits.hh" << 36 #include "G4UIExecutive.hh" << 37 #include "G4UImanager.hh" 43 #include "G4UImanager.hh" >> 44 #include "G4UIterminal.hh" >> 45 #include "G4UItcsh.hh" >> 46 >> 47 #ifdef G4VIS_USE 38 #include "G4VisExecutive.hh" 48 #include "G4VisExecutive.hh" 39 #include "Randomize.hh" << 49 #include "UVA_VisAction.hh" >> 50 #endif 40 51 41 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 42 53 43 int main(int argc, char** argv) << 54 int main(int argc,char** argv) { 44 { << 45 // Detect interactive mode (if no arguments) << 46 // << 47 G4UIExecutive* ui = 0; << 48 if (argc == 1) { << 49 ui = new G4UIExecutive(argc, argv); << 50 } << 51 << 52 // Choose the Random engine << 53 // << 54 G4Random::setTheEngine(new CLHEP::RanecuEngi << 55 << 56 // Construct the default run manager << 57 // << 58 auto* runManager = G4RunManagerFactory::Crea << 59 << 60 // Set mandatory initialization classes << 61 // << 62 // Detector construction << 63 runManager->SetUserInitialization(new B1Dete << 64 << 65 // Physics list << 66 G4VModularPhysicsList* physicsList = new QBB << 67 physicsList->SetVerboseLevel(1); << 68 runManager->SetUserInitialization(physicsLis << 69 55 70 // User action initialization << 56 //my Verbose output class 71 runManager->SetUserInitialization(new B1Acti << 57 G4VSteppingVerbose::SetInstance(new UVA_SteppingVerbose); 72 << 58 73 // Initialize visualization << 59 // Run manager >> 60 G4RunManager * runManager = new G4RunManager; >> 61 >> 62 // UserInitialization classes (mandatory) >> 63 UVA_DetectorConstruction* UVA_detector = new UVA_DetectorConstruction; >> 64 runManager->SetUserInitialization(UVA_detector); >> 65 runManager->SetUserInitialization(new UVA_PhysicsList); >> 66 >> 67 #ifdef G4VIS_USE >> 68 // Visualization, if you choose to have it! 74 G4VisManager* visManager = new G4VisExecutiv 69 G4VisManager* visManager = new G4VisExecutive; 75 // G4VisExecutive can take a verbosity argum << 76 // G4VisManager* visManager = new G4VisExecu << 77 // Register User Vis Action with optional ex << 78 visManager->RegisterRunDurationUserVisAction << 79 "My nice logo", new UVA_VisAction, << 80 G4VisExtent(-20 * cm, -10 * cm, -25 * cm, << 81 visManager->Initialize(); 70 visManager->Initialize(); 82 << 71 // Set User Vis Action... 83 // Get the pointer to the User Interface man << 72 visManager->SetUserAction 84 G4UImanager* UImanager = G4UImanager::GetUIp << 73 (new UVA_VisAction, G4VisExtent(-1*m,1*m,-2*m,0,3.5*m,5.5*m)); 85 << 74 // 2nd argument optional - overridden by /vis/scene/add/userAction 86 if (!ui) { << 75 // arguments, if any. 87 // batch mode << 76 #endif >> 77 >> 78 // UserAction classes >> 79 runManager->SetUserAction(new UVA_PrimaryGeneratorAction(UVA_detector)); >> 80 runManager->SetUserAction(new UVA_RunAction); >> 81 runManager->SetUserAction(new UVA_EventAction); >> 82 runManager->SetUserAction(new UVA_SteppingAction); >> 83 >> 84 //Initialize G4 kernel >> 85 runManager->Initialize(); >> 86 >> 87 //get the pointer to the User Interface manager >> 88 G4UImanager * UI = G4UImanager::GetUIpointer(); >> 89 >> 90 if(argc==1) >> 91 // Define (G)UI terminal for interactive mode >> 92 { >> 93 // G4UIterminal is a (dumb) terminal. >> 94 G4UIsession * session = 0; >> 95 #ifdef G4UI_USE_TCSH >> 96 session = new G4UIterminal(new G4UItcsh); >> 97 #else >> 98 session = new G4UIterminal(); >> 99 #endif >> 100 >> 101 UI->ApplyCommand("/control/execute vis.mac"); >> 102 session->SessionStart(); >> 103 delete session; >> 104 } >> 105 else >> 106 // Batch mode >> 107 { 88 G4String command = "/control/execute "; 108 G4String command = "/control/execute "; 89 G4String fileName = argv[1]; 109 G4String fileName = argv[1]; 90 UImanager->ApplyCommand(command + fileName << 110 UI->ApplyCommand(command+fileName); 91 } 111 } 92 else { << 93 // interactive mode << 94 UImanager->ApplyCommand("/control/execute << 95 ui->SessionStart(); << 96 delete ui; << 97 } << 98 << 99 // Job termination << 100 // Free the store: user actions, physics_lis << 101 // owned and deleted by the run manager, so << 102 // in the main() program ! << 103 112 >> 113 #ifdef G4VIS_USE 104 delete visManager; 114 delete visManager; >> 115 #endif 105 delete runManager; 116 delete runManager; 106 117 107 return 0; 118 return 0; 108 } 119 } 109 120 110 //....oooOO0OOooo........oooOO0OOooo........oo 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 122 111 123