source: trunk/examples/advanced/microbeam/Microbeam.cc @ 1358

Last change on this file since 1358 was 1342, checked in by garnier, 14 years ago

update ti head

  • Property svn:executable set to *
File size: 4.7 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: Microbeam.cc,v 1.11 2010/10/07 14:03:11 sincerti Exp $
28// -------------------------------------------------------------------
29//  GEANT4 - Microbeam example
30//  Developed by S. Incerti et al.
31//  Centre d'Etudes Nucleaires de Bordeaux-Gradignan
32//  CNRS / IN2P3 / Bordeaux 1 University
33//  33175 Gradignan, France
34//  incerti@cenbg.in2p3.fr
35// -------------------------------------------------------------------
36
37#include "G4RunManager.hh"
38#include "G4UImanager.hh"
39#include "G4UIterminal.hh"
40#include "G4UItcsh.hh"
41#include "Randomize.hh"
42
43#ifdef G4VIS_USE
44#include "G4VisExecutive.hh"
45#endif
46
47#include "MicrobeamDetectorConstruction.hh"
48#include "MicrobeamPhysicsList.hh"
49#include "MicrobeamPrimaryGeneratorAction.hh"
50#include "MicrobeamRunAction.hh"
51#include "MicrobeamEventAction.hh"
52#include "MicrobeamTrackingAction.hh"
53#include "MicrobeamSteppingAction.hh"
54#include "MicrobeamSteppingVerbose.hh"
55#include "MicrobeamHistoManager.hh"
56
57int main(int argc,char** argv) {
58
59  // choose the Random engine
60  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
61 
62  // verbose output class
63  G4VSteppingVerbose::SetInstance(new MicrobeamSteppingVerbose);
64 
65  // construct the default run manager
66  G4RunManager * runManager = new G4RunManager;
67
68  // set mandatory initialization classes
69  MicrobeamDetectorConstruction* detector = new MicrobeamDetectorConstruction;
70
71  runManager->SetUserInitialization(detector);
72
73  runManager->SetUserInitialization(new MicrobeamPhysicsList);
74   
75#ifdef G4VIS_USE
76  // visualization manager
77  G4VisManager* visManager = new G4VisExecutive;
78  visManager->Initialize();
79#endif
80
81  // set user action classes
82  MicrobeamPrimaryGeneratorAction* KinAct = new MicrobeamPrimaryGeneratorAction(detector);
83  runManager->SetUserAction(KinAct);
84 
85  MicrobeamHistoManager*  histo = new MicrobeamHistoManager();
86
87  MicrobeamRunAction* RunAct = new MicrobeamRunAction(detector,histo);
88 
89  runManager->SetUserAction(RunAct);
90  runManager->SetUserAction(new MicrobeamEventAction(RunAct,histo));
91  runManager->SetUserAction(new MicrobeamTrackingAction(RunAct)); 
92  runManager->SetUserAction(new MicrobeamSteppingAction(RunAct,detector,histo));
93 
94  // initialize G4 kernel
95  // runManager->Initialize();
96   
97  // get the pointer to the User Interface manager
98  G4UImanager* UI = G4UImanager::GetUIpointer(); 
99 
100  // local user files created by the simulation
101  system ("rm -rf microbeam.root");
102       
103  if (argc==1)   // define UI session for interactive mode.
104    {
105      // G4UIterminal is a (dumb) terminal.
106      G4UIsession * session = 0;
107#ifdef G4UI_USE_TCSH
108      session = new G4UIterminal(new G4UItcsh);
109#else
110      session = new G4UIterminal();
111#endif
112      UI->ApplyCommand("/control/execute microbeam.mac");   
113      session->SessionStart();
114      delete session;
115    }
116  else           // batch mode
117    { 
118      G4String command = "/control/execute ";
119      G4String fileName = argv[1];
120      UI->ApplyCommand(command+fileName);
121    }
122
123  // job termination
124#ifdef G4VIS_USE
125  delete visManager;
126#endif
127  delete runManager;
128
129  return 0;
130 
131}
132
Note: See TracBrowser for help on using the repository browser.