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

Main program of the B3b example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4TScoreNtupleWriter.hh"
#include "Randomize.hh"
#include "B3DetectorConstruction.hh"
#include "B3PhysicsList.hh"
#include "B3bActionInitialization.hh"
#include "B3Analysis.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the B3b example.

Definition in file exampleB3b.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file exampleB3b.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  // Optionally: choose a different Random engine...
62  //
63  // G4Random::setTheEngine(new CLHEP::MTwistEngine);
64 
65  // Construct the default run manager
66  //
67 #ifdef G4MULTITHREADED
68  G4MTRunManager* runManager = new G4MTRunManager;
69 #else
70  G4RunManager* runManager = new G4RunManager;
71 #endif
72 
73  // Set mandatory initialization classes
74  //
75  runManager->SetUserInitialization(new B3DetectorConstruction);
76  //
77  runManager->SetUserInitialization(new B3PhysicsList);
78 
79  // Set user action initialization
80  //
81  runManager->SetUserInitialization(new B3bActionInitialization());
82 
83  // Initialize visualization
84  //
85  G4VisManager* visManager = new G4VisExecutive;
86  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
87  // G4VisManager* visManager = new G4VisExecutive("Quiet");
88  visManager->Initialize();
89 
90  // Get the pointer to the User Interface manager
91  G4UImanager* UImanager = G4UImanager::GetUIpointer();
92 
93  // Activate score ntuple writer
94  // The Root output type (Root) is selected in B3Analysis.hh.
95  // The verbose level can be also set via UI commands
96  // /score/ntuple/writerVerbose level
97  G4TScoreNtupleWriter<G4AnalysisManager> scoreNtupleWriter;
98  scoreNtupleWriter.SetVerboseLevel(1);
99 
100  // Process macro or start UI session
101  //
102  if ( ! ui ) {
103  // batch mode
104  G4String command = "/control/execute ";
105  G4String fileName = argv[1];
106  UImanager->ApplyCommand(command+fileName);
107  }
108  else {
109  // interactive mode
110  UImanager->ApplyCommand("/control/execute init_vis.mac");
111  ui->SessionStart();
112  delete ui;
113  }
114 
115  // Job termination
116  // Free the store: user actions, physics_list and detector_description are
117  // owned and deleted by the run manager, so they should not be deleted
118  // in the main() program !
119 
120  delete visManager;
121  delete runManager;
122 }