ATLAS Offline Software
Loading...
Searching...
No Matches
geo_id.py
Go to the documentation of this file.
1# import ROOT
2
3import sys
4
5# file = sys.argv[1]
6
8 volume_mask = 0xff00000000000000
9 boundary_mask = 0x00ff000000000000
10 layer_mask = 0x0000ff0000000000
11 approach_mask = 0x000000f000000000
12 sensitive_mask = 0x0000000ffff00000
13 channel_mask = 0x00000000000fffff
14
15 def __init__(self, value):
16 assert type(value) == long
17 self._value = value
18
19 def _ffs(self, x):
20 """Returns the index, counting from 0, of the
21 least significant set bit in `x`.
22 """
23 return (x&-x).bit_length()-1
24
25 @property
26 def vol_id(self):
27 return self.value(self.volume_mask)
28
29 @property
30 def bnd_id(self):
31 return self.value(self.boundary_mask)
32
33 @property
34 def lay_id(self):
35 return self.value(self.layer_mask)
36
37 @property
38 def app_id(self):
39 return self.value(self.approach_mask)
40
41 @property
42 def sen_id(self):
43 return self.value(self.sensitive_mask)
44
45 @property
46 def chn_id(self):
47 return self.value(self.channel_mask)
48
49 def value(self, mask = None):
50 if mask == None: return self._value
51 return (self._value & mask) >> self._ffs(mask)
52
53 def __repr__(self):
54 fmt = "GeometryIdentifier(vol={}, bnd={}, lay={}, app={}, sen={}, chn={})"
55 return fmt.format(self.vol_id,
56 self.bnd_id,
57 self.lay_id,
58 self.app_id,
59 self.sen_id,
60 self.chn_id)
61
62# infile = ROOT.TFile.Open(file)
63
64# tree = infile.Get("MaterialTracks")
65
66# for idx, event in enumerate(tree):
67 # for geo_id_ in event.step_geo_id:
68 # geo_id = GeometryIdentifier(geo_id_)
69 # print(geo_id)
70
71 # print("----")
72
73
value(self, mask=None)
Definition geo_id.py:49
__init__(self, value)
Definition geo_id.py:15