Exemplo n.º 1
0
def runsummaryMap(schema,irunlsdict,dataidmap,lumitype='HF'):
    '''
    output: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
    '''
    result={}
    seqresult=runsummary(schema,irunlsdict)
    idresult=dataDML.lumiRunByIds(schema,dataidmap,lumitype)
    for [run,l1key,amodetag,hltkey,fillnum,fillscheme] in seqresult:
        egev=idresult[run][2]
        startT=idresult[run][3]
        stopT=idresult[run][4]
        result[run]=[l1key,amodetag,egev,hltkey,fillnum,fillscheme,startT,stopT]
    return result
Exemplo n.º 2
0
 inputfilename=os.path.abspath(options.inputfile)
 parseresult=parseInputFile(inputfilename,options.singlerun)
 runlist=parseresult.keys()
 irunlsdict={}
 for run in runlist:
     irunlsdict[run]=None
 session.transaction().start(True)
 (pixellumibranchid,pixellumibranchparent)=revisionDML.branchInfoByName(session.nominalSchema(),'DATA')
 print 'pixellumibranchid ',pixellumibranchid,' pixellumibranchparent ',pixellumibranchparent
 pixellumibranchinfo=(pixellumibranchid,'DATA')
 (pixel_tagid,pixel_tagname)=revisionDML.currentDataTag(session.nominalSchema(),lumitype='PIXEL')
 (hf_tagid,hf_tagname)=revisionDML.currentDataTag(session.nominalSchema(),lumitype='HF')    
 hfdataidmap=revisionDML.dataIdsByTagId(session.nominalSchema(),hf_tagid,runlist,withcomment=False,lumitype='HF')
 beamstatusdata=dataDML.beamstatusByIds(session.nominalSchema(),hfdataidmap)
 #print 'beamstatusdata ',beamstatusdata
 lumirundata=dataDML.lumiRunByIds(session.nominalSchema(),hfdataidmap,lumitype='HF')#{runnum: (nominalegev(0),ncollidingbunches(1),starttime(2),stoptime(3),nls(4)}
 session.transaction().commit()
 #print 'lumirundata ', lumirundata
 alllumirundata=generateLumiRundata(inputfilename,lumirundata,runlist)
 alllumilsdata={}
 for runnum,perrundata in parseresult.items():
     pixellumidataid=0
     session.transaction().start(False)
     #session.transaction().start(True)
     hfdataidinfo=hfdataidmap[runnum]
     hflumidataid=hfdataidinfo[0]
     trgdataid=hfdataidinfo[1]
     hltdataid=hfdataidinfo[2]
     beamsta={}
     if runnum in beamstatusdata:
         beamsta=beamstatusdata[runnum]
Exemplo n.º 3
0
 (pixel_tagid,
  pixel_tagname) = revisionDML.currentDataTag(session.nominalSchema(),
                                              lumitype='PIXEL')
 (hf_tagid,
  hf_tagname) = revisionDML.currentDataTag(session.nominalSchema(),
                                           lumitype='HF')
 hfdataidmap = revisionDML.dataIdsByTagId(session.nominalSchema(),
                                          hf_tagid,
                                          runlist,
                                          withcomment=False,
                                          lumitype='HF')
 beamstatusdata = dataDML.beamstatusByIds(session.nominalSchema(),
                                          hfdataidmap)
 #print 'beamstatusdata ',beamstatusdata
 lumirundata = dataDML.lumiRunByIds(
     session.nominalSchema(), hfdataidmap, lumitype='HF'
 )  #{runnum: (nominalegev(0),ncollidingbunches(1),starttime(2),stoptime(3),nls(4)}
 session.transaction().commit()
 #print 'lumirundata ', lumirundata
 alllumirundata = generateLumiRundata(inputfilename, lumirundata, runlist)
 alllumilsdata = {}
 for runnum, perrundata in parseresult.items():
     pixellumidataid = 0
     session.transaction().start(False)
     #session.transaction().start(True)
     hfdataidinfo = hfdataidmap[runnum]
     hflumidataid = hfdataidinfo[0]
     trgdataid = hfdataidinfo[1]
     hltdataid = hfdataidinfo[2]
     beamsta = {}
     if beamstatusdata.has_key(runnum):
Exemplo n.º 4
0
def deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=None,timeFilter=None,normmap=None,withBXInfo=False,bxAlgo=None,xingMinLum=None,withBeamIntensity=False,lumitype='HF',minbiasXsec=None):
    '''
    delivered lumi (including calibration,time integral)
    input:
       irunlsdict:  {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls
       dataidmap : {run:(lumiid,trgid,hltid)}
       runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
       beamstatus: LS filter on beamstatus 
       normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction
       withBXInfo: get per bunch info (optional)
       bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
       xingMinLum: cut on bx lumi value (optional)
       withBeamIntensity: get beam intensity info (optional)
       lumitype: luminosity source
    output:
       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)]}
       
       special meanings:
       {run:None}  None means no run in lumiDB, 
       {run:[]} [] means no lumi for this run in lumiDB
       {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected 
       lumi unit: /ub
    '''
    result = {}
    lumip=lumiParameters.ParametersObject()
    lumirundata=dataDML.lumiRunByIds(schema,dataidmap,lumitype=lumitype)
    instresult=instLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,withBXInfo=withBXInfo,bxAlgo=bxAlgo,withBeamIntensity=withBeamIntensity,lumitype=lumitype)
    
    intglumimap={}
    if lumitype=='HF':
        intglumimap=dataDML.intglumiForRange(schema,irunlsdict.keys())#some runs need drift correction
    allsince=[]
    if normmap:
        allsince=normmap.keys()
        allsince.sort()        
    correctorname='fPoly' #HF default
    correctionparams={'a0':1.0}
    runfillschemeMap={}
    fillschemePatternMap={}
    if lumitype=='PIXEL':
        correctorname='fPolyScheme' #PIXEL default
        fillschemePatternMap=dataDML.fillschemePatternMap(schema,'PIXEL')
    for run,perrundata in instresult.items():
        if perrundata is None:
            result[run]=None
            continue
        intglumi=0.
        if normmap and intglumimap and run in intglumimap and intglumimap[run]:
            intglumi=intglumimap[run]
        nBXs=0
        if normmap and lumirundata and run in lumirundata and lumirundata[run][2]:
            nBXs=lumirundata[run][2]
        fillschemeStr=''
        if normmap and runsummaryMap and run in runsummaryMap and runsummaryMap[run][5]:
            fillschemeStr=runsummaryMap[run][5]
        if allsince:
            lastsince=allsince[0]
            for since in allsince:
                if run>=since:
                    lastsince=since
            correctorname=normmap[lastsince][0]
            correctionparams=normmap[lastsince][1]
            
        correctioninput=[0.,intglumi,nBXs,fillschemeStr,fillschemePatternMap]
        result[run]=[]
        for perlsdata in perrundata:#loop over ls
            lumilsnum=perlsdata[0]
            cmslsnum=perlsdata[1]
            timestamp=perlsdata[2]
            bs=perlsdata[3]
            beamenergy=perlsdata[4]
            instluminonorm=perlsdata[5]
            correctioninput[0]=instluminonorm
            totcorrectionFac=normFunctors.normFunctionCaller(correctorname,*correctioninput,**correctionparams)
            fillnum=perlsdata[11]
            instcorrectedlumi=totcorrectionFac*instluminonorm
            numorbit=perlsdata[8]
            numbx=lumip.NBX
            lslen=lumip.lslengthsec()
            deliveredlumi=instcorrectedlumi*lslen
            calibratedbxdata=None
            beamdata=None
            pu=0.#avgPU
            if nBXs and minbiasXsec:
                pu=(instcorrectedlumi/nBXs)*minbiasXsec/lumip.rotationRate                
            if withBXInfo:                
                (bxidxData,bxvaluesData,bxerrsData)=perlsdata[9]
                if lumitype=='HF':
                    if xingMinLum:
                        bxidxList=[]
                        bxvalueList=[]
                        bxerrList=[]
                        for idx,bxval in enumerate(bxvaluesData):
                            correctedbxintlumi=totcorrectionFac*bxval
                            correctedbxintlumierr=totcorrectionFac*bxerrsData[idx]
                            if correctedbxintlumi>xingMinLum:
                                bxidxList.append(bxidxData[idx])
                                bxvalueList.append(correctedbxintlumi)
                                bxerrList.append(correctedbxintlumierr)
                        calibratedbxdata=(bxidxList,bxvalueList,bxerrList)
                    else:
                        calibratedbxvalue=[totcorrectionFac*x for x in bxvaluesData]
                        calibratedlumierr=[totcorrectionFac*x for x in bxerrsData]
                        calibratedbxdata=(bxidxData,calibratedbxvalue,calibratedlumierr)
            if withBeamIntensity:
                beamdata=perlsdata[10]
            calibratedlumierr=0.0
            result[run].append([lumilsnum,cmslsnum,timestamp,bs,beamenergy,deliveredlumi,calibratedlumierr,calibratedbxdata,beamdata,fillnum,pu])
            del perlsdata[:]
    return result
Exemplo n.º 5
0
 inputfilename=os.path.abspath(options.inputfile)
 parseresult=parseInputFile(inputfilename,options.singlerun)
 runlist=parseresult.keys()
 irunlsdict={}
 for run in runlist:
     irunlsdict[run]=None
 session.transaction().start(True)
 (pixellumibranchid,pixellumibranchparent)=revisionDML.branchInfoByName(session.nominalSchema(),'DATA')
 print 'pixellumibranchid ',pixellumibranchid,' pixellumibranchparent ',pixellumibranchparent
 pixellumibranchinfo=(pixellumibranchid,'DATA')
 (pixel_tagid,pixel_tagname)=revisionDML.currentDataTag(session.nominalSchema(),lumitype='PIXEL')
 (hf_tagid,hf_tagname)=revisionDML.currentDataTag(session.nominalSchema(),lumitype='HF')    
 hfdataidmap=revisionDML.dataIdsByTagId(session.nominalSchema(),hf_tagid,runlist,withcomment=False,lumitype='HF')
 beamstatusdata=dataDML.beamstatusByIds(session.nominalSchema(),hfdataidmap)
 #print 'beamstatusdata ',beamstatusdata
 lumirundata=dataDML.lumiRunByIds(session.nominalSchema(),hfdataidmap,lumitype='HF')
 #{runnum: (datasource(1),nominalegev(2),ncollidingbunches(3)}
 session.transaction().commit()
 alllumirundata=generateLumiRundata(inputfilename,lumirundata,runlist)
 alllumilsdata={}
 for runnum,perrundata in parseresult.items():
     pixellumidataid=0
     session.transaction().start(False)
     #session.transaction().start(True)
     hfdataidinfo=hfdataidmap[runnum]
     hflumidataid=hfdataidinfo[0]
     trgdataid=hfdataidinfo[1]
     hltdataid=hfdataidinfo[2]
     beamsta={}
     if beamstatusdata.has_key(runnum):
         beamsta=beamstatusdata[runnum]
Exemplo n.º 6
0
     session.nominalSchema(), 'DATA')
 print 'pixellumibranchid ', pixellumibranchid, ' pixellumibranchparent ', pixellumibranchparent
 pixellumibranchinfo = (pixellumibranchid, 'DATA')
 (pixel_tagid,
  pixel_tagname) = revisionDML.currentDataTag(session.nominalSchema(),
                                              lumitype='PIXEL')
 (hf_tagid,
  hf_tagname) = revisionDML.currentDataTag(session.nominalSchema(),
                                           lumitype='HF')
 hfdataidmap = revisionDML.dataIdsByTagId(session.nominalSchema(),
                                          hf_tagid,
                                          runlist,
                                          withcomment=False,
                                          lumitype='HF')
 lumirundata = dataDML.lumiRunByIds(session.nominalSchema(),
                                    hfdataidmap,
                                    lumitype='HF')
 #{runnum: (datasource(1),nominalegev(2),ncollidingbunches(3)}
 session.transaction().commit()
 alllumirundata = generateLumiRundata(inputfilename, lumirundata, runlist)
 alllumilsdata = {}
 for runnum, perrundata in parseresult.items():
     pixellumidataid = 0
     session.transaction().start(False)
     hfdataidinfo = hfdataidmap[runnum]
     hflumidataid = hfdataidinfo[0]
     trgdataid = hfdataidinfo[1]
     hltdataid = hfdataidinfo[2]
     alllumilsdata[runnum] = generateLumiLSdataForRun(
         perrundata, alllumirundata[runnum])
     pixellumirundata = alllumirundata[runnum]