Geant4  10.02.p01
monopole.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: monopole.cc 92500 2015-09-02 07:26:32Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "G4RunManager.hh"
35 #include "G4UImanager.hh"
36 #include "Randomize.hh"
37 #include "globals.hh"
38 
39 #include "DetectorConstruction.hh"
40 #include "G4MonopolePhysics.hh"
41 #include "G4PhysListFactory.hh"
42 #include "G4VModularPhysicsList.hh"
43 #include "PrimaryGeneratorAction.hh"
44 
45 #include "RunAction.hh"
46 #include "TrackingAction.hh"
47 #include "SteppingAction.hh"
48 
49 #ifdef G4VIS_USE
50 #include "G4VisExecutive.hh"
51 #endif
52 
53 #ifdef G4UI_USE
54 #include "G4UIExecutive.hh"
55 #endif
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 int main(int argc,char** argv) {
60 
61  //choose the Random engine
62  //CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
63  //CLHEP::HepRandom::setTheEngine(new CLHEP::Ranlux64Engine);
64  CLHEP::HepRandom::setTheEngine(new CLHEP::RanluxEngine);
65 
66  //Construct the default run manager
67  G4RunManager * runManager = new G4RunManager;
68 
69  //create physicsList
70  // Physics List is defined via environment variable PHYSLIST
71  G4PhysListFactory factory;
72  G4VModularPhysicsList* phys = factory.ReferencePhysList();
73 
74  // monopole physics is added
75  G4MonopolePhysics * theMonopole = new G4MonopolePhysics();
76  phys->RegisterPhysics(theMonopole);
77 
78  // visualization manager
79 #ifdef G4VIS_USE
80  G4VisManager* visManager = 0;
81 #endif
82 
83  //get the pointer to the User Interface manager
85 
86  // Setup monopole
87  G4String s = "";
88  if(argc > 2) { s = argv[2]; }
89  UImanager->ApplyCommand("/control/verbose 1");
90  UImanager->ApplyCommand("/monopole/setup "+s);
91 
92  // mandator user classes
94 
95  runManager->SetUserInitialization(det);
96  runManager->SetUserInitialization(phys);
97 
99  runManager->SetUserAction(kin);
100 
101  //user action classes
102  RunAction* run;
103 
104  runManager->SetUserAction(run = new RunAction(det, kin));
105  runManager->SetUserAction(new TrackingAction(run));
106  runManager->SetUserAction(new SteppingAction(run));
107 
108  if (argc!=1) // batch mode
109  {
110  G4String command = "/control/execute ";
111  G4String fileName = argv[1];
112  UImanager->ApplyCommand(command+fileName);
113  }
114  else
115  { // interactive mode : define UI session
116 #ifdef G4VIS_USE
117  //visualization manager
118  visManager = new G4VisExecutive;
119  visManager->Initialize();
120 #endif
121 #ifdef G4UI_USE
122  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
123  ui->SessionStart();
124  delete ui;
125 #endif
126  }
127 
128  //job termination
129 #ifdef G4VIS_USE
130  delete visManager;
131 #endif
132 
133  delete runManager;
134 
135  return 0;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction class.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void RegisterPhysics(G4VPhysicsConstructor *)
int main(int argc, char **argv)
Definition: monopole.cc:59
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
static const double s
Definition: G4SIunits.hh:168
void Initialize()
Definition of the G4MonopolePhysics class.
Detector construction class to demonstrate various ways of placement.
G4VModularPhysicsList * ReferencePhysList()
Run action class.
Definition: RunAction.hh:45
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
virtual void SetUserAction(G4UserRunAction *userAction)