CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/RecoLuminosity/LumiDB/python/hltTrgSeedMapper.py

Go to the documentation of this file.
00001 import re,string
00002 def findUniqueSeed(hltPath,ExprStr):
00003     '''
00004     given a hltpath and its L1SeedExpression, find the L1 bit name
00005     can return None
00006     
00007     if hltPath contains the following, skip do not parse seed.
00008     
00009     FakeHLTPATH*, HLT_Physics*, HLT_*Calibration*, HLT_HFThreashold,
00010     HLT_MiniBias*,HLT_Random*,HLTTriggerFinalPath,HLT_PixelFED*
00011 
00012     parse hltpath contains at most 2 logics x OR y, x AND y, and return left val
00013     do not consider path containing operator NOT
00014 
00015     '''
00016     if re.match('FakeHLTPATH',hltPath)!=None :
00017         return None
00018     if re.match('HLT_Physics',hltPath)!=None :
00019         return None
00020     if re.match('HLT_[aA-zZ]*Calibration',hltPath)!=None :
00021         return None
00022     if re.match('HLT_[aA-zZ]*Threshold',hltPath)!=None :
00023         return None
00024     if re.match('HLT_MiniBias',hltPath)!=None :
00025         return None
00026     if re.match('HLT_Random',hltPath)!=None :
00027         return None
00028     if re.match('HLTriggerFinalPath',hltPath)!=None :
00029         return None
00030     if re.match('HLT_[aA-zZ]*FEDSize',hltPath)!=None :
00031         return None
00032     if ExprStr.find('(')!=-1 : #we don't parse expression with ()
00033         return None
00034     sep=re.compile('(\sAND\s|\sOR\s)',re.IGNORECASE)
00035     result=re.split(sep,ExprStr)
00036     if len(result)>3:
00037         return ('',None)
00038     cleanresult=[]
00039     exptype=''
00040     notsep=re.compile('NOT\s',re.IGNORECASE)
00041     andsep=re.compile('\sAND\s',re.IGNORECASE)
00042     orsep=re.compile('\sOR\s',re.IGNORECASE)
00043 
00044     for r in result:
00045         if notsep.match(r) : #we don't know what to do with NOT
00046             return ('',None)
00047         if orsep.match(r):
00048             exptype='OR'
00049             continue
00050         if andsep.match(r):
00051             exptype='AND'
00052             continue
00053         cleanresult.append('"'+string.strip(r).replace('\"','')+'"')
00054     return (exptype,cleanresult)
00055 
00056 if __name__=='__main__':
00057     print findUniqueSeed("HLT_ForwardBSC","36 OR 37")
00058     print findUniqueSeed("HLT_HcalNZS_8E29","L1_SingleEG1 OR L1_SingleEG2 OR L1_SingleEG5 OR L1_SingleEG8 OR L1_SingleEG10")
00059     print findUniqueSeed("HLT_ZeroBiasPixel_SingleTrack","L1_ZeroBias AND me")
00060