Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
5a0f08b5
Commit
5a0f08b5
authored
4 years ago
by
Markus Frank
Committed by
MarkusFrankATcernch
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add SiD example to show processing of multiple input files from command line
parent
a80949ce
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDG4/python/bin/g4GeometryScan.py
+117
-0
117 additions, 0 deletions
DDG4/python/bin/g4GeometryScan.py
examples/ClientTests/scripts/GdmlDetector.py
+4
-5
4 additions, 5 deletions
examples/ClientTests/scripts/GdmlDetector.py
with
121 additions
and
5 deletions
DDG4/python/bin/g4GeometryScan.py
0 → 100644
+
117
−
0
View file @
5a0f08b5
#!/usr/bin/env python
# ==========================================================================
# AIDA Detector description implementation
# --------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
# ==========================================================================
from
__future__
import
absolute_import
,
unicode_literals
import
os
import
sys
import
errno
import
optparse
import
logging
logging
.
basicConfig
(
format
=
'
%(levelname)s: %(message)s
'
,
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
__name__
)
def
printOpts
(
opts
):
o
=
eval
(
str
(
opts
))
prefix
=
sys
.
argv
[
0
].
split
(
os
.
sep
)[
-
1
]
for
name
,
value
in
o
.
items
():
logger
.
info
(
'
%s > %-18s %s [%s]
'
,
prefix
,
name
+
'
:
'
,
str
(
value
),
str
(
value
.
__class__
))
def
materialScan
(
opts
):
kernel
=
DDG4
.
Kernel
()
kernel
.
loadGeometry
(
str
(
opts
.
compact
))
DDG4
.
Core
.
setPrintFormat
(
str
(
"
%-32s %6s %s
"
))
geant4
=
DDG4
.
Geant4
(
kernel
)
# Configure UI
geant4
.
setupCshUI
(
ui
=
None
)
for
i
in
geant4
.
description
.
detectors
():
o
=
DDG4
.
DetElement
(
i
.
second
.
ptr
())
sd
=
geant4
.
description
.
sensitiveDetector
(
o
.
name
())
if
sd
.
isValid
():
typ
=
sd
.
type
()
if
typ
in
geant4
.
sensitive_types
:
geant4
.
setupDetector
(
o
.
name
(),
geant4
.
sensitive_types
[
typ
])
else
:
logger
.
error
(
'
+++ %-32s type:%-12s --> Unknown Sensitive type: %s
'
,
o
.
name
(),
typ
,
typ
)
sys
.
exit
(
errno
.
EINVAL
)
geant4
.
setupGun
(
"
Gun
"
,
Standalone
=
True
,
particle
=
'
geantino
'
,
energy
=
20
*
g4units
.
GeV
,
position
=
opts
.
position
,
direction
=
opts
.
direction
,
multiplicity
=
1
,
isotrop
=
False
)
scan
=
DDG4
.
SteppingAction
(
kernel
,
'
Geant4GeometryScanner/GeometryScan
'
)
kernel
.
steppingAction
().
adopt
(
scan
)
# Now build the physics list:
geant4
.
setupPhysics
(
'
QGSP_BERT
'
)
kernel
.
configure
()
kernel
.
initialize
()
kernel
.
NumEvents
=
1
kernel
.
run
()
kernel
.
terminate
()
return
0
parser
=
optparse
.
OptionParser
()
parser
.
formatter
.
width
=
132
parser
.
description
=
'
Scan Volumes along a trajectory using Geant4.
'
parser
.
add_option
(
'
-c
'
,
'
--compact
'
,
dest
=
'
compact
'
,
default
=
None
,
help
=
'
Define LCCDD style compact xml input
'
,
metavar
=
'
<FILE>
'
)
parser
.
add_option
(
'
-P
'
,
'
--print
'
,
dest
=
'
print_level
'
,
default
=
2
,
help
=
'
Set dd4hep print level.
'
,
metavar
=
'
<int>
'
)
parser
.
add_option
(
'
-p
'
,
'
--position
'
,
dest
=
'
position
'
,
default
=
'
0.0,0.0,0.0
'
,
help
=
'
Start position of the material scan. [give tuple
"
x,y,z
"
as string]
'
,
metavar
=
'
<tuple>
'
)
parser
.
add_option
(
'
-d
'
,
'
--direction
'
,
dest
=
'
direction
'
,
default
=
'
0.0,1.0,0.0
'
,
help
=
'
Direction of the material scan. [give tuple
"
x,y,z
"
as string]
'
,
metavar
=
'
<tuple>
'
)
(
opts
,
args
)
=
parser
.
parse_args
()
if
opts
.
compact
is
None
:
logger
.
info
(
"
%s
"
,
parser
.
format_help
())
sys
.
exit
(
1
)
opts
.
position
=
eval
(
'
(
'
+
opts
.
position
+
'
)
'
)
opts
.
direction
=
eval
(
'
(
'
+
opts
.
direction
+
'
)
'
)
printOpts
(
opts
)
try
:
from
ROOT
import
gROOT
gROOT
.
SetBatch
(
1
)
except
ImportError
as
X
:
logger
.
error
(
'
PyROOT interface not accessible: %s
'
,
X
)
logger
.
info
(
parser
.
format_help
())
sys
.
exit
(
errno
.
ENOENT
)
try
:
import
DDG4
import
g4units
except
ImportError
as
X
:
logger
.
error
(
'
DDG4 python interface not accessible: %s
'
,
X
)
logger
.
info
(
parser
.
format_help
())
sys
.
exit
(
errno
.
ENOENT
)
#
ret
=
materialScan
(
opts
)
sys
.
exit
(
ret
)
This diff is collapsed.
Click to expand it.
examples/ClientTests/scripts/GdmlDetector.py
+
4
−
5
View file @
5a0f08b5
...
...
@@ -3,10 +3,9 @@
from
__future__
import
absolute_import
,
unicode_literals
import
os
import
sys
import
time
import
DDG4
from
DDG4
import
OutputLevel
as
Output
from
g4units
import
GeV
,
MeV
,
m
from
g4units
import
GeV
#
#
"""
...
...
@@ -40,10 +39,10 @@ def run():
# Configure G4 geometry setup
seq
,
act
=
geant4
.
addDetectorConstruction
(
"
Geant4DetectorGeometryConstruction/ConstructGeo
"
)
act
.
DebugVolumes
=
True
act
.
DebugShapes
=
True
act
.
DebugVolumes
=
True
act
.
DebugShapes
=
True
act
.
DebugPlacements
=
True
act
.
DumpHierarchy
=
True
act
.
DumpHierarchy
=
True
# Setup particle gun
gun
=
geant4
.
setupGun
(
"
Gun
"
,
particle
=
'
mu-
'
,
energy
=
20
*
GeV
,
multiplicity
=
1
)
...
...
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