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

Public Member Functions

def __init__ (self)
 
def setBegin (self, run, lumi)
 
def setEnd (self, run, lumi)
 
def setFileName (self, fileName)
 
def setFolderTag (self, folderTag)
 
def readFile (self)
 
def genDb (self)
 
def dumpDb (self, dbstring)
 

Public Attributes

 beginTime
 
 endTime
 
 FileName
 
 FolderTag
 
 Params
 

Detailed Description

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

Definition at line 24 of file LArHVMapDbFiller.py.

Constructor & Destructor Documentation

◆ __init__()

def LArHVMapDbFiller.LArHVMapDbFiller.__init__ (   self)

Definition at line 30 of file LArHVMapDbFiller.py.

30  def __init__(self):
31  object.__init__(self)
32 
33  self.beginTime = None
34  self.endTime = None
35  self.FileName = None
36  self.FolderTag = None
37  self.Params = {}
38  return
39 

Member Function Documentation

◆ dumpDb()

def LArHVMapDbFiller.LArHVMapDbFiller.dumpDb (   self,
  dbstring 
)

Definition at line 137 of file LArHVMapDbFiller.py.

137  def dumpDb(self, dbstring):
138 
139  print ("LArHVMapDbFiller.dumpDb: Dumping database:", dbstring)
140  # get database service and open database
141  dbSvc = cool.DatabaseSvcFactory.databaseService()
142  # database accessed via physical name
143  try:
144  db = dbSvc.openDatabase(dbstring,False)
145  except Exception as e:
146  print ('LArHVMapDbFiller.dumpDb: Problem opening database',e)
147  sys.exit(-1)
148 
149  # Loop over folders
150  folders = db.listAllNodes()
151  for ff in folders:
152  # Get Folder
153  try:
154  f = db.getFolder(ff)
155  print ("LArHVMapDbFiller.dumpDb: Dumping folder " + str(ff))
156  except Exception:
157  #print ("Skipping " + str(ff))
158  continue
159 
160  # get tags
161  # tags = f.listTags()
162  # print ("for tags ",)
163  # for tag in tags: print (tag)
164 
165  # for tag in tags:
166 
167  nobjs = f.countObjects( cool.ValidityKeyMin,
168  cool.ValidityKeyMax,
169  cool.ChannelSelection.all())
170 
171  print ("LArHVMapDbFiller.dumpDb: number of IOV payloads", nobjs)
172 
173  objs = f.browseObjects( cool.ValidityKeyMin,
174  cool.ValidityKeyMax,
175  cool.ChannelSelection.all())
176  i = 0
177  while objs.goToNext():
178  obj = objs.currentRef()
179  print ("LArHVMapDbFiller.dumpDb: Payload", i,)
180  print ("since [r,l]: [", obj.since() ,']',)
181  print ("until [r,l]: [", obj.until() ,']',)
182  print ("payload", obj.payload(),)
183  print ("chan",obj.channelId() )
184  i += 1
185 
186  objs.close()
187 
188  # finish
189  db.closeDatabase()

◆ genDb()

def LArHVMapDbFiller.LArHVMapDbFiller.genDb (   self)

Definition at line 69 of file LArHVMapDbFiller.py.

69  def genDb(self):
70 
71  dbFileName = 'HVmap.db'
72  dbName = 'COMP200'
73  folderPath = '/LAR/IdentifierOfl/HVLineToElectrodeMap'
74  # Do checks
75  if self.beginTime is None:
76  raise LArHVMapDbFillerError ('Must set begin run number before generating db')
77  if self.endTime is None:
78  self.endTime = cool.ValidityKeyMax
79  if self.FileName is None:
80  raise LArHVMapDbFillerError ('Must give an input file for LArHVToElectrode.data')
81  if self.FolderTag is None:
82  raise LArHVMapDbFillerError ('Must give a folder tag')
83 
84  self.readFile()
85 
86  if len(self.Params) == 0:
87  raise LArHVMapDbFillerError ('No parameters for db ' + dbName)
88 
89  # remove existing db, if any
90  try:
91  os.remove(dbFileName)
92  print ("LArHVMapDbFiller.genDb: Removed db", dbFileName)
93  except OSError:
94  pass
95 
96  # get database service and open database
97  dbSvc=cool.DatabaseSvcFactory.databaseService()
98 
99  # build dbstring - database accessed via physical name
100  dbstring="sqlite://;schema=" + dbFileName + ";dbname=" + dbName
101  try:
102  db=dbSvc.createDatabase(dbstring)
103  except Exception as e:
104  print ('LArHVMapDbFiller.genDb: Problem creating database',e)
105  sys.exit(-1)
106  print ("LArHVMapDbFiller.genDb: Created database",dbstring)
107 
108  # setup a folder payload specification
109  spec=cool.RecordSpecification()
110  for key in self.Params:
111  spec.extend(key, cool.StorageType.String16M)
112 
113  # folder meta-data - note for Athena this has a special meaning
114  desc='<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
115  # create the folder - single version
116  # last argument is createParents - if true, automatically creates parent
117  # folders if needed
118  # note this will not work if the database already exists - delete mycool.db first
119  myfolder=db.createFolder(folderPath, spec, desc, cool.FolderVersioning.MULTI_VERSION,True)
120  # now fill in simlation parameters
121  data=cool.Record(spec)
122  for k, v in six.iteritems (self.Params):
123  data[k] = v
124 
125  print ("LArHVMapDbFiller.genDb: Recording parameters", data)
126 
127  # store object with IOV valid from 0-10, channel 3
128  myfolder.storeObject(self.beginTime, self.endTime, data, 0, self.FolderTag)
129  print ("LArHVMapDbFiller.genDb: Stored object")
130 
131  # finalize
132  db.closeDatabase()
133 
134  # Try to dump out db as test
135  self.dumpDb(dbstring)
136 

◆ readFile()

def LArHVMapDbFiller.LArHVMapDbFiller.readFile (   self)

Definition at line 61 of file LArHVMapDbFiller.py.

61  def readFile(self):
62  value = ''
63  f = open(self.FileName,'r')
64  for lines in f:
65  value += lines
66  self.Params['LArHVMap'] = value
67  return
68 

◆ setBegin()

def LArHVMapDbFiller.LArHVMapDbFiller.setBegin (   self,
  run,
  lumi 
)

Definition at line 41 of file LArHVMapDbFiller.py.

41  def setBegin(self,run,lumi):
42  print (" setBegin run,lumi ",run)
43  self.beginTime = (int(run) << 32) + int(lumi)
44  print (" time ",self.beginTime)
45  return
46 

◆ setEnd()

def LArHVMapDbFiller.LArHVMapDbFiller.setEnd (   self,
  run,
  lumi 
)

Definition at line 47 of file LArHVMapDbFiller.py.

47  def setEnd(self,run,lumi):
48  print ("setEnd runmlumi ",run)
49  self.endTime = (int(run) << 32) + int(lumi)
50  print (" time ",self.endTime)
51  return
52 

◆ setFileName()

def LArHVMapDbFiller.LArHVMapDbFiller.setFileName (   self,
  fileName 
)

Definition at line 53 of file LArHVMapDbFiller.py.

53  def setFileName(self, fileName):
54  self.FileName = fileName
55  return
56 

◆ setFolderTag()

def LArHVMapDbFiller.LArHVMapDbFiller.setFolderTag (   self,
  folderTag 
)

Definition at line 57 of file LArHVMapDbFiller.py.

57  def setFolderTag(self,folderTag):
58  self.FolderTag = folderTag
59  return
60 

Member Data Documentation

◆ beginTime

LArHVMapDbFiller.LArHVMapDbFiller.beginTime

Definition at line 33 of file LArHVMapDbFiller.py.

◆ endTime

LArHVMapDbFiller.LArHVMapDbFiller.endTime

Definition at line 34 of file LArHVMapDbFiller.py.

◆ FileName

LArHVMapDbFiller.LArHVMapDbFiller.FileName

Definition at line 35 of file LArHVMapDbFiller.py.

◆ FolderTag

LArHVMapDbFiller.LArHVMapDbFiller.FolderTag

Definition at line 36 of file LArHVMapDbFiller.py.

◆ Params

LArHVMapDbFiller.LArHVMapDbFiller.Params

Definition at line 37 of file LArHVMapDbFiller.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
FileMerger.readFile
def readFile(name)
Definition: FileMerger.py:27
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
str
Definition: BTagTrackIpAccessor.cxx:11