ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.ParameterDbFiller.ParameterDbFiller Class Reference
Inheritance diagram for python.ParameterDbFiller.ParameterDbFiller:
Collaboration diagram for python.ParameterDbFiller.ParameterDbFiller:

Public Member Functions

def __init__ (self)
 
def setBeginRun (self, beginRun)
 
def setEndRun (self, endRun)
 
def addSimParam (self, name, value)
 
def addDigitParam (self, name, value)
 
def addDigitParam64 (self, name, value)
 
def genSimDb (self, dbFileName=None)
 
def genDigitDb (self, dbFileName=None)
 
def genDb (self, dbFileName, dbName, params, folderPath, params64={})
 
def dumpDb (self, dbstring)
 

Public Attributes

 beginRun
 
 endRun
 
 simParams
 
 digitParams
 
 digitParams64
 

Detailed Description

A simple class used to fill SQLite db file with parameters for simulation
and/or digitization.

Definition at line 26 of file ParameterDbFiller.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ParameterDbFiller.ParameterDbFiller.__init__ (   self)

Definition at line 32 of file ParameterDbFiller.py.

32  def __init__(self):
33  object.__init__(self)
34 
35  self.beginRun = None
36  self.endRun = None
37  self.simParams = collections.OrderedDict()
38  self.digitParams = collections.OrderedDict()
39  self.digitParams64 = collections.OrderedDict()
40  return
41 

Member Function Documentation

◆ addDigitParam()

def python.ParameterDbFiller.ParameterDbFiller.addDigitParam (   self,
  name,
  value 
)

Definition at line 55 of file ParameterDbFiller.py.

55  def addDigitParam(self, name, value):
56  self.digitParams[name] = value
57  return
58 

◆ addDigitParam64()

def python.ParameterDbFiller.ParameterDbFiller.addDigitParam64 (   self,
  name,
  value 
)

Definition at line 59 of file ParameterDbFiller.py.

59  def addDigitParam64(self, name, value):
60  self.digitParams64[name] = value
61  return
62 

◆ addSimParam()

def python.ParameterDbFiller.ParameterDbFiller.addSimParam (   self,
  name,
  value 
)

Definition at line 51 of file ParameterDbFiller.py.

51  def addSimParam(self, name, value):
52  self.simParams[name] = value
53  return
54 

◆ dumpDb()

def python.ParameterDbFiller.ParameterDbFiller.dumpDb (   self,
  dbstring 
)

Definition at line 150 of file ParameterDbFiller.py.

150  def dumpDb(self, dbstring):
151 
152  print ("ParameterDbFiller.dumpDb: Dumping database:", dbstring)
153  # get database service and open database
154  dbSvc = cool.DatabaseSvcFactory.databaseService()
155  # database accessed via physical name
156  try:
157  db = dbSvc.openDatabase(dbstring,False)
158  except Exception as e:
159  print ('ParameterDbFiller.dumpDb: Problem opening database',e)
160  sys.exit(-1)
161 
162  # Loop over folders
163  folders = db.listAllNodes()
164  for ff in folders:
165  # Get Folder
166  if (not db.existsFolder(ff)):
167  continue
168  try:
169  f = db.getFolder(ff)
170  print ("ParameterDbFiller.dumpDb: Dumping folder " + str(ff))
171  except Exception:
172  #print ("Skipping " + str(ff))
173  continue
174 
175  # get tags
176  # tags = f.listTags()
177  # print ("for tags ", end='')
178  # for tag in tags: print (tag)
179 
180  # for tag in tags:
181 
182  nobjs = f.countObjects( cool.ValidityKeyMin,
183  cool.ValidityKeyMax,
184  cool.ChannelSelection.all())
185 
186  print ("ParameterDbFiller.dumpDb: number of IOV payloads", nobjs)
187 
188  objs = f.browseObjects( cool.ValidityKeyMin,
189  cool.ValidityKeyMax,
190  cool.ChannelSelection.all())
191  i = 0
192  while objs.goToNext():
193  obj = objs.currentRef()
194  print ("ParameterDbFiller.dumpDb: Payload", i, end='')
195  print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='')
196  print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='')
197  print ("payload", obj.payload(), end='')
198  print ("chan",obj.channelId() )
199  i += 1
200 
201  objs.close()
202 
203  # finish
204  db.closeDatabase()

◆ genDb()

def python.ParameterDbFiller.ParameterDbFiller.genDb (   self,
  dbFileName,
  dbName,
  params,
  folderPath,
  params64 = {} 
)

Definition at line 83 of file ParameterDbFiller.py.

83  def genDb(self, dbFileName, dbName, params, folderPath, params64 = {}):
84 
85  # Do checks
86  if self.beginRun is None:
87  raise ParameterDbFillerError ('Must set begin run number before generating db')
88  if self.endRun is None:
89  raise ParameterDbFillerError ('Must set end run number before generating db')
90  if len(params) == 0:
91  raise ParameterDbFillerError ('No parameters for db ' + dbName)
92 
93  # remove existing db, if any
94  try:
95  os.remove(dbFileName)
96  print ("ParameterDbFiller.genDb: Removed db", dbFileName)
97  except Exception:
98  pass
99 
100  # get database service and open database
101  dbSvc=cool.DatabaseSvcFactory.databaseService()
102 
103  # build dbstring - database accessed via physical name
104  dbstring="sqlite://;schema=" + dbFileName + ";dbname=" + dbName
105  try:
106  db=dbSvc.createDatabase(dbstring)
107  except Exception as e:
108  print ('ParameterDbFiller.genDb: Problem creating database',e)
109  sys.exit(-1)
110  print ("ParameterDbFiller.genDb: Created database",dbstring)
111 
112  # setup a folder payload specification
113  spec=cool.RecordSpecification()
114  for key in params:
115  spec.extend(key, cool.StorageType.String4k)
116  pass
117  # add in spec for long strings
118  for key in params64:
119  spec.extend(key, cool.StorageType.String64k)
120 
121  # folder meta-data - note for Athena this has a special meaning
122  desc = '<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
123  # create the folder - single version
124  # last argument is createParents - if true, automatically creates parent
125  # folders if needed
126  # note this will not work if the database already exists - delete mycool.db first
127  # myfolder=db.createFolder(folderPath, spec, desc, cool.FolderVersioning.SINGLE_VERSION,True)
128  folderSpec = cool.FolderSpecification(cool.FolderVersioning.SINGLE_VERSION, spec)
129  myfolder = db.createFolder(folderPath, folderSpec, desc, True)
130 
131  # now fill in parameters
132  data = cool.Record(spec)
133  for k, v in six.iteritems(params):
134  data[k] = v
135  for k, v in six.iteritems(params64):
136  data[k] = v
137 
138  print ("ParameterDbFiller.genDb: Recording parameters", data)
139 
140  # store object with IOV valid from 0-10, channel 3
141  myfolder.storeObject(self.beginRun, self.endRun, data, 0)
142  print ("ParameterDbFiller.genDb: Stored object")
143 
144  # finalize
145  db.closeDatabase()
146 
147  # Try to dump out db as test
148  self.dumpDb(dbstring)
149 

◆ genDigitDb()

def python.ParameterDbFiller.ParameterDbFiller.genDigitDb (   self,
  dbFileName = None 
)

Definition at line 73 of file ParameterDbFiller.py.

73  def genDigitDb(self, dbFileName = None):
74  # Allow to define specific file name, otherwise use
75  if dbFileName is None:
76  # Set to default value
77  dbFileName = "DigitParams.db"
78 
79  # Generate db: args - file name, dbname, params, folder path
80  self.genDb(dbFileName, 'DIGPARAM', self.digitParams, '/Digitization/Parameters', self.digitParams64)
81 
82 

◆ genSimDb()

def python.ParameterDbFiller.ParameterDbFiller.genSimDb (   self,
  dbFileName = None 
)

Definition at line 63 of file ParameterDbFiller.py.

63  def genSimDb(self, dbFileName = None):
64  # Allow to define specific file name, otherwise use
65  if dbFileName is None:
66  # Set to default value
67  dbFileName = "SimParams.db"
68 
69  # Generate db: args - file name, dbname, params, folder path
70  self.genDb(dbFileName, 'SIMPARAM', self.simParams, '/Simulation/Parameters')
71 
72 

◆ setBeginRun()

def python.ParameterDbFiller.ParameterDbFiller.setBeginRun (   self,
  beginRun 
)

Definition at line 43 of file ParameterDbFiller.py.

43  def setBeginRun(self, beginRun):
44  self.beginRun = beginRun << 32
45  return
46 

◆ setEndRun()

def python.ParameterDbFiller.ParameterDbFiller.setEndRun (   self,
  endRun 
)

Definition at line 47 of file ParameterDbFiller.py.

47  def setEndRun(self, endRun):
48  self.endRun = endRun << 32
49  return
50 

Member Data Documentation

◆ beginRun

python.ParameterDbFiller.ParameterDbFiller.beginRun

Definition at line 35 of file ParameterDbFiller.py.

◆ digitParams

python.ParameterDbFiller.ParameterDbFiller.digitParams

Definition at line 38 of file ParameterDbFiller.py.

◆ digitParams64

python.ParameterDbFiller.ParameterDbFiller.digitParams64

Definition at line 39 of file ParameterDbFiller.py.

◆ endRun

python.ParameterDbFiller.ParameterDbFiller.endRun

Definition at line 36 of file ParameterDbFiller.py.

◆ simParams

python.ParameterDbFiller.ParameterDbFiller.simParams

Definition at line 37 of file ParameterDbFiller.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11