ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
python.clidGenerator.clidGenerator Class Reference

Athena CLID Generator Class. More...

Inheritance diagram for python.clidGenerator.clidGenerator:
Collaboration diagram for python.clidGenerator.clidGenerator:

Public Member Functions

def __init__ (self, db, debug=False)
 
def cleardb (self)
 
def readdb (self)
 
def setCLIDDB (self, db, debug)
 
def writedb (self, db)
 
def genClidFromName (self, className)
 
def getClidFromName (self, className)
 
def getClidFromTid (self, tidName)
 
def getNameFromClid (self, clid)
 
def getTidFromClid (self, clid)
 
def demangleClassName (self, s)
 
def isCollection (self, className)
 
def findPattern (self, s)
 

Private Attributes

 __cliddbs
 

Static Private Attributes

int __mask = 0x0FFFFFFF
 
dictionary __clidRep = {}
 
dictionary __clidTid = {}
 
dictionary __nameRep = {}
 
dictionary __tidRep = {}
 

Detailed Description

Athena CLID Generator Class.

Athena CLID Generator

Definition at line 26 of file clidGenerator.py.

Constructor & Destructor Documentation

◆ __init__()

def python.clidGenerator.clidGenerator.__init__ (   self,
  db,
  debug = False 
)

Definition at line 36 of file clidGenerator.py.

36  def __init__(self, db, debug=False):
37  self.setCLIDDB(db, debug)
38  self.readdb()
39 

Member Function Documentation

◆ cleardb()

def python.clidGenerator.clidGenerator.cleardb (   self)

Definition at line 40 of file clidGenerator.py.

40  def cleardb(self):
41  clidGenerator.__clidRep = {} # Lookup by CLID
42  clidGenerator.__nameRep = {} # Lookup by ClassName
43 

◆ demangleClassName()

def python.clidGenerator.clidGenerator.demangleClassName (   self,
  s 
)

Definition at line 128 of file clidGenerator.py.

128  def demangleClassName(self,s):
129  return s
130 # pat = re.compile('\s*(.?)__*\s*')
131 # n = pat.findall(s)
132 # if n:
133 # return n[0]
134 # else:
135 # return s
136 

◆ findPattern()

def python.clidGenerator.clidGenerator.findPattern (   self,
  s 
)
Find the regular expression pattern s in dictionary.

Definition at line 141 of file clidGenerator.py.

141  def findPattern(self,s):
142  """Find the regular expression pattern s in dictionary."""
143 # pat = re.compile('^'+s+'$')
144  pat = re.compile(s)
145  results = {}
146  for k in self.__clidRep.keys():
147  if pat.match(str(k)) or pat.match(self.__clidRep[k]):
148  results[k] = self.__clidRep[k]
149  return results
150 

◆ genClidFromName()

def python.clidGenerator.clidGenerator.genClidFromName (   self,
  className 
)
Generate CLID from ClassName: A recursive hash with a bit
mask and validity range. Will check collisions against and
update CLID Repository.

Definition at line 89 of file clidGenerator.py.

89  def genClidFromName(self,className):
90  """Generate CLID from ClassName: A recursive hash with a bit
91  mask and validity range. Will check collisions against and
92  update CLID Repository."""
93  n = self.demangleClassName(className)
94  c = self.getClidFromName(className)
95  if c:
96  return c
97  c = py2_hash(className) & self.__mask
98  if c < 10001 or c > self.__mask:
99  c = self.genClidFromName(className+'_')
100  if self.isCollection(className):
101  c += 0x40000000
102  if c in self.__clidRep:
103  if n != self.__clidRep[c]:
104  c = self.genClidFromName(className+'_')
105  else:
106  self.__clidRep[c] = n
107  self.__clidTid[c] = n # make typeid name the same than class-name
108  self.__nameRep[n] = c
109  self.__tidRep [n] = c # idem
110  return c
111 

◆ getClidFromName()

def python.clidGenerator.clidGenerator.getClidFromName (   self,
  className 
)
Get the CLID in the repository of class name <className>

Definition at line 112 of file clidGenerator.py.

112  def getClidFromName(self,className):
113  """Get the CLID in the repository of class name <className>"""
114  return self.__nameRep.get(className, None)
115 

◆ getClidFromTid()

def python.clidGenerator.clidGenerator.getClidFromTid (   self,
  tidName 
)
Get the CLID in the repository of typeid name <tidName>

Definition at line 116 of file clidGenerator.py.

116  def getClidFromTid(self,tidName):
117  """Get the CLID in the repository of typeid name <tidName>"""
118  return self.__tidRep.get(tidName, None)
119 

◆ getNameFromClid()

def python.clidGenerator.clidGenerator.getNameFromClid (   self,
  clid 
)
Get the class name in the repository with CLID <clid>

Definition at line 120 of file clidGenerator.py.

120  def getNameFromClid(self,clid):
121  """Get the class name in the repository with CLID <clid>"""
122  return self.__clidRep.get(clid, None)
123 

◆ getTidFromClid()

def python.clidGenerator.clidGenerator.getTidFromClid (   self,
  clid 
)
Get the typeid name in the repository with CLID <clid>

Definition at line 124 of file clidGenerator.py.

124  def getTidFromClid(self,clid):
125  """Get the typeid name in the repository with CLID <clid>"""
126  return self.__clidTid.get(clid, None)
127 

◆ isCollection()

def python.clidGenerator.clidGenerator.isCollection (   self,
  className 
)

Definition at line 137 of file clidGenerator.py.

137  def isCollection(self,className):
138  collMatch = re.search(r'.*?Collection_*|.*?Container_*',className)
139  return collMatch
140 

◆ readdb()

def python.clidGenerator.clidGenerator.readdb (   self)
Read CLID DataBase file

Definition at line 44 of file clidGenerator.py.

44  def readdb(self):
45  """Read CLID DataBase file"""
46  try:
47  for cliddb in self.__cliddbs:
48  if os.path.isfile(cliddb):
49  with open(cliddb, 'r') as f_cliddb:
50  for row in csv.reader (f_cliddb, delimiter=';'):
51  row = [i.strip() for i in row]
52  if len(row) >= 2:
53  clid = int(row[0])
54  class_name = row[1]
55  tid_name = row[2] if len(row)>2 else class_name
56 
57  self.__clidRep[clid] = class_name
58  self.__clidTid[clid] = tid_name
59  self.__nameRep[class_name] = clid
60  self.__tidRep [tid_name] = clid
61 
62  else:
63  print ("No CLID DataBase file <%s> " % cliddb)
64  except Exception as err:
65  print ("Error reading from CLID DataBase files <%s>:\n%s " % (
66  self.__cliddbs,
67  err))
68 

◆ setCLIDDB()

def python.clidGenerator.clidGenerator.setCLIDDB (   self,
  db,
  debug 
)
Initializes a CLID Generator object with a CLID Database

Definition at line 69 of file clidGenerator.py.

69  def setCLIDDB(self, db, debug):
70  """Initializes a CLID Generator object with a CLID Database"""
71  if db:
72  self.__cliddbs = search_files(db, os.getenv('DATAPATH'))
73  if debug: print ("Using specified CLID DataBase files %s " % self.__cliddbs)
74  elif os.getenv('CLIDDB'):
75  # CLID DataBase (Default = clid.db)
76  self.__cliddbs.append(os.getenv('CLIDDB'))
77  if debug: print ("Using DataBase file from CLIDDB env variable %s " % self.__cliddbs)
78  else:
79  self.__cliddbs = search_files('clid.db', os.getenv('DATAPATH'))
80  if debug: print ("Using DataBase file from DATAPATH %s " % self.__cliddbs)
81 

◆ writedb()

def python.clidGenerator.clidGenerator.writedb (   self,
  db 
)
Read CLID DataBase file

Definition at line 82 of file clidGenerator.py.

82  def writedb(self,db):
83  """Read CLID DataBase file"""
84  output = open(db,'w')
85  for k in self.__clidRep.keys():
86  output.write("%d "%k+self.__clidRep[k]+"\n")
87  output.close()
88 

Member Data Documentation

◆ __cliddbs

python.clidGenerator.clidGenerator.__cliddbs
private

Definition at line 72 of file clidGenerator.py.

◆ __clidRep

dictionary python.clidGenerator.clidGenerator.__clidRep = {}
staticprivate

Definition at line 31 of file clidGenerator.py.

◆ __clidTid

dictionary python.clidGenerator.clidGenerator.__clidTid = {}
staticprivate

Definition at line 32 of file clidGenerator.py.

◆ __mask

int python.clidGenerator.clidGenerator.__mask = 0x0FFFFFFF
staticprivate

Definition at line 29 of file clidGenerator.py.

◆ __nameRep

dictionary python.clidGenerator.clidGenerator.__nameRep = {}
staticprivate

Definition at line 33 of file clidGenerator.py.

◆ __tidRep

dictionary python.clidGenerator.clidGenerator.__tidRep = {}
staticprivate

Definition at line 34 of file clidGenerator.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.clidGenerator.search_files
def search_files(filename, search_path, pathsep=os.pathsep)
Definition: clidGenerator.py:158
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.clidGenerator.py2_hash
def py2_hash(s)
Definition: clidGenerator.py:14
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798