Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fromRoot
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
johannes bilk
fromRoot
Commits
0b13f59f
Commit
0b13f59f
authored
1 year ago
by
johannes bilk
Browse files
Options
Downloads
Patches
Plain Diff
fixed an layer assigment error, where a ladder from layer one was assigned as layer two
parent
93ea25d1
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
rootable/rootable.py
+37
-5
37 additions, 5 deletions
rootable/rootable.py
with
37 additions
and
5 deletions
rootable/rootable.py
+
37
−
5
View file @
0b13f59f
...
...
@@ -72,7 +72,7 @@ class Rootable:
420
])
# the layer and ladder arrays, for finding them from sensor id
self
.
panelLayer
=
np
.
array
([
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
])
self
.
panelLayer
=
np
.
array
([
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
])
self
.
panelLadder
=
np
.
array
([
1
,
1
,
2
,
2
,
3
,
3
,
4
,
4
,
5
,
5
,
6
,
6
,
7
,
7
,
8
,
8
,
9
,
9
,
10
,
10
,
12
,
12
,
13
,
13
,
14
,
14
,
15
,
15
,
16
,
16
,
17
,
17
,
18
,
18
,
19
,
19
,
20
,
20
,
21
,
21
])
# all transpormaations are stored in a dict, with the sensor id as a keyword
...
...
@@ -143,6 +143,9 @@ class Rootable:
[[
-
2.35
,
-
1.725
,
-
1.725
,
-
2.35
,
-
2.35
],
[
0.345
,
1.4
,
1.4
,
0.345
,
0.345
],
[
-
4.28
,
-
4.28
,
8.08
,
8.08
,
-
4.28
]],
# 18
[[
-
1.85
,
-
0.78
,
-
0.78
,
-
1.85
,
-
1.85
],
[
1.48
,
2.1
,
2.1
,
1.48
,
1.48
],
[
-
4.28
,
-
4.28
,
8.08
,
8.08
,
-
4.28
]]]
# 19
# parameter for checking if coordinates have been loaded
self
.
gotCoordinates
=
False
def
__getitem__
(
self
,
index
:
str
|
int
|
ArrayLike
)
->
np
.
ndarray
|
dict
:
"""
this makes the class subscriptable, one can retrieve one coloumn by using
...
...
@@ -264,7 +267,6 @@ class Rootable:
for
column
in
columns
:
self
.
data
.
pop
(
column
)
def
loadData
(
self
,
file
:
str
,
events
:
int
=
None
,
selection
:
str
=
None
)
->
None
:
"""
Reads the file off of the hard drive; it automatically creates event numbers.
...
...
@@ -370,7 +372,8 @@ class Rootable:
# Combine the results from all chunks
self
.
data
[
'
cluster
'
]
=
np
.
concatenate
(
results
).
astype
(
'
int
'
)
def
_getMatrices
(
self
,
indexChunks
:
ArrayLike
,
uCellIDs
:
ArrayLike
,
vCellIDs
:
ArrayLike
,
cellCharges
:
ArrayLike
,
clusterDigits
:
ArrayLike
,
matrixSize
:
tuple
=
(
9
,
9
))
->
np
.
ndarray
:
@staticmethod
def
_getMatrices
(
indexChunks
:
ArrayLike
,
uCellIDs
:
ArrayLike
,
vCellIDs
:
ArrayLike
,
cellCharges
:
ArrayLike
,
clusterDigits
:
ArrayLike
,
matrixSize
:
tuple
=
(
9
,
9
))
->
np
.
ndarray
:
"""
this takes the ragged/jagged digit arrays and converts them into 9x9 matrices
it
'
s a rather slow process because of all the looping
...
...
@@ -401,9 +404,13 @@ class Rootable:
"""
converting the uv coordinates, together with sensor ids, into xyz coordinates
"""
# checking if cluster parameters have been loaded
if
self
.
gotClusters
is
False
:
self
.
getClusters
()
# setting a bool for checking if coordinates were calculated
self
.
gotCoordinates
=
True
indexChunnks
=
np
.
array_split
(
range
(
len
(
self
.
data
[
'
sensorID
'
])),
4
)
with
ThreadPoolExecutor
(
max_workers
=
None
)
as
executor
:
...
...
@@ -445,6 +452,29 @@ class Rootable:
return
xArr
,
yArr
,
zArr
def
getSphericals
(
self
)
->
None
:
"""
Calculate spherical coordinates for each cluster.
"""
# Checking if coordinates have been loaded
if
self
.
gotClusters
is
False
:
self
.
getCoordinates
()
xSquare
=
np
.
square
(
self
.
data
[
'
xPosition
'
])
ySquare
=
np
.
square
(
self
.
data
[
'
yPosition
'
])
zSquare
=
np
.
square
(
self
.
data
[
'
zPosition
'
])
# Avoid division by zero by replacing zeros with a small number
r
=
np
.
sqrt
(
xSquare
+
ySquare
+
zSquare
)
rSafe
=
np
.
where
(
r
==
0
,
1e-10
,
r
)
theta
=
np
.
arccos
(
self
.
data
[
'
zPosition
'
]
/
rSafe
)
phi
=
np
.
arctan2
(
self
.
data
[
'
yPosition
'
],
self
.
data
[
'
xPosition
'
])
self
.
data
[
'
rPosition
'
]
=
r
self
.
data
[
'
thetaPosition
'
]
=
theta
self
.
data
[
'
phiPosition
'
]
=
phi
def
getLayers
(
self
)
->
None
:
"""
looks up the corresponding layers and ladders for every cluster
...
...
@@ -516,7 +546,8 @@ class Rootable:
self
.
data
[
'
pdg
'
]
=
self
.
_flatten
(
pdgList
)
self
.
data
[
'
clsNumber
'
]
=
self
.
_flatten
(
clusterNumbersList
)
def
_findMissing
(
self
,
lst
:
list
,
length
:
int
)
->
list
:
@staticmethod
def
_findMissing
(
lst
:
list
,
length
:
int
)
->
list
:
"""
a private method for finding missing elements in mc data arrays
"""
...
...
@@ -541,7 +572,8 @@ class Rootable:
fillIndex
+=
1
return
testList
def
_getMCData
(
self
,
toClusters
:
ArrayLike
,
pdgs
:
ArrayLike
,
xMom
:
ArrayLike
,
yMom
:
ArrayLike
,
zMom
:
ArrayLike
)
->
tuple
[
np
.
ndarray
]:
@staticmethod
def
_getMCData
(
toClusters
:
ArrayLike
,
pdgs
:
ArrayLike
,
xMom
:
ArrayLike
,
yMom
:
ArrayLike
,
zMom
:
ArrayLike
)
->
tuple
[
np
.
ndarray
]:
"""
after filling and reorganizing MC data arrays one can finally collect the
actual MC data, where there
'
s data missing I will with zeros
...
...
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