Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSD Detector Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
CSD-team
CSD Detector Project
Commits
17132c41
Commit
17132c41
authored
6 years ago
by
unknown
Browse files
Options
Downloads
Patches
Plain Diff
Generalize Detector class
parent
ea135458
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
Detector.py
+16
-16
16 additions, 16 deletions
Detector.py
with
16 additions
and
16 deletions
Detector.py
+
16
−
16
View file @
17132c41
...
@@ -4,6 +4,7 @@ class Layer:
...
@@ -4,6 +4,7 @@ class Layer:
def
__init__
(
self
,
Position
,
BField
):
def
__init__
(
self
,
Position
,
BField
):
self
.
Position
=
Position
self
.
Position
=
Position
self
.
BField
=
BField
self
.
BField
=
BField
self
.
GridSize
=
0.0025
#micrometer
#Newton-method to calculate the hit time
#Newton-method to calculate the hit time
...
@@ -45,41 +46,40 @@ class Layer:
...
@@ -45,41 +46,40 @@ class Layer:
if
0
<=
x
<
50
:
if
0
<=
x
<
50
:
xHigh
=
int
(
x
/
0.0025
+
1
)
*
0.0025
#upper edge of hit grid
xHigh
=
int
(
x
/
self
.
GridSize
+
1
)
*
self
.
GridSize
#upper edge of hit grid
xLow
=
int
(
x
/
0.0025
)
*
0.0025
#lower edge of hit grid
xLow
=
int
(
x
/
self
.
GridSize
)
*
self
.
GridSize
#lower edge of hit grid
elif
-
50
<
x
<
0
:
#slight different if x<0 or x>0
elif
-
50
<
x
<
0
:
#slight different if x<0 or x>0
xHigh
=
int
(
x
/
0.0025
)
*
0.0025
xHigh
=
int
(
x
/
self
.
GridSize
)
*
self
.
GridSize
xLow
=
int
(
x
/
0.0025
-
1
)
*
0.0025
xLow
=
int
(
x
/
self
.
GridSize
)
*
self
.
GridSize
else
:
else
:
return
((
None
,
None
),
(
None
,
None
),
(
self
.
Position
,
self
.
Position
))
# if the Layer is not hit, return "None"
return
((
None
,
None
),
(
None
,
None
),
(
self
.
Position
,
self
.
Position
))
# if the Layer is not hit, return "None"
if
0
<=
y
<
50
:
if
0
<=
y
<
50
:
yHigh
=
int
(
y
/
0.0025
+
1
)
*
0.0025
yHigh
=
int
(
y
/
self
.
GridSize
+
1
)
*
self
.
GridSize
yLow
=
int
(
y
/
0.0025
)
*
0.0025
yLow
=
int
(
y
/
self
.
GridSize
)
*
self
.
GridSize
elif
-
50
<
y
<
0
:
elif
-
50
<
y
<
0
:
yHigh
=
int
(
y
/
0.0025
)
*
0.0025
yHigh
=
int
(
y
/
self
.
GridSize
)
*
self
.
GridSize
yLow
=
int
(
y
/
0.0025
-
1
)
*
0.0025
yLow
=
int
(
y
/
self
.
GridSize
-
1
)
*
self
.
GridSize
else
:
else
:
return
((
None
,
None
),
(
None
,
None
),
(
self
.
Position
,
self
.
Position
))
return
((
None
,
None
),
(
None
,
None
),
(
self
.
Position
,
self
.
Position
))
return
((
xHigh
,
xLow
),
(
yHigh
,
yLow
),
(
self
.
Position
+
0.00
5
,
self
.
Position
-
0.00
5
))
return
((
xHigh
,
xLow
),
(
yHigh
,
yLow
),
(
self
.
Position
+
0.00
01
,
self
.
Position
-
0.00
01
))
class
Detector
:
class
Detector
:
def
__init__
(
self
,
Magnet
=
0.522
):
def
__init__
(
self
,
LayerArray
=
[
100
,
110
,
120
,
130
,
140
],
Magnet
=
0.522
):
"""
5 Layer of Tracker
"""
"""
5 Layer of Tracker
"""
self
.
BField
=
Magnet
#Tesla
self
.
BField
=
Magnet
#Tesla
self
.
Layer1
=
Layer
(
100
,
self
.
BField
)
self
.
Layers
=
[]
self
.
Layer2
=
Layer
(
110
,
self
.
BField
)
self
.
Layer3
=
Layer
(
120
,
self
.
BField
)
for
zPos
in
LayerArray
:
self
.
Layer4
=
Layer
(
130
,
self
.
BField
)
self
.
Layers
.
append
(
Layer
(
zPos
,
self
.
BField
))
self
.
Layer5
=
Layer
(
140
,
self
.
BField
)
def
detect
(
self
,
particle
):
def
detect
(
self
,
particle
):
"""
Calculate for a given particle class the hit grid. The class needs the membervalues: vx, vy, vz, q, m - Velocity in 3 dimensions, charge, mass.
"""
Calculate for a given particle class the hit grid. The class needs the membervalues: vx, vy, vz, q, m - Velocity in 3 dimensions, charge, mass.
...
@@ -87,7 +87,7 @@ class Detector:
...
@@ -87,7 +87,7 @@ class Detector:
result
=
np
.
array
([[(
0
+
0.0001
,
0
-
0.0001
),(
0
+
0.0001
,
0
-
0.0001
),(
0
+
0.0001
,
0
-
0.0001
)]])
result
=
np
.
array
([[(
0
+
0.0001
,
0
-
0.0001
),(
0
+
0.0001
,
0
-
0.0001
),(
0
+
0.0001
,
0
-
0.0001
)]])
for
Layer
in
[
self
.
Layer
1
,
self
.
Layer2
,
self
.
Layer3
,
self
.
Layer4
,
self
.
Layer5
]
:
for
Layer
in
self
.
Layer
s
:
result
=
np
.
append
(
result
,
[
Layer
.
detect
(
particle
)],
axis
=
0
)
result
=
np
.
append
(
result
,
[
Layer
.
detect
(
particle
)],
axis
=
0
)
if
result
[
-
1
][
0
][
0
]
==
None
:
#If any layer is not hit, exit the detection
if
result
[
-
1
][
0
][
0
]
==
None
:
#If any layer is not hit, exit the detection
return
None
return
None
...
...
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