-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathActarSim.cc
executable file
·109 lines (91 loc) · 3.49 KB
/
ActarSim.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/////////////////////////////////////////////////////////////////
//*-- AUTHOR : Hector Alvarez-Pol (hapol@fpddux.usc.es)
// Beatriz Fernandez (bfd@ns.ph.liv.ac.uk)
// Esther Estevez (hachebarra79@yahoo.es)
// Elisangela Benjamim (ebenjami@usc.es)
//*-- Date: 03/2006
//*-- Last Update: 22/04/20
//*-- Copyright: GENP (Univ. Santiago de Compostela)
//
// --------------------------------------------------------------
// Comments:
// ACTARSIM is an application for the simulation of the
// ACTive TArget detector.
//
// --------------------------------------------------------------
/////////////////////////////////////////////////////////////////
#include <time.h>
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4UIQt.hh"
#include "Randomize.hh"
#include "G4VisManager.hh"
#include "G4UIExecutive.hh"
#include "ActarSimDetectorConstruction.hh"
#include "ActarSimPhysicsList.hh"
#include "ActarSimPrimaryGeneratorAction.hh"
#include "ActarSimRunAction.hh"
#include "ActarSimEventAction.hh"
#include "ActarSimSteppingAction.hh"
#include "ActarSimSteppingVerbose.hh"
#include "ActarSimROOTAnalysis.hh"
#include "ActarSimVisManager.hh"
int main(int argc,char** argv)
{
// choose the Random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
G4long seed=time(0); //returns time in seconds as an integer
CLHEP::HepRandom::setTheSeed(seed);//changes the seed of the random engine
//my Verbose output class
G4VSteppingVerbose::SetInstance(new ActarSimSteppingVerbose);
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
ActarSimDetectorConstruction* detector = new ActarSimDetectorConstruction;
runManager->SetUserInitialization(detector);
runManager->SetUserInitialization(new ActarSimPhysicsList);
// histogramming
//ActarSimROOTAnalysis *analysis = new ActarSimROOTAnalysis(detector);
ActarSimROOTAnalysis *analysis = new ActarSimROOTAnalysis();
G4UIsession* session=0;
if (argc==1){ // Define UI session for interactive mode.
session = new G4UIQt(argc,argv);
}
// visualization manager
G4VisManager* visManager = new ActarSimVisManager;
visManager->Initialize();
// set mandatory user action class
runManager->SetUserAction(new ActarSimPrimaryGeneratorAction);
runManager->SetUserAction(new ActarSimRunAction);
ActarSimEventAction* eventaction = new ActarSimEventAction;
runManager->SetUserAction(eventaction);
runManager->SetUserAction(new ActarSimSteppingAction(detector,eventaction));
// Initialize G4 kernel -->Make it manually to allow the definition of
// commands in PreInit state (for instance to define the PhysicsList)
//runManager->Initialize();
// get the pointer to the UI manager and set verbosities
G4UImanager* UI = G4UImanager::GetUIpointer();
if (session) {
// G4UIterminal is a (dumb) terminal.
//UI->ApplyCommand("/control/execute vis2.mac");
UI->ApplyCommand("/control/execute gui.mac");
session->SessionStart();
if ( (G4UImanager::GetUIpointer()) &&
(session ==(G4UImanager::GetUIpointer())->GetSession()) )
delete session;
}
else {
//This part should be used for batch
G4String command = "/control/execute ";
G4String fileName = argv[1];
UI->ApplyCommand(command+fileName);
}
// job termination
delete analysis;
delete visManager;
G4cout << "RunManager deleting... "<< G4endl;
delete runManager;
return 0;
}