Geant4  10.02.p01
fanoCavity2.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: fanoCavity2.cc 90829 2015-06-10 08:37:55Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #ifdef G4MULTITHREADED
35 #include "G4MTRunManager.hh"
36 #else
37 #include "G4RunManager.hh"
38 #endif
39 
40 #include "G4UImanager.hh"
41 #include "Randomize.hh"
42 
43 #include "ActionInitialization.hh"
44 #include "DetectorConstruction.hh"
45 #include "PhysicsList.hh"
46 #include "PrimaryGeneratorAction.hh"
47 
48 #include "RunAction.hh"
49 #include "EventAction.hh"
50 #include "TrackingAction.hh"
51 #include "SteppingAction.hh"
52 #include "SteppingVerbose.hh"
53 
54 #ifdef G4VIS_USE
55  #include "G4VisExecutive.hh"
56 #endif
57 
58 #ifdef G4UI_USE
59  #include "G4UIExecutive.hh"
60 #endif
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
64 int main(int argc,char** argv) {
65 
66  //choose the Random engine
67  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
68 
69 
70 #ifdef G4MULTITHREADED
71  G4MTRunManager* runManager = new G4MTRunManager;
73  if (argc==3) nThreads = G4UIcommand::ConvertToInt(argv[2]);
74  runManager->SetNumberOfThreads(nThreads);
75 #else
77  G4RunManager* runManager = new G4RunManager;
78 #endif
79 
80 
81  //my Verbose output class
82  //G4VSteppingVerbose::SetInstance(new SteppingVerbose);
83 
84  //Construct the default run manager
85  //G4RunManager * runManager = new G4RunManager;
86 
87  //set mandatory initialization classes
89  PhysicsList* phys;
90 
91 
92  runManager->SetUserInitialization(det = new DetectorConstruction);
93  runManager->SetUserInitialization(phys = new PhysicsList());
94 
95  // set user action classes
96  runManager->SetUserInitialization(new ActionInitialization(det));
97 
98 
99  //get the pointer to the User Interface manager
100  G4UImanager* UImanager = G4UImanager::GetUIpointer();
101 
102 #ifdef G4VIS_USE
103  G4VisManager* visManager = new G4VisExecutive;
104  visManager->Initialize();
105 #endif
106 
107  if (argc!=1) // batch mode
108  {
109  G4String command = "/control/execute ";
110  G4String fileName = argv[1];
111  UImanager->ApplyCommand(command+fileName);
112  }
113 
114  else // interactive mode :define visualization and UI terminal
115  {
116 #ifdef G4UI_USE
117  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
118 #ifdef G4VIS_USE
119  UImanager->ApplyCommand("/control/execute vis.mac");
120 #endif
121  ui->SessionStart();
122  delete ui;
123 #endif
124 
125 #ifdef G4VIS_USE
126  delete visManager;
127 #endif
128  }
129 
130  //job termination
131  //
132  delete runManager;
133 
134  return 0;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
int main(int argc, char **argv)
Definition: fanoCavity2.cc:64
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:127
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
Action initialization class.
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
Detector construction class to demonstrate various ways of placement.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Physics list class.
Definition: PhysicsList.hh:47