Geant4
10.03
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
GammaRayTelRunAction.cc
Go to the documentation of this file.
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: GammaRayTelRunAction.cc 82630 2014-07-01 09:43:00Z gcosmo $
28
// ------------------------------------------------------------
29
// GEANT 4 class implementation file
30
// CERN Geneva Switzerland
31
//
32
//
33
// ------------ GammaRayTelRunAction ------
34
// by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
35
// 18.11.2001 G.Santin
36
// - Modified the analysis management according to the new design
37
//
38
// ************************************************************
39
40
41
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43
44
#include "
GammaRayTelRunAction.hh
"
45
46
#include "
GammaRayTelAnalysis.hh
"
47
48
#include <stdlib.h>
49
#include "
G4Run.hh
"
50
#include "
G4UImanager.hh
"
51
#include "
G4VVisManager.hh
"
52
#include "
G4ios.hh
"
53
#include "
G4Threading.hh
"
54
55
GammaRayTelRunAction::GammaRayTelRunAction
() :
56
outFile(0),fileName(
"NULL"
),fRunID(-1)
57
{;}
58
59
60
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61
62
GammaRayTelRunAction::~GammaRayTelRunAction
()
63
{;}
64
65
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66
67
void
GammaRayTelRunAction::BeginOfRunAction
(
const
G4Run
* aRun)
68
{
69
fRunID
= aRun->
GetRunID
();
70
71
//Master mode or sequential
72
if
(
IsMaster
())
73
G4cout
<<
"### Run "
<< aRun->
GetRunID
() <<
" starts (master)."
<<
G4endl
;
74
else
75
G4cout
<<
"### Run "
<< aRun->
GetRunID
() <<
" starts (worker)."
<<
G4endl
;
76
77
// Prepare the visualization
78
if
(
G4VVisManager::GetConcreteInstance
())
79
{
80
G4UImanager
* UI =
G4UImanager::GetUIpointer
();
81
UI->
ApplyCommand
(
"/vis/scene/notifyHandlers"
);
82
}
83
84
// If analysis is used reset the histograms
85
GammaRayTelAnalysis
* analysis =
GammaRayTelAnalysis::getInstance
();
86
// analysis->BeginOfRun(aRun->GetRunID());
87
analysis->
BeginOfRun
();
88
}
89
90
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
91
92
void
GammaRayTelRunAction::EndOfRunAction
(
const
G4Run
* aRun)
93
{
94
G4cout
<<
"End of Run "
<< aRun->
GetRunID
() <<
G4endl
;
95
96
// Close the file with the hits information
97
#ifdef G4STORE_DATA
98
if
(
outFile
)
99
{
100
G4cout
<<
"File "
<<
fileName
<<
G4endl
;
101
outFile
->close();
102
delete
outFile
;
103
outFile
= 0;
104
}
105
#endif
106
107
// If analysis is used, print out the histograms
108
GammaRayTelAnalysis
* analysis =
GammaRayTelAnalysis::getInstance
();
109
analysis->
EndOfRun
();
110
}
111
112
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113
114
115
std::ofstream*
GammaRayTelRunAction::GetOutputFile
()
116
{
117
if
(!
outFile
)
118
OpenFile
();
119
return
outFile
;
120
}
121
122
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
123
void
GammaRayTelRunAction::OpenFile
()
124
{
125
// Open the file for the tracks of this run
126
#ifdef G4STORE_DATA
127
//check that we are in a worker: returns -1 in a master and -2 in sequential
128
//one file per thread is produced
129
//Tracks_runR.N.dat, where R=run number, N=thread ID
130
char
name
[25];
131
if
(
G4Threading::G4GetThreadId
() >= 0)
132
sprintf(name,
"Tracks_run%d.%d.dat"
,
fRunID
,
133
G4Threading::G4GetThreadId
());
134
else
135
sprintf(name,
"Tracks_run%d.dat"
,
fRunID
);
136
if
(!
outFile
)
137
{
138
outFile
=
new
std::ofstream;
139
outFile
->open(name);
140
fileName
=
G4String
(name);
141
}
142
G4cout
<<
"Open file: "
<<
fileName
<<
G4endl
;
143
#endif
144
}
145
146
GammaRayTelRunAction::~GammaRayTelRunAction
~GammaRayTelRunAction()
Definition:
GammaRayTelRunAction.cc:62
GammaRayTelRunAction::GetOutputFile
std::ofstream * GetOutputFile()
Definition:
GammaRayTelRunAction.cc:115
GammaRayTelRunAction::fileName
G4String fileName
Definition:
GammaRayTelRunAction.hh:65
G4VVisManager::GetConcreteInstance
static G4VVisManager * GetConcreteInstance()
Definition:
G4VVisManager.cc:39
GammaRayTelAnalysis::getInstance
static GammaRayTelAnalysis * getInstance()
Definition:
GammaRayTelAnalysis.cc:97
GammaRayTelRunAction::BeginOfRunAction
void BeginOfRunAction(const G4Run *)
Definition:
GammaRayTelRunAction.cc:67
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:77
GammaRayTelRunAction::outFile
std::ofstream * outFile
Definition:
GammaRayTelRunAction.hh:64
G4UImanager::GetUIpointer
static G4UImanager * GetUIpointer()
Definition:
G4UImanager.cc:58
G4VVisManager.hh
GammaRayTelAnalysis.hh
GammaRayTelRunAction::GammaRayTelRunAction
GammaRayTelRunAction()
Definition:
GammaRayTelRunAction.cc:55
G4cout
G4GLOB_DLL std::ostream G4cout
GammaRayTelRunAction::EndOfRunAction
void EndOfRunAction(const G4Run *)
Definition:
GammaRayTelRunAction.cc:92
G4Threading.hh
GammaRayTelAnalysis::BeginOfRun
void BeginOfRun()
Definition:
GammaRayTelAnalysis.cc:150
G4UserRunAction::IsMaster
G4bool IsMaster() const
Definition:
G4UserRunAction.hh:69
GammaRayTelRunAction::fRunID
G4int fRunID
Definition:
GammaRayTelRunAction.hh:68
G4Run::GetRunID
G4int GetRunID() const
Definition:
G4Run.hh:76
G4Run
Definition:
G4Run.hh:46
GammaRayTelRunAction::OpenFile
void OpenFile()
Definition:
GammaRayTelRunAction.cc:123
G4UImanager.hh
GammaRayTelAnalysis
Definition:
GammaRayTelAnalysis.hh:71
G4Run.hh
G4ios.hh
GammaRayTelAnalysis::EndOfRun
void EndOfRun()
Definition:
GammaRayTelAnalysis.cc:229
G4UImanager
Definition:
G4UImanager.hh:56
G4endl
#define G4endl
Definition:
G4ios.hh:61
GammaRayTelRunAction.hh
G4Threading::G4GetThreadId
G4int G4GetThreadId()
Definition:
G4Threading.cc:144
G4UImanager::ApplyCommand
G4int ApplyCommand(const char *aCommand)
Definition:
G4UImanager.cc:446
G4String
Definition:
G4String.hh:45
geant4.10.03
examples
advanced
gammaray_telescope
src
GammaRayTelRunAction.cc
Generated on Thu Feb 14 2002 02:27:33 for Geant4 by
1.8.8