2 Update the bookkeeping tables for G1 O2O. 7 from CondTools.SiStrip.o2o_db_manager
import make_dbtype, DbManager
12 from importlib
import import_module
14 from sqlalchemy.ext.declarative
import declared_attr
17 __tablename__ =
'STRIP_GAIN_O2O_PARTITION' 18 o2oid = sqlalchemy.Column(sqlalchemy.BigInteger, primary_key=
True)
19 iovstart = sqlalchemy.Column(sqlalchemy.BigInteger, nullable=
False)
20 o2otimestamp = sqlalchemy.Column(sqlalchemy.TIMESTAMP, nullable=
False)
21 subDetector = sqlalchemy.Column(sqlalchemy.String(256), primary_key=
True)
22 partitionname = sqlalchemy.Column(sqlalchemy.String(256), nullable=
False)
23 fecVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
24 fecVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
25 fedVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
26 fedVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
27 connectionVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
28 connectionVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
29 dcuInfoVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
30 dcuInfoVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
31 dcuPsuMapVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
32 dcuPsuMapVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
33 maskVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
34 maskVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
35 apvTimingVersionMajorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
36 apvTimingVersionMinorId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
False)
37 timingRunNumber = sqlalchemy.Column(sqlalchemy.BigInteger, nullable=
False)
40 __tablename__ =
'STRIP_GAIN_O2O_SKIPPED' 42 o2oid = sqlalchemy.Column(sqlalchemy.BigInteger, primary_key=
True)
43 itemid = sqlalchemy.Column(sqlalchemy.BigInteger, primary_key=
True)
45 fecCrate = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
46 fecSlot = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
47 fecRing = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
48 ccuAddr = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
49 ccuChan = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
50 lldChan = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
51 i2cAddr = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
53 fedId = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
54 feUnit = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
55 feChan = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
56 fedApv = sqlalchemy.Column(sqlalchemy.Integer, nullable=
True)
58 detid = sqlalchemy.Column(sqlalchemy.BigInteger, nullable=
True)
61 __tablename__ =
'STRIP_GAIN_O2O_WHITELISTED' 66 DbManager.__init__(self, db, authFile)
73 partitionDict = {
'PartTECM':
'TEC-',
'PartTECP':
'TEC+',
'PartTIBD':
'TIB/TID',
'PartTOB':
'TOB'}
74 o2otimestamp = datetime.datetime.utcnow()
75 for part
in partitionDict:
76 psetPart = p.SiStripConfigDb.Partitions.getParameter(part)
77 if not psetPart:
continue 81 o2otimestamp = o2otimestamp,
82 subDetector = partitionDict[part],
83 partitionname = psetPart.getParameter(
'PartitionName').
value(),
84 fecVersionMajorId = psetPart.getParameter(
'FecVersion')[0],
85 fecVersionMinorId = psetPart.getParameter(
'FecVersion')[1],
86 fedVersionMajorId = psetPart.getParameter(
'FedVersion')[0],
87 fedVersionMinorId = psetPart.getParameter(
'FedVersion')[1],
88 connectionVersionMajorId = psetPart.getParameter(
'CablingVersion')[0],
89 connectionVersionMinorId = psetPart.getParameter(
'CablingVersion')[1],
90 dcuInfoVersionMajorId = psetPart.getParameter(
'DcuDetIdsVersion')[0],
91 dcuInfoVersionMinorId = psetPart.getParameter(
'DcuDetIdsVersion')[1],
92 dcuPsuMapVersionMajorId = psetPart.getParameter(
'DcuPsuMapVersion')[0],
93 dcuPsuMapVersionMinorId = psetPart.getParameter(
'DcuPsuMapVersion')[1],
94 maskVersionMajorId = psetPart.getParameter(
'MaskVersion')[0],
95 maskVersionMinorId = psetPart.getParameter(
'MaskVersion')[1],
96 apvTimingVersionMajorId = psetPart.getParameter(
'ApvTimingVersion')[0],
97 apvTimingVersionMinorId = psetPart.getParameter(
'ApvTimingVersion')[1],
98 timingRunNumber = psetPart.getParameter(
'RunNumber').
value()
100 self.o2o_partitions.append(entry)
104 attr_name =
'SkippedDevices' 107 attr_name =
'WhitelistedDevices' 110 value =
lambda p:
None if p
is None else p.value()
111 for itemid, pset
in enumerate(getattr(p.SiStripCondObjBuilderFromDb, attr_name)):
115 fecCrate =
value(pset.getParameter(
'fecCrate')),
116 fecSlot =
value(pset.getParameter(
'fecSlot')),
117 fecRing =
value(pset.getParameter(
'fecRing')),
118 ccuAddr =
value(pset.getParameter(
'ccuAddr')),
119 ccuChan =
value(pset.getParameter(
'ccuChan')),
120 lldChan =
value(pset.getParameter(
'lldChan')),
121 i2cAddr =
value(pset.getParameter(
'i2cAddr')),
122 fedId =
value(pset.getParameter(
'fedId')),
123 feUnit =
value(pset.getParameter(
'feUnit')),
124 feChan =
value(pset.getParameter(
'feChan')),
125 fedApv =
value(pset.getParameter(
'fedApv')),
126 detid =
value(pset.getParameter(
'detid'))
128 dev_list.append(entry)
133 """Insert bookkeeping info to the tables. 135 iov (int or str): IOV number 136 cfgname (str): name of the CMSSW cfg file. 137 The cfg file need to be placed in the current directory. 141 sys.path.append(os.getcwd())
142 if cfgname.endswith(
'.py'):
143 cfgname = cfgname.replace(
'.py',
'')
144 cfg = import_module(cfgname)
149 destSession = self.connect()
150 o2oid = destSession.query(self.GainO2OPartition.o2oid).order_by(self.GainO2OPartition.o2oid.desc()).
first()
158 destSession.add(entry)
161 for entry
in o2o_skipped:
162 destSession.add(entry)
165 for entry
in o2o_whitelisted:
166 destSession.add(entry)
169 logging.info(
'Inserted Gain O2O info to DB!')
172 if __name__ ==
'__main__':
175 dbmgr.update_gain_logs(1,
'test')
def __init__(self, db, authFile=None)
def _readPartitions(self, p)
def update_gain_logs(self, iov, cfgname)
def make_dbtype(backendName, schemaName, baseType)
def _readSkippedDevices(self, p, whitelist=False)
GainO2OWhitelistedDevices