5 from RecoLuminosity.LumiDB
import argparse,dbUtil,nameDealer
8 print 'creating lumi db schema...' 9 dbsession.transaction().
start(
False)
10 schema=dbsession.nominalSchema()
14 cmsrunsummary=coral.TableDescription()
16 cmsrunsummary.insertColumn(
'RUNNUM',
'unsigned int')
17 cmsrunsummary.insertColumn(
'HLTKEY',
'string')
18 cmsrunsummary.insertColumn(
'FILLNUM',
'unsigned int')
19 cmsrunsummary.insertColumn(
'SEQUENCE',
'string')
20 cmsrunsummary.insertColumn(
'STARTTIME',
'time stamp',6)
21 cmsrunsummary.insertColumn(
'STOPTIME',
'time stamp',6)
22 cmsrunsummary.setPrimaryKey(
'RUNNUM')
23 cmsrunsummary.setNotNullConstraint(
'HLTKEY',
True)
24 cmsrunsummary.setNotNullConstraint(
'FILLNUM',
True)
25 cmsrunsummary.setNotNullConstraint(
'SEQUENCE',
True)
26 cmsrunsummary.createIndex(
'cmsrunsummary_fillnum',(
'FILLNUM'))
27 cmsrunsummary.createIndex(
'cmsrunsummary_startime',(
'STARTTIME'))
28 db.createTable(cmsrunsummary,
False)
31 summary=coral.TableDescription()
33 summary.insertColumn(
'LUMISUMMARY_ID',
'unsigned long long')
34 summary.insertColumn(
'RUNNUM',
'unsigned int')
35 summary.insertColumn(
'CMSLSNUM',
'unsigned int')
36 summary.insertColumn(
'LUMILSNUM',
'unsigned int')
37 summary.insertColumn(
'LUMIVERSION',
'string')
38 summary.insertColumn(
'DTNORM',
'float')
39 summary.insertColumn(
'LHCNORM',
'float')
40 summary.insertColumn(
'INSTLUMI',
'float')
41 summary.insertColumn(
'INSTLUMIERROR',
'float')
42 summary.insertColumn(
'INSTLUMIQUALITY',
'short')
43 summary.insertColumn(
'CMSALIVE',
'short')
44 summary.insertColumn(
'STARTORBIT',
'unsigned int')
45 summary.insertColumn(
'NUMORBIT',
'unsigned int')
46 summary.insertColumn(
'LUMISECTIONQUALITY',
'short')
47 summary.insertColumn(
'BEAMENERGY',
'float')
48 summary.insertColumn(
'BEAMSTATUS',
'string')
49 summary.insertColumn(
'CMSBXINDEXBLOB',
'blob')
50 summary.insertColumn(
'BEAMINTENSITYBLOB_1',
'blob')
51 summary.insertColumn(
'BEAMINTENSITYBLOB_2',
'blob')
53 summary.setPrimaryKey(
'LUMISUMMARY_ID')
54 summary.setNotNullConstraint(
'RUNNUM',
True)
55 summary.setNotNullConstraint(
'CMSLSNUM',
True)
56 summary.setNotNullConstraint(
'LUMILSNUM',
True)
57 summary.setNotNullConstraint(
'LUMIVERSION',
True)
58 summary.setNotNullConstraint(
'DTNORM',
True)
59 summary.setNotNullConstraint(
'LHCNORM',
True)
60 summary.setNotNullConstraint(
'INSTLUMI',
True)
61 summary.setNotNullConstraint(
'INSTLUMIERROR',
True)
62 summary.setNotNullConstraint(
'INSTLUMIQUALITY',
True)
63 summary.setNotNullConstraint(
'CMSALIVE',
True)
64 summary.setNotNullConstraint(
'STARTORBIT',
True)
65 summary.setNotNullConstraint(
'NUMORBIT',
True)
66 summary.setNotNullConstraint(
'LUMISECTIONQUALITY',
True)
67 summary.setNotNullConstraint(
'BEAMENERGY',
True)
68 summary.setNotNullConstraint(
'BEAMSTATUS',
True)
70 summary.setUniqueConstraint((
'RUNNUM',
'LUMIVERSION',
'LUMILSNUM'))
71 summary.createIndex(
'lumisummary_runnum',(
'RUNNUM'))
73 db.createTable(summary,
True)
75 detail=coral.TableDescription()
77 detail.insertColumn(
'LUMIDETAIL_ID',
'unsigned long long')
78 detail.insertColumn(
'LUMISUMMARY_ID',
'unsigned long long')
79 detail.insertColumn(
'BXLUMIVALUE',
'blob')
80 detail.insertColumn(
'BXLUMIERROR',
'blob')
81 detail.insertColumn(
'BXLUMIQUALITY',
'blob')
82 detail.insertColumn(
'ALGONAME',
'string')
83 detail.setPrimaryKey(
'LUMIDETAIL_ID')
85 detail.setNotNullConstraint(
'BXLUMIVALUE',
True)
86 detail.setNotNullConstraint(
'BXLUMIERROR',
True)
87 detail.setNotNullConstraint(
'BXLUMIQUALITY',
True)
88 detail.setNotNullConstraint(
'ALGONAME',
True)
90 detail.setUniqueConstraint((
'LUMISUMMARY_ID',
'ALGONAME'))
92 db.createTable(detail,
True)
94 trg=coral.TableDescription()
96 trg.insertColumn(
'TRG_ID',
'unsigned long long')
97 trg.insertColumn(
'RUNNUM',
'unsigned int')
98 trg.insertColumn(
'CMSLSNUM',
'unsigned int')
99 trg.insertColumn(
'BITNUM',
'unsigned int')
100 trg.insertColumn(
'BITNAME',
'string')
101 trg.insertColumn(
'TRGCOUNT',
'unsigned int')
102 trg.insertColumn(
'DEADTIME',
'unsigned long long')
103 trg.insertColumn(
'PRESCALE',
'unsigned int')
105 trg.setNotNullConstraint(
'RUNNUM',
True)
106 trg.setNotNullConstraint(
'CMSLSNUM',
True)
107 trg.setNotNullConstraint(
'BITNUM',
True)
108 trg.setNotNullConstraint(
'BITNAME',
True)
109 trg.setNotNullConstraint(
'TRGCOUNT',
True)
110 trg.setNotNullConstraint(
'DEADTIME',
True)
111 trg.setNotNullConstraint(
'PRESCALE',
True)
112 trg.setPrimaryKey(
'TRG_ID')
113 trg.createIndex(
'trg_runnum',(
'RUNNUM'))
115 db.createTable(trg,
True)
117 hlt=coral.TableDescription()
119 hlt.insertColumn(
'HLT_ID',
'unsigned long long')
120 hlt.insertColumn(
'RUNNUM',
'unsigned int')
121 hlt.insertColumn(
'CMSLSNUM',
'unsigned int')
122 hlt.insertColumn(
'PATHNAME',
'string')
123 hlt.insertColumn(
'INPUTCOUNT',
'unsigned int')
124 hlt.insertColumn(
'ACCEPTCOUNT',
'unsigned int')
125 hlt.insertColumn(
'PRESCALE',
'unsigned int')
126 hlt.setPrimaryKey(
'HLT_ID' )
127 hlt.setNotNullConstraint(
'RUNNUM',
True)
128 hlt.setNotNullConstraint(
'CMSLSNUM',
True)
129 hlt.setNotNullConstraint(
'PATHNAME',
True)
130 hlt.setNotNullConstraint(
'INPUTCOUNT',
True)
131 hlt.setNotNullConstraint(
'ACCEPTCOUNT',
True)
132 hlt.setNotNullConstraint(
'PRESCALE',
True)
133 hlt.createIndex(
'hlt_runnum',(
'RUNNUM'))
134 db.createTable(hlt,
True)
136 trghlt=coral.TableDescription()
139 trghlt.insertColumn(
'HLTKEY',
'string' )
140 trghlt.insertColumn(
'HLTPATHNAME',
'string' )
141 trghlt.insertColumn(
'L1SEED',
'string' )
142 trghlt.setNotNullConstraint(
'HLTKEY',
True)
143 trghlt.setNotNullConstraint(
'HLTPATHNAME',
True)
144 trghlt.setNotNullConstraint(
'L1SEED',
True)
145 db.createTable(trghlt,
False)
147 lumiresult=coral.TableDescription()
149 lumiresult.insertColumn(
'RUNNUM',
'unsigned int' )
150 lumiresult.insertColumn(
'LUMIVERSION',
'string' )
151 lumiresult.insertColumn(
'DELIVEREDLUMI',
'float' )
152 lumiresult.insertColumn(
'RECORDEDLUMI',
'float' )
153 db.createTable(lumiresult,
False)
155 lumihltresult=coral.TableDescription()
157 lumihltresult.insertColumn(
'RUNNUM',
'unsigned int' )
158 lumihltresult.insertColumn(
'LUMIVERSION',
'string' )
159 lumihltresult.insertColumn(
'HLTPATH',
'float' )
160 lumihltresult.insertColumn(
'RECORDEDLUMI',
'float' )
161 db.createTable(lumihltresult,
False)
164 lumivalidation=coral.TableDescription()
166 lumivalidation.insertColumn(
'RUNNUM',
'unsigned int' )
167 lumivalidation.insertColumn(
'CMSLSNUM',
'unsigned int' )
168 lumivalidation.insertColumn(
'FLAG',
'string' )
169 lumivalidation.insertColumn(
'COMMENT',
'string' )
170 lumivalidation.setPrimaryKey((
'RUNNUM',
'CMSLSNUM'))
171 lumivalidation.setNotNullConstraint(
'FLAG',
True)
173 db.createTable(lumivalidation,
False)
174 dbsession.transaction().commit()
180 dbsession.transaction().
start(
False)
181 schema=dbsession.nominalSchema()
183 lumivalidation=coral.TableDescription()
185 lumivalidation.insertColumn(
'RUNNUM',
'unsigned int' )
186 lumivalidation.insertColumn(
'CMSLSNUM',
'unsigned int' )
187 lumivalidation.insertColumn(
'FLAG',
'string' )
188 lumivalidation.insertColumn(
'COMMENT',
'string' )
189 lumivalidation.setPrimaryKey((
'RUNNUM',
'CMSLSNUM'))
190 lumivalidation.setNotNullConstraint(
'FLAG',
True)
191 db.createTable(lumivalidation,
False)
192 dbsession.transaction().commit()
195 print 'droping lumi db schema...' 196 dbsession.transaction().
start(
False)
197 schema=dbsession.nominalSchema()
208 dbsession.transaction().commit()
211 print 'lumi db schema dump...' 212 dbsession.transaction().
start(
True)
213 schema=dbsession.nominalSchema()
216 dbsession.transaction().commit()
219 dbsession.transaction().
start(
False)
220 schema=dbsession.nominalSchema()
224 dbsession.transaction().commit()
227 dbsession.transaction().
start(
False)
228 schema=dbsession.nominalSchema()
232 dbsession.transaction().commit()
237 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to lumiDB')
238 parser.add_argument(
'-P',dest=
'authpath',action=
'store',help=
'path to authentication file')
239 parser.add_argument(
'action',choices=[
'create',
'drop',
'describe',
'addindex',
'dropindex'],help=
'action on the schema')
240 parser.add_argument(
'--validationTab',dest=
'validationTab',action=
'store_true',help=
'validation table only')
241 parser.add_argument(
'--verbose',dest=
'verbose',action=
'store_true',help=
'verbose')
242 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug mode')
244 args=parser.parse_args()
245 connectstring=args.connect
247 msg=coral.MessageStream(
'')
248 msg.setMsgVerbosity(coral.message_Level_Debug)
249 svc = coral.ConnectionService()
250 if args.authpath
and len(args.authpath)!=0:
251 os.environ[
'CORAL_AUTH_PATH']=args.authpath
252 session=svc.connect(connectstring,accessMode=coral.access_Update)
253 if args.action ==
'create':
254 if args.validationTab:
258 if args.action ==
'drop':
260 if args.action ==
'describe':
262 if args.action ==
'addindex':
264 if args.action ==
'dropindex':
268 if __name__==
'__main__':
def lumidetailTableName()
def lumisummaryTableName()
def createIndex(dbsession)
def lumivalidationTableName()
def createLumi(dbsession)
def lumiresultTableName()
def cmsrunsummaryTableName()
def lumihltresultTableName()
def describeLumi(dbsession)
def createValidation(dbsession)