ATLAS Offline Software
TileCalorimeter
TileCalib
TileCalibBlobPython
python
TileCellTools.py
Go to the documentation of this file.
1
#!/bin/env python
2
3
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
# TileCellTools.py
5
# Alexander Solodkov <Sanya.Solodkov@cern.ch>, 2014-11-01
6
7
8
import
bisect
9
10
class
TileCellHashMgr
():
11
"""
12
This class ised to convert cell hash to cell name
13
"""
14
#____________________________________________________________________
15
def
__init__
(self, geometry='Default', cabling='RUN2'):
16
17
#=== initialize all arrays
18
self.
_geometry
=geometry
19
self.
_cabling
=cabling
20
if
geometry ==
"UpgradeABC"
:
21
self.
_cellNames
=[
22
[
"A-1"
,
"A-2"
,
"A-3"
,
"B-1"
,
"C-1"
,
"A-4"
,
"A-5"
,
"A-6"
,
"A-7"
,
"B-2"
,
"C-2"
,
"A-8"
,
"A-9"
,
"D-1"
,
"A-10"
,
"A-11"
,
"B-3"
,
"C-3"
,
"A-12"
,
"A-13"
,
"A-14"
,
"A-15"
,
"B-4"
,
"C-4"
,
23
"A-16"
,
"A-17"
,
"D-2"
,
"A-18"
,
"A-19"
,
"B-5"
,
"C-5"
,
"A-20"
,
"A-21"
,
"A-22"
,
"A-23"
,
"B-6"
,
"C-6"
,
"A-24"
,
"A-25"
,
"D-3"
,
"A-26"
,
"A-27"
,
"B-7"
,
"C-7"
,
"A-28"
,
"A-29"
,
"A-30"
,
24
"A-31"
,
"B-8"
,
"C-8"
,
"A-32"
,
"A-33"
,
"A-34"
,
"A-35"
,
"B-9"
,
"A-36"
,
"A-37"
,
"A-38"
,
"A-39"
,
"A-40"
],
25
[
"A+1"
,
"D*0"
,
"A+2"
,
"A+3"
,
"B+1"
,
"C+1"
,
"A+4"
,
"A+5"
,
"A+6"
,
"A+7"
,
"B+2"
,
"C+2"
,
"A+8"
,
"A+9"
,
"D+1"
,
"A+10"
,
"A+11"
,
"B+3"
,
"C+3"
,
"A+12"
,
"A+13"
,
"A+14"
,
"A+15"
,
"B+4"
,
"C+4"
,
26
"A+16"
,
"A+17"
,
"D+2"
,
"A+18"
,
"A+19"
,
"B+5"
,
"C+5"
,
"A+20"
,
"A+21"
,
"A+22"
,
"A+23"
,
"B+6"
,
"C+6"
,
"A+24"
,
"A+25"
,
"D+3"
,
"A+26"
,
"A+27"
,
"B+7"
,
"C+7"
,
"A+28"
,
"A+29"
,
"A+30"
,
27
"A+31"
,
"B+8"
,
"C+8"
,
"A+32"
,
"A+33"
,
"A+34"
,
"A+35"
,
"B+9"
,
"A+36"
,
"A+37"
,
"A+38"
,
"A+39"
,
"A+40"
],
28
[
"D-5"
,
"A-42"
,
"B-11"
,
"A-44"
,
"A-45"
,
"A-46"
,
"A-47"
,
"B-12"
,
"A-48"
,
"A-49"
,
"D-6"
,
"A-50"
,
"A-51"
,
"B-13"
,
"A-52"
,
"A-53"
,
"A-54"
,
"A-55"
,
"B-14"
,
"A-56"
,
"A-57"
,
"A-58"
,
"A-59"
,
"B-15"
,
29
"A-60"
,
"A-61"
,
"A-62"
,
"A-63"
,
"A-64"
],
30
[
"D+5"
,
"A+42"
,
"B+11"
,
"A+44"
,
"A+45"
,
"A+46"
,
"A+47"
,
"B+12"
,
"A+48"
,
"A+49"
,
"D+6"
,
"A+50"
,
"A+51"
,
"B+13"
,
"A+52"
,
"A+53"
,
"A+54"
,
"A+55"
,
"B+14"
,
"A+56"
,
"A+57"
,
"A+58"
,
"A+59"
,
"B+15"
,
31
"A+60"
,
"A+61"
,
"A+62"
,
"A+63"
,
"A+64"
],
32
[
"D-4"
,
"C-10"
,
"E-1"
,
"E-2"
,
"E-3"
,
"E-4"
,
"spD-4"
,
"spC-10"
,
"spD-40"
,
"spE-1"
,
"mbE-1"
,
"e4E-1"
],
33
[
"D+4"
,
"C+10"
,
"E+1"
,
"E+2"
,
"E+3"
,
"E+4"
,
"spD+4"
,
"spC+10"
,
"spD+40"
,
"spE+1"
,
"mbE+1"
,
"e4E+1"
]
34
]
35
self.
_nCellsModule
= [60,61,29,29,6,6]
36
37
elif
geometry ==
"UpgradeBC"
:
38
self.
_cellNames
=[
39
[
"A-1"
,
"B-1"
,
"C-1"
,
"A-2"
,
"B-2"
,
"C-2"
,
"A-3"
,
"B-3"
,
"C-3"
,
"D-1"
,
"A-4"
,
"B-4"
,
"C-4"
,
"A-5"
,
"B-5"
,
"C-5"
,
"D-2"
,
"A-6"
,
"B-6"
,
"C-6"
,
"A-7"
,
"B-7"
,
"C-7"
,
40
"D-3"
,
"A-8"
,
"B-8"
,
"C-8"
,
"A-9"
,
"B-9"
,
"A-10"
],
41
[
"A+1"
,
"B+1"
,
"C+1"
,
"D*0"
,
"A+2"
,
"B+2"
,
"C+2"
,
"A+3"
,
"B+3"
,
"C+3"
,
"D+1"
,
"A+4"
,
"B+4"
,
"C+4"
,
"A+5"
,
"B+5"
,
"C+5"
,
"D+2"
,
"A+6"
,
"B+6"
,
"C+6"
,
"A+7"
,
"B+7"
,
"C+7"
,
42
"D+3"
,
"A+8"
,
"B+8"
,
"C+8"
,
"A+9"
,
"B+9"
,
"A+10"
],
43
[
"B-11"
,
"D-5"
,
"A-12"
,
"B-12"
,
"A-13"
,
"B-13"
,
"D-6"
,
"A-14"
,
"B-14"
,
"A-15"
,
"B-15"
,
"A-16"
],
44
[
"B+11"
,
"D+5"
,
"A+12"
,
"B+12"
,
"A+13"
,
"B+13"
,
"D+6"
,
"A+14"
,
"B+14"
,
"A+15"
,
"B+15"
,
"A+16"
],
45
[
"D-4"
,
"C-10"
,
"E-1"
,
"E-2"
,
"E-3"
,
"E-4"
,
"spD-4"
,
"spC-10"
,
"spD-40"
,
"spE-1"
,
"mbE-1"
,
"e4E-1"
],
46
[
"D+4"
,
"C+10"
,
"E+1"
,
"E+2"
,
"E+3"
,
"E+4"
,
"spD+4"
,
"spC+10"
,
"spD+40"
,
"spE+1"
,
"mbE+1"
,
"e4E+1"
]
47
]
48
self.
_nCellsModule
= [30,31,12,12,6,6]
49
50
elif
geometry ==
"UpgradeA"
:
51
self.
_cellNames
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A-57"
,
"A-58"
,
"A-59"
,
"B-15"
,
59
"A-60"
,
"A-61"
,
"A-62"
,
"A-63"
,
"A-64"
],
60
[
"D+5"
,
"A+42"
,
"B+11"
,
"A+44"
,
"A+45"
,
"A+46"
,
"A+47"
,
"B+12"
,
"A+48"
,
"A+49"
,
"D+6"
,
"A+50"
,
"A+51"
,
"B+13"
,
"A+52"
,
"A+53"
,
"A+54"
,
"A+55"
,
"B+14"
,
"A+56"
,
"A+57"
,
"A+58"
,
"A+59"
,
"B+15"
,
61
"A+60"
,
"A+61"
,
"A+62"
,
"A+63"
,
"A+64"
],
62
[
"D-4"
,
"C-10"
,
"E-1"
,
"E-2"
,
"E-3"
,
"E-4"
,
"spD-4"
,
"spC-10"
,
"spD-40"
,
"spE-1"
,
"mbE-1"
,
"e4E-1"
],
63
[
"D+4"
,
"C+10"
,
"E+1"
,
"E+2"
,
"E+3"
,
"E+4"
,
"spD+4"
,
"spC+10"
,
"spD+40"
,
"spE+1"
,
"mbE+1"
,
"e4E+1"
]
64
]
65
self.
_nCellsModule
= [52,53,29,29,6,6]
66
67
else
:
68
self.
_geometry
=
"Default"
69
self.
_cellNames
=[
70
[
"A-1"
,
"B-1"
,
"A-2"
,
"B-2"
,
"A-3"
,
"B-3"
,
"D-1"
,
"A-4"
,
"B-4"
,
"A-5"
,
"B-5"
,
"D-2"
,
"A-6"
,
"B-6"
,
"A-7"
,
"B-7"
,
"D-3"
,
"A-8"
,
"B-8"
,
"A-9"
,
"B-9"
,
"A-10"
],
71
[
"A+1"
,
"B+1"
,
"D*0"
,
"A+2"
,
"B+2"
,
"A+3"
,
"B+3"
,
"D+1"
,
"A+4"
,
"B+4"
,
"A+5"
,
"B+5"
,
"D+2"
,
"A+6"
,
"B+6"
,
"A+7"
,
"B+7"
,
"D+3"
,
"A+8"
,
"B+8"
,
"A+9"
,
"B+9"
,
"A+10"
],
72
[
"B-11"
,
"D-5"
,
"A-12"
,
"B-12"
,
"A-13"
,
"B-13"
,
"D-6"
,
"A-14"
,
"B-14"
,
"A-15"
,
"B-15"
,
"A-16"
],
73
[
"B+11"
,
"D+5"
,
"A+12"
,
"B+12"
,
"A+13"
,
"B+13"
,
"D+6"
,
"A+14"
,
"B+14"
,
"A+15"
,
"B+15"
,
"A+16"
],
74
[
"D-4"
,
"C-10"
,
"E-1"
,
"E-2"
,
"E-3"
,
"E-4"
,
"spD-4"
,
"spC-10"
,
"spD-40"
,
"spE-1"
,
"mbE-1"
,
"e4E-1"
],
75
[
"D+4"
,
"C+10"
,
"E+1"
,
"E+2"
,
"E+3"
,
"E+4"
,
"spD+4"
,
"spC+10"
,
"spD+40"
,
"spE+1"
,
"mbE+1"
,
"e4E+1"
]
76
]
77
self.
_nCellsModule
= [22,23,12,12,6,6]
78
79
self.
_partNames
=[
"LBC"
,
"LBA"
,
"EBC"
,
"EBA"
,
"EBC"
,
"EBA"
]
80
self.
_nModules
= 64
81
self.
_nCellsPart
= [0]
82
self.
_nHashMax
=0
83
for
p
in
range
(6):
84
self.
_nHashMax
+=self.
_nCellsModule
[p]*self.
_nModules
85
self.
_nCellsPart
.
append
(self.
_nHashMax
)
86
87
#____________________________________________________________________
88
def
getGeometry
(self):
89
"""
90
return geometry name
91
"""
92
return
self.
_geometry
93
94
#____________________________________________________________________
95
def
getHashMax
(self):
96
"""
97
return max hash value
98
"""
99
return
self.
_nHashMax
100
101
#____________________________________________________________________
102
def
getNames
(self, hash):
103
"""
104
return module name and cell name for given hash
105
"""
106
if
hash>=self.
_nHashMax
or
hash<0:
107
return
(
None
,
None
)
108
109
part=bisect.bisect(self.
_nCellsPart
,hash)-1
110
module=(hash-self.
_nCellsPart
[part])//self.
_nCellsModule
[part]+1
111
modName=
"%s%02d"
% (self.
_partNames
[part],module)
112
index=(hash-self.
_nCellsPart
[part])%self.
_nCellsModule
[part]
113
if
part>=4:
114
if
index==0
and
((part==4
and
module==18)
or
(part==5
and
module==15)):
115
index+=8
116
if
index==0
and
(module==14
or
module==15
or
module==18
or
module==19):
117
index+=6
118
if
index==1
and
((module>=39
and
module<=42)
or
(module>=55
and
module<=58)):
119
index+=6
120
if
index==2
and
(self.
_cabling
==
'RUN2'
or
self.
_cabling
==
'RUN2a'
or
self.
_cabling
==
'RUN3'
):
121
if
part==4
and
(self.
_cabling
==
'RUN2'
or
self.
_cabling
==
'RUN2a'
):
# E4' in EBC
122
if
module==28
or
module==31
or
module==35
or
module==38:
123
index+=7
# E1m
124
if
module==29
or
module==32
or
module==34
or
module==37:
125
index+=9
# E4'
126
if
module==7
or
module==25
or
module==44
or
module==53:
127
index+=7
# E1m
128
if
module==8
or
module==24
or
module==43
or
module==54:
129
index+=8
# MBTS
130
if
self.
_cabling
==
'RUN2a'
or
self.
_cabling
==
'RUN3'
:
131
if
part==5:
# EBA
132
if
module==4
or
module==21
or
module==47
or
module==60:
133
index+=7
# E1m
134
if
module==3
or
module==20
or
module==46
or
module==59:
135
index+=8
# MBTS
136
if
part==4:
# EBC
137
if
module==4
or
module==18
or
module==47
or
module==60:
138
index+=7
# E1m
139
if
module==3
or
module==19
or
module==46
or
module==59:
140
index+=8
# MBTS
141
142
return
(modName,self.
_cellNames
[part][index])
143
144
#____________________________________________________________________
145
def
cellName
(self, hash):
146
"""
147
return cell name for given hash
148
"""
149
if
hash>=self.
_nHashMax
or
hash<0:
150
return
None
151
152
part=bisect.bisect(self.
_nCellsPart
,hash)-1
153
module=(hash-self.
_nCellsPart
[part])//self.
_nCellsModule
[part]+1
154
index=(hash-self.
_nCellsPart
[part])%self.
_nCellsModule
[part]
155
if
part>=4:
156
if
index==0
and
((part==4
and
module==18)
or
(part==5
and
module==15)):
157
index+=8
158
if
index==0
and
(module>=15
and
module<=18):
159
index+=6
160
if
index==1
and
((module>=39
and
module<=42)
or
(module>=55
and
module<=58)):
161
index+=6
162
if
index==2
and
(self.
_cabling
==
'RUN2'
or
self.
_cabling
==
'RUN2a'
or
self.
_cabling
==
'RUN3'
):
163
if
part==4
and
(self.
_cabling
==
'RUN2'
or
self.
_cabling
==
'RUN2a'
):
# E4' in EBC
164
if
module==28
or
module==29
or
module==31
or
module==32
or
module==35
or
module==34
or
module==38
or
module==37:
165
index+=7
# E1m or E4'
166
if
module==7
or
module==8
or
module==25
or
module==24
or
module==44
or
module==43
or
module==53
or
module==54:
167
index+=7
# E1m or MBTS
168
if
self.
_cabling
==
'RUN2a'
or
self.
_cabling
==
'RUN3'
:
169
if
part==5:
# EBA
170
if
module==4
or
module==3
or
module==21
or
module==20
or
module==47
or
module==46
or
module==60
or
module==59:
171
index+=7
# E1m or MBTS
172
if
part==4:
# EBC
173
if
module==4
or
module==3
or
module==18
or
module==19
or
module==47
or
module==46
or
module==60
or
module==59:
174
index+=7
# E1m or MBTS
175
176
return
self.
_cellNames
[part][index]
177
178
#____________________________________________________________________
179
def
moduleName
(self, hash):
180
"""
181
return module name for given hash
182
"""
183
if
hash>=self.
_nHashMax
or
hash<0:
184
return
None
185
186
part=bisect.bisect(self.
_nCellsPart
,hash)-1
187
module=(hash-self.
_nCellsPart
[part])//self.
_nCellsModule
[part]+1
188
modName=
"%s%02d"
% (self.
_partNames
[part],module)
189
190
return
modName
python.TileCellTools.TileCellHashMgr._nModules
_nModules
Definition:
TileCellTools.py:80
python.TileCellTools.TileCellHashMgr._partNames
_partNames
Definition:
TileCellTools.py:79
python.TileCellTools.TileCellHashMgr.moduleName
def moduleName(self, hash)
Definition:
TileCellTools.py:179
python.TileCellTools.TileCellHashMgr.getNames
def getNames(self, hash)
Definition:
TileCellTools.py:102
python.TileCellTools.TileCellHashMgr.__init__
def __init__(self, geometry='Default', cabling='RUN2')
Definition:
TileCellTools.py:15
python.TileCellTools.TileCellHashMgr._nCellsModule
_nCellsModule
Definition:
TileCellTools.py:35
dumpHVPathFromNtuple.append
bool append
Definition:
dumpHVPathFromNtuple.py:91
python.TileCellTools.TileCellHashMgr.getHashMax
def getHashMax(self)
Definition:
TileCellTools.py:95
python.TileCellTools.TileCellHashMgr.cellName
def cellName(self, hash)
Definition:
TileCellTools.py:145
python.TileCellTools.TileCellHashMgr.getGeometry
def getGeometry(self)
Definition:
TileCellTools.py:88
python.TileCellTools.TileCellHashMgr._cellNames
_cellNames
Definition:
TileCellTools.py:21
plotBeamSpotVxVal.range
range
Definition:
plotBeamSpotVxVal.py:195
python.TileCellTools.TileCellHashMgr._geometry
_geometry
Definition:
TileCellTools.py:18
python.TileCellTools.TileCellHashMgr._cabling
_cabling
Definition:
TileCellTools.py:19
python.TileCellTools.TileCellHashMgr
Definition:
TileCellTools.py:10
python.TileCellTools.TileCellHashMgr._nCellsPart
_nCellsPart
Definition:
TileCellTools.py:81
python.TileCellTools.TileCellHashMgr._nHashMax
_nHashMax
Definition:
TileCellTools.py:82
Generated on Mon Dec 23 2024 21:19:54 for ATLAS Offline Software by
1.8.18