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

Main program of the eventgenerator/HepMC/MCTruth example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "MCTruthTrackingAction.hh"
#include "MCTruthEventAction.hh"
#include "MCTruthManager.hh"

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Main program of the eventgenerator/HepMC/MCTruth example.

Definition in file mctruthex.cc.

Function Documentation

int main ( )

Definition at line 42 of file mctruthex.cc.

43 {
44  // Construct the default run manager
45  G4RunManager* runManager = new G4RunManager;
46 
47  // set mandatory initialization classes
48  runManager->SetUserInitialization(new DetectorConstruction);
49  runManager->SetUserInitialization(new FTFP_BERT);
50 
51  // set mandatory user action class
52  runManager->SetUserAction(new PrimaryGeneratorAction);
53 
54  // set MCTruth user action classes
55  runManager->SetUserAction(new MCTruthTrackingAction);
56  runManager->SetUserAction(new MCTruthEventAction);
57 
58  // Initialize G4 kernel
59  runManager->Initialize();
60 
61  // get the pointer to the UI manager and set verbosities
62  G4UImanager* UI = G4UImanager::GetUIpointer();
63  UI->ApplyCommand("/run/verbose 1");
64  UI->ApplyCommand("/event/verbose 1");
65  UI->ApplyCommand("/tracking/verbose 1");
66 
67  // configure MCTruth handling
68  MCTruthConfig* config = new MCTruthConfig;
69  config->SetMinE(1000.0);
70  config->AddParticleType(11);
71  MCTruthManager::GetInstance()->SetConfig(config);
72 
73  // start a run
74  int numberOfEvent = 1;
75  runManager->BeamOn(numberOfEvent);
76 
77  // job termination
78  delete runManager;
79 }