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
a8c22e19
Commit
a8c22e19
authored
9 months ago
by
Markus Frank
Committed by
MarkusFrankATcernch
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix python style errors. Get example tolerances right
parent
359a1fb2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DDG4/python/DDG4.py
+2
-2
2 additions, 2 deletions
DDG4/python/DDG4.py
examples/ClientTests/scripts/BoxOfStraws.py
+11
-33
11 additions, 33 deletions
examples/ClientTests/scripts/BoxOfStraws.py
examples/ClientTests/src/BoxOfStraws_geo.cpp
+2
-1
2 additions, 1 deletion
examples/ClientTests/src/BoxOfStraws_geo.cpp
with
15 additions
and
36 deletions
DDG4/python/DDG4.py
+
2
−
2
View file @
a8c22e19
...
...
@@ -670,7 +670,7 @@ class Geant4:
return
(
seq
,
acts
)
return
(
seq
,
acts
[
0
])
def
setupCalorimeter
(
self
,
name
,
type
=
None
,
collections
=
None
):
# noqa: A002
def
setupCalorimeter
(
self
,
name
,
type
=
None
,
collections
=
None
):
# noqa:
A001,
A002
"""
Setup subdetector of type
'
calorimeter
'
and assign the proper sensitive action
...
...
@@ -686,7 +686,7 @@ class Geant4:
typ
=
self
.
sensitive_types
[
typ
]
return
self
.
setupDetector
(
name
,
typ
,
collections
)
def
setupTracker
(
self
,
name
,
type
=
None
,
collections
=
None
):
# noqa: A002
def
setupTracker
(
self
,
name
,
type
=
None
,
collections
=
None
):
# noqa:
A001,
A002
"""
Setup subdetector of type
'
tracker
'
and assign the proper sensitive action
...
...
This diff is collapsed.
Click to expand it.
examples/ClientTests/scripts/BoxOfStraws.py
+
11
−
33
View file @
a8c22e19
...
...
@@ -13,7 +13,6 @@
from
__future__
import
absolute_import
,
unicode_literals
import
os
import
time
import
cmath
import
DDG4
from
DDG4
import
OutputLevel
as
Output
from
g4units
import
GeV
,
MeV
,
m
...
...
@@ -46,70 +45,49 @@ def run():
ui
=
geant4
.
setupCshUI
()
if
args
.
batch
:
ui
.
Commands
=
[
'
/run/beamOn
'
+
str
(
args
.
events
),
'
/ddg4/UI/terminate
'
]
if
args
.
print
:
logger
.
setPrintLevel
(
int
(
args
.
print
))
#
# Configure field
geant4
.
setupTrackingField
(
prt
=
True
)
# Configure Event actions
prt
=
DDG4
.
EventAction
(
kernel
,
'
Geant4ParticlePrint/ParticlePrint
'
)
prt
.
OutputLevel
=
Output
.
DEBUG
prt
.
OutputType
=
3
kernel
.
eventAction
().
adopt
(
prt
)
generator_output_level
=
Output
.
DEBUG
#
# Configure G4 geometry setup
seq
,
act
=
geant4
.
addDetectorConstruction
(
"
Geant4DetectorGeometryConstruction/ConstructGeo
"
)
act
.
DebugVolumes
=
True
#
# Assign sensitive detectors according to the declarations 'tracker' or 'calorimeter', etc
seq
,
act
=
geant4
.
addDetectorConstruction
(
"
Geant4DetectorSensitivesConstruction/ConstructSD
"
)
#
#
# Assign sensitive detectors in Geant4 by matching a regular expression in the detector sub-tree
seq
,
act
=
geant4
.
addDetectorConstruction
(
"
Geant4RegexSensitivesConstruction/ConstructSDRegEx
"
)
act
.
Detector
=
'
BoxOfStrawsDet
'
act
.
Regex
=
'
/world_volume_(.*)/BoxOfStrawsDet_(.*)/row_(.*)/straw_(.*)
'
act
.
OutputLevel
=
Output
.
ALWAYS
act
.
enableUI
()
act
.
Regex
=
'
/world_volume_(.*)/BoxOfStrawsDet_(.*)/row_(.*)/straw_(.*)
'
#
# Configure I/O
geant4
.
setupROOTOutput
(
'
RootOutput
'
,
'
BoxOfStraws_
'
+
time
.
strftime
(
'
%Y-%m-%d_%H-%M
'
))
#
# Setup particle gun
gun
=
geant4
.
setupGun
(
"
Gun
"
,
particle
=
'
e+
'
,
energy
=
10
*
GeV
,
multiplicity
=
1
)
gun
.
OutputLevel
=
Output
.
DEBUG
#
# And handle the simulation particles.
part
=
DDG4
.
GeneratorAction
(
kernel
,
"
Geant4ParticleHandler/ParticleHandler
"
)
kernel
.
generatorAction
().
adopt
(
part
)
part
.
SaveProcesses
=
[
'
Decay
'
]
part
.
MinimalKineticEnergy
=
100
*
MeV
part
.
OutputLevel
=
Output
.
DEBUG
# generator_output_level
part
.
enableUI
()
user
=
DDG4
.
Action
(
kernel
,
"
Geant4TCUserParticleHandler/UserParticleHandler
"
)
user
.
TrackingVolume_Zmax
=
2.5
*
m
user
.
TrackingVolume_Rmax
=
2.5
*
m
user
.
enableUI
()
part
.
adopt
(
user
)
#
# Map sensitive detectors of type 'BoxOfStraws' to Geant4CalorimeterAction
sd
=
geant4
.
description
.
sensitiveDetector
(
str
(
'
BoxOfStrawsDet
'
))
logger
.
info
(
f
'
+++ BoxOfStraws: SD type:
{
str
(
sd
.
type
())
}
'
)
seq
,
act
=
geant4
.
setupDetector
(
name
=
'
BoxOfStrawsDet
'
,
action
=
'
MyTrackerSDAction
'
)
act
.
HaveCellID
=
False
#
# Now build the physics list:
phys
=
geant4
.
setupPhysics
(
str
(
'
QGSP_BERT
'
))
ph
=
DDG4
.
PhysicsList
(
kernel
,
str
(
'
Geant4PhysicsList/Myphysics
'
))
# Add b osons to the model (redundant if already implemented by the model)
ph
.
addParticleGroup
(
str
(
'
G4BosonConstructor
'
))
ph
.
addParticleGroup
(
str
(
'
G4BaryonConstructor
'
))
ph
.
addParticleGroup
(
str
(
'
G4MesonConstructor
'
))
ph
.
addParticleGroup
(
str
(
'
G4LeptonConstructor
'
))
# Add multiple scattering in the material
ph
.
addParticleProcess
(
str
(
'
e[+-]
'
),
str
(
'
G4eMultipleScattering
'
),
-
1
,
1
,
1
)
# Interactivity
ph
.
enableUI
()
phys
.
adopt
(
ph
)
phys
.
dump
()
geant4
.
execute
()
...
...
This diff is collapsed.
Click to expand it.
examples/ClientTests/src/BoxOfStraws_geo.cpp
+
2
−
1
View file @
a8c22e19
...
...
@@ -17,12 +17,13 @@
//
//==========================================================================
#include
<DD4hep/DetFactoryHelper.h>
#include
<DD4hep/DD4hepUnits.h>
#include
<DD4hep/Printout.h>
using
namespace
dd4hep
;
static
Ref_t
create_detector
(
Detector
&
description
,
xml_h
e
,
SensitiveDetector
sens
)
{
double
tol
=
1e-
2
;
double
tol
=
1e-
5
*
dd4hep
::
mm
;
xml_det_t
x_det
=
e
;
xml_dim_t
x_box
=
x_det
.
child
(
_U
(
box
));
xml_dim_t
x_rot
=
x_det
.
child
(
_U
(
rotation
));
...
...
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