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.3 2009-12-22 15:07:19 allison Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ >> 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" 38 #include "G4VisExecutive.hh" << 39 #include "Randomize.hh" << 40 44 41 //....oooOO0OOooo........oooOO0OOooo........oo << 45 #ifdef G4VIS_USE >> 46 #include "G4VisExecutive.hh" >> 47 #include "UVA_VisAction.hh" >> 48 #endif 42 49 43 int main(int argc, char** argv) << 50 #ifdef G4UI_USE 44 { << 51 #include "G4UIExecutive.hh" 45 // Detect interactive mode (if no arguments) << 52 #endif 46 // << 47 G4UIExecutive* ui = 0; << 48 if (argc == 1) { << 49 ui = new G4UIExecutive(argc, argv); << 50 } << 51 53 52 // Choose the Random engine << 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 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 int main(int argc,char** argv) { 71 runManager->SetUserInitialization(new B1Acti << 72 57 73 // Initialize visualization << 58 //my Verbose output class >> 59 G4VSteppingVerbose::SetInstance(new UVA_SteppingVerbose); >> 60 >> 61 // Run manager >> 62 G4RunManager * runManager = new G4RunManager; >> 63 >> 64 // UserInitialization classes (mandatory) >> 65 UVA_DetectorConstruction* UVA_detector = new UVA_DetectorConstruction; >> 66 runManager->SetUserInitialization(UVA_detector); >> 67 runManager->SetUserInitialization(new UVA_PhysicsList); >> 68 >> 69 #ifdef G4VIS_USE >> 70 // Visualization, if you choose to have it! 74 G4VisManager* visManager = new G4VisExecutiv 71 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(); 72 visManager->Initialize(); 82 << 73 // Set User Vis Action... 83 // Get the pointer to the User Interface man << 74 visManager->SetUserAction 84 G4UImanager* UImanager = G4UImanager::GetUIp << 75 (new UVA_VisAction, G4VisExtent(-1*m,1*m,-2*m,0,3.5*m,5.5*m)); 85 << 76 // 2nd argument optional - overridden by /vis/scene/add/userAction 86 if (!ui) { << 77 // arguments, if any. 87 // batch mode << 78 #endif 88 G4String command = "/control/execute "; << 79 89 G4String fileName = argv[1]; << 80 // UserAction classes 90 UImanager->ApplyCommand(command + fileName << 81 runManager->SetUserAction(new UVA_PrimaryGeneratorAction(UVA_detector)); 91 } << 82 runManager->SetUserAction(new UVA_RunAction); 92 else { << 83 runManager->SetUserAction(new UVA_EventAction); 93 // interactive mode << 84 runManager->SetUserAction(new UVA_SteppingAction); 94 UImanager->ApplyCommand("/control/execute << 85 >> 86 //Initialize G4 kernel >> 87 runManager->Initialize(); >> 88 >> 89 //get the pointer to the User Interface manager >> 90 G4UImanager * UImanager = G4UImanager::GetUIpointer(); >> 91 >> 92 if(argc==1) >> 93 #ifdef G4UI_USE >> 94 // Define (G)UI terminal for interactive mode >> 95 { >> 96 G4UIExecutive * ui = new G4UIExecutive(argc, argv); >> 97 UImanager->ApplyCommand("/control/execute vis.mac"); 95 ui->SessionStart(); 98 ui->SessionStart(); 96 delete ui; 99 delete ui; >> 100 #endif >> 101 } >> 102 else >> 103 // Batch mode >> 104 { >> 105 G4String command = "/control/execute "; >> 106 G4String fileName = argv[1]; >> 107 UImanager->ApplyCommand(command+fileName); 97 } 108 } 98 109 99 // Job termination << 110 #ifdef G4VIS_USE 100 // Free the store: user actions, physics_lis << 101 // owned and deleted by the run manager, so << 102 // in the main() program ! << 103 << 104 delete visManager; 111 delete visManager; >> 112 #endif 105 delete runManager; 113 delete runManager; 106 114 107 return 0; 115 return 0; 108 } 116 } 109 117 110 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 119 111 120