ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSim.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////
2 //*-- AUTHOR : Hector Alvarez-Pol (hapol@fpddux.usc.es)
3 // Beatriz Fernandez (bfd@ns.ph.liv.ac.uk)
4 // Esther Estevez (hachebarra79@yahoo.es)
5 // Elisangela Benjamim (ebenjami@usc.es)
6 //*-- Date: 03/2006
7 //*-- Last Update: 28/10/05
8 //*-- Copyright: GENP (Univ. Santiago de Compostela)
9 //
10 // --------------------------------------------------------------
11 // Comments:
12 // ACTARSIM is an application for the simulation of the
13 // ACTive TArget detector.
14 //
15 // --------------------------------------------------------------
16 /////////////////////////////////////////////////////////////////
17 
18 #include <time.h>
19 
20 #include "G4RunManager.hh"
21 #include "G4UImanager.hh"
22 #include "G4UIterminal.hh"
23 #include "G4UItcsh.hh"
24 #include "G4UIQt.hh"
25 
26 #ifdef G4UI_USE_ROOT
27 #include "G4UIRoot.hh"
28 #endif
29 
30 #ifdef G4UI_USE_XM
31 #include "G4UIXm.hh"
32 #endif
33 
34 #include "Randomize.hh"
35 
36 #ifdef G4VIS_USE
37 #include "ActarSimVisManager.hh"
38 #endif
39 
40 #ifdef G4UI_USE
41 #include "G4UIExecutive.hh"
42 #endif
43 
45 #include "ActarSimPhysicsList.hh"
47 #include "ActarSimRunAction.hh"
48 #include "ActarSimEventAction.hh"
51 #include "ActarSimROOTAnalysis.hh"
52 
53 int main(int argc,char** argv)
54 {
55  // choose the Random engine
56  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
57  G4long seed=time(0); //returns time in seconds as an integer
58  CLHEP::HepRandom::setTheSeed(seed);//changes the seed of the random engine
59 
60 
61  //my Verbose output class
62  G4VSteppingVerbose::SetInstance(new ActarSimSteppingVerbose);
63 
64  // Construct the default run manager
65  G4RunManager* runManager = new G4RunManager;
66 
67  // set mandatory initialization classes
69  runManager->SetUserInitialization(detector);
70  runManager->SetUserInitialization(new ActarSimPhysicsList);
71 
72  // histogramming
73  //ActarSimROOTAnalysis *analysis = new ActarSimROOTAnalysis(detector);
75 
76  G4UIsession* session=0;
77 
78  if (argc==1){ // Define UI session for interactive mode.
79 #if defined (G4UI_USE_ROOT)
80  // G4URoot is a ROOT based GUI.
81  session = new G4UIRoot(argc,argv);
82 #elif defined (G4UI_USE_XM)
83  // G4UIXm is an Xm based GUI.
84  session = new G4UIXm(argc,argv);
85 #elif defined(G4UI_USE_TCSH)
86  session = new G4UIterminal(new G4UItcsh);
87 #else
88  session = new G4UIterminal();
89 #endif
90 #ifdef G4UI_USE
91  session = new G4UIQt(argc,argv);
92 #endif
93  }
94 #ifdef G4VIS_USE
95  // visualization manager
96  G4VisManager* visManager = new ActarSimVisManager;
97  visManager->Initialize();
98 #endif
99 
100  // set mandatory user action class
101  runManager->SetUserAction(new ActarSimPrimaryGeneratorAction);
102  runManager->SetUserAction(new ActarSimRunAction);
103  ActarSimEventAction* eventaction = new ActarSimEventAction;
104  runManager->SetUserAction(eventaction);
105  runManager->SetUserAction(new ActarSimSteppingAction(detector,eventaction));
106 
107  // Initialize G4 kernel -->Make it manually to allow the definition of
108  // commands in PreInit state (for instance to define the PhysicsList)
109  //runManager->Initialize();
110 
111  // get the pointer to the UI manager and set verbosities
112  G4UImanager* UI = G4UImanager::GetUIpointer();
113 
114  if (session) {
115  // G4UIterminal is a (dumb) terminal.
116  //UI->ApplyCommand("/control/execute vis2.mac");
117  UI->ApplyCommand("/control/execute gui.mac");
118  session->SessionStart();
119  if ( (G4UImanager::GetUIpointer()) &&
120  (session ==(G4UImanager::GetUIpointer())->GetSession()) )
121  delete session;
122  }
123  else {
124  //This part should be used for batch
125  G4String command = "/control/execute ";
126  G4String fileName = argv[1];
127  UI->ApplyCommand(command+fileName);
128  }
129 
130  // job termination
131  delete analysis;
132 #ifdef G4VIS_USE
133  delete visManager;
134 #endif
135  G4cout << "RunManager deleting... "<< G4endl;
136  delete runManager;
137 
138 return 0;
139 }
140 
141 
142 
int main(int argc, char **argv)
Definition: ActarSim.cc:53