Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
calypso
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Charlotte Cavanagh
calypso
Commits
a81eb106
Commit
a81eb106
authored
2 years ago
by
Carl Gwilliam
Browse files
Options
Downloads
Patches
Plain Diff
Add energy cut into Fluka reader
parent
eed7010e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Generators/FlukaReader/python/FlukaReaderAlg.py
+22
-5
22 additions, 5 deletions
Generators/FlukaReader/python/FlukaReaderAlg.py
with
22 additions
and
5 deletions
Generators/FlukaReader/python/FlukaReaderAlg.py
+
22
−
5
View file @
a81eb106
...
@@ -36,7 +36,8 @@ class FlukaReader(EvgenAlg):
...
@@ -36,7 +36,8 @@ class FlukaReader(EvgenAlg):
if
self
.
test
:
if
self
.
test
:
self
.
before
=
dict
(
zip
(
self
.
columns
,
[[]
for
i
in
range
(
len
(
self
.
columns
))]))
self
.
before
=
dict
(
zip
(
self
.
columns
,
[[]
for
i
in
range
(
len
(
self
.
columns
))]))
self
.
after
=
dict
(
zip
(
self
.
columns
,
[[]
for
i
in
range
(
len
(
self
.
columns
))]))
self
.
after
=
dict
(
zip
(
self
.
columns
,
[[]
for
i
in
range
(
len
(
self
.
columns
))]))
return
return
...
@@ -153,6 +154,8 @@ class FlukaReader(EvgenAlg):
...
@@ -153,6 +154,8 @@ class FlukaReader(EvgenAlg):
thetaX
=
self
.
angle
(
cosThetaX
)
thetaX
=
self
.
angle
(
cosThetaX
)
xout
=
np
.
copy
(
x
)
xout
=
np
.
copy
(
x
)
if
xout
.
ndim
==
0
:
xout
=
float
(
xout
)
# Add displacement due to initial angle
# Add displacement due to initial angle
#xang = z * np.tan(thetaX)
#xang = z * np.tan(thetaX)
...
@@ -275,7 +278,16 @@ class FlukaReader(EvgenAlg):
...
@@ -275,7 +278,16 @@ class FlukaReader(EvgenAlg):
gp
=
HepMC
.
GenParticle
()
gp
=
HepMC
.
GenParticle
()
m
=
105.66
m
=
105.66
e
=
newentry
[
"
E
"
]
*
1000.
#MeV
e
=
newentry
[
"
E
"
]
*
1000.
#MeV
# If the energy is less than mass then skip the event
if
e
<
m
:
self
.
setFilterPassed
(
False
)
self
.
msg
.
debug
(
"
Event failed energy cut
"
)
return
False
else
:
self
.
setFilterPassed
(
True
)
p
=
np
.
sqrt
(
e
**
2
-
m
**
2
)
p
=
np
.
sqrt
(
e
**
2
-
m
**
2
)
thetaX
=
self
.
angle
(
newentry
[
"
cosX
"
])
thetaX
=
self
.
angle
(
newentry
[
"
cosX
"
])
...
@@ -288,22 +300,27 @@ class FlukaReader(EvgenAlg):
...
@@ -288,22 +300,27 @@ class FlukaReader(EvgenAlg):
#phi = np.arctan(newentry["cosY"] / newentry["cosX"])
#phi = np.arctan(newentry["cosY"] / newentry["cosX"])
if
phi
<
0
:
phi
+=
2
*
np
.
pi
if
phi
<
0
:
phi
+=
2
*
np
.
pi
if
phi
==
2
*
np
.
pi
:
phi
=
0
if
phi
==
2
*
np
.
pi
:
phi
=
0
#self.msg.debug(f"INPUT: {e}, {m}, {p}, {theta}, {phi}, {np.sin(theta)}, {np.cos(theta)}, {np.sin(phi)}, {np.cos(phi)}")
px
=
p
*
np
.
sin
(
theta
)
*
np
.
cos
(
phi
)
px
=
p
*
np
.
sin
(
theta
)
*
np
.
cos
(
phi
)
py
=
p
*
np
.
sin
(
theta
)
*
np
.
sin
(
phi
)
py
=
p
*
np
.
sin
(
theta
)
*
np
.
sin
(
phi
)
pz
=
p
*
np
.
cos
(
theta
)
pz
=
p
*
np
.
cos
(
theta
)
mom
=
HepMC
.
FourVector
(
px
,
py
,
pz
,
e
)
mom
=
HepMC
.
FourVector
(
px
,
py
,
pz
,
e
)
gp
.
set_momentum
(
mom
)
gp
.
set_momentum
(
mom
)
gp
.
set_generated_mass
(
m
)
gp
.
set_generated_mass
(
m
)
gp
.
set_pdg_id
(
self
.
pid
(
newentry
[
"
type
"
]))
gp
.
set_pdg_id
(
self
.
pid
(
newentry
[
"
type
"
]))
gp
.
set_status
(
1
)
gp
.
set_status
(
1
)
#self.msg.debug(f"HEPMC:{px, py, pz, e}")
#gp.print()
ROOT
.
SetOwnership
(
gp
,
False
)
ROOT
.
SetOwnership
(
gp
,
False
)
gv
.
add_particle_out
(
gp
)
gv
.
add_particle_out
(
gp
)
return
return
True
def
plot
(
self
):
def
plot
(
self
):
"
Plot entries before and after propagation/smeating for tests
"
"
Plot entries before and after propagation/smeating for tests
"
...
@@ -434,6 +451,6 @@ if __name__ == "__main__":
...
@@ -434,6 +451,6 @@ if __name__ == "__main__":
itemList
=
[
"
EventInfo#McEventInfo
"
,
"
McEventCollection#*
"
]
itemList
=
[
"
EventInfo#McEventInfo
"
,
"
McEventCollection#*
"
]
from
OutputStreamAthenaPool.OutputStreamConfig
import
OutputStreamCfg
from
OutputStreamAthenaPool.OutputStreamConfig
import
OutputStreamCfg
cfg
.
merge
(
OutputStreamCfg
(
ConfigFlags
,
"
EVNT
"
,
itemList
,
disableEventTag
=
True
))
cfg
.
merge
(
OutputStreamCfg
(
ConfigFlags
,
"
EVNT
"
,
itemList
,
disableEventTag
=
True
))
cfg
.
getEventAlgo
(
"
OutputStreamEVNT
"
).
AcceptAlgs
=
[
"
FlukaReader
"
]
sc
=
cfg
.
run
(
maxEvents
=
getNEvents
(
args
.
file
,
args
.
nevents
)
*
args
.
nsamples
)
sc
=
cfg
.
run
(
maxEvents
=
getNEvents
(
args
.
file
,
args
.
nevents
)
*
args
.
nsamples
)
sys
.
exit
(
not
sc
.
isSuccess
())
sys
.
exit
(
not
sc
.
isSuccess
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment