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

Main program of the analysis/AnaEx01 example. More...

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the analysis/AnaEx01 example.

Definition in file AnaEx01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file AnaEx01.cc.

53 {
54  // Detect interactive mode (if no arguments) and define UI session
55  //
56  G4UIExecutive* ui = 0;
57  if ( argc == 1 ) {
58  ui = new G4UIExecutive(argc, argv);
59  }
60 
61  // Construct the default run manager
62  //
63 #ifdef G4MULTITHREADED
64  G4int nThreads = 4;
65  G4MTRunManager * runManager = new G4MTRunManager;
66  runManager->SetNumberOfThreads(nThreads);
67 #else
68  G4RunManager * runManager = new G4RunManager;
69 #endif
70 
71  // Set mandatory initialization classes
72  //
74  runManager->SetUserInitialization(detector);
75  runManager->SetUserInitialization(new FTFP_BERT);
76  runManager->SetUserInitialization(new ActionInitialization(detector));
77 
78  // Initialize visualization
79  //
80  G4VisManager* visManager = new G4VisExecutive;
81  visManager->Initialize();
82 
83  // Get the pointer to the User Interface manager
84  //
85  G4UImanager* UImanager = G4UImanager::GetUIpointer();
86 
87  if ( ! ui ) {
88  // batch mode
89  G4String command = "/control/execute ";
90  G4String fileName = argv[1];
91  UImanager->ApplyCommand(command+fileName);
92  }
93  else {
94  // interactive mode
95  UImanager->ApplyCommand("/control/execute init_vis.mac");
96  ui->SessionStart();
97  delete ui;
98  }
99 
100  // Job termination
101  delete visManager;
102  delete runManager;
103 
104  return 0;
105 }