Geant4  10.00.p03
PurgMag.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 //
26 // Code developed by:
27 // S.Larsson
28 //
29 // *********************
30 // * *
31 // * PurgMag.cc *
32 // * *
33 // *********************
34 //
35 // $Id: PurgMag.cc 72967 2013-08-14 14:57:48Z gcosmo $
36 //
37 // Comments: Main program for the Purgin Magnet example.
38 //
39 
40 #include "G4RunManager.hh"
41 #include "G4UImanager.hh"
42 #include "Randomize.hh"
43 
44 #ifdef G4VIS_USE
45 #include "G4VisExecutive.hh"
46 #endif
47 
48 #ifdef G4UI_USE
49 #include "G4UIExecutive.hh"
50 #endif
51 
53 #include "PurgMagPhysicsList.hh"
55 #include "PurgMagRunAction.hh"
56 #include "PurgMagEventAction.hh"
57 #include "PurgMagTrackingAction.hh"
58 #include "PurgMagSteppingAction.hh"
60 
61 int main(int argc,char** argv) {
62 
63  //choose the Random engine
64  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
65 
66  //PurgMag Verbose output class
68 
69  // Construct the default run manager
70  G4RunManager * runManager = new G4RunManager;
71 
72  // set mandatory initialization classes
74  runManager->SetUserInitialization(detector);
76 
78 
79 #ifdef G4VIS_USE
80  // visualization manager
81  G4VisManager* visManager = new G4VisExecutive;
82  visManager->Initialize();
83 #endif
84 
85 // output environment variables:
86 #ifdef G4ANALYSIS_USE
87  G4cout << G4endl << G4endl << G4endl
88  << " User Environment " << G4endl
89  << " Using AIDA 3.0 analysis " << G4endl;
90 # else
91  G4cout << G4endl << G4endl << G4endl
92  << " User Environment " << G4endl
93  << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS "
94  << G4endl;
95 #endif
96 
97  // set user action classes
98  PurgMagRunAction* RunAct = new PurgMagRunAction();
99  runManager->SetUserAction(RunAct);
100  runManager->SetUserAction(new PurgMagEventAction());
101  runManager->SetUserAction(new PurgMagTrackingAction());
102  runManager->SetUserAction(new PurgMagSteppingAction(detector));
103 
104  //Initialize G4 kernel
105  runManager->Initialize();
106 
107  // get the pointer to the User Interface manager
108  G4UImanager* UImanager = G4UImanager::GetUIpointer();
109 
110 
111  if (argc==1) // Define UI session for interactive mode.
112  {
113 #ifdef G4UI_USE
114  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
115 #ifdef G4VIS_USE
116  UImanager->ApplyCommand("/control/execute vis.mac");
117 #endif
118  ui->SessionStart();
119  delete ui;
120 #endif
121  }
122  else // Batch mode
123  {
124  G4String command = "/control/execute ";
125  G4String fileName = argv[1];
126  UImanager->ApplyCommand(command+fileName);
127  }
128 
129 
130  // For bg jobs with 100000 events.
131  /*
132  int numberOfEvent = 100000;
133  runManager->BeamOn(numberOfEvent);
134  */
135 
136 
137  // job termination
138 #ifdef G4VIS_USE
139  delete visManager;
140 #endif
141  delete runManager;
142 
143  return 0;
144 }
145 
int main(int argc, char **argv)
Definition: PurgMag.cc:61
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
virtual void SetUserAction(G4UserRunAction *userAction)