ATLAS Offline Software
Loading...
Searching...
No Matches
DataQuality
DQUtils
python
detector_hierarchy.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
3
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4
5
6
HIERARCHY = (
7
(
"Inner_Detector"
,(
8
(
"Pixel"
, (
"PIXB"
,
"PIX0"
,
"PIXEA"
,
"PIXEC"
)),
9
(
"SCT"
, (
"SCTB"
,
"SCTEA"
,
"SCTEC"
)),
10
(
"TRT"
, (
"TRTB"
,
"TRTEA"
,
"TRTEC"
)),
11
(
"IDGlobal"
, (
"IDGL"
,
"IDAL"
,
"IDBS"
,
"IDPF"
,
"IDBCM"
)),
12
)),
13
(
"Calorimeters"
,(
14
(
"LAr"
, (
"EMBA"
,
"EMBC"
,
"EMECA"
,
"EMECC"
,
"HECA"
,
15
"HECC"
,
"FCALA"
,
"FCALC"
)),
16
(
"Tile"
, (
"TIGB"
,
"TILBA"
,
"TILBC"
,
"TIEBA"
,
"TIEBC"
)),
17
(
"MBTS"
, (
"MBTSA"
,
"MBTSC"
)),
18
(
"CaloGlobal"
, (
"CALBA"
,
"CALEA"
,
"CALEC"
)),
19
)),
20
(
"Muons"
,(
21
(
"MDT"
, (
"MDTBA"
,
"MDTBC"
,
"MDTEA"
,
"MDTEC"
)),
22
(
"RPC"
, (
"RPCBA"
,
"RPCBC"
)),
23
(
"TGC"
, (
"TGCEA"
,
"TGCEC"
)),
24
(
"CSC"
, (
"CSCEA"
,
"CSCEC"
)),
25
)),
26
(
"Luminosity"
,(
27
(
"LUCID"
, (
"LCD"
,
"LCDA"
,
"LCDC"
)),
28
(
"Other"
, (
"ALFA"
,
"ZDC"
,
"LUMI"
)),
29
(
"RC"
, (
"RUNCLT"
,
"RCOPS"
)),
30
(
"GL"
, (
"ATLGL"
,))
31
)),
32
(
"Trigger"
,(
33
(
"L1"
, (
"L1CAL"
,
"L1MUB"
,
"L1MUE"
,
"L1CTP"
)),
34
(
"HLT"
, (
"TRCAL"
,
"TRBJT"
,
"TRBPH"
,
"TRCOS"
,
"TRGAM"
,
35
"TRMET"
,
"TRMBI"
,
"TRMUO"
,
"TRTAU"
,
"TRIDT"
)),
36
)),
37
(
"Physics_Objects"
,(
38
(
"egammaID"
, (
"EIDCR"
,
"EIDE"
,
"PIDB"
,
"PIDCR"
,
"PIDE"
,
39
"EIDF"
,
"EIDSOFT"
)),
40
(
"muonID"
, (
"MSTACO"
,
"MMUIDCB"
,
"MMUIDVX"
,
"MMUGIRL"
,
41
"MMUBOY"
,
"MMUIDSA"
,
"MMUTAG"
,
"MMTIMO"
,
42
"MCMUTAG"
,
"MCALLHR"
)),
43
(
"Jets"
, (
"JETB"
,
"JETEA"
,
"JETEC"
)),
44
(
"MET"
, (
"MET"
,
"METCALO"
,
"METMUON"
)),
45
(
"b_tag"
, (
"BTGB"
,
"BTGEA"
,
"BTGEC"
)),
46
(
"tauID"
, (
"TAUE"
,
"TAUB"
,
"TAUCR"
)),
47
)),
48
)
49
50
class
DetectorHierarchy
(
object
):
51
def
__init__
(self, hierarchy, depth=0, parent=None):
52
"""
53
Create a DetectorHierarchy object
54
"""
55
56
self.
depth
= depth
57
self.
parent
= parent
58
59
if
isinstance(hierarchy, str):
60
self.
name
, sub_hierarchy = hierarchy, []
61
else
:
62
self.
name
, sub_hierarchy = hierarchy
63
64
self.
sub_hierarchy
= [
DetectorHierarchy
(sub_part, depth+1, self)
65
for
sub_part
in
sub_hierarchy]
66
67
if
self.
sub_hierarchy
:
68
self.
max_sub_width
=
max
(len(x.name)
for
x
in
self.
sub_hierarchy
)
69
else
:
70
self.
max_sub_width
= 7
71
72
def
get_channels
(self, name, selected=False, parts=()):
73
"""
74
Accumulate the lowest parts of the hierarchy which contain "name"
75
"""
76
if
self.
name
== name:
77
selected =
True
78
79
if
not
self.
sub_hierarchy
:
80
return
[(self.
name
, parts)]
if
selected
else
[]
81
82
result = []
83
for
sub_part
in
self.
sub_hierarchy
:
84
breadcrumbs = parts + (self.
name
,)
85
result.extend(sub_part.get_channels(name, selected, breadcrumbs))
86
return
result
87
88
def
__repr__
(self):
89
"""
90
String representation of the hierarchy
91
"""
92
sub_part = ()
93
if
self.
sub_hierarchy
:
94
jstr =
"\n"
95
indent =
"\n"
96
if
self.
depth
== 2:
97
jstr =
" "
98
indent =
" : "
99
sub_part = indent, jstr.join(repr(x)
for
x
in
self.
sub_hierarchy
)
100
101
width = self.
parent
.max_sub_width
if
self.
parent
else
len(self.
name
)
102
indent =
" "
*self.
depth
if
self.
depth
< 3
else
""
103
name = self.
name
.ljust(width)
104
105
return
""
.join((indent, name) + sub_part)
106
107
detector_hierarchy =
DetectorHierarchy
((
"All"
, HIERARCHY))
108
109
def
test
():
110
print
(
"Detector hierarchy:"
)
111
print
(detector_hierarchy)
112
print
()
113
114
accumulated = detector_hierarchy.get_channels(
"Inner_Detector"
)
115
116
from
pprint
import
pprint
117
pprint(accumulated)
118
119
from
itertools
import
groupby
120
pprint(list(groupby(accumulated, key=
lambda
x: x[1])))
121
122
if
__name__ ==
"__main__"
:
123
test
()
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
max
#define max(a, b)
Definition
cfImp.cxx:41
python.detector_hierarchy.DetectorHierarchy
Definition
detector_hierarchy.py:50
python.detector_hierarchy.DetectorHierarchy.depth
int depth
Definition
detector_hierarchy.py:56
python.detector_hierarchy.DetectorHierarchy.__init__
__init__(self, hierarchy, depth=0, parent=None)
Definition
detector_hierarchy.py:51
python.detector_hierarchy.DetectorHierarchy.name
name
Definition
detector_hierarchy.py:60
python.detector_hierarchy.DetectorHierarchy.max_sub_width
int max_sub_width
Definition
detector_hierarchy.py:68
python.detector_hierarchy.DetectorHierarchy.get_channels
get_channels(self, name, selected=False, parts=())
Definition
detector_hierarchy.py:72
python.detector_hierarchy.DetectorHierarchy.parent
parent
Definition
detector_hierarchy.py:57
python.detector_hierarchy.DetectorHierarchy.sub_hierarchy
list sub_hierarchy
Definition
detector_hierarchy.py:64
python.detector_hierarchy.DetectorHierarchy.__repr__
__repr__(self)
Definition
detector_hierarchy.py:88
python.detector_hierarchy.test
test()
Definition
detector_hierarchy.py:109
object
Generated on
for ATLAS Offline Software by
1.14.0