LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
exampleP02.cc File Reference

Main program of the persistency/P02 example. More...

#include "ExP02DetectorConstruction.hh"
#include "ExP02DetConstrReader.hh"
#include "ExP02PrimaryGeneratorAction.hh"
#include "FTFP_BERT.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the persistency/P02 example.

Definition in file exampleP02.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file exampleP02.cc.

57 {
58 
59  if(argc==1)
60  {
61  G4cout << "Please give 'write' or 'read' as argument " << G4endl;
62  return 0;
63  }
64 
65  G4VUserDetectorConstruction* det;
66 
67  if(std::string(argv[1]) == "read")
68  {
69  det = new ExP02DetConstrReader;
70  }
71  else if(std::string(argv[1]) == "write")
72  {
73  det = new ExP02DetectorConstruction;
74  }
75  else
76  {
77  G4cout << "Wrong argument!" << G4endl;
78  return 0;
79  }
80 
81  // Run manager
82  G4RunManager * runManager = new G4RunManager;
83 
84  // UserInitialization classes (mandatory)
85  runManager->SetUserInitialization(det);
86 
87  G4VModularPhysicsList* physicsList = new FTFP_BERT;
88  runManager->SetUserInitialization(physicsList);
89 
90 #ifdef G4VIS_USE
91  // Visualization, if you choose to have it!
92  G4VisManager* visManager = new G4VisExecutive;
93  visManager->Initialize();
94 #endif
95 
96  // UserAction classes
97  runManager->SetUserAction(new ExP02PrimaryGeneratorAction());
98 
99  //Initialize G4 kernel
100  runManager->Initialize();
101 
102  //get the pointer to the User Interface manager
103  G4UImanager * UImanager = G4UImanager::GetUIpointer();
104 
105 #ifdef G4UI_USE
106  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
107 #ifdef G4VIS_USE
108  UImanager->ApplyCommand("/control/execute vis.mac");
109 #endif
110  ui->SessionStart();
111  delete ui;
112 #endif
113 
114 #ifdef G4VIS_USE
115  delete visManager;
116 #endif
117  delete runManager;
118 
119  return 0;
120 }