Пример #1
0
    (runnum, lumiLSdata) = dataDML.lumiLSById(schema, lumidataid)

    lumils = sorted(lumiLSdata.keys())
    for lsnum in lumils:
        print('lumilsnum,cmslsnum,instlumi ', lsnum, lumiLSdata[lsnum][0],
              lumiLSdata[lsnum][1] * normval)

    (runnum, trgLSdata) = dataDML.trgLSById(schema, trgdataid)
    cmsls = trgLSdata.keys()
    cmsls.sort()
    for lsnum in cmsls:
        print('cmslsnum,deadtime,bizerocount,bitzeroprescale,deadfrac ', lsnum,
              trgLSdata[lsnum][0], trgLSdata[lsnum][1], trgLSdata[lsnum][2],
              trgLSdata[lsnum][3])
    [runnum, datasource, npath,
     pathnames] = dataDML.hltRunById(schema, hltdataid)
    print('npath,pathnames ', npath, pathnames)
    pathnameList = pathnames.split(',')
    (runnum, hltLSdata) = dataDML.hltLSById(schema, hltdataid)
    cmsls = hltLSdata.keys()
    cmsls.sort()
    for lsnum in cmsls:
        prescaleblob = hltLSdata[lsnum][0]
        print('lsnum ', lsnum)
        if prescaleblob:
            hltprescales = CommonUtil.unpackBlobtoArray(prescaleblob, 'h')
            for pidx, pathname in enumerate(pathnameList):
                print('pathname, hltprescales ', pathname, hltprescales[pidx])
    session.transaction().commit()
    del session
    print('')
Пример #2
0
def patchV2(dbsession,runnum,inputpathnames,inputdata):
    '''
    inputpathnames: [pathname,]
    inputdata: {cmslsnum:[presc,presc...]}
    update the most recent version of lshlt data if some ls exist
    if none old ls exists
    insert new hlt records
    '''
    try:
        dbsession.transaction().start(True)
        oldhltdataid=dataDML.guessHltDataIdByRun(dbsession.nominalSchema(),runnum)
        existingrundata=dataDML.hltRunById(dbsession.nominalSchema(),oldhltdataid)
        dbsession.transaction().commit()
        if not oldhltdataid:#no data at all
            dbsession.transaction().start(False)
            insertV2(dbsession,runnum,inputpathnames,inputdata)
            dbsession.transaction().commit()
            return
        hltnamedict=existingrundata[3]#[(pathidx,hltname),(pathidx,hltname)...]
        dbsession.transaction().start(True)
        existinglsdata=dataDML.hltLSById(dbsession.nominalSchema(),oldhltdataid)
        dbsession.transaction().commit()
        oldlsdata=existinglsdata[1]
        existinglslist=oldlsdata.keys()
        toupdate={}#{cmslsnum:[presc,presc...]}
        toinsert={}#{cmslsnum:[presc,presc...]}
        if existinglslist and len(existinglslist)!=0:#there are some existing data
            for cmslsnum,oldlscontent in oldlsdata.items():
                if cmslsnum in inputdata.keys(): # if overlap with new data, update old data with new 
                    toupdate[cmslsnum]=inputdata[cmslsnum]
        for cmslsnum,lshltcontent in inputdata.items():
            if cmslsnum in toupdate: continue #it's to update not to insert
            toinsert[cmslsnum]=inputdata[cmslsnum]
        #
        # insert into lshlt(data_id,runnum,cmslsnum,prescaleblob,hltcountblob,hltacceptblob) values()
        #
        dbsession.transaction().start(False)
        tabrowDefDict={'DATA_ID':'unsigned long long','RUNNUM':'unsigned int','CMSLSNUM':'unsigned int','PRESCALEBLOB':'blob','HLTCOUNTBLOB':'blob','HLTACCEPTBLOB':'blob'}
        for cmslsnum,perlsdata in toinsert.items():
            prescaleArray=array.array('I')
            hltcountArray=array.array('I')
            hltacceptArray=array.array('I')
            for (pathidx,hltname) in hltnamedict:
                thispathIdx=inputpathnames.index(hltname)
                thispresc=perlsdata[thispathIdx]
                thiscount=0
                thisaccept=0
                prescaleArray.append(thispresc)
                hltcountArray.append(thiscount)
                hltacceptArray.append(thisaccept)
            prescaleblob=CommonUtil.packArraytoBlob(prescaleArray)
            hltcountblob=CommonUtil.packArraytoBlob(hltcountArray)
            hltacceptblob=CommonUtil.packArraytoBlob(hltacceptArray)
            tabrowValueDict={'DATA_ID':oldhltdataid,'RUNNUM':int(runnum),'CMSLSNUM':int(cmslsnum),'PRESCALEBLOB':prescaleblob,'HLTCOUNTBLOB':hltcountblob,'HLTACCEPTBLOB':hltacceptblob}
            db=dbUtil.dbUtil(dbsession.nominalSchema())
            db.insertOneRow(nameDealer.lshltTableName(),tabrowDefDict,tabrowValueDict)
            #
            # update lshlt set prescaleblob=:prescaleblob,hltcoutblob=:hltcountblob,hltacceptblob=:hltacceptblob where data_id=:olddata_id and cmslsnum=:cmslsnum;
            #
        setClause='PRESCALEBLOB=:prescaleblob,HLTCOUNTBLOB=:hltcountblob,HLTACCEPTBLOB=:hltacceptblob'
        updateCondition='DATA_ID=:oldhltdataid and CMSLSNUM=:cmslsnum'
        for cmslsnum,perlsdata in toupdate.items():
            prescaleArray=array.array('I')
            hltcountArray=array.array('I')
            hltacceptArray=array.array('I')
            for (pathidx,hltname) in hltnamedict:
                thispathIdx=inputpathnames.index(hltname)
                thispresc=perlsdata[thispathIdx]
                thiscount=0
                thisaccept=0
                prescaleArray.append(thispresc)
                hltcountArray.append(thiscount)
                hltacceptArray.append(thisaccept)
            prescaleblob=CommonUtil.packArraytoBlob(prescaleArray)
            hltcountblob=CommonUtil.packArraytoBlob(hltcountArray)
            hltacceptblob=CommonUtil.packArraytoBlob(hltacceptArray)
            iData=coral.AttributeList()
            iData.extend('prescaleblob','blob')
            iData.extend('hltcountblob','blob')
            iData.extend('hltacceptblob','blob')
            iData.extend('olddata_id','unsigned int')
            iData.extend('cmslsnum','unsigned int')
            iData['prescaleblob'].setData(prescaleblob)
            iData['hltcountblob'].setData(hltcountblob)
            iData['hltacceptblob'].setData(hltacceptblob)
            iData['olddata_id'].setData(int(olddata_id))
            iData['cmslsnum'].setData(int(cmslsnum))
            db=dbUtil.dbUtil(schema)
            db.singleUpdate(nameDealer.lshltTableName(),setClause,updateCondition,iData)
        dbsession.transaction().commit()
        #dbsession.transaction().rollback()
    except :
        raise
Пример #3
0
def patchV2(dbsession,runnum,inputpathnames,inputdata):
    '''
    inputpathnames: [pathname,]
    inputdata: {cmslsnum:[presc,presc...]}
    update the most recent version of lshlt data if some ls exist
    if none old ls exists
    insert new hlt records
    '''
    try:
        dbsession.transaction().start(True)
        oldhltdataid=dataDML.guessHltDataIdByRun(dbsession.nominalSchema(),runnum)
        existingrundata=dataDML.hltRunById(dbsession.nominalSchema(),oldhltdataid)
        dbsession.transaction().commit()
        if not oldhltdataid:#no data at all
            dbsession.transaction().start(False)
            insertV2(dbsession,runnum,inputpathnames,inputdata)
            dbsession.transaction().commit()
            return
        hltnamedict=existingrundata[3]#[(pathidx,hltname),(pathidx,hltname)...]
        dbsession.transaction().start(True)
        existinglsdata=dataDML.hltLSById(dbsession.nominalSchema(),oldhltdataid)
        dbsession.transaction().commit()
        oldlsdata=existinglsdata[1]
        existinglslist=oldlsdata.keys()
        toupdate={}#{cmslsnum:[presc,presc...]}
        toinsert={}#{cmslsnum:[presc,presc...]}
        if existinglslist and len(existinglslist)!=0:#there are some existing data
            for cmslsnum,oldlscontent in oldlsdata.items():
                if cmslsnum in inputdata.keys(): # if overlap with new data, update old data with new 
                    toupdate[cmslsnum]=inputdata[cmslsnum]
        for cmslsnum,lshltcontent in inputdata.items():
            if cmslsnum in toupdate: continue #it's to update not to insert
            toinsert[cmslsnum]=inputdata[cmslsnum]
        #
        # insert into lshlt(data_id,runnum,cmslsnum,prescaleblob,hltcountblob,hltacceptblob) values()
        #
        dbsession.transaction().start(False)
        tabrowDefDict={'DATA_ID':'unsigned long long','RUNNUM':'unsigned int','CMSLSNUM':'unsigned int','PRESCALEBLOB':'blob','HLTCOUNTBLOB':'blob','HLTACCEPTBLOB':'blob'}
        for cmslsnum,perlsdata in toinsert.items():
            prescaleArray=array.array('I')
            hltcountArray=array.array('I')
            hltacceptArray=array.array('I')
            for (pathidx,hltname) in hltnamedict:
                thispathIdx=inputpathnames.index(hltname)
                thispresc=perlsdata[thispathIdx]
                thiscount=0
                thisaccept=0
                prescaleArray.append(thispresc)
                hltcountArray.append(thiscount)
                hltacceptArray.append(thisaccept)
            prescaleblob=CommonUtil.packArraytoBlob(prescaleArray)
            hltcountblob=CommonUtil.packArraytoBlob(hltcountArray)
            hltacceptblob=CommonUtil.packArraytoBlob(hltacceptArray)
            tabrowValueDict={'DATA_ID':oldhltdataid,'RUNNUM':int(runnum),'CMSLSNUM':int(cmslsnum),'PRESCALEBLOB':prescaleblob,'HLTCOUNTBLOB':hltcountblob,'HLTACCEPTBLOB':hltacceptblob}
            db=dbUtil.dbUtil(dbsession.nominalSchema())
            db.insertOneRow(nameDealer.lshltTableName(),tabrowDefDict,tabrowValueDict)
            #
            # update lshlt set prescaleblob=:prescaleblob,hltcoutblob=:hltcountblob,hltacceptblob=:hltacceptblob where data_id=:olddata_id and cmslsnum=:cmslsnum;
            #
        setClause='PRESCALEBLOB=:prescaleblob,HLTCOUNTBLOB=:hltcountblob,HLTACCEPTBLOB=:hltacceptblob'
        updateCondition='DATA_ID=:oldhltdataid and CMSLSNUM=:cmslsnum'
        for cmslsnum,perlsdata in toupdate.items():
            prescaleArray=array.array('I')
            hltcountArray=array.array('I')
            hltacceptArray=array.array('I')
            for (pathidx,hltname) in hltnamedict:
                thispathIdx=inputpathnames.index(hltname)
                thispresc=perlsdata[thispathIdx]
                thiscount=0
                thisaccept=0
                prescaleArray.append(thispresc)
                hltcountArray.append(thiscount)
                hltacceptArray.append(thisaccept)
            prescaleblob=CommonUtil.packArraytoBlob(prescaleArray)
            hltcountblob=CommonUtil.packArraytoBlob(hltcountArray)
            hltacceptblob=CommonUtil.packArraytoBlob(hltacceptArray)
            iData=coral.AttributeList()
            iData.extend('prescaleblob','blob')
            iData.extend('hltcountblob','blob')
            iData.extend('hltacceptblob','blob')
            iData.extend('olddata_id','unsigned int')
            iData.extend('cmslsnum','unsigned int')
            iData['prescaleblob'].setData(prescaleblob)
            iData['hltcountblob'].setData(hltcountblob)
            iData['hltacceptblob'].setData(hltacceptblob)
            iData['olddata_id'].setData(int(olddata_id))
            iData['cmslsnum'].setData(int(cmslsnum))
            db=dbUtil.dbUtil(schema)
            db.singleUpdate(nameDealer.lshltTableName(),setClause,updateCondition,iData)
        dbsession.transaction().commit()
        #dbsession.transaction().rollback()
    except :
        raise
Пример #4
0
 print 'norm in use ',normval
 (lumidataid,trgdataid,hltdataid)=dataDML.guessDataIdByRun(schema,myrun)
 print 'all dataids ',lumidataid,trgdataid,hltdataid
 (runnum,lumiLSdata)=dataDML.lumiLSById(schema,lumidataid)
 
 lumils=lumiLSdata.keys()
 lumils.sort()
 for lsnum in lumils:
     print 'lumilsnum,cmslsnum,instlumi ',lsnum,lumiLSdata[lsnum][0],lumiLSdata[lsnum][1]*normval
     
 (runnum,trgLSdata)=dataDML.trgLSById(schema,trgdataid)
 cmsls=trgLSdata.keys()
 cmsls.sort()
 for lsnum in cmsls:
     print 'cmslsnum,deadtime,bizerocount,bitzeroprescale,deadfrac ',lsnum,trgLSdata[lsnum][0],trgLSdata[lsnum][1],trgLSdata[lsnum][2],trgLSdata[lsnum][3]
 [runnum,datasource,npath,pathnames]=dataDML.hltRunById(schema,hltdataid)
 print 'npath,pathnames ',npath,pathnames
 pathnameList=pathnames.split(',')
 (runnum,hltLSdata)=dataDML.hltLSById(schema,hltdataid)
 cmsls=hltLSdata.keys()
 cmsls.sort()
 for lsnum in cmsls:
     prescaleblob=hltLSdata[lsnum][0]
     print 'lsnum ',lsnum
     if prescaleblob:
         hltprescales=CommonUtil.unpackBlobtoArray(prescaleblob,'h')
         for pidx,pathname in enumerate(pathnameList):
             print 'pathname, hltprescales ',pathname,hltprescales[pidx]
 session.transaction().commit()
 del session
 
Пример #5
0
 print 'norm in use ',normval
 (lumidataid,trgdataid,hltdataid)=dataDML.guessDataIdByRun(schema,myrun)
 print 'all dataids ',lumidataid,trgdataid,hltdataid
 (runnum,lumiLSdata)=dataDML.lumiLSById(schema,lumidataid)
 
 lumils=lumiLSdata.keys()
 lumils.sort()
 for lsnum in lumils:
     print 'lumilsnum,cmslsnum,instlumi ',lsnum,lumiLSdata[lsnum][0],lumiLSdata[lsnum][1]*normval
     
 (runnum,trgLSdata)=dataDML.trgLSById(schema,trgdataid)
 cmsls=trgLSdata.keys()
 cmsls.sort()
 for lsnum in cmsls:
     print 'cmslsnum,deadtime,bizerocount,bitzeroprescale,deadfrac ',lsnum,trgLSdata[lsnum][0],trgLSdata[lsnum][1],trgLSdata[lsnum][2],trgLSdata[lsnum][3]
 [runnum,datasource,npath,pathnames]=dataDML.hltRunById(schema,hltdataid)
 print 'npath,pathnames ',npath,pathnames
 pathnameList=pathnames.split(',')
 (runnum,hltLSdata)=dataDML.hltLSById(schema,hltdataid)
 cmsls=hltLSdata.keys()
 cmsls.sort()
 for lsnum in cmsls:
     prescaleblob=hltLSdata[lsnum][0]
     print 'lsnum ',lsnum
     if prescaleblob:
         hltprescales=CommonUtil.unpackBlobtoArray(prescaleblob,'h')
         for pidx,pathname in enumerate(pathnameList):
             print 'pathname, hltprescales ',pathname,hltprescales[pidx]
 session.transaction().commit()
 del session
 print ''