Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
field01.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 //
30 // $Id$
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - TestF01
35 //
36 // --------------------------------------------------------------
37 // Comments
38 //
39 //
40 // --------------------------------------------------------------
41 
42 #include "G4RunManager.hh"
43 #include "G4UImanager.hh"
44 #include "Randomize.hh"
45 
47 // #include "F01FieldSetup.hh"
48 #include "F01PhysicsList.hh"
50 #include "F01RunAction.hh"
51 #include "F01EventAction.hh"
52 #include "F01SteppingVerbose.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 int main(int argc,char** argv)
63 {
64 
65  //choose the Random engine
66 
68 
69  //my Verbose output class
70 
72 
73  // Construct the default run manager
74 
75  G4RunManager * runManager = new G4RunManager;
76 
77  // Create class that constructs & messages the magnetic field
78  // *** F01FieldSetup* field = new F01FieldSetup() ;
79  // --> Now done in detector construction
80 
81  // Set mandatory initialization classes
82 
83  F01DetectorConstruction* detector;
84  detector = new F01DetectorConstruction;
85  runManager->SetUserInitialization(detector);
86  runManager->SetUserInitialization(new F01PhysicsList(detector));
87 
88  // Set user action classes
89 
90  runManager->SetUserAction(new F01PrimaryGeneratorAction(detector));
91 
92  F01RunAction* runAction = new F01RunAction;
93 
94  runManager->SetUserAction(runAction);
95 
96  F01EventAction* eventAction = new F01EventAction(runAction);
97 
98  runManager->SetUserAction(eventAction);
99 
100  // Initialize G4 kernel, physics tables ...
101 
102  runManager->Initialize();
103 
104 #ifdef G4VIS_USE
105 
106  // visualization manager
107 
108  G4VisManager* visManager = new G4VisExecutive;
109  visManager->Initialize();
110 
111 #endif
112 
113  // Get the pointer to the User Interface manager
114 
115  G4UImanager* UImanager = G4UImanager::GetUIpointer();
116 
117  if (argc!=1) // batch mode
118  {
119  G4String command = "/control/execute ";
120  G4String fileName = argv[1];
121  UImanager->ApplyCommand(command+fileName);
122  }
123  else
124  { // interactive mode : define UI session
125 #ifdef G4UI_USE
126  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
127  ui->SessionStart();
128  delete ui;
129 #endif
130  }
131 
132  // job termination
133 
134 #ifdef G4VIS_USE
135  delete visManager;
136 #endif
137  // delete field;
138  delete runManager;
139 
140  return 0;
141 }
142