source: trunk/examples/extended/hadronic/Hadr01/hadr01.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.8 KB
Line 
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: hadr01.cc,v 1.12 2010/05/26 11:53:40 allison Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// -------------------------------------------------------------
31//      GEANT4 hadr01
32//
33//  Application demonstrating Geant4 hadronic physics:
34//  beam interaction with a target
35//
36//  Authors: A.Bagulya, I.Gudowska, V.Ivanchenko, N.Starkov
37//
38//  Modified:
39//  29.12.2009 V.Ivanchenko introduced access to reference PhysLists
40//
41// -------------------------------------------------------------
42//
43//
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
47#include "G4RunManager.hh"
48#include "G4UImanager.hh"
49#include "Randomize.hh"
50
51#include "DetectorConstruction.hh"
52#include "PhysicsList.hh"
53#include "G4PhysListFactory.hh"
54#include "G4VModularPhysicsList.hh"
55#include "PrimaryGeneratorAction.hh"
56#include "PhysicsListMessenger.hh"
57
58#include "RunAction.hh"
59#include "EventAction.hh"
60#include "StackingAction.hh"
61
62#ifdef G4VIS_USE
63#include "G4VisExecutive.hh"
64#endif
65
66#ifdef G4UI_USE
67#include "G4UIExecutive.hh"
68#endif
69
70//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71
72int main(int argc,char** argv) {
73
74  //choose the Random engine
75  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
76
77  //Construct the default run manager
78  G4RunManager * runManager = new G4RunManager();
79
80  //set mandatory initialization classes
81  runManager->SetUserInitialization(new DetectorConstruction());
82
83  G4PhysListFactory factory;
84  G4VModularPhysicsList* phys = 0;
85  PhysicsListMessenger* mess = 0;
86  G4String physName = "";
87
88  // Physics List name defined via 2nd argument
89  if (argc==3) { physName = argv[2]; }
90
91  // Physics List name defined via environment variable
92  char* path = getenv("PHYSLIST");
93  if (path) { physName = G4String(path); }
94
95  // reference PhysicsList via its name
96  if(factory.IsReferencePhysList(physName)) {
97    phys = factory.GetReferencePhysList(physName);
98    mess = new PhysicsListMessenger();
99  } 
100
101  // local Physics List
102  if(!phys) { phys = new PhysicsList(); }
103
104  // define physics
105  runManager->SetUserInitialization(phys);
106  runManager->SetUserAction(new PrimaryGeneratorAction());
107
108  //set user action classes
109  runManager->SetUserAction(new RunAction());
110  runManager->SetUserAction(new EventAction());
111  runManager->SetUserAction(new StackingAction());
112
113  //get the pointer to the User Interface manager
114  G4UImanager* UImanager = G4UImanager::GetUIpointer();
115  G4VisManager* visManager = 0;
116
117  if (argc==1)   // Define UI terminal for interactive mode
118    {
119#ifdef G4VIS_USE
120      //visualization manager
121      visManager = new G4VisExecutive;
122      visManager->Initialize();
123#endif
124#ifdef G4UI_USE
125      G4UIExecutive* ui = new G4UIExecutive(argc, argv);
126      ui->SessionStart();
127      delete ui;
128#endif
129    }
130  else           // Batch mode
131    {
132      G4String command = "/control/execute ";
133      G4String fileName = argv[1];
134      UImanager->ApplyCommand(command+fileName);
135    }
136
137  //job termination
138  delete visManager;
139  delete runManager;
140  delete mess;
141
142  return 0;
143}
144
145//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.