Ejemplo n.º 1
0
def recordedInvMicrobarns(json) :
    jsonALT = dict([(int(run),sum([range(begin,end+1) for begin,end in lumis],[])) for run,lumis in json.items()])

    session = sessionManager.sessionManager("frontier://LumiCalc/CMS_LUMI_PROD").openSession( cpp2sqltype = [('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
    session.transaction().start(True)
    lumidata = lumiCalcAPI.lumiForRange( session.nominalSchema(),
                                         jsonALT,
                                         norm = 1.0,
                                         finecorrections = lumiCorrections.pixelcorrectionsForRange(session.nominalSchema(),jsonALT.keys()),
                                         lumitype='PIXEL',
                                         branchName='DATA')
    return sum( sum(data[6] for data in lumis) for run,lumis in lumidata.iteritems() if lumis)
Ejemplo n.º 2
0
 finecorrections=None
 driftcorrections=None
 if not options.withoutCorrection:
     rruns=runlsfromDB.keys()
     session.transaction().start(True)
     schema=session.nominalSchema()
     if options.correctionv3:
         cterms=lumiCorrections.nonlinearV3()               
     else:#default
         cterms=lumiCorrections.nonlinearV2()
     finecorrections=lumiCorrections.correctionsForRangeV2(schema,rruns,cterms)#constant+nonlinear corrections
     driftcorrections=lumiCorrections.driftcorrectionsForRange(schema,rruns,cterms)
     session.transaction().commit()
 session.transaction().start(True)
 if not options.hltpath:
     lumibyls=lumiCalcAPI.lumiForRange(session.nominalSchema(),runlsfromDB,amodetag=options.amodetag,egev=options.beamenergy,beamstatus=pbeammode,norm=normfactor,finecorrections=finecorrections,driftcorrections=driftcorrections,usecorrectionv2=True)
 else:
     referenceLabel='Recorded'
     hltname=options.hltpath
     hltpat=None
     if hltname=='*' or hltname=='all':
         hltname=None
     elif 1 in [c in hltname for c in '*?[]']: #is a fnmatch pattern
         hltpat=hltname
         hltname=None
     lumibyls=lumiCalcAPI.effectiveLumiForRange(session.nominalSchema(),runlsfromDB,hltpathname=hltname,hltpathpattern=hltpat,amodetag=options.amodetag,egev=options.beamenergy,beamstatus=pbeammode,norm=normfactor,finecorrections=finecorrections,driftcorrections=driftcorrections,usecorrectionv2=True)
 session.transaction().commit()
 rawdata={}
 #
 # start to plot
 #
Ejemplo n.º 3
0
     print('failed to parse the input file', options.inputfile)
     raise
 if not options.withoutFineCorrection:
     rruns = inputRange.keys()
     schema = session.nominalSchema()
     session.transaction().start(True)
     finecorrections = lumiCorrections.correctionsForRange(
         schema, rruns)
     session.transaction().commit()
 session.transaction().start(True)
 schema = session.nominalSchema()
 lumiData = lumiCalcAPI.lumiForRange(schema,
                                     inputRange,
                                     beamstatus=options.beamstatus,
                                     withBXInfo=True,
                                     bxAlgo=options.algoname,
                                     xingMinLum=options.xingMinLum,
                                     withBeamIntensity=False,
                                     datatag=None,
                                     finecorrections=finecorrections)
 session.transaction().commit()
 # {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),None]}}
 ##convert lumiData to lumiDict format #{run:[[cmslsnum,avg]]}
 for runnum, perrundata in lumiData.items():
     bxlumiinfo = []
     for perlsdata in perrundata:
         cmslsnum = perlsdata[1]
         deliveredlumi = perlsdata[5]
         recordedlumi = perlsdata[6]
         bxlist = perlsdata[8]
         bxlumiinfo.append(
Ejemplo n.º 4
0
         else:
             f = open (options.inputfile, 'r')
             inputfilecontent = f.read()
             inputRange =  selectionParser.selectionParser (inputfilecontent).runsandls()
     if not inputRange:
         print('failed to parse the input file', options.inputfile)
         raise
     if not options.withoutFineCorrection:
         rruns=inputRange.keys()
         schema=session.nominalSchema()
         session.transaction().start(True)
         finecorrections=lumiCorrections.correctionsForRange(schema,rruns)
         session.transaction().commit()
     session.transaction().start(True)
     schema=session.nominalSchema()
     lumiData=lumiCalcAPI.lumiForRange(schema,inputRange,beamstatus=options.beamstatus,withBXInfo=True,bxAlgo=options.algoname,xingMinLum=options.xingMinLum,withBeamIntensity=False,datatag=None,finecorrections=finecorrections)
     session.transaction().commit()
     # {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),None]}}
 ##convert lumiData to lumiDict format #{run:[[cmslsnum,avg]]}
     for runnum,perrundata in lumiData.items():
         bxlumiinfo=[]
         for perlsdata in perrundata:
             cmslsnum=perlsdata[1]
             deliveredlumi=perlsdata[5]
             recordedlumi=perlsdata[6]
             bxlist=perlsdata[8]
             bxlumiinfo.append([cmslsnum,deliveredlumi,recordedlumi,bxlist])
             runDict.setdefault(runnum,[]).append([cmslsnum,deliveredlumi,recordedlumi,bxlist])
 #print 'runDict ',runDict
 
 import ROOT 
Ejemplo n.º 5
0
     session.transaction().start(True)
     finecorrections=lumiCorrections.pixelcorrectionsForRange(session.nominalSchema(),irunlsdict.keys())
     session.transaction().commit()
 if options.verbose:
         print 'afterglow ',finecorrections
 if options.action == 'delivered':
     session.transaction().start(True)
     result=lumiCalcAPI.deliveredLumiForRange(session.nominalSchema(),irunlsdict,amodetag=None,egev=None,beamstatus=None,norm=1.0,finecorrections=finecorrections,driftcorrections=None,usecorrectionv2=False,lumitype='PIXEL',branchName='DATA')
     session.transaction().commit()
     if not options.outputfile:
         lumiReport.toScreenTotDelivered(result,iresults,options.scalefactor,options.verbose)
     else:
         lumiReport.toCSVTotDelivered(result,options.outputfile,iresults,options.scalefactor,options.verbose)           
 if options.action == 'overview':
    session.transaction().start(True)
    result=lumiCalcAPI.lumiForRange(session.nominalSchema(),irunlsdict,amodetag=None,egev=None,beamstatus=None,norm=1.0,finecorrections=finecorrections,driftcorrections=None,usecorrectionv2=False,lumitype='PIXEL',branchName='DATA')
    session.transaction().commit()
    if not options.outputfile:
        lumiReport.toScreenOverview(result,iresults,options.scalefactor,options.verbose)
    else:
        lumiReport.toCSVOverview(result,options.outputfile,iresults,options.scalefactor,options.verbose)
 if options.action == 'lumibyls':
    if not options.hltpath:
        session.transaction().start(True)
        result=lumiCalcAPI.lumiForRange(session.nominalSchema(),irunlsdict,amodetag=None,egev=None,beamstatus=None,norm=1.0,finecorrections=finecorrections,driftcorrections=None,usecorrectionv2=False,lumitype='PIXEL',branchName='DATA')
        session.transaction().commit()
        if not options.outputfile:
            lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,options.verbose)
        else:
            lumiReport.toCSVLumiByLS(result,options.outputfile,iresults,options.scalefactor,options.verbose)
    else:
Ejemplo n.º 6
0
     if options.verbose:
         print finecorrections,driftcorrections    
     session.transaction().commit()
     
 if options.action == 'delivered':
     session.transaction().start(True)
     #print irunlsdict
     result=lumiCalcAPI.deliveredLumiForRange(session.nominalSchema(),irunlsdict,amodetag=options.amodetag,egev=options.beamenergy,beamstatus=pbeammode,norm=normfactor,finecorrections=finecorrections,driftcorrections=driftcorrections,usecorrectionv2=True)
     session.transaction().commit()
     if not options.outputfile:
         lumiReport.toScreenTotDelivered(result,iresults,options.scalefactor,options.verbose)
     else:
         lumiReport.toCSVTotDelivered(result,options.outputfile,iresults,options.scalefactor,options.verbose)           
 if options.action == 'overview':
    session.transaction().start(True)
    result=lumiCalcAPI.lumiForRange(session.nominalSchema(),irunlsdict,amodetag=options.amodetag,egev=options.beamenergy,beamstatus=pbeammode,norm=normfactor,finecorrections=finecorrections,driftcorrections=driftcorrections,usecorrectionv2=True)
    session.transaction().commit()
    if not options.outputfile:
        lumiReport.toScreenOverview(result,iresults,options.scalefactor,options.verbose)
    else:
        lumiReport.toCSVOverview(result,options.outputfile,iresults,options.scalefactor,options.verbose)
 if options.action == 'lumibyls':
    if not options.hltpath:
        session.transaction().start(True)
        result=lumiCalcAPI.lumiForRange(session.nominalSchema(),irunlsdict,amodetag=options.amodetag,egev=options.beamenergy,beamstatus=pbeammode,norm=normfactor,finecorrections=finecorrections,driftcorrections=driftcorrections,usecorrectionv2=True)
        session.transaction().commit()
        if not options.outputfile:
            lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,options.verbose)
        else:
            lumiReport.toCSVLumiByLS(result,options.outputfile,iresults,options.scalefactor,options.verbose)
    else: