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