Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
optical
wls
src
WLSEventAction.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
//
28
//
29
//
30
//
31
32
#include "
WLSEventAction.hh
"
33
34
#include "
WLSRunAction.hh
"
35
36
#include "
WLSEventActionMessenger.hh
"
37
38
#include "
WLSPhotonDetHit.hh
"
39
40
#include "
G4Event.hh
"
41
#include "
G4EventManager.hh
"
42
#include "
WLSTrajectory.hh
"
43
#include "
G4TrajectoryContainer.hh
"
44
#include "
G4VVisManager.hh
"
45
#include "
G4SDManager.hh
"
46
47
//#include "G4ThreeVector.hh"
48
49
//#include "G4UnitsTable.hh"
50
51
#include "
Randomize.hh
"
52
53
// Purpose: Invoke visualization at the end
54
// Also can accumulate statistics regarding hits
55
// in the PhotonDet detector
56
57
WLSEventAction::WLSEventAction
(
WLSRunAction
* RA)
58
: runaction(RA), verboselevel(0),
59
printModulo(100), drawFlag(
"all"
)
60
{
61
eventMessenger =
new
WLSEventActionMessenger
(
this
);
62
63
forcedrawphotons =
false
;
64
forcenophotons =
false
;
65
66
}
67
68
WLSEventAction::~WLSEventAction
()
69
{
70
delete
eventMessenger;
71
}
72
73
void
WLSEventAction::BeginOfEventAction
(
const
G4Event
* evt)
74
{
75
G4int
evtNb = evt->
GetEventID
();
76
if
(evtNb%printModulo == 0)
77
G4cout
<<
"\n---> Begin of Event: "
<< evtNb <<
G4endl
;
78
79
if
(verboselevel>0)
80
G4cout
<<
"<<< Event "
<< evtNb <<
" started."
<<
G4endl
;
81
}
82
83
void
WLSEventAction::EndOfEventAction
(
const
G4Event
* evt)
84
{
85
G4VVisManager
* pVVisManager =
G4VVisManager::GetConcreteInstance
();
86
87
// Visualization of Trajectory
88
if
(pVVisManager)
89
{
90
G4TrajectoryContainer
* trajectoryContainer = evt->
GetTrajectoryContainer
();
91
92
G4int
n_trajectories = 0;
93
if
(trajectoryContainer) n_trajectories = trajectoryContainer->
entries
();
94
G4cout
<<
"n_trajectories: "
<< n_trajectories <<
G4endl
;
95
if
(drawFlag ==
"all"
)
G4cout
<<
"draw all trajectories"
<<
G4endl
;
96
if
(drawFlag ==
"charged"
)
G4cout
<<
"draw only charged"
<<
G4endl
;
97
98
for
(
G4int
i=0; i<n_trajectories; i++)
99
{
WLSTrajectory
* trj =
100
(
WLSTrajectory
*)((*(evt->
GetTrajectoryContainer
()))[i]);
101
if
(drawFlag ==
"all"
) {
102
G4cout
<<
"Now calling DrawTrajectory"
<<
G4endl
;
103
G4cout
<<
"Particle Name: "
<< trj->
GetParticleName
() <<
G4endl
;
104
trj->
DrawTrajectory
(50);
105
}
106
else
if
((drawFlag ==
"charged"
)&&(trj->
GetCharge
() != 0.))
107
trj->
DrawTrajectory
(50);
108
else
if
(trj->
GetParticleName
()==
"opticalphoton"
)
109
{
110
G4cout
<<
"We should be drawing an opticalphoton"
<<
G4endl
;
111
trj->
SetForceDrawTrajectory
(forcedrawphotons);
112
trj->
SetForceNoDrawTrajectory
(forcenophotons);
113
trj->
DrawTrajectory
(50);
114
}
115
}
116
}
117
118
if
(verboselevel>0)
119
G4cout
<<
"<<< Event "
<< evt->
GetEventID
() <<
" ended."
<<
G4endl
;
120
121
// Save the Random Engine Status at the of event
122
if
(runaction->
GetRndmFreq
() == 2)
123
{
124
CLHEP::HepRandom::saveEngineStatus
(
"endOfEvent.rndm"
);
125
G4int
evtNb = evt->
GetEventID
();
126
if
(evtNb%printModulo == 0)
127
{
128
G4cout
<<
"\n---> End of Event: "
<< evtNb <<
G4endl
;
129
CLHEP::HepRandom::showEngineStatus
();
130
}
131
}
132
133
// Get Hits from the detector if any
134
G4SDManager
* SDman =
G4SDManager::GetSDMpointer
();
135
G4String
colName =
"PhotonDetHitCollection"
;
136
mppcCollID = SDman->
GetCollectionID
(colName);
137
138
G4HCofThisEvent
* HCE = evt->
GetHCofThisEvent
();
139
WLSPhotonDetHitsCollection
* mppcHC = 0;
140
141
// Get the hit collections
142
if
(HCE)
143
{
144
if
(mppcCollID>=0) mppcHC =
145
(
WLSPhotonDetHitsCollection
*)(HCE->
GetHC
(mppcCollID));
146
}
147
148
// Get hit information about photons that reached the detector in this event
149
if
(mppcHC)
150
{
151
// G4int n_hit = mppcHC->entries();
152
}
153
}
154
155
G4int
WLSEventAction::GetEventNo
()
156
{
157
G4int
evno =
fpEventManager
->
GetConstCurrentEvent
()->
GetEventID
();
158
return
evno;
159
}
160
161
void
WLSEventAction::SetEventVerbose
(
G4int
level)
162
{
163
verboselevel = level;
164
}
Generated on Sat May 25 2013 14:32:58 for Geant4 by
1.8.4