ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArExample
LArConditionsCommon
python
LArExtendedSubDetGrouping.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
class
LArExtendedSubDetGrouping
:
4
def
__init__
(self):
5
self.
_EMBC
=()
6
self.
_EMBA
=()
7
self.
_EMBCPS
=()
8
self.
_EMBAPS
=()
9
self.
_EMECC
=()
10
self.
_EMECA
=()
11
self.
_EMECCPS
=()
12
self.
_EMECAPS
=()
13
self.
_HECC
=()
14
self.
_HECA
=()
15
self.
_FCALC
=()
16
self.
_FCALA
=()
17
for
gain
in
range(0,3):
18
self.
_EMBC
+=(3+gain*12,)
19
self.
_EMBA
+=(9+gain*12,)
20
21
self.
_EMBCPS
+=(4+gain*12,)
22
self.
_EMBAPS
+=(10+gain*12,)
23
24
self.
_EMECC
+=(5+gain*12,)
25
self.
_EMECA
+=(11+gain*12,)
26
27
self.
_EMECCPS
+=(6+gain*12,)
28
self.
_EMECAPS
+=(12+gain*12,)
29
30
self.
_HECC
+=(7+gain*12,)
31
self.
_HECA
+=(13+gain*12,)
32
33
self.
_FCALC
+=(8+gain*12,)
34
self.
_FCALA
+=(14+gain*12,)
35
36
self.
_emptyC
=()
37
self.
_emptyA
=()
38
self.
_empty
=self.
_emptyC
+ self.
_emptyA
39
40
self.
_withCorr
=
True
41
42
#Build dictionary:
43
self.
_partitions
=dict()
44
self.
_partitions
[
'EMBAPS'
] = self.
_EMBAPS
45
self.
_partitions
[
'EMBCPS'
] = self.
_EMBCPS
46
self.
_partitions
[
'EMECAPS'
] = self.
_EMECAPS
47
self.
_partitions
[
'EMECCPS'
] = self.
_EMECCPS
48
self.
_partitions
[
'EMBA'
] = self.
_EMBA
49
self.
_partitions
[
'EMBC'
] = self.
_EMBC
50
self.
_partitions
[
'EMECA'
]= self.
_EMECA
51
self.
_partitions
[
'EMECC'
] = self.
_EMECC
52
self.
_partitions
[
'HECA'
] = self.
_HECA
53
self.
_partitions
[
'HECC'
] = self.
_HECC
54
self.
_partitions
[
'FCALA'
] = self.
_FCALA
55
self.
_partitions
[
'FCALC'
] = self.
_FCALC
56
self.
_partitions
[
'EMPTYA'
] = self.
_emptyA
57
self.
_partitions
[
'EMPTYC'
] = self.
_emptyC
58
59
#Correction Channels:
60
self.
_corr
=dict()
61
self.
_corr
[
'EMBAPS'
] = 1001
62
self.
_corr
[
'EMBCPS'
] = 1002
63
self.
_corr
[
'EMECAPS'
] = 1003
64
self.
_corr
[
'EMECCPS'
] = 1004
65
self.
_corr
[
'EMBA'
] = 1005
66
self.
_corr
[
'EMBC'
] = 1006
67
self.
_corr
[
'EMECA'
] = 1007
68
self.
_corr
[
'EMECC'
] = 1008
69
self.
_corr
[
'HECA'
] = 1009
70
self.
_corr
[
'HECC'
] = 1010
71
self.
_corr
[
'FCALA'
] = 1011
72
self.
_corr
[
'FCALC'
] = 1012
73
74
#Lookup-dict indexed by channel (partition is the payload)
75
self.
_revLookup
=dict()
76
for
(p, chs)
in
self.
_partitions
.items():
77
for
c
in
chs:
78
self.
_revLookup
[c]=p
79
80
81
def
setWithCorr
(self,val):
82
self.
_withCorr
=val
83
84
def
Print
(self):
85
print
(self.
_EMBC
)
86
print
(self.
_EMBA
)
87
88
89
def
getChannelList
(self,partitions,gains=[0]):
90
chans=list()
91
for
g
in
gains:
92
if
g<0
or
g>2:
93
print
(
"ERROR: Unkown gain"
,g)
94
return
None
95
96
extPart=list()
97
for
partition
in
partitions:
98
p=partition.upper()
99
if
(p==
"ECC"
):
100
extPart+=[
"EMECCPS"
,
"EMECC"
,
"HECC"
,
"FCALC"
]
101
elif
(p==
"ECA"
):
102
extPart+=[
"EMECAPS"
,
"EMECA"
,
"HECA"
,
"FCALA"
]
103
elif
(p==
"EC"
):
104
extPart+=[
"EMECAPS"
,
"EMECA"
,
"HECA"
,
"FCALA"
,
105
"EMECCPS"
,
"EMECC"
,
"HECC"
,
"FCALC"
]
106
elif
(p==
"EMB"
):
107
extPart+=[
"EMBA"
,
"EMBAPS"
,
"EMBC"
,
"EMBCPS"
]
108
else
:
109
extPart+=[p]
110
111
for
p
in
extPart:
112
if
p
in
self.
_partitions
:
113
for
g
in
gains:
114
print
(self.
_partitions
[p])
115
chans+=[self.
_partitions
[p][g]]
116
if
(self.
_withCorr
):
117
for
g
in
gains:
118
chans+=[self.
_corr
[p]+g*12]
119
else
:
120
print
(
"ERROR: Unkown partition '"
,partition,
"'"
)
121
122
return
chans
123
124
def
makeRange
(self,chans):
125
chans.sort()
126
retVal=
""
127
if
(len(chans)==0):
128
return
retVal
129
retVal=str(chans[0])
130
c1=chans[0]
131
series=
False
132
for
c2
in
chans[1:]:
133
if
c1 == c2:
134
print
(
"Duplicated entry"
,c2)
135
continue
136
if
c2-1 == c1
or
c2-1
in
self.
_empty
:
137
series=
True
138
else
:
139
if
series:
140
retVal+=
":"
+str(c1)+
","
+str(c2)
141
series=
False
142
else
:
143
retVal+=
","
+str(c2)
144
# print ("c1=",c1,"c2=",c2,"sep=",sep)
145
c1=c2
146
if
series: retVal+=
":"
+str(c1)
147
return
retVal
148
149
150
151
def
getChannelSelection
(self,partitions,gains):
152
return
self.
makeRange
(self.
getChannelList
(partitions,gains))
153
154
def
getChannelSelectionAllGains
(self,partitions):
155
chans=list()
156
for
p
in
partitions:
157
chans+=self.
getChannelList
([p],[0,1,2])
158
return
self.
makeRange
(chans)
159
160
161
def
getGain
(self,c):
162
if
c<2:
163
return
(0,
None
)
164
if
c<15:
165
return
(0,c)
166
if
c<27:
167
return
(1,c-12)
168
if
c<39:
169
return
(2,c-24)
170
if
c<1001:
171
return
(0,
None
)
172
if
c<1013:
173
return
(0,c)
174
if
c<1025:
175
return
(1,c-12)
176
if
c<1037:
177
return
(2,c-24)
178
return
(0,
None
)
179
180
181
def
channelsPerPartition
(self,chans,show=True):
182
class
counterElem:
183
def
__init__
(self,l,n):
184
self.
size
=l
185
self.
name
=n
186
self.
counts
=[0,0,0]
187
def
inc(self,g):
188
self.
counts
[g]=1+self.
counts
[g]
189
190
def
show(self):
191
print
(
"%7s: "
% self.
name
,end=
""
)
192
print
(
"HIGH:%2i/%2i"
% (self.
counts
[0],self.
size
),)
193
if
self.
counts
[0] != self.
size
:
194
print
(
"* "
,end=
""
)
195
else
:
196
print
(
" "
,end=
""
)
197
print
(
"MED:%2i/%2i"
% (self.
counts
[1],self.
size
),)
198
if
self.
counts
[1] != self.
size
:
199
print
(
"* "
,end=
""
)
200
else
:
201
print
(
" "
,end=
""
)
202
print
(
"LOW:%2i/%2i"
% (self.
counts
[2],self.
size
),)
203
if
self.
counts
[2] != self.
size
:
204
print
(
"* "
)
205
else
:
206
print
(
" "
)
207
208
partCounter=dict()
209
for
(p, chs)
in
self.
_partitions
.items():
210
partCounter[p]=counterElem(len(chs),p)
211
212
for
c
in
chans:
213
(gain,cs)=self.
getGain
(c)
214
if
cs
is
None
:
215
print
(
"ERROR: Unkown channel"
,c )
216
else
:
217
if
(c<39):
218
#p=self._revLookup[cs]
219
p=self.
_revLookup
[c]
220
partCounter[p].inc(gain)
221
222
return
partCounter
223
224
225
#Create COOL-channel selection string for partitions/gain strings as use by by the
226
#Automatic Processing of LAr Elec Calib runs
227
228
229
_lArExtendedSubDetGrouping =
LArExtendedSubDetGrouping
()
230
def
channelSelectionFromString
(Partition,PartitionType, PartitionTypeGeneric, GainList):
231
print
(
'LArExtendedSubDetGrouping'
)
232
print
(
'Partition: '
,Partition)
233
print
(
'PGen: '
,PartitionTypeGeneric)
234
235
236
237
238
239
240
241
if
( GainList[0]==
"HIGH"
):
242
gain= [0]
243
244
245
elif
( GainList[0]==
"MEDIUM"
) :
246
gain= [1]
247
248
249
elif
( GainList[0]==
"LOW"
) :
250
gain= [2]
251
252
else
:
253
gain=[0,1,2]
254
255
256
257
258
if
( Partition==
'EB-EMBA'
and
( PartitionTypeGeneric!=
'EMBPS'
) ) :
259
partition =[
'EMBA'
]
260
print
(
'EMBA partition'
)
261
elif
( Partition==
'EB-EMBC'
and
( PartitionTypeGeneric!=
'EMBPS'
) ) :
262
partition =[
'EMBC'
]
263
print
(
'EMBC partition'
)
264
elif
( Partition==
'EB-EMB'
and
( PartitionTypeGeneric!=
'EMBPS'
) ) :
265
partition =[
'EMBA'
,
'EMBC'
]
266
print
(
'EMB partition'
)
267
268
269
if
( Partition==
'EB-EMBA'
and
( PartitionTypeGeneric==
'EMBPS'
) ) :
270
partition =[
'EMBAPS'
]
271
print
(
'EMBAPS partition'
)
272
elif
( Partition==
'EB-EMBC'
and
( PartitionTypeGeneric==
'EMBPS'
) ) :
273
partition =[
'EMBCPS'
]
274
print
(
'EMBCPS partition'
)
275
elif
( Partition==
'EB-PS'
and
( PartitionTypeGeneric==
'EMBPS'
) ) :
276
partition =[
'EMBAPS'
,
'EMBCPS'
]
277
print
(
'EMBAPS and EMBCPS partition'
)
278
279
if
( Partition==
'EB-EM'
) :
280
partition =[
'EMBAPS'
,
'EMBCPS'
,
'EMBA'
,
'EMBC'
,
'EMECAPS'
,
'EMECA'
,
'EMECCPS'
,
'EMECC'
]
281
print
(
'EM partition'
)
282
283
284
if
( Partition==
'EB-EMECA'
) :
285
partition =[
'EMECAPS'
,
'EMECA'
]
286
elif
( Partition==
'EB-EMECC'
) :
287
partition =[
'EMECCPS'
,
'EMECC'
]
288
elif
( Partition==
'EB-EMEC'
) :
289
partition =[
'EMECAPS'
,
'EMECA'
,
'EMECCPS'
,
'EMECC'
]
290
291
elif
( PartitionType==
'HEC'
):
292
partition =[
'HECA'
,
'HECC'
]
293
294
295
elif
( PartitionType==
'FCAL'
) :
296
partition =[
'FCALA'
,
'FCALC'
]
297
298
elif
( Partition==
'HECFCALC'
) :
299
partition =[
'HECC'
,
'FCALC'
]
300
301
selection = _lArExtendedSubDetGrouping.getChannelSelection(partition,gain)
302
ChannelSelection=
'<channelSelection>'
+selection+
'</channelSelection>'
303
print
(ChannelSelection)
304
print
(
"CoolChannel Selection for "
, partition,
" and "
,gain,
" gain. "
)
305
return
ChannelSelection
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping
Definition
LArExtendedSubDetGrouping.py:3
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMECCPS
tuple _EMECCPS
Definition
LArExtendedSubDetGrouping.py:11
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._corr
_corr
Definition
LArExtendedSubDetGrouping.py:60
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMBCPS
tuple _EMBCPS
Definition
LArExtendedSubDetGrouping.py:7
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMECC
tuple _EMECC
Definition
LArExtendedSubDetGrouping.py:9
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.getChannelList
getChannelList(self, partitions, gains=[0])
Definition
LArExtendedSubDetGrouping.py:89
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._empty
tuple _empty
Definition
LArExtendedSubDetGrouping.py:38
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._HECC
tuple _HECC
Definition
LArExtendedSubDetGrouping.py:13
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._partitions
_partitions
Definition
LArExtendedSubDetGrouping.py:43
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._revLookup
_revLookup
Definition
LArExtendedSubDetGrouping.py:75
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.__init__
__init__(self)
Definition
LArExtendedSubDetGrouping.py:4
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._withCorr
bool _withCorr
Definition
LArExtendedSubDetGrouping.py:40
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.counts
list counts
Definition
LArExtendedSubDetGrouping.py:186
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.setWithCorr
setWithCorr(self, val)
Definition
LArExtendedSubDetGrouping.py:81
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMECA
tuple _EMECA
Definition
LArExtendedSubDetGrouping.py:10
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.name
name
Definition
LArExtendedSubDetGrouping.py:185
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.getChannelSelectionAllGains
getChannelSelectionAllGains(self, partitions)
Definition
LArExtendedSubDetGrouping.py:154
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMECAPS
tuple _EMECAPS
Definition
LArExtendedSubDetGrouping.py:12
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.getChannelSelection
getChannelSelection(self, partitions, gains)
Definition
LArExtendedSubDetGrouping.py:151
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._FCALC
tuple _FCALC
Definition
LArExtendedSubDetGrouping.py:15
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._emptyC
tuple _emptyC
Definition
LArExtendedSubDetGrouping.py:36
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMBA
tuple _EMBA
Definition
LArExtendedSubDetGrouping.py:6
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._emptyA
tuple _emptyA
Definition
LArExtendedSubDetGrouping.py:37
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.size
size
Definition
LArExtendedSubDetGrouping.py:184
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.getGain
getGain(self, c)
Definition
LArExtendedSubDetGrouping.py:161
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.channelsPerPartition
channelsPerPartition(self, chans, show=True)
Definition
LArExtendedSubDetGrouping.py:181
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.Print
Print(self)
Definition
LArExtendedSubDetGrouping.py:84
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._FCALA
tuple _FCALA
Definition
LArExtendedSubDetGrouping.py:16
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMBAPS
tuple _EMBAPS
Definition
LArExtendedSubDetGrouping.py:8
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping.makeRange
makeRange(self, chans)
Definition
LArExtendedSubDetGrouping.py:124
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._HECA
tuple _HECA
Definition
LArExtendedSubDetGrouping.py:14
python.LArExtendedSubDetGrouping.LArExtendedSubDetGrouping._EMBC
tuple _EMBC
Definition
LArExtendedSubDetGrouping.py:5
python.LArExtendedSubDetGrouping.channelSelectionFromString
channelSelectionFromString(Partition, PartitionType, PartitionTypeGeneric, GainList)
Definition
LArExtendedSubDetGrouping.py:230
Generated on
for ATLAS Offline Software by
1.17.0