Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nanobeam.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 // -------------------------------------------------------------------
27 // $Id: Nanobeam.cc,v 1.8 2010-10-09 16:30:27 sincerti Exp $
28 // -------------------------------------------------------------------
29 
30 #include "G4RunManager.hh"
31 #include "G4UImanager.hh"
32 #include "Randomize.hh"
33 
34 #ifdef G4UI_USE
35  #include "G4UIExecutive.hh"
36 #endif
37 
38 #include "DetectorConstruction.hh"
39 #include "PhysicsList.hh"
40 #include "PrimaryGeneratorAction.hh"
41 #include "RunAction.hh"
42 #include "EventAction.hh"
43 #include "TrackingAction.hh"
44 #include "SteppingAction.hh"
45 #include "SteppingVerbose.hh"
46 #include "HistoManager.hh"
47 
48 int main(int argc,char** argv) {
49 
50  // Choose the Random engine
52 
53  // Verbose output class
55 
56  // Construct the default run manager
57  G4RunManager * runManager = new G4RunManager;
58 
59  // Set mandatory initialization classes
61  runManager->SetUserInitialization(detector);
62  runManager->SetUserInitialization(new PhysicsList);
63 
64  PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
65  runManager->SetUserAction(primary);
66 
67  HistoManager* histo = new HistoManager();
68 
69  // Set user action classes
70  RunAction* RunAct = new RunAction(detector,primary,histo);
71 
72  runManager->SetUserAction(RunAct);
73  runManager->SetUserAction(new EventAction(RunAct));
74  runManager->SetUserAction(new TrackingAction(RunAct));
75  runManager->SetUserAction(new SteppingAction(RunAct,detector,primary,histo));
76 
77  // Initialize G4 kernel
78  runManager->Initialize();
79 
80  // Get the pointer to the User Interface manager
81  G4UImanager* UImanager = G4UImanager::GetUIpointer();
82 
83  //
84  remove ("nanobeam.root");
85 
86  if (argc==1) // Define UI session for interactive mode.
87  {
88 #ifdef G4UI_USE
89  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
90  UImanager->ApplyCommand("/control/execute default.mac");
91  ui->SessionStart();
92  delete ui;
93 #endif
94  }
95 
96  else // Batch mode
97  {
98  G4String command = "/control/execute ";
99  G4String fileName = argv[1];
100  UImanager->ApplyCommand(command+fileName);
101  }
102 
103  delete runManager;
104 
105  return 0;
106 }