当前位置: 首页>>代码示例>>Python>>正文


Python CommonUtil.packArraytoBlob方法代码示例

本文整理汇总了Python中RecoLuminosity.LumiDB.CommonUtil.packArraytoBlob方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtil.packArraytoBlob方法的具体用法?Python CommonUtil.packArraytoBlob怎么用?Python CommonUtil.packArraytoBlob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecoLuminosity.LumiDB.CommonUtil的用法示例。


在下文中一共展示了CommonUtil.packArraytoBlob方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insertV2

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertV2(dbsession,runnum,inputpathnames,inputdata):
    '''
    inputpathnames: [pathname]
    inputdata: {cmslsnum:[presc,presc...]}
    '''
    branchrevision_id=DATABRANCH_ID
    try:
        pathnamesClob=','.join(inputpathnames)
        hltrundata=[pathnamesClob,'text file']
        (hltrevid,hltentryid,hltdataid)=dataDML.addHLTRunDataToBranch(dbsession.nominalSchema(),runnum,hltrundata,(branchrevision_id,'DATA'))
        hltlsdata={}
        for cmslsnum,perlsdata in inputdata.items():
            prescaleArray=array.array('I')
            hltcountArray=array.array('I')
            hltacceptArray=array.array('I')
            for presc in perlsdata:
                thiscount=0
                thisaccept=0
                prescaleArray.append(presc)
                hltcountArray.append(thiscount)
                hltacceptArray.append(thisaccept)
            prescaleblob=CommonUtil.packArraytoBlob(prescaleArray)
            hltcountblob=CommonUtil.packArraytoBlob(hltcountArray)
            hltacceptblob=CommonUtil.packArraytoBlob(hltacceptArray)
            hltlsdata[cmslsnum]=[hltcountblob,hltacceptblob,prescaleblob]
        dataDML.bulkInsertHltLSData(dbsession,runnum,hltdataid,hltlsdata,500)
    except:
        raise
开发者ID:Moanwar,项目名称:cmssw,代码行数:30,代码来源:patchHLT.py

示例2: trg

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def trg(schema,nls):
    '''
    input:
    output: [datasource,bitzeroname,bitnameclob,{cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}]
    '''
    o=['oracle://cms_orcon_prod/cms_gtmon','L1_ZeroBias']
    bitnameclob='L1_ZeroBias,False,L1_SingleHfBitCountsRing1_1,L1_SingleHfBitCountsRing2_1,L1_SingleMu15,L1SingleJet,Jura'
    o.append(bitnameclob)
    perlsdata={}
    for cmslsnum in range(1,nls+1):
        deadtime=99+cmslsnum
        bitzerocount=897865
        bitzeroprescale=17
        trgcounts=array.array('I')
        prescalecounts=array.array('I')
        for i in range(1,192):
            trgcounts.append(778899+i)
            prescalecounts.append(17)
        trgcountsBlob=CommonUtil.packArraytoBlob(trgcounts)
        prescalecountsBlob=CommonUtil.packArraytoBlob(prescalecounts)
        if not perlsdata.has_key(cmslsnum):
            perlsdata[cmslsnum]=[]
        perlsdata[cmslsnum].extend([deadtime,bitzerocount,bitzeroprescale,trgcountsBlob,prescalecountsBlob])
    o.append(perlsdata)
    return o
开发者ID:CMSRA2Tau,项目名称:PATConfig,代码行数:27,代码来源:generateDummyData.py

示例3: hlt

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def hlt(schema,nls):
    '''
    input:
    output: [datasource,pathnameclob,{cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}]
    '''
    o=['oracle://cms_orcon_prod/cms_runinfo']
    pathnameclob='HLT_PixelTracks_Multiplicity70,HLT_PixelTracks_Multiplicity85,HLT_PixelTracks_Multiplicity100,HLT_GlobalRunHPDNoise,HLT_TechTrigHCALNoise'
    o.append(pathnameclob)
    perlsdata={}
    for cmslsnum in range(1,nls+1):
        inputcounts=array.array('I')
        acceptcounts=array.array('I')
        prescalecounts=array.array('I')
        for i in range(1,201):
            inputcounts.append(6677889 )
            acceptcounts.append(3344565)
            prescalecounts.append(17)
        inputcountsBlob=CommonUtil.packArraytoBlob(inputcounts)
        acceptcountsBlob=CommonUtil.packArraytoBlob(acceptcounts)
        prescalecountsBlob=CommonUtil.packArraytoBlob(prescalecounts)
        if not perlsdata.has_key(cmslsnum):
            perlsdata[cmslsnum]=[]
        perlsdata[cmslsnum].extend([inputcountsBlob,acceptcountsBlob,prescalecountsBlob])
    o.append(perlsdata)
    return o
开发者ID:CMSRA2Tau,项目名称:PATConfig,代码行数:27,代码来源:generateDummyData.py

示例4: insertLumiDetaildata

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertLumiDetaildata(dbsession,perlsrawdata,perbunchrawdata,summaryidlsmap):               
    dataDef=[]
    dataDef.append(('LUMISUMMARY_ID','unsigned long long'))
    dataDef.append(('LUMIDETAIL_ID','unsigned long long'))
    dataDef.append(('BXLUMIVALUE','blob'))
    dataDef.append(('BXLUMIERROR','blob'))
    dataDef.append(('BXLUMIQUALITY','blob'))
    dataDef.append(('ALGONAME','string'))
    perbunchiData=[]
    dbsession.transaction().start(False)
    iddealer=idDealer.idDealer(dbsession.nominalSchema())
    db=dbUtil.dbUtil(dbsession.nominalSchema())
    print('to insert lumidetail ')
    for algoname in ['OCC1','OCC2','ET']:
        for cmslsnum,instlumi in perlsrawdata.items():
            lumisummary_id=summaryidlsmap[cmslsnum]
            lumidetail_id=iddealer.generateNextIDForTable('LUMIDETAIL')
            bxdata=array.array('f')
            bxerror=array.array('f')
            bxquality=array.array('h')
            for bxidx in range(1,3565):
                lumifraction=0.0
                if bxidx in perbunchrawdata:
                    lumifraction=perbunchrawdata[bxidx]
                bxlumivalue=float(instlumi*lumifraction)/float(bunchnorm)
                bxdata.append(bxlumivalue)
                bxerror.append(0.0)
                bxquality.append(1)
            bxdataBlob=CommonUtil.packArraytoBlob(bxdata)
            bxerrorBlob=CommonUtil.packArraytoBlob(bxerror)
            bxqualityBlob=CommonUtil.packArraytoBlob(bxquality)
            perbunchiData.append([('LUMISUMMARY_ID',lumisummary_id),('LUMIDETAIL_ID',lumidetail_id),('BXLUMIVALUE',bxdataBlob),('BXLUMIERROR',bxerrorBlob),('BXLUMIQUALITY',bxqualityBlob),('ALGONAME',algoname)])
    db.bulkInsert('LUMIDETAIL',dataDef,perbunchiData)
    dbsession.transaction().commit()
    return 
开发者ID:Moanwar,项目名称:cmssw,代码行数:37,代码来源:analyze148829.py

示例5: insertLumiDetaildata

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertLumiDetaildata(dbsession, perlsrawdata, perbunchrawdata, summaryidlsmap):
    dataDef = []
    dataDef.append(("LUMISUMMARY_ID", "unsigned long long"))
    dataDef.append(("LUMIDETAIL_ID", "unsigned long long"))
    dataDef.append(("BXLUMIVALUE", "blob"))
    dataDef.append(("BXLUMIERROR", "blob"))
    dataDef.append(("BXLUMIQUALITY", "blob"))
    dataDef.append(("ALGONAME", "string"))
    perbunchiData = []
    dbsession.transaction().start(False)
    iddealer = idDealer.idDealer(dbsession.nominalSchema())
    db = dbUtil.dbUtil(dbsession.nominalSchema())
    print "to insert lumidetail "
    for algoname in ["OCC1", "OCC2", "ET"]:
        for cmslsnum, instlumi in perlsrawdata.items():
            lumisummary_id = summaryidlsmap[cmslsnum]
            lumidetail_id = iddealer.generateNextIDForTable("LUMIDETAIL")
            print "cmslsnum ", lumidetail_id, lumisummary_id
            bxdataocc1 = array.array("f")
            bxdataocc2 = array.array("f")
            bxdataet = array.array("f")
            bxerror = array.array("f")
            bxquality = array.array("h")
            for bxidx in range(1, 3565):
                lumifraction = 0.0
                if perbunchrawdata.has_key(bxidx):
                    lumifraction = perbunchrawdata[bxidx]
                bxlumivalue = float(instlumi * lumifraction)
                bxdataocc1.append(bxlumivalue)
                bxdataocc2.append(bxlumivalue)
                bxdataet.append(bxlumivalue)
            bxdataocc1Blob = CommonUtil.packArraytoBlob(bxdataocc1)
            bxdataocc2Blob = CommonUtil.packArraytoBlob(bxdataocc2)
            bxdataetBlob = CommonUtil.packArraytoBlob(bxdataet)
            bxqualityBlob = CommonUtil.packArraytoBlob(bxquality)
            perbunchiData.append(
                [
                    ("LUMISUMMARY_ID", lumisummary_id),
                    ("LUMIDETAIL_ID", lumidetail_id),
                    ("BXLUMIVALUE", bxdataocc1Blob),
                    ("BXLUMIERROR", bxdataocc2Blob),
                    ("BXLUMIQUALITY", bxqualityBlob),
                    ("ALGONAME", algoname),
                ]
            )
    db.bulkInsert("LUMIDETAIL", dataDef, perbunchiData)
    print perbunchiData
    dbsession.transaction().commit()
    return
开发者ID:kmtos,项目名称:RecoLuminosity-LumiDB,代码行数:51,代码来源:patchinstlumi.py

示例6: lumiSummary

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def lumiSummary(schema,nlumils):
    '''
    input:
    output: [datasource,{lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensitublob_2,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}]
    '''
    o=['file:fake.root']
    perlsdata={}
    for lumilsnum in range(1,nlumils+1):
        cmslsnum=0
        if lumilsnum<100:
            cmslsnum=lumilsnum
        instlumi=2.37
        instlumierror=0.56
        instlumiquality=2
        beamstatus='STABLE BEAMS'
        beamenergy=3.5e03
        numorbit=12345
        startorbit=numorbit*lumilsnum
        if cmslsnum==0:
            cmsbxindex=None
            beam1intensity=None
            beam2intensity=None
        else:
            cmsbxindex=array.array('I')
            beam1intensity=array.array('f')
            beam2intensity=array.array('f')
            for idx in range(1,3565):
                cmsbxindex.append(idx)
                beam1intensity.append(1.5e09)
                beam2intensity.append(5.5e09)
                cmsbxindexBlob=CommonUtil.packArraytoBlob(cmsbxindex)
                beam1intensityBlob=CommonUtil.packArraytoBlob(beam1intensity)
                beam2intensityBlob=CommonUtil.packArraytoBlob(beam2intensity)
        bxlumivalue=array.array('f')
        bxlumierror=array.array('f')
        bxlumiquality=array.array('I')
        for idx in range(1,3565):
            bxlumivalue.append(2.3)
            bxlumierror.append(0.4)
            bxlumiquality.append(2)
        bxlumivalueBlob=CommonUtil.packArraytoBlob(bxlumivalue)
        bxlumierrorBlob=CommonUtil.packArraytoBlob(bxlumierror)
        bxlumiqualityBlob=CommonUtil.packArraytoBlob(bxlumiquality)
        if not perlsdata.has_key(lumilsnum):
            perlsdata[lumilsnum]=[]
        perlsdata[lumilsnum].extend([cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexBlob,beam1intensityBlob,beam2intensityBlob,bxlumivalueBlob,bxlumierrorBlob,bxlumiqualityBlob,bxlumivalueBlob,bxlumierrorBlob,bxlumiqualityBlob,bxlumivalueBlob,bxlumierrorBlob,bxlumiqualityBlob])
    o.append(perlsdata)
    return o
开发者ID:CMSRA2Tau,项目名称:PATConfig,代码行数:50,代码来源:generateDummyData.py

示例7: insertLumischemaV2

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertLumischemaV2(dbsession,runnum,datasource,perlsrawdata,perbunchrawdata):
    '''
    input:
    lumirundata[datasource]
    perlsrawdata: {cmslsnum:instlumi}
    perbunchrawdata: {bxidx:lumifraction}

    lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}
    '''
    branchrevision_id=3#databranch_id
    branchinfo=(branchrevision_id,'DATA')
    lumirundata=[datasource]
    lumilsdata={}
    for cmslsnum,instlumi in perlsrawdata.items():
        mystartorbit=startorbit+numorbit*(cmslsnum-1)
        bxdataArray=array.array('f')
        bxerrorArray=array.array('f')
        bxqualityArray=array.array('h')
        cmsbxindexArray=array.array('h')
        beam1intensityArray=array.array('f')
        beam2intensityArray=array.array('f')
        for bxidx in range(1,3565):
            lumifraction=0.0
            if bxidx in perbunchrawdata:
                lumifraction=perbunchrawdata[bxidx]
            bxlumivalue=float(instlumi*lumifraction)/float(bunchnorm)
            bxdataArray.append(bxlumivalue)
            beam1intensityArray.append(9124580336.0)
            beam1intensityArray.append(8932813306.0)
            cmsbxindexArray.append(bxidx)
            bxqualityArray.append(1)
            bxerrorArray.append(0.0)           
        bxdataocc1blob=CommonUtil.packArraytoBlob(bxdataArray)
        bxdataocc2blob=CommonUtil.packArraytoBlob(bxdataArray)
        bxdataetblob=CommonUtil.packArraytoBlob(bxdataArray)
        bxerrorocc1blob=CommonUtil.packArraytoBlob(bxerrorArray)
        bxerrorocc2blob=CommonUtil.packArraytoBlob(bxerrorArray)
        bxerroretblob=CommonUtil.packArraytoBlob(bxerrorArray)
        bxqualityocc1blob=CommonUtil.packArraytoBlob(bxqualityArray)
        bxqualityocc2blob=CommonUtil.packArraytoBlob(bxqualityArray)
        bxqualityetblob=CommonUtil.packArraytoBlob(bxqualityArray)         
        cmsbxindexblob=CommonUtil.packArraytoBlob(cmsbxindexArray)
        beam1intensityblob=CommonUtil.packArraytoBlob(beam1intensityArray)
        beam2intensityblob=CommonUtil.packArraytoBlob(beam2intensityArray)
        perlsdata=[cmslsnum,float(instlumi)/float(6370),0.0,1,'STABLE BEAMS',beamenergy,numorbit,mystartorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxdataocc1blob,bxerrorocc1blob,bxqualityocc1blob,bxdataocc2blob,bxerrorocc2blob,bxqualityocc2blob,bxdataetblob,bxerroretblob,bxqualityetblob]
        lumilsdata[cmslsnum]=perlsdata
    print(lumilsdata)
    dbsession.transaction().start(False)
    (revision_id,entry_id,data_id)=dataDML.addLumiRunDataToBranch(dbsession.nominalSchema(),runnum,lumirundata,branchinfo)
    dataDML.bulkInsertLumiLSSummary(dbsession,runnum,data_id,lumilsdata)
    dbsession.transaction().commit()
开发者ID:Moanwar,项目名称:cmssw,代码行数:53,代码来源:analyze148829.py

示例8: patchV2

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
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
开发者ID:Moanwar,项目名称:cmssw,代码行数:95,代码来源:patchHLT.py

示例9: insertLumischemaV2

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertLumischemaV2(dbsession,runnum,datasource,perlsrawdata,perbunchrawdata,bxdistribution,withDetails=False,deliveredonly=False):
    '''
    input:
    lumirundata[datasource]
    perlsrawdata: {cmslsnum:instlumi}
    perbunchrawdata: {bxidx:lumifraction}

    lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}
    '''
    branchrevision_id=3#databranch_id
    branchinfo=(branchrevision_id,'DATA')
    lumirundata=[datasource]
    lumilsdata={}
    for cmslsnum,instlumi in perlsrawdata.items():
        mystartorbit=startorbit+numorbit*(cmslsnum-1)
        bxdataocc1blob=None
        bxdataocc2blob=None
        bxdataetblob=None
        bxerrorocc1blob=None
        bxerrorocc2blob=None
        bxerroretblob=None
        bxqualityocc1blob=None
        bxqualityocc2blob=None
        bxqualityetblob=None
        cmsbxindexblob=None
        beam1intensityblob=None
        beam2intensityblob=None
        beamstatus='STABLE BEAMS'
        beamenergy=4000.
        instlumierror=0.
        instlumiquality=1
        if perbunchrawdata:
            withDetails=True
            bxdataocc1blob=perbunchrawdata[cmslsnum][0]
            bxerrorocc1blob=perbunchrawdata[cmslsnum][1]
            bxqualityocc1blob=perbunchrawdata[cmslsnum][2]
            bxdataocc2blob=perbunchrawdata[cmslsnum][3]
            bxerrorocc2blob=perbunchrawdata[cmslsnum][4]
            bxqualityocc2blob=perbunchrawdata[cmslsnum][5]
            bxdataetblob=perbunchrawdata[cmslsnum][6]
            bxerroretblob=perbunchrawdata[cmslsnum][7]
            bxqualityetblob=perbunchrawdata[cmslsnum][8]
            bxindexblob=perbunchrawdata[cmslsnum][9]
            beam1intensityblob=perbunchrawdata[cmslsnum][10]
            beam2intensityblob=perbunchrawdata[cmslsnum][11]
            beamstatus=perbunchrawdata[cmslsnum][12]
            beamenergy=perbunchrawdata[cmslsnum][13]
            instlumierror=perbunchrawdata[cmslsnum][14]
            instlumiquality=perbunchrawdata[cmslsnum][15]
        elif bxdistribution:
            withDetails=True
            bxdataArray=array.array('f')
            bxerrorArray=array.array('f')
            bxqualityArray=array.array('h')
            cmsbxindexArray=array.array('h')
            beam1intensityArray=array.array('f')
            beam2intensityArray=array.array('f')
            for bxidx in range(1,3565):
                lumifraction=0.0
                if bxidx in perbunchrawdata:
                    lumifraction=perbunchrawdata[bxidx]
                bxlumivalue=float(instlumi*lumifraction)
                bxdataArray.append(bxlumivalue)
                beam1intensityArray.append(9124580336.0)
                beam1intensityArray.append(8932813306.0)
                cmsbxindexArray.append(bxidx)
                bxqualityArray.append(1)
                bxerrorArray.append(0.0)           
            bxdataocc1blob=CommonUtil.packArraytoBlob(bxdataArray)
            bxdataocc2blob=CommonUtil.packArraytoBlob(bxdataArray)
            bxdataetblob=CommonUtil.packArraytoBlob(bxdataArray)
            bxerrorocc1blob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxerrorocc2blob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxerroretblob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxqualityocc1blob=CommonUtil.packArraytoBlob(bxqualityArray)
            bxqualityocc2blob=CommonUtil.packArraytoBlob(bxqualityArray)
            bxqualityetblob=CommonUtil.packArraytoBlob(bxqualityArray)         
            cmsbxindexblob=CommonUtil.packArraytoBlob(cmsbxindexArray)
            beam1intensityblob=CommonUtil.packArraytoBlob(beam1intensityArray)
            beam2intensityblob=CommonUtil.packArraytoBlob(beam2intensityArray)
        if deliveredonly:
            perlsdata=[0,float(instlumi),instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,mystartorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxdataocc1blob,bxerrorocc1blob,bxqualityocc1blob,bxdataocc2blob,bxerrorocc2blob,bxqualityocc2blob,bxdataetblob,bxerroretblob,bxqualityetblob]
        else:
            perlsdata=[cmslsnum,float(instlumi),instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,mystartorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxdataocc1blob,bxerrorocc1blob,bxqualityocc1blob,bxdataocc2blob,bxerrorocc2blob,bxqualityocc2blob,bxdataetblob,bxerroretblob,bxqualityetblob]
        lumilsdata[cmslsnum]=perlsdata
    #print 'toinsert from scratch',lumilsdata
    print(lumilsdata)
    dbsession.transaction().start(False)
    (revision_id,entry_id,data_id)=dataDML.addLumiRunDataToBranch(dbsession.nominalSchema(),runnum,lumirundata,branchinfo,'LUMIDATA')
    dataDML.bulkInsertLumiLSSummary(dbsession,runnum,data_id,lumilsdata,'LUMISUMMARYV2',withDetails=withDetails)
    dbsession.transaction().commit()
开发者ID:ahmad3213,项目名称:cmssw,代码行数:93,代码来源:analyzelostruns.py

示例10: generateLumidata

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def generateLumidata(lumirundatafromfile,lsdatafromfile,rundatafromdb,lsdatafromdb,replacelsMin,replacelsMax):
    '''
    input:
     perrunresultfromfile=[]#source,starttime,stoptime,nls
     perlsresultfromfile={} #{lumilsnum:instlumiub}
     lumirundatafromdb=[]   #[source,nominalegev,ncollidingbunches,starttime,stoptime,nls]
     lumilsdatafromdb={}#{lumilsnum:[cmslsnum(0),instlumi(1),instlumierror(2),instlumiquality(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),cmsbxindexblob(8),beamintensityblob_1(9),beamintensityblob_2(10),bxlumivalue_occ1(11),bxlumierror_occ1(12),bxlumiquality_occ1(13),bxlumivalue_occ2(14),bxlumierror_occ2(15),bxlumiquality_occ2(16),bxlumivalue_et(17),bxlumierror_et(18),bxlumiquality_et(19)]}


    '''
    lumip=lumiParameters.ParametersObject()
    numorbit=lumip.numorbit
    startorbit=0
    fakebeamenergy=4000.
    fakebeamstatus='STABLE BEAMS'
    fakefloatArray=array.array('f')
    fakeidxArray=array.array('h')
    fakeshortArray=array.array('h')
    for bxidx in range(1,3565):
        fakeidxArray.append(bxidx)
        fakefloatArray.append(0.)
        fakeshortArray.append(0)
    
    lumirundata=[]
    lumilsdata={}
        
    if rundatafromdb:
        lumirundata=rundatafromdb
        lumirundata[0]=rundatafromdb[0]+'+file:'+lumirundatafromfile[0]
    else:
        lu=lumiTime.lumiTime()        
        source='+file:'+lumirundatafromfile[0]
        nominalegev=fakebeamenergy
        ncollidingbunches=72
        starttime=lumirundatafromfile[1]
        stoptime=lumirundatafromfile[2]
        starttimeT=lu.timestampTodatetimeUTC(starttime)
        stoptimeT=lu.timestampTodatetimeUTC(stoptime)
        print(starttimeT.day,starttimeT.month,starttimeT.year)
        
        starttimeT_coral=coral.TimeStamp(starttimeT.year,starttimeT.month,starttimeT.day,starttimeT.hour,starttimeT.minute,starttimeT.second,0)
        stoptimeT_coral=coral.TimeStamp(stoptimeT.year,stoptimeT.month,stoptimeT.day,stoptimeT.hour,stoptimeT.minute,stoptimeT.second,0)
        nls=lumirundatafromfile[3]
        lumirundata=[source,nominalegev,ncollidingbunches,starttimeT_coral,stoptimeT_coral,nls]
        
    if lsdatafromdb: 
        lumilsdata=lsdatafromdb
        if replacelsMin>len(lsdatafromdb):
            print('[INFO]Operation: extend an existing run from LS=',replacelsMin)
            lumirundata[5]+=len(lsdatafromfile)
        else:
            print('[INFO]Operation: replace instlumi in an existing run LS range=',replacelsMin,replacelsMax)
    else:
        print('[INFO]Operation: insert a new fake run')
    for lumilsnum in range(replacelsMin,replacelsMax+1):
        instlumi=lsdatafromfile[lumilsnum]
        if lumilsnum in lsdatafromdb.keys(): #if this is a hole
            lumilsdata[lumilsnum][1]=instlumi
        else:                                #if this is an extension
            instlumierror=0.0
            instlumiquality=0
            startorbit=(lumilsnum-1)*numorbit
            cmsbxindexblob=CommonUtil.packArraytoBlob(fakeshortArray)
            beamintensityblob_1=CommonUtil.packArraytoBlob(fakefloatArray)
            beamintensityblob_2=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumivalue_occ1=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumierror_occ1=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumiquality_occ1=CommonUtil.packArraytoBlob(fakeshortArray)
            bxlumivalue_occ2=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumierror_occ2=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumiquality_occ2=CommonUtil.packArraytoBlob(fakeshortArray)
            bxlumivalue_et=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumierror_et=CommonUtil.packArraytoBlob(fakefloatArray)
            bxlumiquality_et=CommonUtil.packArraytoBlob(fakeshortArray)
            lumilsdata[lumilsnum]=[0,instlumi,instlumierror,instlumiquality,fakebeamstatus,fakebeamenergy,numorbit,startorbit,cmsbxindexblob,beamintensityblob_1,beamintensityblob_2,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]
    return (lumirundata,lumilsdata)
开发者ID:ahmad3213,项目名称:cmssw,代码行数:78,代码来源:csvLumiLoader.py

示例11: insertLumischemaV2

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import packArraytoBlob [as 别名]
def insertLumischemaV2(dbsession,runnum,datasource,perlsrawdata,perbunchrawdata,deliveredonly=False):
    '''
    input:
    lumirundata[datasource]
    perlsrawdata: {cmslsnum:instlumi}
    perbunchrawdata: {bxidx:lumifraction}

    lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}
    '''
    branchrevision_id=3#databranch_id
    branchinfo=(branchrevision_id,'DATA')
    lumirundata=[datasource]
    lumilsdata={}
    dbsession.transaction().start(True)
    oldlumidataid=dataDML.guessLumiDataIdByRun(dbsession.nominalSchema(),runnum)
    dbsession.transaction().commit()

    for cmslsnum,instlumi in perlsrawdata.items():
        mystartorbit=startorbit+numorbit*(cmslsnum-1)
        bxdataocc1blob=None
        bxdataocc2blob=None
        bxdataetblob=None
        bxerrorocc1blob=None
        bxerrorocc2blob=None
        bxerroretblob=None
        bxqualityocc1blob=None
        bxqualityocc2blob=None
        bxqualityetblob=None
        cmsbxindexblob=None
        beam1intensityblob=None
        beam2intensityblob=None
        if perbunchrawdata:
            bxdataArray=array.array('f')
            bxerrorArray=array.array('f')
            bxqualityArray=array.array('h')
            cmsbxindexArray=array.array('h')
            beam1intensityArray=array.array('f')
            beam2intensityArray=array.array('f')
            for bxidx in range(1,3565):
                lumifraction=0.0
                if perbunchrawdata.has_key(bxidx):
                    lumifraction=perbunchrawdata[bxidx]
                bxlumivalue=float(instlumi*lumifraction)/float(bunchnorm)
                bxdataArray.append(bxlumivalue)
                beam1intensityArray.append(9124580336.0)
                beam1intensityArray.append(8932813306.0)
                cmsbxindexArray.append(bxidx)
                bxqualityArray.append(1)
                bxerrorArray.append(0.0)           
            bxdataocc1blob=CommonUtil.packArraytoBlob(bxdataArray)
            bxdataocc2blob=CommonUtil.packArraytoBlob(bxdataArray)
            bxdataetblob=CommonUtil.packArraytoBlob(bxdataArray)
            bxerrorocc1blob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxerrorocc2blob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxerroretblob=CommonUtil.packArraytoBlob(bxerrorArray)
            bxqualityocc1blob=CommonUtil.packArraytoBlob(bxqualityArray)
            bxqualityocc2blob=CommonUtil.packArraytoBlob(bxqualityArray)
            bxqualityetblob=CommonUtil.packArraytoBlob(bxqualityArray)         
            cmsbxindexblob=CommonUtil.packArraytoBlob(cmsbxindexArray)
            beam1intensityblob=CommonUtil.packArraytoBlob(beam1intensityArray)
            beam2intensityblob=CommonUtil.packArraytoBlob(beam2intensityArray)
        if deliveredonly:
            perlsdata=[0,float(instlumi)/float(6370),0.0,1,'STABLE BEAMS',beamenergy,numorbit,mystartorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxdataocc1blob,bxerrorocc1blob,bxqualityocc1blob,bxdataocc2blob,bxerrorocc2blob,bxqualityocc2blob,bxdataetblob,bxerroretblob,bxqualityetblob]
        else:
            perlsdata=[cmslsnum,float(instlumi)/float(6370),0.0,1,'STABLE BEAMS',beamenergy,numorbit,mystartorbit,cmsbxindexblob,beam1intensityblob,beam2intensityblob,bxdataocc1blob,bxerrorocc1blob,bxqualityocc1blob,bxdataocc2blob,bxerrorocc2blob,bxqualityocc2blob,bxdataetblob,bxerroretblob,bxqualityetblob]
        lumilsdata[cmslsnum]=perlsdata
    print 'toinsert from scratch',lumilsdata
    
    dbsession.transaction().start(False)
    (revision_id,entry_id,data_id)=dataDML.addLumiRunDataToBranch(dbsession.nominalSchema(),runnum,lumirundata,branchinfo)
    newlumilsnumMin=min(lumilsdata.keys())
    newlumilsnumMax=max(lumilsdata.keys())
    #update id of existing to new
    #update lumisummaryv2 set DATA_ID=:data_id where DATA_ID=:oldid and lumilsnum<newlumilsnumMin or lumilsnum>newlumilsnumMax
    #lumidataid is not None  update lumilsdata set lumidataid=:newlumidataid where runnum=:run a
    inputData=coral.AttributeList()
    inputData.extend('dataid','unsigned long long')
    inputData.extend('oldid','unsigned long long')
    inputData.extend('lumilsnumMin','unsigned int')
    inputData.extend('lumilsnumMax','unsigned int')
    inputData['dataid'].setData( data_id )
    inputData['oldid'].setData( oldlumidataid )
    inputData['lumilsnumMin'].setData( newlumilsnumMin )
    inputData['lumilsnumMax'].setData( newlumilsnumMax )
    db=dbUtil.dbUtil(dbsession.nominalSchema())
    db.singleUpdate('LUMISUMMARYV2','DATA_ID=:dataid','DATA_ID=:oldid AND LUMILSNUM<:lumilsnumMin OR lumilsnum>:lumilsnumMax',inputData)
    print 'to update existing id ',oldlumidataid,' outside region ',newlumilsnumMin,' , ',newlumilsnumMax
    dataDML.bulkInsertLumiLSSummary(dbsession,runnum,data_id,lumilsdata)
    dbsession.transaction().commit()
开发者ID:fabozzi,项目名称:ST_44,代码行数:91,代码来源:analyzelostruns.py


注:本文中的RecoLuminosity.LumiDB.CommonUtil.packArraytoBlob方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。