示例#1
0
        else:
            normid=normDML.normIdByName(session.nominalSchema(),normname)
        if not normid:
            raise RuntimeError('[ERROR] cannot resolve norm/correction')
            sys.exit(12)
        normvalueDict=normDML.normValueById(session.nominalSchema(),normid) #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    session.transaction().commit()
    lumiReport.toScreenHeader(thiscmmd,datatagname,normname,workingversion,updateversion,'PIXEL',toFile=options.headerfile)

    ##################
    # ls level       #
    ##################
    session.transaction().start(True)
    GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict,dataidmap,lumitype='PIXEL')
    if options.action == 'overview':
       result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,lumitype='PIXEL')
       lumiReport.toScreenOverview(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
    if options.action == 'lumibyls':
       if not options.hltpath:
           result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,lumitype='PIXEL',minbiasXsec=options.minbiasxsec)
           lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
       else:
           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
           result=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=False,bxAlgo=None,withBeamIntensity=False,lumitype='PIXEL')
           lumiReport.toScreenLSEffective(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile,)
示例#2
0
        normvalueDict = normDML.normValueById(
            session.nominalSchema(), normid
        )  #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}

    fig = Figure(figsize=(figureparams['sizex'], figureparams['sizey']),
                 dpi=figureparams['dpi'])
    m = matplotRender.matplotRender(fig)
    logfig = Figure(figsize=(figureparams['sizex'], figureparams['sizey']),
                    dpi=figureparams['dpi'])
    mlog = matplotRender.matplotRender(logfig)

    if not options.hltpath:
        lumibyls = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                          irunlsdict,
                                          dataidmap,
                                          runsummaryMap=GrunsummaryData,
                                          beamstatusfilter=pbeammode,
                                          normmap=normvalueDict,
                                          lumitype='HF')
    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.effectiveLumiForIds(
            session.nominalSchema(),
            irunlsdict,
                                              runsummaryMap=GrunsummaryData,
                                              beamstatusfilter=pbeammode,
                                              timeFilter=timeFilter,
                                              normmap=normvalueDict,
                                              lumitype='HF')
     lumiReport.toScreenTotDelivered(result,
                                     iresults,
                                     options.scalefactor,
                                     irunlsdict=irunlsdict,
                                     noWarning=options.nowarning,
                                     toFile=options.outputfile)
 if options.action == 'overview':
     result = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                     irunlsdict,
                                     dataidmap,
                                     runsummaryMap=GrunsummaryData,
                                     beamstatusfilter=pbeammode,
                                     timeFilter=timeFilter,
                                     normmap=normvalueDict,
                                     lumitype='HF')
     lumiReport.toScreenOverview(result,
                                 iresults,
                                 options.scalefactor,
                                 irunlsdict=irunlsdict,
                                 noWarning=options.nowarning,
                                 toFile=options.outputfile)
 if options.action == 'lumibyls':
     if not options.hltpath:
         result = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                         irunlsdict,
                                         dataidmap,
                                         runsummaryMap=GrunsummaryData,
示例#4
0
        else:
            normid=normDML.normIdByName(session.nominalSchema(),normname)
        if not normid:
            raise RuntimeError('[ERROR] cannot resolve norm/correction')
            sys.exit(12)
        normvalueDict=normDML.normValueById(session.nominalSchema(),normid) #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    session.transaction().commit()
    lumiReport.toScreenHeader(thiscmmd,datatagname,normname,workingversion,updateversion,'PIXEL',toFile=options.headerfile)

    ##################
    # ls level       #
    ##################
    session.transaction().start(True)
    GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict,dataidmap,lumitype='PIXEL')
    if options.action == 'overview':
       result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,lumitype='PIXEL')
       lumiReport.toScreenOverview(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
    if options.action == 'lumibyls':
       if not options.hltpath:
           result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,lumitype='PIXEL',minbiasXsec=options.minbiasxsec)
           lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
       else:
           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
           result=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=None,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=False,bxAlgo=None,withBeamIntensity=False,lumitype='PIXEL')
           lumiReport.toScreenLSEffective(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile,)
示例#5
0
                normname=normmap.keys()[0]
                normid=normmap[normname]
        else:
            normid=normDML.normIdByName(session.nominalSchema(),normname)
        if not normid:
            raise RuntimeError('[ERROR] cannot resolve norm/correction')
            sys.exit(-1)
        normvalueDict=normDML.normValueById(session.nominalSchema(),normid) #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}

    fig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
    m=matplotRender.matplotRender(fig)
    logfig=Figure(figsize=(figureparams['sizex'],figureparams['sizey']),dpi=figureparams['dpi'])
    mlog=matplotRender.matplotRender(logfig)

    if not options.hltpath:
        lumibyls=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,lumitype='HF')
    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.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat)
    session.transaction().commit()
    rawdata={}
    #
    # start to plot
    #
示例#6
0
        normvalueDict=normDML.normValueById(session.nominalSchema(),normid) #{since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
    session.transaction().commit()
    lumiReport.toScreenHeader(thiscmmd,datatagname,normname,workingversion,updateversion,'HF',toFile=options.headerfile)

                
    ##################
    # ls level       #
    ##################
    session.transaction().start(True)
    
    GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict,dataidmap,lumitype='HF')
    if options.action == 'delivered':
        result=lumiCalcAPI.deliveredLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF')
        lumiReport.toScreenTotDelivered(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
    if options.action == 'overview':
        result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF')
        lumiReport.toScreenOverview(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
    if options.action == 'lumibyls':
        if not options.hltpath:
            result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF',minbiasXsec=options.minbiasxsec)
            lumiReport.toScreenLumiByLS(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)            
        else:
            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
            result=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=False,bxAlgo=None,xingMinLum=options.xingMinLum,withBeamIntensity=False,lumitype='HF')
            lumiReport.toScreenLSEffective(result,iresults,options.scalefactor,irunlsdict=irunlsdict,noWarning=noWarning,toFile=options.outputfile)
示例#7
0
文件: lumidb.py 项目: dmwm/cmssh
def lumidb(run_lumi_dict, action='delivered', lumi_report=False):
    "Call lumidb to get luminosity numbers"
    actions  = ['overview', 'delivered', 'recorded', 'lumibyls', 'lumibylsXing']
    if  action not in actions:
        raise Exception('Unsupported action="%s", please check from %s' % (action, actions))
    beamModeChoices = ['stable']
    amodetagChoices = ['PROTPHYS', 'IONPHYS', 'PAPHYS' ]
    xingAlgoChoices = ['OCC1', 'OCC2', 'ET']

    #
    # parse arguments
    #  
    connect='frontier://LumiCalc/CMS_LUMI_PROD'
    authpath = None
    scalefactor = 1.0
    beamfluctuation = 0.2
    minbiasxsec = 69300.0 # minbias cross-secvtion in ub
    xingMinLum = 1e-03 # Minimum perbunch luminosity to print, default=1e-03/ub
    xingAlgo = 'OCC1'
    hltpath = None
    outputfile = None
    siteconfpath = None
    withoutNorm = False
    withoutCheckforupdate = False
    fillnum = None
    nowarning = True
    debug = False
    beamenergy = None
    amodetag = None
    reqrunmin=None
    reqfillmin=None
    reqtimemin=None
    reqrunmax=None
    reqfillmax=None
    reqtimemax=None
    timeFilter=[None,None]
    pbeammode = None
    iresults=[]
    reqTrg=False
    reqHlt=False
    svc = sessionManager.sessionManager(connect, authpath, siteconfpath, debugON=debug)
    session=svc.openSession(isReadOnly=True,
            cpp2sqltype=[('unsigned int', 'NUMBER(10)'), ('unsigned long long', 'NUMBER(20)')])

    ##############################################################
    # check run/ls list
    ##############################################################
    irunlsdict={}
    rruns=[]
    session.transaction().start(True)
    irunlsdict = run_lumi_dict
    iresults = []
    runlist=lumiCalcAPI.runList(session.nominalSchema(),
            fillnum, runmin=reqrunmin, runmax=reqrunmax,
            fillmin=reqfillmin, fillmax=reqfillmax,
            startT=reqtimemin, stopT=reqtimemax,
            l1keyPattern=None, hltkeyPattern=None,
            amodetag=amodetag, nominalEnergy=beamenergy,
            energyFlut=beamfluctuation,
            requiretrg=False, requirehlt=False)
    rruns = [val for val in runlist if val in irunlsdict.keys()]
    for selectedrun in irunlsdict.keys():#if there's further filter on the runlist,clean input dict
        if selectedrun not in rruns:
            del irunlsdict[selectedrun]
    ##############################################################
    # check datatag
    # #############################################################       
    datatagid, datatagname = revisionDML.currentDataTag(session.nominalSchema())
    dataidmap=revisionDML.dataIdsByTagId(\
            session.nominalSchema(), datatagid,
            runlist=rruns, withcomment=False)
    session.transaction().commit()
    if not dataidmap:
        print_warning('No data found in LumiDB for given set run lumi section')
        return 0, '/ub' # return lumi, units
                
    normvalueDict={}
    ##################
    # ls level       #
    ##################
    session.transaction().start(True)
    GrunsummaryData=lumiCalcAPI.runsummaryMap(session.nominalSchema(),irunlsdict)
    if  action == 'delivered':
        result=lumiCalcAPI.deliveredLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF')
        if  lumi_report:
            lumiReport.toScreenTotDelivered(result,iresults,scalefactor,irunlsdict=irunlsdict,noWarning=nowarning,toFile=outputfile)

        # result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]}
        totlumi = 0
        for run, val in result.items():
            for llist in val:
                if  irunlsdict[run]:
                    if  llist[0] in irunlsdict[run]: # select only lumis from input run ls dict
                        totlumi += llist[5]
                else:
                    totlumi += llist[5]
        totlumival, lumiunit = CommonUtil.guessUnit(totlumi)
        return totlumival, lumiunit
    if  action == 'overview':
        result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF')
        lumiReport.toScreenOverview(result,iresults,scalefactor,irunlsdict=irunlsdict,noWarning=nowarning,toFile=outputfile)
    if  action == 'lumibyls':
        if not hltpath:
            result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,lumitype='HF',minbiasXsec=minbiasxsec)
            lumiReport.toScreenLumiByLS(result,iresults,scalefactor,irunlsdict=irunlsdict,noWarning=nowarning,toFile=outputfile)            
        else:
            hltname=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
            result=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=False,bxAlgo=None,xingMinLum=xingMinLum,withBeamIntensity=False,lumitype='HF')
            lumiReport.toScreenLSEffective(result,iresults,scalefactor,irunlsdict=irunlsdict,noWarning=nowarning,toFile=outputfile)
    if  action == 'recorded':#recorded actually means effective because it needs to show all the hltpaths...
        hltname=hltpath
        hltpat=None
        if hltname is not 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
        result=lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,hltpathname=hltname,hltpathpattern=hltpat,withBXInfo=False,bxAlgo=None,xingMinLum=xingMinLum,withBeamIntensity=False,lumitype='HF')
        lumiReport.toScreenTotEffective(result,iresults,scalefactor,irunlsdict=irunlsdict,noWarning=nowarning,toFile=outputfile)
    if  action == 'lumibylsXing':
        result=lumiCalcAPI.lumiForIds(session.nominalSchema(),irunlsdict,dataidmap,runsummaryMap=GrunsummaryData,beamstatusfilter=pbeammode,timeFilter=timeFilter,normmap=normvalueDict,withBXInfo=True,bxAlgo=xingAlgo,xingMinLum=xingMinLum,withBeamIntensity=False,lumitype='HF')
        outfile=outputfile
        if  not outfile:
            print '[WARNING] no output file given. lumibylsXing writes per-bunch lumi only to default file lumibylsXing.csv'
            outfile='lumibylsXing.csv'           
        lumiReport.toCSVLumiByLSXing(result,scalefactor,outfile,irunlsdict=irunlsdict,noWarning=nowarning)
    session.transaction().commit()
    del session
    del svc 
示例#8
0
文件: lumidb.py 项目: vkuznet/cmssh
def lumidb(run_lumi_dict, action='delivered', lumi_report=False):
    "Call lumidb to get luminosity numbers"
    actions = ['overview', 'delivered', 'recorded', 'lumibyls', 'lumibylsXing']
    if action not in actions:
        raise Exception('Unsupported action="%s", please check from %s' %
                        (action, actions))
    beamModeChoices = ['stable']
    amodetagChoices = ['PROTPHYS', 'IONPHYS', 'PAPHYS']
    xingAlgoChoices = ['OCC1', 'OCC2', 'ET']

    #
    # parse arguments
    #
    connect = 'frontier://LumiCalc/CMS_LUMI_PROD'
    authpath = None
    scalefactor = 1.0
    beamfluctuation = 0.2
    minbiasxsec = 69300.0  # minbias cross-secvtion in ub
    xingMinLum = 1e-03  # Minimum perbunch luminosity to print, default=1e-03/ub
    xingAlgo = 'OCC1'
    hltpath = None
    outputfile = None
    siteconfpath = None
    withoutNorm = False
    withoutCheckforupdate = False
    fillnum = None
    nowarning = True
    debug = False
    beamenergy = None
    amodetag = None
    reqrunmin = None
    reqfillmin = None
    reqtimemin = None
    reqrunmax = None
    reqfillmax = None
    reqtimemax = None
    timeFilter = [None, None]
    pbeammode = None
    iresults = []
    reqTrg = False
    reqHlt = False
    svc = sessionManager.sessionManager(connect,
                                        authpath,
                                        siteconfpath,
                                        debugON=debug)
    session = svc.openSession(isReadOnly=True,
                              cpp2sqltype=[('unsigned int', 'NUMBER(10)'),
                                           ('unsigned long long', 'NUMBER(20)')
                                           ])

    ##############################################################
    # check run/ls list
    ##############################################################
    irunlsdict = {}
    rruns = []
    session.transaction().start(True)
    irunlsdict = run_lumi_dict
    iresults = []
    runlist = lumiCalcAPI.runList(session.nominalSchema(),
                                  fillnum,
                                  runmin=reqrunmin,
                                  runmax=reqrunmax,
                                  fillmin=reqfillmin,
                                  fillmax=reqfillmax,
                                  startT=reqtimemin,
                                  stopT=reqtimemax,
                                  l1keyPattern=None,
                                  hltkeyPattern=None,
                                  amodetag=amodetag,
                                  nominalEnergy=beamenergy,
                                  energyFlut=beamfluctuation,
                                  requiretrg=False,
                                  requirehlt=False)
    rruns = [val for val in runlist if val in irunlsdict.keys()]
    for selectedrun in irunlsdict.keys(
    ):  #if there's further filter on the runlist,clean input dict
        if selectedrun not in rruns:
            del irunlsdict[selectedrun]
    ##############################################################
    # check datatag
    # #############################################################
    datatagid, datatagname = revisionDML.currentDataTag(
        session.nominalSchema())
    dataidmap=revisionDML.dataIdsByTagId(\
            session.nominalSchema(), datatagid,
            runlist=rruns, withcomment=False)
    session.transaction().commit()
    if not dataidmap:
        print_warning('No data found in LumiDB for given set run lumi section')
        return 0, '/ub'  # return lumi, units

    normvalueDict = {}
    ##################
    # ls level       #
    ##################
    session.transaction().start(True)
    GrunsummaryData = lumiCalcAPI.runsummaryMap(session.nominalSchema(),
                                                irunlsdict)
    if action == 'delivered':
        result = lumiCalcAPI.deliveredLumiForIds(session.nominalSchema(),
                                                 irunlsdict,
                                                 dataidmap,
                                                 runsummaryMap=GrunsummaryData,
                                                 beamstatusfilter=pbeammode,
                                                 timeFilter=timeFilter,
                                                 normmap=normvalueDict,
                                                 lumitype='HF')
        if lumi_report:
            lumiReport.toScreenTotDelivered(result,
                                            iresults,
                                            scalefactor,
                                            irunlsdict=irunlsdict,
                                            noWarning=nowarning,
                                            toFile=outputfile)

        # result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]}
        totlumi = 0
        for run, val in result.items():
            for llist in val:
                if irunlsdict[run]:
                    if llist[0] in irunlsdict[
                            run]:  # select only lumis from input run ls dict
                        totlumi += llist[5]
                else:
                    totlumi += llist[5]
        totlumival, lumiunit = CommonUtil.guessUnit(totlumi)
        return totlumival, lumiunit
    if action == 'overview':
        result = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                        irunlsdict,
                                        dataidmap,
                                        runsummaryMap=GrunsummaryData,
                                        beamstatusfilter=pbeammode,
                                        timeFilter=timeFilter,
                                        normmap=normvalueDict,
                                        lumitype='HF')
        lumiReport.toScreenOverview(result,
                                    iresults,
                                    scalefactor,
                                    irunlsdict=irunlsdict,
                                    noWarning=nowarning,
                                    toFile=outputfile)
    if action == 'lumibyls':
        if not hltpath:
            result = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                            irunlsdict,
                                            dataidmap,
                                            runsummaryMap=GrunsummaryData,
                                            beamstatusfilter=pbeammode,
                                            timeFilter=timeFilter,
                                            normmap=normvalueDict,
                                            lumitype='HF',
                                            minbiasXsec=minbiasxsec)
            lumiReport.toScreenLumiByLS(result,
                                        iresults,
                                        scalefactor,
                                        irunlsdict=irunlsdict,
                                        noWarning=nowarning,
                                        toFile=outputfile)
        else:
            hltname = 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
            result = lumiCalcAPI.effectiveLumiForIds(
                session.nominalSchema(),
                irunlsdict,
                dataidmap,
                runsummaryMap=GrunsummaryData,
                beamstatusfilter=pbeammode,
                timeFilter=timeFilter,
                normmap=normvalueDict,
                hltpathname=hltname,
                hltpathpattern=hltpat,
                withBXInfo=False,
                bxAlgo=None,
                xingMinLum=xingMinLum,
                withBeamIntensity=False,
                lumitype='HF')
            lumiReport.toScreenLSEffective(result,
                                           iresults,
                                           scalefactor,
                                           irunlsdict=irunlsdict,
                                           noWarning=nowarning,
                                           toFile=outputfile)
    if action == 'recorded':  #recorded actually means effective because it needs to show all the hltpaths...
        hltname = hltpath
        hltpat = None
        if hltname is not 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
        result = lumiCalcAPI.effectiveLumiForIds(session.nominalSchema(),
                                                 irunlsdict,
                                                 dataidmap,
                                                 runsummaryMap=GrunsummaryData,
                                                 beamstatusfilter=pbeammode,
                                                 timeFilter=timeFilter,
                                                 normmap=normvalueDict,
                                                 hltpathname=hltname,
                                                 hltpathpattern=hltpat,
                                                 withBXInfo=False,
                                                 bxAlgo=None,
                                                 xingMinLum=xingMinLum,
                                                 withBeamIntensity=False,
                                                 lumitype='HF')
        lumiReport.toScreenTotEffective(result,
                                        iresults,
                                        scalefactor,
                                        irunlsdict=irunlsdict,
                                        noWarning=nowarning,
                                        toFile=outputfile)
    if action == 'lumibylsXing':
        result = lumiCalcAPI.lumiForIds(session.nominalSchema(),
                                        irunlsdict,
                                        dataidmap,
                                        runsummaryMap=GrunsummaryData,
                                        beamstatusfilter=pbeammode,
                                        timeFilter=timeFilter,
                                        normmap=normvalueDict,
                                        withBXInfo=True,
                                        bxAlgo=xingAlgo,
                                        xingMinLum=xingMinLum,
                                        withBeamIntensity=False,
                                        lumitype='HF')
        outfile = outputfile
        if not outfile:
            print '[WARNING] no output file given. lumibylsXing writes per-bunch lumi only to default file lumibylsXing.csv'
            outfile = 'lumibylsXing.csv'
        lumiReport.toCSVLumiByLSXing(result,
                                     scalefactor,
                                     outfile,
                                     irunlsdict=irunlsdict,
                                     noWarning=nowarning)
    session.transaction().commit()
    del session
    del svc