ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | List of all members
sim_rttUpdate.SimRttDataBase Class Reference
Collaboration diagram for sim_rttUpdate.SimRttDataBase:

Public Member Functions

def __init__ (self, fname)
 
def openConnection (self)
 
def create (self)
 
def initialFill (self)
 
def getUsers (self, right='a')
 
def findPackage (self, package)
 
def findReference (self, branch, project)
 
def findJobs (self, testname, jobtype)
 
def dump (self)
 
def addUser (self, username='aschaeli', right='a')
 
def addBranch (self, branch='17.X.0-VAL', refid='17.X.0')
 
def addTest (self, testname='SimCoreTests', path='Simulation/Tests')
 
def addJob (self, testname='SimCoreTests', jobname='AtlasG4_muons', files=['truth.root'], typeid='dcube')
 
def defineJobAlias (self, alias='dcube_jobs', joblist=['AtlasG4_muons', 'AtlasG4_electrons', 'AtlasG4_pions'])
 

Public Attributes

 fname
 
 cnx
 
 cur
 
 djobs
 
 jobs
 
 jobs0
 
 jobs1
 
 alias
 
 users
 

Private Member Functions

def _execute (self, cmd, args=())
 
def _createTable (self, tname, *args)
 
def _fillTable (self, tname, *args)
 
def _hasKey (self, tname, column, value)
 
def _updateTable (self, tname, keys, *args)
 
def _dropTable (self, tname)
 
def _dumpTable (self, t)
 

Detailed Description

Definition at line 46 of file sim_rttUpdate.py.

Constructor & Destructor Documentation

◆ __init__()

def sim_rttUpdate.SimRttDataBase.__init__ (   self,
  fname 
)

Definition at line 47 of file sim_rttUpdate.py.

47  def __init__(self,fname):
48  self.fname=fname
49  self.cnx=None
50  self.cur=None
51 
52 

Member Function Documentation

◆ _createTable()

def sim_rttUpdate.SimRttDataBase._createTable (   self,
  tname,
args 
)
private

Definition at line 61 of file sim_rttUpdate.py.

61  def _createTable(self,tname,*args):
62  #print 'creating table',tname
63  vals=','.join(('%s text ',)*len(args))
64  cmd=('create table %s ('+vals+')')% ( (tname,)+args )
65  self._execute(cmd)
66 

◆ _dropTable()

def sim_rttUpdate.SimRttDataBase._dropTable (   self,
  tname 
)
private

Definition at line 100 of file sim_rttUpdate.py.

100  def _dropTable(self,tname):
101  cmd='drop table %s'%tname
102  try:
103  self._execute(cmd)
104  except:
105  print 'SQL Error:',cmd
106 

◆ _dumpTable()

def sim_rttUpdate.SimRttDataBase._dumpTable (   self,
  t 
)
private

Definition at line 198 of file sim_rttUpdate.py.

198  def _dumpTable(self,t):
199  #t = (symbol,)
200  #cur.execute('select * from stocks where symbol=?', t)
201  self._execute('select * from %s'%t)
202  header= [ s[0] for s in self.cur.description ]
203  format= ' '.join([ '%25s' for s in self.cur.description])
204  print format%tuple(header)
205  for res in self.cur.fetchall():
206  print format%res
207 

◆ _execute()

def sim_rttUpdate.SimRttDataBase._execute (   self,
  cmd,
  args = () 
)
private

Definition at line 57 of file sim_rttUpdate.py.

57  def _execute(self,cmd,args=()):
58  print 'SQL:',cmd,args
59  self.cur.execute(cmd,args)
60 

◆ _fillTable()

def sim_rttUpdate.SimRttDataBase._fillTable (   self,
  tname,
args 
)
private

Definition at line 67 of file sim_rttUpdate.py.

67  def _fillTable(self,tname,*args):
68  #print 'updating table',tname
69  vals=','.join(('?',)*len(args))
70  cmd="insert into %s values (%s)"%(tname,vals)
71  self._execute(cmd,args)
72 
73  #insert into t_branches values ('17.2.X-VAL','17.2.X','simulation');
74  #Error: column branch is not unique
75 

◆ _hasKey()

def sim_rttUpdate.SimRttDataBase._hasKey (   self,
  tname,
  column,
  value 
)
private

Definition at line 76 of file sim_rttUpdate.py.

76  def _hasKey(self,tname,column,value):
77  cmd='select count(*) from %s where %s=?'%(tname,column)
78  self._execute(cmd,(value,))
79  res=sel.cur.fetchone()
80  print res
81  print res[0]>0
82  return res[0]
83 

◆ _updateTable()

def sim_rttUpdate.SimRttDataBase._updateTable (   self,
  tname,
  keys,
args 
)
private

Definition at line 84 of file sim_rttUpdate.py.

84  def _updateTable(self,tname,keys,*args):
85  cmd='select * from %s limit 1'%tname
86  self._execute(cmd)
87  header= [ s[0] for s in self.cur.description ]
88  res=self.cur.fetchall()
89 
90  values=[ k+'=?' for k in header if k not in keys ]
91  key_values=tuple([ a for k,a in zip(header,args) if k in keys])
92  set_values=tuple([ a for k,a in zip(header,args) if k not in keys])
93  vals=','.join(values)
94  cmd="update %s set %s where %s=?"%(tname,vals,keys[0])
95  for k in keys[1:]:
96  cmd+=' and %s=?'%k
97  self._execute(cmd, set_values+key_values)
98  self.cnx.commit()
99 

◆ addBranch()

def sim_rttUpdate.SimRttDataBase.addBranch (   self,
  branch = '17.X.0-VAL',
  refid = '17.X.0' 
)

Definition at line 258 of file sim_rttUpdate.py.

258  def addBranch(self,branch='17.X.0-VAL',refid='17.X.0'):
259  self._fillTable('t_branches',branch,refid)
260  self.cnx.commit()
261 

◆ addJob()

def sim_rttUpdate.SimRttDataBase.addJob (   self,
  testname = 'SimCoreTests',
  jobname = 'AtlasG4_muons',
  files = ['truth.root'],
  typeid = 'dcube' 
)

Definition at line 266 of file sim_rttUpdate.py.

266  def addJob(self,testname='SimCoreTests',jobname='AtlasG4_muons',
267  files=['truth.root'],typeid='dcube'):
268  for fn in files:
269  self._fillTable('t_jobs',testname,jobname,fn,typeid)
270  self.cnx.commit()
271 

◆ addTest()

def sim_rttUpdate.SimRttDataBase.addTest (   self,
  testname = 'SimCoreTests',
  path = 'Simulation/Tests' 
)

Definition at line 262 of file sim_rttUpdate.py.

262  def addTest(self,testname='SimCoreTests',path='Simulation/Tests'):
263  self._fillTable('t_tests',testname,path)
264  self.cnx.commit()
265 

◆ addUser()

def sim_rttUpdate.SimRttDataBase.addUser (   self,
  username = 'aschaeli',
  right = 'a' 
)

Definition at line 254 of file sim_rttUpdate.py.

254  def addUser(self,username='aschaeli',right='a'):
255  self._fillTable('t_user',username,right)
256  self.cnx.commit()
257 

◆ create()

def sim_rttUpdate.SimRttDataBase.create (   self)

Definition at line 107 of file sim_rttUpdate.py.

107  def create(self):
108  for t in ['t_logs','t_branches','t_alias','t_tests','t_jobs','t_joblist','t_user']:
109  self._dropTable(t)
110  self._createTable('t_logs','branch','rel','cmt','res_date','up_date')
111  #self._createTable('t_branches','branch','ref','project')
112  #'alter table t_branches rename to t_branches_old;'
113  self._execute('create table t_branches (branch text, ref text, project text, primary key (branch,project) ) ;')
114  #'insert into t_branches select * from t_branches_old;'
115  self._createTable('t_alias','alias','value')
116  self._createTable('t_tests','testname','pathpiece','project')
117  self._createTable('t_jobs','testname','job','file','type')
118  self._createTable('t_joblist','jalias','job')
119  self._createTable('t_user','login','rights')
120  self.cnx.commit()
121 

◆ defineJobAlias()

def sim_rttUpdate.SimRttDataBase.defineJobAlias (   self,
  alias = 'dcube_jobs',
  joblist = ['AtlasG4_muons','AtlasG4_electrons','AtlasG4_pions'] 
)

Definition at line 272 of file sim_rttUpdate.py.

272  def defineJobAlias(self,alias='dcube_jobs',
273  joblist=['AtlasG4_muons','AtlasG4_electrons','AtlasG4_pions']):
274  for job in joblist:
275  self._fillTable('t_joblist',alias,job)
276  self.cnx.commit()
277 
278 
279 

◆ dump()

def sim_rttUpdate.SimRttDataBase.dump (   self)

Definition at line 249 of file sim_rttUpdate.py.

249  def dump(self):
250  for t in ['t_user','t_branches','t_tests','t_jobs','t_alias','t_joblist']:
251  self._dumpTable(t)
252 
253 

◆ findJobs()

def sim_rttUpdate.SimRttDataBase.findJobs (   self,
  testname,
  jobtype 
)

Definition at line 233 of file sim_rttUpdate.py.

233  def findJobs(self,testname,jobtype):
234  cmd='select job,file from t_jobs where testname=? and type=?'
235  self._execute(cmd,(testname,jobtype))
236  res=self.cur.fetchall()
237  jobs={}
238  for r in res:
239  key=r[0]
240  fname=r[1]
241  if jobs.has_key(key):
242  jobs[key].append(fname)
243  else:
244  jobs[key]=[fname]
245 
246  return jobs
247 
248 

◆ findPackage()

def sim_rttUpdate.SimRttDataBase.findPackage (   self,
  package 
)

Definition at line 213 of file sim_rttUpdate.py.

213  def findPackage(self,package):
214  cmd='select pathpiece,project from t_tests where testname=?'
215  self._execute(cmd,(package,))
216  return self.cur.fetchone()
217 

◆ findReference()

def sim_rttUpdate.SimRttDataBase.findReference (   self,
  branch,
  project 
)

Definition at line 218 of file sim_rttUpdate.py.

218  def findReference(self,branch,project):
219  cmd='select ref from t_branches where branch=? and project=?'
220  if branch=='devval' :
221  branch='18.X.0-VAL'
222  if branch=='dev':
223  branch='18.X.0'
224  self._execute(cmd,(branch,project))
225  res=self.cur.fetchone()
226  if res is None:
227  print 'ERROR',branch,project,'not found in t_branches'
228  raise SimRttDBError
229 
230  #print res
231  return res[0]
232 

◆ getUsers()

def sim_rttUpdate.SimRttDataBase.getUsers (   self,
  right = 'a' 
)

Definition at line 208 of file sim_rttUpdate.py.

208  def getUsers(self,right='a'):
209  cmd='select login from t_user where rights=?'
210  self._execute(cmd,(right,))
211  return [res[0] for res in self.cur.fetchall()]
212 

◆ initialFill()

def sim_rttUpdate.SimRttDataBase.initialFill (   self)

Definition at line 122 of file sim_rttUpdate.py.

122  def initialFill(self):
123  # dev, devval ??!!
124  sim='simulation'
125  for br in ['17.X.0-VAL','17.X.0']:
126  self._fillTable('t_branches', br, '17.X.0',sim)
127  for br in ['17.1.X-VAL','17.1.X','17.1.X.Y-VAL','17.1.X.Y','17.2.X-VAL','17.2.X']:
128  self._fillTable('t_branches', br, '17.1.X',sim)
129  for br in ['16.6.X.Y-VAL','16.6.X.Y','16.6.X-VAL','16.6.X']:
130  self._fillTable('t_branches', br, '16.6.X',sim)
131 
132 
133  self.djobs={ 'AtlasG4_electrons' : ['truth.root'],
134  'AtlasG4_muons' : ['truth.root'],
135  'WriteCalHitsTest' : ['truth.root'],
136  'AtlasG4_pions' : ['truth.root'] }
137 
138  self.jobs={'AtlasGeom19Sim' : ['test.HITS.pool.root'],
139  'CavernBg_EVNT2TR' : ['cavbg.EVNT.pool.root'],
140  'CavernBg_TR2HITS' : ['cavbg.HITS.pool.root'],
141  'CosmicSim' : ['testCosmics.HITS.pool.root','testCosmics.TR.pool.root'],
142  'CosmicSimTR' : ['testCosmics.HITS.pool.root'],
143  'HeavyIonSim': ['test.HITS.pool.root'],
144  'TTbarSim' : ['test.HITS.pool.root'],
145  'FtfpBertTest': ['test.HITS.pool.root'],
146  'LucidSimTest': ['testLucid.HITS.pool.root'],
147  'NeutronCutTest': ['test.HITS.pool.root'],
148  'QgsBicTest': ['test.HITS.pool.root'],
149  'QgspBertChipsTest': ['test.HITS.pool.root'],
150  'SimCheckDBRel': ['test.HITS.pool.root'],
151  'ALFASimTest' : ['testALFA.HITS.pool.root'],
152  'ZDCSimTest' : ['testZDC.HITS.pool.root']}
153 
154  self.jobs0={'FrozenShowerFCalOnly': ['test.HITS.pool.root']}
155  self.jobs1={'FrozenShowerTest1': ['test.HITS.pool.root'],
156  'FrozenShowerTest2': ['test.HITS.pool.root']}
157  self.alias={} #{'FrozenShowerFCalOnly':'FrozenShowerTest1'}
158 
159  tn='SimCoreTests'
160  self._fillTable('t_tests',tn,'Simulation/Tests','simulation')
161  tn1='G4AtlasTests'
162  self._fillTable('t_tests',tn1,'Simulation/G4Atlas','simulation')
163  for dj,files in self.djobs.iteritems():
164  self._fillTable('t_joblist','dcube_jobs',dj)
165  for fn in files:
166  self._fillTable('t_jobs',tn,dj,fn,'dcube')
167  self._fillTable('t_jobs',tn1,dj,fn,'dcube')
168 
169  for j,files in self.jobs.iteritems():
170  self._fillTable('t_joblist','diffpool_jobs',j)
171  for fn in files:
172  self._fillTable('t_jobs',tn,j,fn,'diffpool')
173  self._fillTable('t_jobs',tn1,j,fn,'diffpool')
174 
175  for j,files in self.jobs0.iteritems():
176  self._fillTable('t_joblist','diffpool_jobs',j)
177  for fn in files:
178  self._fillTable('t_jobs',tn,j,fn,'diffpool')
179 
180  for j,files in self.jobs1.iteritems():
181  self._fillTable('t_joblist','diffpool_jobs',j)
182  for fn in files:
183  self._fillTable('t_jobs',tn1,j,fn,'diffpool')
184 
185  tn2='SimExoticsTests'
186  self._fillTable('t_tests',tn2,'Simulation/Tests','simulation')
187 
188  tn3='SimPerformanceTests'
189  self._fillTable('t_tests',tn3,'Simulation/Tests','simulation')
190 
191 
192  self.users=['aschaeli', 'jchapman', 'fmgaray']
193  for u in self.users:
194  self._fillTable('t_user',u,'a')
195 
196  self.cnx.commit()
197 

◆ openConnection()

def sim_rttUpdate.SimRttDataBase.openConnection (   self)

Definition at line 53 of file sim_rttUpdate.py.

53  def openConnection(self):
54  self.cnx = sqlite3.connect(self.fname)
55  self.cur = self.cnx.cursor()
56 

Member Data Documentation

◆ alias

sim_rttUpdate.SimRttDataBase.alias

Definition at line 157 of file sim_rttUpdate.py.

◆ cnx

sim_rttUpdate.SimRttDataBase.cnx

Definition at line 49 of file sim_rttUpdate.py.

◆ cur

sim_rttUpdate.SimRttDataBase.cur

Definition at line 50 of file sim_rttUpdate.py.

◆ djobs

sim_rttUpdate.SimRttDataBase.djobs

Definition at line 133 of file sim_rttUpdate.py.

◆ fname

sim_rttUpdate.SimRttDataBase.fname

Definition at line 48 of file sim_rttUpdate.py.

◆ jobs

sim_rttUpdate.SimRttDataBase.jobs

Definition at line 138 of file sim_rttUpdate.py.

◆ jobs0

sim_rttUpdate.SimRttDataBase.jobs0

Definition at line 154 of file sim_rttUpdate.py.

◆ jobs1

sim_rttUpdate.SimRttDataBase.jobs1

Definition at line 155 of file sim_rttUpdate.py.

◆ users

sim_rttUpdate.SimRttDataBase.users

Definition at line 192 of file sim_rttUpdate.py.


The documentation for this class was generated from the following file:
python.Bindings.iteritems
iteritems
Definition: Control/AthenaPython/python/Bindings.py:812
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
query_example.cursor
cursor
Definition: query_example.py:21
calibdata.commit
bool commit
Definition: calibdata.py:832
FourMomUtils::dump
std::ostream & dump(std::ostream &out, const I4MomIter iBeg, const I4MomIter iEnd)
Helper to stream out a range of I4Momentum objects.
Definition: P4Dumper.h:24