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

Main program of the biasing/ReverseMC01 example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4AdjointSimManager.hh"
#include "RMC01DetectorConstruction.hh"
#include "RMC01PrimaryGeneratorAction.hh"
#include "RMC01EventAction.hh"
#include "RMC01RunAction.hh"
#include "G4AdjointPhysicsList.hh"
#include "RMC01AdjointEventAction.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the biasing/ReverseMC01 example.

Definition in file exampleRMC01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file exampleRMC01.cc.

67  {
68 
69  // Instantiate G4UIExecutive if interactive mode
70  G4UIExecutive* ui = nullptr;
71  if ( argc == 1 ) {
72  ui = new G4UIExecutive(argc, argv);
73  }
74 
75  // Construct the default run manager
76  G4RunManager * theRunManager = new G4RunManager;
77 
78 
79  RMC01DetectorConstruction* detector = new RMC01DetectorConstruction();
80 
81  //Physics and geometry are declared as in a normal G4 application
82  //--------------------------------------------
83  theRunManager->SetUserInitialization(detector);
84  theRunManager->SetUserInitialization(new G4AdjointPhysicsList);
85 
86  theRunManager->SetUserAction(new RMC01PrimaryGeneratorAction);
87  theRunManager->SetUserAction(new RMC01EventAction);
88  RMC01RunAction* theRunAction = new RMC01RunAction;
89  theRunManager->SetUserAction(theRunAction);
90 
91  //The adjoint simulation manager will control the Reverse MC mode
92  //---------------------------------------------------------------
93 
94  G4AdjointSimManager* theAdjointSimManager
95  = G4AdjointSimManager::GetInstance();
96 
97  //It is possible to define action that will be used during
98  // the adjoint tracking phase
99 
100  theAdjointSimManager->SetAdjointRunAction(theRunAction);
101  //theAdjointSimManager->SetAdjointEventAction(new RMC01AdjointEventAction);
102  theAdjointSimManager->SetAdjointEventAction(new RMC01EventAction);
103 
104  // visualization manager
105  G4VisManager* visManager = new G4VisExecutive;
106  visManager->Initialize();
107 
108  // get the pointer to the User Interface manager
109  G4UImanager* UImanager = G4UImanager::GetUIpointer();
110 
111  if (!ui) // batch mode
112  {
113  G4String command = "/control/execute ";
114  G4String fileName = argv[1];
115  UImanager->ApplyCommand(command+fileName);
116  }
117  else
118  { // interactive mode : define UI session
119  ui->SessionStart();
120  delete ui;
121  }
122 
123  // job termination
124  delete visManager;
125  delete theRunManager;
126 
127  return 0;
128 }