-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lucas.cc
156 lines (134 loc) · 4.49 KB
/
Lucas.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*============================================================================
* Name : LumiCalJA.cpp
* Author : Jonathan Aguilar
* Version : 1
* Copyright :
* Description : LumiCal stand-alone application for Geant4
*============================================================================
$Id$
$URL$
*/
//
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/times.h>
#include <string.h>
#include <unistd.h>
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UItcsh.hh"
#include "G4UIterminal.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingAction.hh"
#include "LCDetectorConstruction.hh"
#include "PhysicsListFactory.hh"
#include "LCRunAction.hh"
#include "LCEventAction.hh"
#include "LCRootOut.hh"
#include "Setup.hh"
#include "banner.hh"
#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif
#include <iostream>
using namespace std;
int main( int argc, char* argv[] ) {
//
//
char *Me = strrchr(argv[0], '/');
if (Me == NULL) Me = argv[0];
else Me++;
print_lucas_banner();
LCRootOut *theLCRootOut = NULL;
G4RunManager* runManager = new G4RunManager;
//
Setup* theSetup = Setup::GetSetup();
theSetup -> SetupInit( argc, argv );
// User initialization classes
runManager->SetUserInitialization(new LCDetectorConstruction);
//
G4VUserPhysicsList *theList = PhysicsListFactory::create( Setup::PhysicsListName );
theList -> SetDefaultCutValue( Setup::rangeCut );
runManager->SetUserInitialization( theList );
tms fStartTime;
clock_t StartTime = times (&fStartTime); // times returns time in miliseconds
// Initialize the run manager
//
runManager->Initialize();
// User Action Classes
runManager->SetUserAction(new PrimaryGeneratorAction);
//
if( Setup::batchMode ){ // Initialize the ROOT output class
LCRootOut *theRootOut = new LCRootOut();
LCEventAction *theEventAction = new LCEventAction( theRootOut );
runManager->SetUserAction(new LCRunAction ( theRootOut ));
runManager->SetUserAction( theEventAction );
runManager->SetUserAction(new SteppingAction ( theEventAction) );
}else{
LCEventAction *theEventAction = new LCEventAction();
runManager->SetUserAction(new LCRunAction());
runManager->SetUserAction( theEventAction );
runManager->SetUserAction(new SteppingAction ( theEventAction ) );
}
//
// Get pointer to the UI
//
G4UImanager* UI = G4UImanager::GetUIpointer();
G4cout << "Setup::batchMode " << Setup::batchMode << G4endl;
G4cout << "/control/execute " + Setup::macroName << G4endl;
if ( Setup::batchMode ) // batch mode
{
G4String command = "/control/execute ";
UI->ApplyCommand(command + Setup::macroName);
}
else // interactive mode
{
#ifdef G4VIS_USE
// visualization manager
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
#endif
// G4int numberOfEvent = 3;
// runManager->BeamOn(numberOfEvent);
// Run from UI
G4UIsession *session = 0;
#ifdef G4UI_USE_TCSH
session = new G4UIterminal(new G4UItcsh);
#else
session = new G4UIterminal();
#endif
// send output of G4cout and G4cerr to external files
// Specifically, session will use methods ReceiveG4cout and "G4err
UI->SetCoutDestination(session);
G4String command = "/control/execute ";
if( Setup::macroName != "" )UI->ApplyCommand(command + Setup::macroName);
session->SessionStart();
delete session;
#ifdef G4VIS_USE
delete visManager;
#endif
}
// Job termination - free the store. Do not delete physicslist, detectorconstruction,
// other user actions, because those are deleted by the run manager
if ( Setup::AccumulateEvents ) {
if ( LCRootOut::pRootFile ) {
G4cout<< " Writing to and closing file : "<< Setup::RootFileName << G4endl;
LCRootOut::pRootFile->Write();
LCRootOut::pRootFile->Close();
G4cout <<Me<< " main::Closed file: " << Setup::RootFileName << G4endl;
}
delete theLCRootOut;
}
delete runManager;
//
time_t now; time(&now);
tms fEndTime;
clock_t EndTime = times (&fEndTime); // times returns time in 10 miliseconds units
G4double diff = 10.*( EndTime - StartTime ) *ms ;
G4cout << " End Job - time elapsed : " << diff / s << " seconds " << G4endl;
delete theSetup;
G4cout << "\n**** "<< Me <<" run ended at " << ctime(&now) << G4endl;;
return 0;
}