8         (
"Pixel",    (
"PIXB", 
"PIX0", 
"PIXEA", 
"PIXEC")),
 
    9         (
"SCT",      (
"SCTB", 
"SCTEA", 
"SCTEC")),
 
   10         (
"TRT",      (
"TRTB", 
"TRTEA", 
"TRTEC")),
 
   11         (
"IDGlobal", (
"IDGL", 
"IDAL", 
"IDBS", 
"IDPF", 
"IDBCM")),
 
   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")),
 
   21         (
"MDT", (
"MDTBA", 
"MDTBC", 
"MDTEA", 
"MDTEC")),
 
   22         (
"RPC", (
"RPCBA", 
"RPCBC")),
 
   23         (
"TGC", (
"TGCEA", 
"TGCEC")),
 
   24         (
"CSC", (
"CSCEA", 
"CSCEC")),
 
   27         (
"LUCID", (
"LCD", 
"LCDA", 
"LCDC")),
 
   28         (
"Other", (
"ALFA", 
"ZDC", 
"LUMI")),
 
   29         (
"RC",    (
"RUNCLT", 
"RCOPS")),
 
   33         (
"L1",  (
"L1CAL", 
"L1MUB", 
"L1MUE", 
"L1CTP")),
 
   34         (
"HLT", (
"TRCAL", 
"TRBJT", 
"TRBPH", 
"TRCOS", 
"TRGAM", 
 
   35                  "TRMET", 
"TRMBI", 
"TRMUO", 
"TRTAU", 
"TRIDT")),
 
   38         (
"egammaID", (
"EIDCR", 
"EIDE", 
"PIDB", 
"PIDCR", 
"PIDE",
 
   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")),
 
   51     def __init__(self, hierarchy, depth=0, parent=None):
 
   53         Create a DetectorHierarchy object 
   59         if isinstance(hierarchy, str):
 
   60             self.
name, sub_hierarchy = hierarchy, []
 
   62             self.
name, sub_hierarchy = hierarchy
 
   65                               for sub_part 
in sub_hierarchy]
 
   74         Accumulate the lowest parts of the hierarchy which contain "name" 
   80             return [(self.
name, parts)] 
if selected 
else []
 
   84             breadcrumbs = parts + (self.
name,)
 
   85             result.extend(sub_part.get_channels(name, selected, breadcrumbs))
 
   90         String representation of the hierarchy 
  102         indent = 
" "*self.
depth if self.
depth < 3 
else "" 
  103         name = self.
name.ljust(width)
 
  105         return "".
join((indent, name) + sub_part)
 
  110     print(
"Detector hierarchy:")
 
  111     print(detector_hierarchy)
 
  114     accumulated = detector_hierarchy.get_channels(
"Inner_Detector")
 
  116     from pprint 
import pprint
 
  119     from itertools 
import groupby
 
  120     pprint(
list(groupby(accumulated, key=
lambda x: x[1])))
 
  122 if __name__ == 
"__main__":