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

Main program of the eventgenerator/userPrimaryGenerator example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingVerbose.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the eventgenerator/userPrimaryGenerator example.

Definition in file userPrimaryGenerator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 48 of file userPrimaryGenerator.cc.

48  {
49 
50  //detect interactive mode (if no arguments) and define UI session
51  G4UIExecutive* ui = 0;
52  if (argc == 1) ui = new G4UIExecutive(argc,argv);
53 
54  //choose the Random engine
55  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
56 
57  //my Verbose output class
58  G4VSteppingVerbose::SetInstance(new SteppingVerbose);
59 
60  //construct the default run manager
61  G4RunManager* runManager = new G4RunManager;
62 
63  //set mandatory initialization classes
64  //
65  runManager->SetUserInitialization(new DetectorConstruction);
66  runManager->SetUserInitialization(new PhysicsList);
67 
68  runManager->SetUserAction(new PrimaryGeneratorAction);
69 
70  //initialize visualization
71  G4VisManager* visManager = nullptr;
72 
73  //get the pointer to the User Interface manager
74  G4UImanager* UImanager = G4UImanager::GetUIpointer();
75 
76  if (ui) {
77  //interactive mode
78  visManager = new G4VisExecutive;
79  visManager->Initialize();
80  UImanager->ApplyCommand("/control/execute vis.mac");
81  ui->SessionStart();
82  delete ui;
83  }
84  else {
85  //batch mode
86  G4String command = "/control/execute ";
87  G4String fileName = argv[1];
88  UImanager->ApplyCommand(command+fileName);
89  }
90 
91  //job termination
92  delete visManager;
93  delete runManager;
94 }