2 from __future__
import print_function
6 from RecoLuminosity.LumiDB
import argparse,dbUtil,nameDealer
9 print(
'creating lumi db schema...')
10 dbsession.transaction().
start(
False)
11 schema=dbsession.nominalSchema()
15 cmsrunsummary=coral.TableDescription()
17 cmsrunsummary.insertColumn(
'RUNNUM',
'unsigned int')
18 cmsrunsummary.insertColumn(
'HLTKEY',
'string')
19 cmsrunsummary.insertColumn(
'FILLNUM',
'unsigned int')
20 cmsrunsummary.insertColumn(
'SEQUENCE',
'string')
21 cmsrunsummary.insertColumn(
'STARTTIME',
'time stamp',6)
22 cmsrunsummary.insertColumn(
'STOPTIME',
'time stamp',6)
23 cmsrunsummary.setPrimaryKey(
'RUNNUM')
24 cmsrunsummary.setNotNullConstraint(
'HLTKEY',
True)
25 cmsrunsummary.setNotNullConstraint(
'FILLNUM',
True)
26 cmsrunsummary.setNotNullConstraint(
'SEQUENCE',
True)
27 cmsrunsummary.createIndex(
'cmsrunsummary_fillnum',(
'FILLNUM'))
28 cmsrunsummary.createIndex(
'cmsrunsummary_startime',(
'STARTTIME'))
29 db.createTable(cmsrunsummary,
False)
32 summary=coral.TableDescription()
34 summary.insertColumn(
'LUMISUMMARY_ID',
'unsigned long long')
35 summary.insertColumn(
'RUNNUM',
'unsigned int')
36 summary.insertColumn(
'CMSLSNUM',
'unsigned int')
37 summary.insertColumn(
'LUMILSNUM',
'unsigned int')
38 summary.insertColumn(
'LUMIVERSION',
'string')
39 summary.insertColumn(
'DTNORM',
'float')
40 summary.insertColumn(
'LHCNORM',
'float')
41 summary.insertColumn(
'INSTLUMI',
'float')
42 summary.insertColumn(
'INSTLUMIERROR',
'float')
43 summary.insertColumn(
'INSTLUMIQUALITY',
'short')
44 summary.insertColumn(
'CMSALIVE',
'short')
45 summary.insertColumn(
'STARTORBIT',
'unsigned int')
46 summary.insertColumn(
'NUMORBIT',
'unsigned int')
47 summary.insertColumn(
'LUMISECTIONQUALITY',
'short')
48 summary.insertColumn(
'BEAMENERGY',
'float')
49 summary.insertColumn(
'BEAMSTATUS',
'string')
50 summary.insertColumn(
'CMSBXINDEXBLOB',
'blob')
51 summary.insertColumn(
'BEAMINTENSITYBLOB_1',
'blob')
52 summary.insertColumn(
'BEAMINTENSITYBLOB_2',
'blob')
54 summary.setPrimaryKey(
'LUMISUMMARY_ID')
55 summary.setNotNullConstraint(
'RUNNUM',
True)
56 summary.setNotNullConstraint(
'CMSLSNUM',
True)
57 summary.setNotNullConstraint(
'LUMILSNUM',
True)
58 summary.setNotNullConstraint(
'LUMIVERSION',
True)
59 summary.setNotNullConstraint(
'DTNORM',
True)
60 summary.setNotNullConstraint(
'LHCNORM',
True)
61 summary.setNotNullConstraint(
'INSTLUMI',
True)
62 summary.setNotNullConstraint(
'INSTLUMIERROR',
True)
63 summary.setNotNullConstraint(
'INSTLUMIQUALITY',
True)
64 summary.setNotNullConstraint(
'CMSALIVE',
True)
65 summary.setNotNullConstraint(
'STARTORBIT',
True)
66 summary.setNotNullConstraint(
'NUMORBIT',
True)
67 summary.setNotNullConstraint(
'LUMISECTIONQUALITY',
True)
68 summary.setNotNullConstraint(
'BEAMENERGY',
True)
69 summary.setNotNullConstraint(
'BEAMSTATUS',
True)
71 summary.setUniqueConstraint((
'RUNNUM',
'LUMIVERSION',
'LUMILSNUM'))
72 summary.createIndex(
'lumisummary_runnum',(
'RUNNUM'))
74 db.createTable(summary,
True)
76 detail=coral.TableDescription()
78 detail.insertColumn(
'LUMIDETAIL_ID',
'unsigned long long')
79 detail.insertColumn(
'LUMISUMMARY_ID',
'unsigned long long')
80 detail.insertColumn(
'BXLUMIVALUE',
'blob')
81 detail.insertColumn(
'BXLUMIERROR',
'blob')
82 detail.insertColumn(
'BXLUMIQUALITY',
'blob')
83 detail.insertColumn(
'ALGONAME',
'string')
84 detail.setPrimaryKey(
'LUMIDETAIL_ID')
86 detail.setNotNullConstraint(
'BXLUMIVALUE',
True)
87 detail.setNotNullConstraint(
'BXLUMIERROR',
True)
88 detail.setNotNullConstraint(
'BXLUMIQUALITY',
True)
89 detail.setNotNullConstraint(
'ALGONAME',
True)
91 detail.setUniqueConstraint((
'LUMISUMMARY_ID',
'ALGONAME'))
93 db.createTable(detail,
True)
95 trg=coral.TableDescription()
97 trg.insertColumn(
'TRG_ID',
'unsigned long long')
98 trg.insertColumn(
'RUNNUM',
'unsigned int')
99 trg.insertColumn(
'CMSLSNUM',
'unsigned int')
100 trg.insertColumn(
'BITNUM',
'unsigned int')
101 trg.insertColumn(
'BITNAME',
'string')
102 trg.insertColumn(
'TRGCOUNT',
'unsigned int')
103 trg.insertColumn(
'DEADTIME',
'unsigned long long')
104 trg.insertColumn(
'PRESCALE',
'unsigned int')
106 trg.setNotNullConstraint(
'RUNNUM',
True)
107 trg.setNotNullConstraint(
'CMSLSNUM',
True)
108 trg.setNotNullConstraint(
'BITNUM',
True)
109 trg.setNotNullConstraint(
'BITNAME',
True)
110 trg.setNotNullConstraint(
'TRGCOUNT',
True)
111 trg.setNotNullConstraint(
'DEADTIME',
True)
112 trg.setNotNullConstraint(
'PRESCALE',
True)
113 trg.setPrimaryKey(
'TRG_ID')
114 trg.createIndex(
'trg_runnum',(
'RUNNUM'))
116 db.createTable(trg,
True)
118 hlt=coral.TableDescription()
120 hlt.insertColumn(
'HLT_ID',
'unsigned long long')
121 hlt.insertColumn(
'RUNNUM',
'unsigned int')
122 hlt.insertColumn(
'CMSLSNUM',
'unsigned int')
123 hlt.insertColumn(
'PATHNAME',
'string')
124 hlt.insertColumn(
'INPUTCOUNT',
'unsigned int')
125 hlt.insertColumn(
'ACCEPTCOUNT',
'unsigned int')
126 hlt.insertColumn(
'PRESCALE',
'unsigned int')
127 hlt.setPrimaryKey(
'HLT_ID' )
128 hlt.setNotNullConstraint(
'RUNNUM',
True)
129 hlt.setNotNullConstraint(
'CMSLSNUM',
True)
130 hlt.setNotNullConstraint(
'PATHNAME',
True)
131 hlt.setNotNullConstraint(
'INPUTCOUNT',
True)
132 hlt.setNotNullConstraint(
'ACCEPTCOUNT',
True)
133 hlt.setNotNullConstraint(
'PRESCALE',
True)
134 hlt.createIndex(
'hlt_runnum',(
'RUNNUM'))
135 db.createTable(hlt,
True)
137 trghlt=coral.TableDescription()
140 trghlt.insertColumn(
'HLTKEY',
'string' )
141 trghlt.insertColumn(
'HLTPATHNAME',
'string' )
142 trghlt.insertColumn(
'L1SEED',
'string' )
143 trghlt.setNotNullConstraint(
'HLTKEY',
True)
144 trghlt.setNotNullConstraint(
'HLTPATHNAME',
True)
145 trghlt.setNotNullConstraint(
'L1SEED',
True)
146 db.createTable(trghlt,
False)
148 lumiresult=coral.TableDescription()
150 lumiresult.insertColumn(
'RUNNUM',
'unsigned int' )
151 lumiresult.insertColumn(
'LUMIVERSION',
'string' )
152 lumiresult.insertColumn(
'DELIVEREDLUMI',
'float' )
153 lumiresult.insertColumn(
'RECORDEDLUMI',
'float' )
154 db.createTable(lumiresult,
False)
156 lumihltresult=coral.TableDescription()
158 lumihltresult.insertColumn(
'RUNNUM',
'unsigned int' )
159 lumihltresult.insertColumn(
'LUMIVERSION',
'string' )
160 lumihltresult.insertColumn(
'HLTPATH',
'float' )
161 lumihltresult.insertColumn(
'RECORDEDLUMI',
'float' )
162 db.createTable(lumihltresult,
False)
165 lumivalidation=coral.TableDescription()
167 lumivalidation.insertColumn(
'RUNNUM',
'unsigned int' )
168 lumivalidation.insertColumn(
'CMSLSNUM',
'unsigned int' )
169 lumivalidation.insertColumn(
'FLAG',
'string' )
170 lumivalidation.insertColumn(
'COMMENT',
'string' )
171 lumivalidation.setPrimaryKey((
'RUNNUM',
'CMSLSNUM'))
172 lumivalidation.setNotNullConstraint(
'FLAG',
True)
174 db.createTable(lumivalidation,
False)
175 dbsession.transaction().commit()
181 dbsession.transaction().
start(
False)
182 schema=dbsession.nominalSchema()
184 lumivalidation=coral.TableDescription()
186 lumivalidation.insertColumn(
'RUNNUM',
'unsigned int' )
187 lumivalidation.insertColumn(
'CMSLSNUM',
'unsigned int' )
188 lumivalidation.insertColumn(
'FLAG',
'string' )
189 lumivalidation.insertColumn(
'COMMENT',
'string' )
190 lumivalidation.setPrimaryKey((
'RUNNUM',
'CMSLSNUM'))
191 lumivalidation.setNotNullConstraint(
'FLAG',
True)
192 db.createTable(lumivalidation,
False)
193 dbsession.transaction().commit()
196 print(
'droping lumi db schema...')
197 dbsession.transaction().
start(
False)
198 schema=dbsession.nominalSchema()
209 dbsession.transaction().commit()
212 print(
'lumi db schema dump...')
213 dbsession.transaction().
start(
True)
214 schema=dbsession.nominalSchema()
217 dbsession.transaction().commit()
220 dbsession.transaction().
start(
False)
221 schema=dbsession.nominalSchema()
225 dbsession.transaction().commit()
228 dbsession.transaction().
start(
False)
229 schema=dbsession.nominalSchema()
233 dbsession.transaction().commit()
236 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description=
"Lumi DB schema operations.")
238 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to lumiDB')
239 parser.add_argument(
'-P',dest=
'authpath',action=
'store',help=
'path to authentication file')
240 parser.add_argument(
'action',choices=[
'create',
'drop',
'describe',
'addindex',
'dropindex'],help=
'action on the schema')
241 parser.add_argument(
'--validationTab',dest=
'validationTab',action=
'store_true',help=
'validation table only')
242 parser.add_argument(
'--verbose',dest=
'verbose',action=
'store_true',help=
'verbose')
243 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug mode')
245 args=parser.parse_args()
246 connectstring=args.connect
248 msg=coral.MessageStream(
'')
249 msg.setMsgVerbosity(coral.message_Level_Debug)
250 svc = coral.ConnectionService()
251 if args.authpath
and len(args.authpath)!=0:
252 os.environ[
'CORAL_AUTH_PATH']=args.authpath
253 session=svc.connect(connectstring,accessMode=coral.access_Update)
254 if args.action ==
'create':
255 if args.validationTab:
259 if args.action ==
'drop':
261 if args.action ==
'describe':
263 if args.action ==
'addindex':
265 if args.action ==
'dropindex':
268 print(
'verbose mode')
269 if __name__==
'__main__':
def lumidetailTableName()
S & print(S &os, JobReport::InputFile const &f)
def lumisummaryTableName()
def createIndex(dbsession)
def lumivalidationTableName()
def createLumi(dbsession)
def lumiresultTableName()
def cmsrunsummaryTableName()
def lumihltresultTableName()
def describeLumi(dbsession)
def createValidation(dbsession)