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


Python LumiDB.CommonUtil类代码示例

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


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

示例1: fieldtotal

 def fieldtotal(self,fieldname,fieldtype):
     '''
     given the input result field name and type, return the total
     '''
     fieldidx=None
     result=0
     try:
         fieldidx=self.__inputResultHeader.index(fieldname)
     except:
         print('field ',fieldname,' not found')
         raise
     for r in self.__inputResult:
         stringvalue=r[fieldidx]
         if fieldtype in ['int','unsigned int']:
             if not CommonUtil.is_intstr(stringvalue):
                 print('field ',fieldname,' is not integer type')
                 raise
             else:
                 result=int(result)+int(stringvalue)
                 continue
         elif fieldtype in ['float'] :
             if not CommonUtil.is_floatstr(stringvalue):
                 print('field ',fieldname,' is not float type')
                 raise
             else:
                 result=float(result)+float(stringvalue)
                 continue
         else:
             raise RunTimeError('cannot sum types other than int ,float')
     return result
开发者ID:Moanwar,项目名称:cmssw,代码行数:30,代码来源:inputFilesetParser.py

示例2: fieldvalues

 def fieldvalues(self,fieldname,fieldtype):
     '''
     given the input result field name and typem return the list of values
     '''
     fieldidx=None
     result=[]
     try:
         fieldidx=self.__inputResultHeader.index(fieldname)
     except:
         print('field ',fieldname,' not found')
         raise RuntimeError('field')
     for r in self.__inputResult:
         stringvalue=r[fieldidx]
         if fieldtype in ['int','unsigned int']:
             if not CommonUtil.is_intstr(stringvalue):
                 print('field ',fieldname,' is not integer type')
                 raise RuntimeError('field')
             else:
                 result.append(int(stringvalue))
                 continue
         elif fieldtype in ['float']:
             if not CommonUtil.is_floatstr(stringvalue):
                 print('field ',fieldname,' is not float type')
                 raise RuntimeError('field')
             else:
                 result.append(float(stringvalue))
                 contine
         elif  fieldtype in ['string','str']:
             result.append(stringvalue)
         else:
             raise RuntimeError('unsupported type '+fieldtype)
     return result
开发者ID:Moanwar,项目名称:cmssw,代码行数:32,代码来源:inputFilesetParser.py

示例3: insertV2

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,代码行数:28,代码来源:patchHLT.py

示例4: insertLumiDetaildata

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,代码行数:35,代码来源:analyze148829.py

示例5: hlt

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,代码行数:25,代码来源:generateDummyData.py

示例6: trg

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,代码行数:25,代码来源:generateDummyData.py

示例7: insertLumiDetaildata

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,代码行数:49,代码来源:patchinstlumi.py

示例8: _getnorm

def _getnorm(schema,norm):
    if isinstance(norm,int) or isinstance(norm,float) or CommonUtil.is_floatstr(norm) or CommonUtil.is_intstr(norm):
        return float(norm)
    if not isinstance(norm,str):
        raise ValueError('wrong parameter type')
    normdataid=dataDML.guessnormIdByName(schema,norm)
    normresult=dataDML.luminormById(schema,normdataid)
    return normresult[2]
开发者ID:mariadalfonso,项目名称:cmg-wmass-44X,代码行数:8,代码来源:lumiCalcAPI.py

示例9: toCSVLumiByLSXing

def toCSVLumiByLSXing(lumidata,scalefactor,filename):
    '''
    input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]},bxdata,beamdata]}
    output:
    fieldnames=['Run','CMSLS','Delivered(/ub)','Recorded(/ub)','BX']
    '''
    result=[]
    assert(filename)
    fieldnames=['run','ls','delivered(/ub)','recorded(/ub)','bx']
    for run in sorted(lumidata):
        rundata=lumidata[run]
        if rundata is None:
            result.append([run,'n/a','n/a','n/a','n/a'])
            continue
        for lsdata in rundata:
            cmslsnum=lsdata[1]
            if cmslsnum==0:
                continue
            deliveredlumi=lsdata[5]
            recordedlumi=lsdata[6]
            (bxidxlist,bxvaluelist,bxerrorlist)=lsdata[8]
            bxresult=[]
            if bxidxlist and bxvaluelist:
                bxinfo=CommonUtil.transposed([bxidxlist,bxvaluelist])
                bxresult=CommonUtil.flatten([run,cmslsnum,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
                result.append(bxresult)
            else:
                result.append([run,cmslsnum,deliveredlumi*scalefactor,recordedlumi*scalefactor])
    r=None
    if filename.upper()=='STDOUT':
        r=sys.stdout
        r.write(','.join(fieldnames)+'\n')
        for l in result:
            r.write(str(l)+'\n')
    else:
        r=csvReporter.csvReporter(filename)
        r.writeRow(fieldnames)
        r.writeRows(result)
开发者ID:fabozzi,项目名称:ST_44,代码行数:38,代码来源:lumiReport.py

示例10: runsWithresult

 def runsWithresult(self):
     '''
     output: [run,run,...]
     '''
     result={}
     for f in self.__inputresultfiles:
         csvReader=csv.reader(open(f),delimiter=',')
         for row in csvReader:
             field0=str(row[0]).strip()
             if not CommonUtil.is_intstr(field0):
                 continue
             runnumber=int(field0)
             if runnumber not in result:
                 result[runnumber]=None
     return result.keys()
开发者ID:Moanwar,项目名称:cmssw,代码行数:15,代码来源:inputFilesetParser.py

示例11: toCSVOverview

def toCSVOverview(lumidata,filename,resultlines,scalefactor,isverbose):
    '''
    input:
    lumidata {run:[lumilsnum,cmslsnum,timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,(bxidx,bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}
    resultlines [[resultrow1],[resultrow2],...,] existing result row
    '''
    result=[]
    fieldnames = ['Run', 'DeliveredLS', 'Delivered(/ub)','SelectedLS','Recorded(/ub)']
    r=csvReporter.csvReporter(filename)
    for rline in resultlines:
        result.append(rline)
        
    for run in lumidata.keys():
        lsdata=lumidata[run]
        if lsdata is None:
            result.append([run,'n/a','n/a','n/a','n/a'])
            continue
        nls=len(lsdata)
        deliveredData=[x[5] for x in lsdata]
        recordedData=[x[6] for x in lsdata if x[6] is not None]
        totdeliveredlumi=0.0
        totrecordedlumi=0.0
        if len(deliveredData)!=0:
            totdeliveredlumi=sum(deliveredData)
        if len(recordedData)!=0:
            totrecordedlumi=sum(recordedData)
        selectedcmsls=[x[1] for x in lsdata if x[1]!=0]
        if len(selectedcmsls)==0:
            selectedlsStr='n/a'
        else:
            selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
        result.append([run,nls,totdeliveredlumi*scalefactor,selectedlsStr,totrecordedlumi*scalefactor])
    sortedresult=sorted(result,key=lambda x : int(x[0]))
    
    r=None
    assert(filename)
    if filename.upper()=='STDOUT':
        r=sys.stdout
        r.write(','.join(fieldnames)+'\n')
        for l in sortedresult:
            r.write(str(l)+'\n')
    else:
        r=csvReporter.csvReporter(filename)
        r.writeRow(fieldnames)
        r.writeRows(sortedresult)
开发者ID:fabozzi,项目名称:ST_44,代码行数:45,代码来源:lumiReport.py

示例12: getInstLumiPerLS

def getInstLumiPerLS(dbsession,c,runList,selectionDict,beamstatus=None,beamenergy=None,beamenergyfluctuation=0.09,finecorrections=None):
    '''
    input: runList[runnum], selectionDict{runnum:[ls]}
    output:[[runnumber,lsnumber,deliveredInst,recordedInst,norbit,startorbit,runstarttime,runstoptime]]
    '''
    result=[]
    selectedRunlist=runList
    if len(selectionDict)!=0:
        selectedRunlist=[]
        allruns=runlist+selectionDict.keys()
        dups=CommonUtil.count_dups(allruns)
        for runnum,dupcount in dups:
            if dupcount==2:
                selectedRunlist.append(runnum)
    dbsession.transaction().start(True)
    for run in selectedRunlist:
        q=dbsession.nominalSchema().newQuery()
        runsummary=lumiQueryAPI.runsummaryByrun(q,run)
        del q
        runstarttime=runsummary[3]
        runstoptime=runsummary[4]
        q=dbsession.nominalSchema().newQuery()
        if finecorrections and finecorrections[run]:            
            lumiperrun=lumiQueryAPI.lumisummaryByrun(q,run,c.LUMIVERSION,beamstatus,beamenergy,beamenergyfluctuation,finecorrections=finecorrections[run])
        else:
            lumiperrun=lumiQueryAPI.lumisummaryByrun(q,run,c.LUMIVERSION,beamstatus,beamenergy,beamenergyfluctuation)
        del q
        if len(lumiperrun)==0: #no result for this run
            result.append([run,1,0.0,0.0,0,0,runstarttime,runstoptime])
        else:
            for lumiperls in lumiperrun:
                cmslsnum=lumiperls[0]
                instlumi=lumiperls[1]
                recordedlumi=0.0
                numorbit=lumiperls[2]
                startorbit=lumiperls[3]
                deadcount=0
                bitzero=0
                result.append([run,cmslsnum,instlumi,recordedlumi,numorbit,startorbit,runstarttime,runstoptime])
    dbsession.transaction().commit()
    if c.VERBOSE:
        print result
    return result              
开发者ID:fabozzi,项目名称:ST_44,代码行数:43,代码来源:lumiInstPlot.py

示例13: lumiSummary

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,代码行数:48,代码来源:generateDummyData.py

示例14: normValueById

def normValueById(schema,normid):
    '''
    select * from luminormsv2data where data_id=normid
    output:
        {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    '''
    result={}
    l=nameDealer.luminormv2dataTableName()
    paramdict={}
    qHandle=schema.newQuery()
    try:
        qHandle.addToTableList(l)
        qConditionStr='DATA_ID=:normid'
        qCondition=coral.AttributeList()
        qCondition.extend('normid','unsigned long long')
        qCondition['normid'].setData(normid)
        qResult=coral.AttributeList()
        qHandle.setCondition(qConditionStr,qCondition)
        cursor=qHandle.execute()
        while cursor.next():
            since=cursor.currentRow()['SINCE'].data()
            corrector=cursor.currentRow()['CORRECTOR'].data()
            amodetag=cursor.currentRow()['AMODETAG'].data()
            nominalegev=cursor.currentRow()['NOMINALEGEV'].data()
            comment=''
            if not cursor.currentRow()['COMMENT'].isNull():
                comment=cursor.currentRow()['COMMENT'].data()
            (correctorfunc,params)=CommonUtil.parselumicorrector(corrector)
            paramdict={}
            for param in params:
                paramvalue=0.0
                if not cursor.currentRow()[param.upper()].isNull():
                    paramvalue=cursor.currentRow()[param.upper()].data()
                    paramdict[param]=paramvalue
            result[since]=[correctorfunc,paramdict,amodetag,nominalegev,comment]
    except:
        raise
    return result
开发者ID:CMSRA2Tau,项目名称:PATConfig,代码行数:38,代码来源:normDML.py

示例15: main


#.........这里部分代码省略.........
                if args.outputfile :
                    reporter.writeRow([fill,run,lumiDict[run][0],lumiDict[run][1]])   
        #print 'input fillDict ',len(fillDict.keys()),fillDict
        m.plotSumX_Fill(xdata,ydata,fillDict,yscale='linear')
        mlog.plotSumX_Fill(xdata,ydata,fillDict,yscale='log')
    elif args.action == 'time' : 
        lumiDict={}
        lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation,finecorrections=finecorrections)
        #lumiDict=getLumiInfoForRuns(session,c,runList,selectionDict,hltpath,beamstatus='STABLE BEAMS')
        xdata={}#{run:[starttime,stoptime]}
        ydata={}
        ydata['Delivered']=[]
        ydata['Recorded']=[]
        keylist=lumiDict.keys()
        keylist.sort()
        if args.outputfile:
            reporter=csvReporter.csvReporter(ofilename)
            fieldnames=['run','starttime','stoptime','delivered','recorded']
            reporter.writeRow(fieldnames)
        for run in keylist:
            ydata['Delivered'].append(lumiDict[run][0])
            ydata['Recorded'].append(lumiDict[run][1])
            starttime=runDict[run][0]
            stoptime=runDict[run][1]
            xdata[run]=[starttime,stoptime]
            if args.outputfile :
                reporter.writeRow([run,starttime,stoptime,lumiDict[run][0],lumiDict[run][1]])
        m.plotSumX_Time(xdata,ydata,startRunTime,stopRunTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
        mlog.plotSumX_Time(xdata,ydata,startRunTime,stopRunTime,hltpath=hltpath,annotateBoundaryRunnum=args.annotateboundary,yscale='log')
    elif args.action == 'perday':
        daydict={}#{day:[[run,cmslsnum,lsstarttime,delivered,recorded]]}
        lumibyls=getLumiOrderByLS(session,c,runList,selectionDict,hltpath,beamstatus=beamstatus,beamenergy=beamenergy,beamfluctuation=beamfluctuation,finecorrections=finecorrections)
        #lumibyls [[runnumber,runstarttime,lsnum,lsstarttime,delivered,recorded,recordedinpath]]
        if args.outputfile:
            reporter=csvReporter.csvReporter(ofilename)
            fieldnames=['day','begrunls','endrunls','delivered','recorded']
            reporter.writeRow(fieldnames)
        beginfo=[lumibyls[0][3],str(lumibyls[0][0])+':'+str(lumibyls[0][2])]
        endinfo=[lumibyls[-1][3],str(lumibyls[-1][0])+':'+str(lumibyls[-1][2])]
        for perlsdata in lumibyls:
            lsstarttime=perlsdata[3]
            delivered=perlsdata[4]
            recorded=perlsdata[5]
            day=lsstarttime.toordinal()
            if not daydict.has_key(day):
                daydict[day]=[]
            daydict[day].append([delivered,recorded])
        days=daydict.keys()
        days.sort()
        daymin=days[0]
        daymax=days[-1]
        #alldays=range(daymin,daymax+1)
        resultbyday={}
        resultbyday['Delivered']=[]
        resultbyday['Recorded']=[]
        #for day in days:
        #print 'day min ',daymin
        #print 'day max ',daymax
        for day in range(daymin,daymax+1):
            if not daydict.has_key(day):
                delivered=0.0
                recorded=0.0
            else:
                daydata=daydict[day]
                mytransposed=CommonUtil.transposed(daydata,defaultval=0.0)
                delivered=sum(mytransposed[0])
                recorded=sum(mytransposed[1])
            resultbyday['Delivered'].append(delivered)
            resultbyday['Recorded'].append(recorded)
            if args.outputfile:
                reporter.writeRow([day,beginfo[1],endinfo[1],delivered,recorded])
        #print 'beginfo ',beginfo
        #print 'endinfo ',endinfo
        #print resultbyday
        m.plotPerdayX_Time( range(daymin,daymax+1) ,resultbyday,startRunTime,stopRunTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='linear')
        mlog.plotPerdayX_Time( range(daymin,daymax+1),resultbyday,startRunTime,stopRunTime,boundaryInfo=[beginfo,endinfo],annotateBoundaryRunnum=args.annotateboundary,yscale='log')
    else:
        raise Exception,'must specify the type of x-axi'

    del session
    del svc

    if args.batch and args.yscale=='linear':
        m.drawPNG(args.batch)
    elif args.batch and args.yscale=='log':
        mlog.drawPNG(args.batch)
    elif args.batch and args.yscale=='both':
        m.drawPNG(args.batch)
        basename,extension=os.path.splitext(args.batch)
        logfilename=basename+'_log'+extension        
        mlog.drawPNG(logfilename)
    else:
        if not args.interactive:
            return
        if args.interactive is True and args.yscale=='linear':
            m.drawInteractive()
        elif args.interactive is True and args.yscale=='log':
            mlog.drawInteractive()
        else:
            raise Exception('unsupported yscale for interactive mode : '+args.yscale)
开发者ID:fabozzi,项目名称:ST_44,代码行数:101,代码来源:lumiSumPlot.py


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