LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
userVisAction.cc File Reference

Main program of the visualization/userVisAction example. More...

#include "B1DetectorConstruction.hh"
#include "B1ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "QBBC.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "UVA_VisAction.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the visualization/userVisAction example.

Definition in file userVisAction.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file userVisAction.cc.

51 {
52  // Detect interactive mode (if no arguments) and define UI session
53  //
54  G4UIExecutive* ui = 0;
55  if ( argc == 1 ) {
56  ui = new G4UIExecutive(argc, argv);
57  }
58 
59  // Choose the Random engine
60  //
61  G4Random::setTheEngine(new CLHEP::RanecuEngine);
62 
63  // Construct the default run manager
64  //
65 #ifdef G4MULTITHREADED
66  G4MTRunManager* runManager = new G4MTRunManager;
67 #else
68  G4RunManager* runManager = new G4RunManager;
69 #endif
70 
71  // Set mandatory initialization classes
72  //
73  // Detector construction
74  runManager->SetUserInitialization(new B1DetectorConstruction());
75 
76  // Physics list
77  G4VModularPhysicsList* physicsList = new QBBC;
78  physicsList->SetVerboseLevel(1);
79  runManager->SetUserInitialization(physicsList);
80 
81  // User action initialization
82  runManager->SetUserInitialization(new B1ActionInitialization());
83 
84  // Initialize visualization
85  G4VisManager* visManager = new G4VisExecutive;
86  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
87  // G4VisManager* visManager = new G4VisExecutive("Quiet");
88  // Register User Vis Action with optional extent
89  visManager->RegisterRunDurationUserVisAction
90  ("My nice logo",
91  new UVA_VisAction,
92  G4VisExtent(-20*cm,-10*cm,-25*cm,-15*cm,20*cm,40*cm));
93  visManager->Initialize();
94 
95  // Get the pointer to the User Interface manager
96  G4UImanager* UImanager = G4UImanager::GetUIpointer();
97 
98  if ( ! ui ) {
99  // batch mode
100  G4String command = "/control/execute ";
101  G4String fileName = argv[1];
102  UImanager->ApplyCommand(command+fileName);
103  }
104  else {
105  // interactive mode
106  UImanager->ApplyCommand("/control/execute init_vis.mac");
107  ui->SessionStart();
108  delete ui;
109  }
110 
111  // Job termination
112  // Free the store: user actions, physics_list and detector_description are
113  // owned and deleted by the run manager, so they should not be deleted
114  // in the main() program !
115 
116  delete visManager;
117  delete runManager;
118 
119  return 0;
120 }