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
geometry
olap
src
OlapGenerator.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
// $Id$
31
//
32
//
33
// --------------------------------------------------------------
34
// OlapGenerator
35
//
36
// Author: Martin Liendl - Martin.Liendl@cern.ch
37
//
38
// --------------------------------------------------------------
39
//
40
#include "
OlapGenerator.hh
"
41
#include "
G4Event.hh
"
42
#include "
G4VisExtent.hh
"
43
#include "
G4PrimaryParticle.hh
"
44
#include "
G4Geantino.hh
"
45
#include "
G4ChargedGeantino.hh
"
46
#include "
G4RunManager.hh
"
47
#include "
G4Run.hh
"
48
#include "
G4Event.hh
"
49
50
//#define OLAPDEBUG1
51
52
OlapGrid::OlapGrid
()
53
: count(3,0), gsize(3,3), axis(0), eventsPerRun(27)
54
{
55
Reset
();
56
G4cout
<<
"OlapGrid(): "
<<
G4endl
57
<<
" gsize: "
<<
gsize
[0] <<
" "
<<
gsize
[1]
58
<<
" "
<<
gsize
[2] <<
G4endl
;
59
}
60
61
void
OlapGrid::Next
()
62
{
63
G4int
out = (
axis
+1)%3;
// outer loop
64
G4int
in
= (
axis
+2)%3;
// inner loop
65
if
( !(
count
[in] = (
count
[in]+1)%
gsize
[
in
]) )
66
{
67
if
( !(
count
[out] = (
count
[out]+1)%
gsize
[out]) )
68
{
69
axis
= (
axis
+1)%3;
70
}
71
}
72
}
73
74
OlapGenerator::OlapGenerator
() : autoinc(false)
75
{
76
if
(!
ext
.size())
77
{
78
ext
.push_back(1);
79
ext
.push_back(2);
80
ext
.push_back(3);
81
}
82
/*
83
ext[0]=1.;
84
ext[1]=2.;
85
ext[2]=3.;
86
*/
87
}
88
89
90
OlapGenerator::~OlapGenerator
()
91
{
92
}
93
94
95
void
OlapGenerator::GeneratePrimaries
(
G4Event
* anEvent)
96
{
97
G4int
out = (
grid
.
axis
+1)%3;
// outer loop
98
G4int
in
= (
grid
.
axis
+2)%3;
// inner loop
99
100
posAB
[
grid
.
axis
]=-
ext
[
grid
.
axis
]/2.;
101
posAB
[
in
]=-
ext
[
in
]/2.+
ext
[
in
]/
G4double
(
grid
.
gsize
[in]-1)
102
*
G4double
(
grid
.
count
[in]);
103
posAB
[out]=-
ext
[out]/2.+
ext
[out]/
G4double
(
grid
.
gsize
[out]-1)
104
*
G4double
(
grid
.
count
[out]);
105
106
posBA
=
posAB
;
107
posBA
[
grid
.
axis
]=-
posBA
[
grid
.
axis
];
108
109
G4ThreeVector
dirAB, dirBA;
110
dirAB[
grid
.
axis
] = 1;
111
dirBA[
grid
.
axis
] = -1;
112
113
#ifdef OLAPDEBUG1
114
G4int
runID =
G4RunManager::GetRunManager
()->
GetCurrentRun
()->
GetRunID
();
115
G4int
evtID = anEvent->
GetEventID
();
116
G4cout
<<
"generator: "
117
<<
"run="
<< runID <<
" evt="
<< evtID
118
<<
" axis="
<<
grid
.
axis
<<
" out="
<<
grid
.
count
[out]
119
<<
" in="
<<
grid
.
count
[
in
]
120
<<
" posAB="
<<
posAB
121
<<
" posBA="
<<
posBA
<<
G4endl
;
122
#endif
123
124
// now generator 2 geantinos flying in opposite direction from A->B and B->A
125
// ==========================
126
G4ParticleDefinition
* pd =
G4Geantino::GeantinoDefinition
();
127
128
// create 2 opposite positioned vertices
129
G4PrimaryVertex
* vertexAB =
130
new
G4PrimaryVertex
(
posAB
,0);
131
G4PrimaryVertex
* vertexBA =
132
new
G4PrimaryVertex
(
posBA
,0);
133
134
// create one geantino per vertex as primary
135
G4double
mass = pd->
GetPDGMass
();
136
G4double
energy
= 1. + mass;
137
G4double
pmom = std::sqrt(energy*energy-mass*mass);
138
G4double
pxAB = pmom*dirAB.
x
();
139
G4double
pyAB = pmom*dirAB.
y
();
140
G4double
pzAB = pmom*dirAB.
z
();
141
G4double
pxBA = pmom*dirBA.
x
();
142
G4double
pyBA = pmom*dirBA.
y
();
143
G4double
pzBA = pmom*dirBA.
z
();
144
145
G4PrimaryParticle
* particleAB =
new
G4PrimaryParticle
(pd,pxAB,pyAB,pzAB);
146
G4PrimaryParticle
* particleBA =
new
G4PrimaryParticle
(pd,pxBA,pyBA,pzBA);
147
particleAB->
SetMass
( mass );
148
particleBA->
SetMass
( mass );
149
particleAB->
SetCharge
(0.);
150
particleBA->
SetCharge
(0.);
151
vertexAB->
SetPrimary
( particleAB );
152
vertexBA->
SetPrimary
( particleBA );
153
anEvent->
AddPrimaryVertex
( vertexAB );
154
anEvent->
AddPrimaryVertex
( vertexBA );
155
156
// ok, set all counters to be ready for the next position
157
if
(
autoinc
)
158
grid
.
Next
();
159
/*
160
if ( !(count[in] = (count[in]+1)%grid[in]) ) {
161
if( !(count[out] = (count[out]+1)%grid[out]) ) {
162
axis = (axis+1)%3;
163
}
164
}
165
*/
166
167
}
168
169
170
void
OlapGenerator::SetExtent
(
const
G4VisExtent
& anExt)
171
{
172
ext
[0]=(anExt.
GetXmax
()-anExt.
GetXmin
());
173
ext
[1]=(anExt.
GetYmax
()-anExt.
GetYmin
());
174
ext
[2]=(anExt.
GetZmax
()-anExt.
GetZmin
());
175
for
(
G4int
i=0; i<3; i++)
176
ext
[i] +=
ext
[i]/2000.;
// enlarge by 1%
177
178
Reset
();
179
180
}
181
182
void
OlapGenerator::SetExtent
(
G4double
e
)
183
{
184
ext
[0]=
e
;
185
ext
[1]=
e
;
186
ext
[2]=
e
;
187
}
188
189
190
void
OlapGenerator::Reset
()
191
{
192
grid
.
Reset
();
193
/*
194
for (G4int i=0; i<3; i++) {
195
count[i]=0;
196
}
197
198
axis=0;
199
*/
200
}
201
202
203
void
OlapGenerator::SetGrid
(
G4int
x
,
G4int
y
,
G4int
z
)
204
{
205
if
(x>2)
206
grid
.
gsize
[0]=
x
;
207
else
208
G4cerr
<<
"Warning in OlapGenerator::SetGrid(): wrong x-grid parameter: "
<< x <<
G4endl
;
209
210
211
if
(y>2)
212
grid
.
gsize
[1]=
y
;
213
else
214
G4cerr
<<
"Warning in OlapGenerator::SetGrid(): wrong y-grid parameter: "
<< y <<
G4endl
;
215
216
if
(z>2)
217
grid
.
gsize
[2]=
z
;
218
else
219
G4cerr
<<
"Warning in OlapGenerator::SetGrid(): wrong z-grid parameter: "
<< z <<
G4endl
;
220
221
grid
.
eventsPerRun
= x*y + y*z + x*
z
;
222
Reset
();
223
}
Generated on Sat May 25 2013 14:32:27 for Geant4 by
1.8.4