5 from __future__
import print_function
9 (
"Pixel", (
"PIXB",
"PIX0",
"PIXEA",
"PIXEC")),
10 (
"SCT", (
"SCTB",
"SCTEA",
"SCTEC")),
11 (
"TRT", (
"TRTB",
"TRTEA",
"TRTEC")),
12 (
"IDGlobal", (
"IDGL",
"IDAL",
"IDBS",
"IDPF",
"IDBCM")),
15 (
"LAr", (
"EMBA",
"EMBC",
"EMECA",
"EMECC",
"HECA",
16 "HECC",
"FCALA",
"FCALC")),
17 (
"Tile", (
"TIGB",
"TILBA",
"TILBC",
"TIEBA",
"TIEBC")),
18 (
"MBTS", (
"MBTSA",
"MBTSC")),
19 (
"CaloGlobal", (
"CALBA",
"CALEA",
"CALEC")),
22 (
"MDT", (
"MDTBA",
"MDTBC",
"MDTEA",
"MDTEC")),
23 (
"RPC", (
"RPCBA",
"RPCBC")),
24 (
"TGC", (
"TGCEA",
"TGCEC")),
25 (
"CSC", (
"CSCEA",
"CSCEC")),
28 (
"LUCID", (
"LCD",
"LCDA",
"LCDC")),
29 (
"Other", (
"ALFA",
"ZDC",
"LUMI")),
30 (
"RC", (
"RUNCLT",
"RCOPS")),
34 (
"L1", (
"L1CAL",
"L1MUB",
"L1MUE",
"L1CTP")),
35 (
"HLT", (
"TRCAL",
"TRBJT",
"TRBPH",
"TRCOS",
"TRGAM",
36 "TRMET",
"TRMBI",
"TRMUO",
"TRTAU",
"TRIDT")),
39 (
"egammaID", (
"EIDCR",
"EIDE",
"PIDB",
"PIDCR",
"PIDE",
41 (
"muonID", (
"MSTACO",
"MMUIDCB",
"MMUIDVX",
"MMUGIRL",
42 "MMUBOY",
"MMUIDSA",
"MMUTAG",
"MMTIMO",
43 "MCMUTAG",
"MCALLHR")),
44 (
"Jets", (
"JETB",
"JETEA",
"JETEC")),
45 (
"MET", (
"MET",
"METCALO",
"METMUON")),
46 (
"b_tag", (
"BTGB",
"BTGEA",
"BTGEC")),
47 (
"tauID", (
"TAUE",
"TAUB",
"TAUCR")),
52 def __init__(self, hierarchy, depth=0, parent=None):
54 Create a DetectorHierarchy object
60 if isinstance(hierarchy, str):
61 self.
name, sub_hierarchy = hierarchy, []
63 self.
name, sub_hierarchy = hierarchy
66 for sub_part
in sub_hierarchy]
75 Accumulate the lowest parts of the hierarchy which contain "name"
81 return [(self.
name, parts)]
if selected
else []
85 breadcrumbs = parts + (self.
name,)
86 result.extend(sub_part.get_channels(name, selected, breadcrumbs))
91 String representation of the hierarchy
103 indent =
" "*self.
depth if self.
depth < 3
else ""
104 name = self.
name.ljust(width)
106 return "".
join((indent, name) + sub_part)
111 print(
"Detector hierarchy:")
112 print(detector_hierarchy)
115 accumulated = detector_hierarchy.get_channels(
"Inner_Detector")
117 from pprint
import pprint
120 from itertools
import groupby
121 pprint(
list(groupby(accumulated, key=
lambda x: x[1])))
123 if __name__ ==
"__main__":