def _addTopoInfo(theChainDef, chainDict, doAtL2AndEF=True): maxL2SignatureIndex = -1 for signatureIndex, signature in enumerate(theChainDef.signatureList): if signature['listOfTriggerElements'][0][0:2] == "L2": maxL2SignatureIndex = max(maxL2SignatureIndex, signatureIndex) inputTEsEF = theChainDef.signatureList[-1]['listOfTriggerElements'] EFChainName = "EF_" + chainDict['chainName'] topoThresh = chainDict['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None if "Jpsiee" in chainDict["topo"]: if topoStartFrom: EFChainName = EFChainName + '_tsf' from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Jpsi, TrigEFDielectronMassHypo_Jpsi EFFex = TrigEFDielectronMassFex_Jpsi() EFHypo = TrigEFDielectronMassHypo_Jpsi() theChainDef.addSequence([EFFex, EFHypo], inputTEsEF, EFChainName, topo_start_from=topoStartFrom) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [EFChainName]) elif "Zeg" in chainDict["topo"]: from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Zeg, TrigEFDielectronMassHypo_Zeg EFFex = TrigEFDielectronMassFex_Zeg() EFHypo = TrigEFDielectronMassHypo_Zeg() theChainDef.addSequence([EFFex, EFHypo], inputTEsEF, EFChainName) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [EFChainName]) elif "Zee" in chainDict["topo"]: from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Zee, TrigEFDielectronMassHypo_ZeeTight if 'etcut' in chainDict['chainName']: from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFexElectronCluster_Zee, TrigEFDielectronMassHypoElectronCluster_Zee EFFex = TrigEFDielectronMassFexElectronCluster_Zee() EFHypo = TrigEFDielectronMassHypoElectronCluster_Zee() else: EFFex = TrigEFDielectronMassFex_Zee() EFHypo = TrigEFDielectronMassHypo_ZeeTight() theChainDef.addSequence([EFFex, EFHypo], inputTEsEF, EFChainName) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [EFChainName]) if 'etcut' in chainDict['chainName']: from TrigIDTPMonitor.TrigIDTPMonitorConfig import IDTPMonitorElectron IDTP = IDTPMonitorElectron() myInputTEsEF = theChainDef.signatureList[-1][ 'listOfTriggerElements'] theChainDef.addSequence([IDTP], myInputTEsEF, EFChainName + "_monit") theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [EFChainName + "_monit"]) elif "bBeexv2" in chainDict["topo"] or "bBeexM2700" in chainDict[ "topo"] or "bBeexM6000" in chainDict[ "topo"] or "bBeexM6000t" in chainDict["topo"]: # this algorithm is set up in generateBPhysicsChainDef from TriggerMenu.bphysics.generateBPhysicsChainDefs import bBeexTopos inputTEsL2 = theChainDef.signatureList[maxL2SignatureIndex][ 'listOfTriggerElements'] theChainDef = bBeexTopos(theChainDef, chainDict, inputTEsL2, inputTEsEF) else: pass return theChainDef
def myBjetConfig1(theChainDef, chainDict, inputTEsEF, numberOfSubChainDicts=1): useTRT = 'noTRT' not in chainDict['chainParts']['extra'] EFChainName = "EF_bjet_" + chainDict['chainName'] chainParts = chainDict['chainParts'] btagthresh = chainParts['threshold'] btagmult = chainParts['multiplicity'] btagcut = chainParts['bTag'] btagcut = btagcut[1:] #import fexes/hypos ef_bjetSequence = getEFBjetAllTEInstance() if (int(btagthresh) == 0): ef_ethypo_startseq = getBjetEtHypoInstance("EF", "StartSequence", "0GeV") elif (int(btagthresh) < 35): ef_ethypo_startseq = getBjetEtHypoInstance("EF", "StartSequence", "15GeV") else: ef_ethypo_startseq = getBjetEtHypoInstance("EF", "StartSequence", "35GeV") # tracking if useTRT: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step"]).getSequence() else: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step", "noTRT"]).getSequence() ef_bjet_tracks = trkftf + trkprec ef_VxSecondary_EF = TrigVxSecondary_EF() ef_EtHypo_Btagging = getBjetEtHypoInstance("EF", "Btagging", btagthresh + "GeV") # B-tagging if ('boffperf' in chainParts['bTag'] or 'bmv2c20' in chainParts['bTag'] or 'bmv2c10' in chainParts['bTag'] or 'bhmv2c10' in chainParts['bTag']): ef_bjet = getBtagFexInstance("EF", "2012", "EFID") else: ef_bjet = getBjetFexInstance("EF", "2012", "EFID") # Hypo testing if ('bperf' in chainParts['bTag'] or 'boffperf' in chainParts['bTag']): ef_hypo = getBjetHypoNoCutInstance("EF") elif ('bmv2c20' in chainParts['bTag']): ef_hypo = getBjetHypoInstance("EF", "2015", btagcut) elif ('bmv2c10' in chainParts['bTag']): ef_hypo = getBjetHypoInstance("EF", "2017", btagcut) elif ('bhmv2c10' in chainParts['bTag']): ef_hypo = getBjetHypoInstance("EF", "2018", btagcut) else: ef_hypo = getBjetHypoInstance("EF", "2012", btagcut) #------- 2012 EF Sequences based on j35 intput TE------- # TE naming ef2 = 'HLT_Bj' ef3 = 'HLT_Bj_EtCut%s' % btagthresh if ('EFID' in chainParts['bTracking']): ef4 = 'HLT_Bj_EtCut%s_EFID' % btagthresh ef5 = 'HLT_Bj_EtCut%s_AllTEPrmVtx_EFID' % btagthresh ef6 = 'HLT_Bj_EtCut%s_ComboPrmVtx_EFID' % btagthresh elif not useTRT: ef4 = 'HLT_Bj_EtCut%s_IDTrig_noTRT' % btagthresh ef5 = 'HLT_Bj_EtCut%s_AllTEPrmVtx_IDTrig_noTRT' % btagthresh ef6 = 'HLT_Bj_EtCut%s_ComboPrmVtx_IDTrig_noTRT' % btagthresh else: ef4 = 'HLT_Bj_EtCut%s_IDTrig' % btagthresh ef5 = 'HLT_Bj_EtCut%s_AllTEPrmVtx_IDTrig' % btagthresh ef6 = 'HLT_Bj_EtCut%s_ComboPrmVtx_IDTrig' % btagthresh if (btagmult == '1'): if not useTRT: ef7 = 'EF_b%s_%s_%s_SecVxBhypo' % ( btagthresh, btagcut, chainParts['chainPartName'].replace( "_" + chainParts['bTracking'] + "_noTRT", ""), ) else: ef7 = 'EF_b%s_%s_%s_SecVxBhypo' % ( btagthresh, btagcut, chainParts['chainPartName'].replace( "_" + chainParts['bTracking'], ""), ) else: if not useTRT: ef7 = 'EF_%sb%s_%s_%s_SecVxBhypo' % ( btagmult, btagthresh, btagcut, chainParts['chainPartName'].replace( "_" + chainParts['bTracking'] + "noTRT", "")) else: ef7 = 'EF_%sb%s_%s_%s_SecVxBhypo' % ( btagmult, btagthresh, btagcut, chainParts['chainPartName'].replace( "_" + chainParts['bTracking'], "")) lastTEout = "EF_bj_" + chainParts[ 'chainPartName'] if numberOfSubChainDicts > 1 else EFChainName if not useTRT: lastTEout = lastTEout + "_noTRT" topoThresh = chainDict['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None if topoStartFrom: lastTEout = lastTEout + '_tsf' theChainDef.addSequence([ef_bjetSequence], inputTEsEF, ef2) theChainDef.addSequence(ef_ethypo_startseq, ef2, ef3) theChainDef.addSequence(ef_bjet_tracks, ef3, ef4) theChainDef.addSequence([EFHistoPrmVtxAllTE_Jet()], ef4, ef5) theChainDef.addSequence([EFHistoPrmVtxCombo_Jet()], [ef4, ef5], ef6) #theChainDef.addSequence([ef_EtHypo_Btagging], ef6, ef7) theChainDef.addSequence([ef_VxSecondary_EF, ef_EtHypo_Btagging], ef6, ef7) theChainDef.addSequence([ef_bjet, ef_hypo], ef7, lastTEout, topo_start_from=topoStartFrom) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [lastTEout] * int(btagmult)) return theChainDef
def myBjetConfig_split(theChainDef, chainDict, inputTEsEF, numberOfSubChainDicts=1): useTRT = 'noTRT' not in chainDict['chainParts']['extra'] log.debug("In myBjetConfig_split") EFChainName = "EF_bjet_" + chainDict['chainName'] chainParts = chainDict['chainParts'] btagthresh = chainParts['threshold'] gscthresh = chainParts['gscThreshold'] if ('gscThreshold' in chainParts) else '' btagmult = chainParts['multiplicity'] btagcut = chainParts['bTag'] btagcut = btagcut[1:] #----------------------------------------------------------------------------------- # Import of algs #----------------------------------------------------------------------------------- algoInstance = "EF" #-------------------- # super ROI building theSuperRoi = getSuperRoiBuilderAllTEInstance() #-------------------- # jet splitting theJetSplit = getJetSplitterAllTEInstance() #-------------------- #find jets far away from a muon (for mu-jet chains with b-jet requirements only) if any('antimatchdr' in bM for bM in chainParts['bMatching']): # Extract the dR value from the chain name here.. the deltaR value has to consist of 2 numbers deltaR = -1 for anti_match_part in chainParts['bMatching']: if 'dr' in anti_match_part: deltaR = anti_match_part.split('dr')[1][0:2] if deltaR == -1: log.error("No DeltaR cut could be extracted!") theFarawayJet = getFarawayJetFinderAllTEInstance(str(deltaR)) algoInstance = "MuJetChain" #-------------------- # Et hypo (for b-tagging) #from TrigBjetHypo.TrigBjetEtHypoConfig import getBjetEtHypoInstance theBjetEtHypo = getBjetEtHypoInstance(algoInstance, "Btagging", btagthresh + "GeV") #-------------------- # tracking if useTRT: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step"]).getSequence() else: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step", "noTRT"]).getSequence() # for b-tagging theBjetTracks = trkftf + trkprec # for vertexing ## theVertexTracks = trkvtx #-------------------- # primary vertexing #-------------------- # GSC if ('gscThreshold' in chainParts) and chainParts['gscThreshold']: theGSCFex = getGSCFexSplitInstance(algoInstance) #from TrigBjetHypo.TrigBjetEtHypoConfig import getBjetEtHypoInstance theGSCEtHypo = getBjetEtHypoInstance( "GSC", "Btagging", gscthresh.replace("gsc", "") + "GeV") #-------------------- # secondary vertexing theVxSecondary = TrigVxSecondaryCombo_EF() #-------------------- # bjet fex # if ('boffperf' in chainParts['bTag'] or 'bmv2c20' in chainParts['bTag']): # # Offline taggers # from TrigBjetHypo.TrigBtagFexConfig import getBtagFexSplitInstance # theBjetFex = getBtagFexSplitInstance(algoInstance,"2012","EFID") # else: # # Run 1 style taggers # from TrigBjetHypo.TrigBjetFexConfig import getBjetFexSplitInstance # theBjetFex = getBjetFexSplitInstance(algoInstance,"2012","EFID") if ('boffperf' in chainParts['bTag'] or 'bmv2c20' in chainParts['bTag'] or 'bmv2c10' in chainParts['bTag'] or 'bhmv2c10' in chainParts['bTag']): # Offline taggers theBjetFex = getBtagFexSplitInstance(algoInstance, "2012", "EFID") else: # Run 1 style taggers theBjetFex = getBjetFexSplitInstance(algoInstance, "2012", "EFID") #-------------------- # bjet hypo if ('bperf' in chainParts['bTag'] or 'boffperf' in chainParts['bTag']): # Performance chains (run 1 and run 2 style) # Runs in NoCut mode theBtagReq = getBjetHypoSplitNoCutInstance(algoInstance) elif ('bmv2c20' in chainParts['bTag']): # MV2c20 tagger series theBtagReq = getBjetHypoSplitInstance(algoInstance, "2015", btagcut) elif ('bmv2c10' in chainParts['bTag']): # MV2c10 tagger series theBtagReq = getBjetHypoSplitInstance(algoInstance, "2017", btagcut) elif ('bhmv2c10' in chainParts['bTag']): # MV2c10hybrid tagger series theBtagReq = getBjetHypoSplitInstance(algoInstance, "2018", btagcut) else: # Run 1 style chains theBtagReq = getBjetHypoSplitInstance(algoInstance, "2012", btagcut) #----------------------------------------------------------------------------------- # TE naming #----------------------------------------------------------------------------------- tracking = "IDTrig" if 'noTRT' in chainParts['extra']: tracking = "IDTrig_noTRT" jetEtHypoTE = "HLT_j" + btagthresh jetHypoTE = "HLT_j" + btagthresh + "_eta" jetSplitTE = jetHypoTE + "_jsplit" jetTrackTE = jetSplitTE + "_" + tracking if not useTRT: jetEtHypoTE = jetEtHypoTE + "_noTRT" jetSplitTE = jetSplitTE + "_noTRT" jetFarawayTE = jetSplitTE + "_faraway" gsc_jetTrackTEPreCut = "HLT_precut_gsc" + btagthresh + "_eta" + "_jsplit" + "_" + tracking gsc_jetTrackTE = "HLT_" + gscthresh + "_eta" + "_jsplit" + "_" + tracking if any('antimatch' in bM for bM in chainParts['bMatching']) and any( 'mu' in bM for bM in chainParts['bMatching']): # extract muon threshold from chainname allChainParts = chainDict['chainName'].split('_') muonthr = -1 for cp in allChainParts: if 'mu' in cp and 'antimatch' not in cp: muonthr = cp.split('mu')[ -1] # assume the last bit is the threshold break #print 'muon thr for antimatch:' + str(muonthr) muonTE = "EF_SuperEF_mu{0}_MU{1}".format(muonthr, muonthr) jetEtHypoTE = jetEtHypoTE + '_antimatchmu{0}'.format(muonthr) jetHypoTE = jetHypoTE + '_antimatchmu{0}'.format(muonthr) jetTrackTE = jetTrackTE + '_antimatchmu{0}'.format(muonthr) superTE = "HLT_super" superTrackingTE = superTE + tracking prmVertexTE = superTrackingTE + "_prmVtx" comboPrmVtxTE = prmVertexTE + "Combo" secVtxTE = jetTrackTE + "__" + "secVtx" lastTEout = "HLT_bjet_" + chainParts[ 'chainPartName'] if numberOfSubChainDicts > 1 else EFChainName if not useTRT: lastTEout = lastTEout + "_noTRT" topoThresh = chainDict['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None if topoStartFrom: lastTEout = lastTEout + '_tsf' #----------------------------------------------------------------------------------- # sequence assembling #----------------------------------------------------------------------------------- # Vertexing part of the chain theChainDef.addSequence(theSuperRoi, inputTEsEF, superTE) theChainDef.addSequence(trkvtx, superTE, superTrackingTE) theChainDef.addSequence([EFHistoPrmVtxAllTE_Jet()], superTrackingTE, prmVertexTE) theChainDef.addSequence([EFHistoPrmVtxCombo_Jet()], [superTrackingTE, prmVertexTE], comboPrmVtxTE) # b-tagging part of the chain (requires PV) theChainDef.addSequence(theJetSplit, [inputTEsEF, comboPrmVtxTE], jetSplitTE) #theChainDef.addSequence(theFarawayJet, [muonTE, jetSplitTE], jetFarawayTE) #theChainDef.addSequence(theBjetEtHypo, jetFarawayTE, jetEtHypoTE) #theChainDef.addSequence(theBjetEtHypo, jetSplitTE, jetEtHypoTE) if any('antimatch' in bM for bM in chainParts['bMatching']) and any( 'mu' in bM for bM in chainParts['bMatching']): theChainDef.addSequence(theFarawayJet, [muonTE, jetSplitTE], jetFarawayTE) jetForTrackingEtCut = jetFarawayTE #theChainDef.addSequence(theBjetEtHypo, jetFarawayTE, jetEtHypoTE) else: jetForTrackingEtCut = jetSplitTE #theChainDef.addSequence(theBjetEtHypo, jetSplitTE, jetEtHypoTE) #Et cut before tracking theChainDef.addSequence(theBjetEtHypo, jetForTrackingEtCut, jetEtHypoTE) theChainDef.addSequence(theBjetTracks, jetEtHypoTE, jetTrackTE) theChainDef.addSequence(theVxSecondary, [jetTrackTE, comboPrmVtxTE], secVtxTE) #GSC if ('gscThreshold' in chainParts) and chainParts['gscThreshold']: log.debug("Doing GSC Calculation:" + chainParts["gscThreshold"]) theChainDef.addSequence(theGSCFex, secVtxTE, gsc_jetTrackTEPreCut) theChainDef.addSequence(theGSCEtHypo, gsc_jetTrackTEPreCut, gsc_jetTrackTE) jetsForBTagging = gsc_jetTrackTE #secVtxTE = gsc_jetTrackTE+"__"+"superVtx" else: log.debug("No GSC Calculation") jetsForBTagging = secVtxTE #secVtxTE = jetTrackTE+"__"+"superVtx" theChainDef.addSequence([theBjetFex, theBtagReq], jetsForBTagging, lastTEout, topo_start_from=topoStartFrom) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [lastTEout] * int(btagmult)) return theChainDef
def buildBjetChainsAllTE(theChainDef, bjetdict, numberOfSubChainDicts=1): log.debug("In buildBjetChainsAllTE") inputTEsEF = theChainDef.signatureList[-1]['listOfTriggerElements'][0] useTRT = 'noTRT' not in bjetdict[0]['chainParts']['extra'] # # Initial Config # ###############################3 # # Get the min threshold for tracking # This cut is applied after the jet splitting # So we only run precision tracking in ROIs above the minimum considered # minBTagThreshold = 1e9 for bjetPart in bjetdict: thisBTagThresholdInt = int(bjetPart['chainParts']['threshold']) if thisBTagThresholdInt < minBTagThreshold: minBTagThreshold = thisBTagThresholdInt log.debug("min jet Pt %s", minBTagThreshold) # # Configure the GSC calibration # This cut is applied after the GSC calibration # So we only btag ROIs above the minimum considered # doGSC = False minGSCThreshold = 1e9 for bjetPart in bjetdict: if ('gscThreshold' in bjetPart['chainParts']) and ( bjetPart['chainParts']['gscThreshold']): doGSC = True thisGSCThresholdInt = int( bjetPart['chainParts']['gscThreshold'].replace("gsc", "")) if thisGSCThresholdInt < minGSCThreshold: minGSCThreshold = thisGSCThresholdInt if doGSC: log.debug("Doing GSC Calculation:" + str(minGSCThreshold) + "GeV") # # Now build the chain # ###########################3 # # super ROI building # theSuperRoi = getSuperRoiBuilderAllTEInstance() superTE = "HLT_super" theChainDef.addSequence(theSuperRoi, inputTEsEF, superTE) # # PV Tracking # if useTRT: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step"]).getSequence() else: [trkvtx, trkftf, trkprec] = TrigInDetSequence("Bjet", "bjet", "IDTrig", sequenceFlavour=["2step", "noTRT"]).getSequence() tracking = "IDTrig" if not useTRT: tracking = tracking + "_noTRT" superTrackingTE = superTE + tracking theChainDef.addSequence(trkvtx, superTE, superTrackingTE) # # PV Finding # prmVertexTE = superTrackingTE + "_prmVtx" theChainDef.addSequence([EFHistoPrmVtxAllTE_Jet()], superTrackingTE, prmVertexTE) comboPrmVtxTE = prmVertexTE + "Combo" theChainDef.addSequence([EFHistoPrmVtxCombo_Jet()], [superTrackingTE, prmVertexTE], comboPrmVtxTE) # # Jet splitting # # get the minimum et before gsc cut theJetSplit = getJetSplitterAllTEInstance() jetHypoTE = "HLT_j" + str(minBTagThreshold) + "_eta" jetSplitTE = jetHypoTE + "_jsplit" if not useTRT: jetSplitTE = jetSplitTE + "_noTRT" theChainDef.addSequence(theJetSplit, [inputTEsEF, comboPrmVtxTE], jetSplitTE) # # If do the btagging in away muons # algoInstance = "EF" # # Et cut berfore running precision tracking # theBjetEtHypo = getBjetEtHypoInstance(algoInstance, "Btagging", str(minBTagThreshold) + "GeV") jetEtHypoTE = "HLT_j" + str(minBTagThreshold) if not useTRT: jetEtHypoTE = jetEtHypoTE + "_noTRT" theChainDef.addSequence(theBjetEtHypo, jetSplitTE, jetEtHypoTE) # # Precision tracking # if not useTRT: jetSplitTE = jetSplitTE.replace( "_noTRT", "") # remove noTRT since we are adding tracking !!!! jetTrackTE = jetSplitTE + "_" + tracking theBjetTracks = trkftf + trkprec theChainDef.addSequence(theBjetTracks, jetEtHypoTE, jetTrackTE) # # Secondary Vertexing # theVxSecondary = TrigVxSecondaryCombo_EF() secVtxTE = jetTrackTE + "__" + "secVtx" theChainDef.addSequence(theVxSecondary, [jetTrackTE, comboPrmVtxTE], secVtxTE) # # GSC calculation # if doGSC: gsc_jetTrackTEPreCut = "HLT_precut_gsc" + str( minBTagThreshold) + "_eta" + "_jsplit" + "_" + tracking theGSCFex = getGSCFexSplitInstance(algoInstance) theChainDef.addSequence(theGSCFex, secVtxTE, gsc_jetTrackTEPreCut) algoInstance = "GSC" gsc_jetTrackTE = "HLT_gsc" + str( minGSCThreshold) + "_eta" + "_jsplit" + "_" + tracking theGSCEtHypo = getBjetEtHypoInstance(algoInstance, "Btagging", str(minGSCThreshold) + "GeV") theChainDef.addSequence(theGSCEtHypo, gsc_jetTrackTEPreCut, gsc_jetTrackTE) jetsForBTagging = gsc_jetTrackTE else: log.debug("No GSC Calculation") jetsForBTagging = secVtxTE # # the tagging fex # log.debug("Getting tagging fex") theBjetFex = getBtagFexSplitInstance(algoInstance, "2012", "EFID") btaggingTE = jetsForBTagging + "_btagged" theChainDef.addSequence(theBjetFex, jetsForBTagging, btaggingTE) # # The btagging hypo # log.debug("Getting tagging hypo") lastTEout = "HLT_" + bjetdict[0]['chainName'] if not useTRT: lastTEout = lastTEout + "_noTRT" topoThresh = bjetdict[0]['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None if topoStartFrom: lastTEout = lastTEout + '_tsf' # # Derive multiplicity requirements # log.debug("Derive multiplicity requirements") btagReqs = [] for bjetchain in bjetdict: log.debug(bjetdict) btagCut = bjetchain['chainParts']['bTag'] mult = bjetchain['chainParts']['multiplicity'] threshold = bjetchain['chainParts']['threshold'] if 'gscThreshold' in bjetchain['chainParts']: threshold = bjetchain['chainParts']['gscThreshold'].replace( "gsc", "") btagReqs.append([threshold, btagCut, mult]) log.debug("Config the ALLTE Hypo") name = bjetdict[0]['chainName'] theBjetHypoAllTE = getBjetHypoAllTEInstance("EF", "2017", name, btagReqs) #theChainDef.signatureList[-1]['listOfTriggerElements'][0] log.debug("Adding Sequence") theChainDef.addSequence(theBjetHypoAllTE, btaggingTE, lastTEout, topo_start_from=topoStartFrom) log.debug("Adding Signature") theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [lastTEout]) log.debug("Left buildBjetChainsAllTE") theChainDef.chain_name = 'HLT_' + bjetdict[0]['chainName'] return theChainDef
def _addTopoInfo(theChainDef, chainDict, doAtL2AndEF=False): maxL2SignatureIndex = -1 for signatureIndex, signature in enumerate(theChainDef.signatureList): if signature['listOfTriggerElements'][0][0:2] == "L2": maxL2SignatureIndex = max(maxL2SignatureIndex, signatureIndex) inputTEsL2 = theChainDef.signatureList[maxL2SignatureIndex][ 'listOfTriggerElements'] L2ChainName = "L2_" + chainDict['chainName'] topoThresh = chainDict['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None topoAlgs = chainDict["topo"] if (('tautsf' in topoAlgs) or ('notautsf' in topoAlgs)): #log.info("Adding Tau tsf Topological Algorithm(s) to chain") #topoName = 'tsf' #if topoStartFrom: # L2ChainName = L2ChainName+topoName #import topo hypos at L2 from TrigTauHypo.TrigTauHypoConf import L2TauTopoFex from TrigTauHypo.TrigTauHypoConfig2012 import L2TauTopoHypo L2Fex = L2TauTopoFex() hypo_name = 'l2topo_' + L2ChainName theL2Hypo = L2TauTopoHypo(hypo_name) theChainDef.addSequence([L2Fex, theL2Hypo], inputTEsL2, L2ChainName, topo_start_from=topoStartFrom) theChainDef.addSignatureL2([L2ChainName]) if (('ditauL' in topoAlgs) or ('ditauM' in topoAlgs) or ('ditauT' in topoAlgs)): ditau_hypo = 'ditauL' if ('ditauM' in topoAlgs): ditau_hypo = 'ditauM' if ('ditauT' in topoAlgs): ditau_hypo = 'ditauT' from TrigTauHypo.TrigTauHypoConfig2012 import HLTVertexPreSelHypo from TrigTauHypo.TrigTauHypoConf import HLTVertexCombo theHLTVertexCombo = HLTVertexCombo() hypo_name = 'l2topo_tau_' + ditau_hypo theVars = ['acceptableZ0Distance'] theThresh = L2VertexDistances[(ditau_hypo)] theHLTVertexPreSelHypo = HLTVertexPreSelHypo(hypo_name, theVars, theThresh) preselectionTEName = "L2_" + chainDict['chainName'] + '_ditau' preselectionAlgorithms = [theHLTVertexCombo, theHLTVertexPreSelHypo] theChainDef.addSequence(preselectionAlgorithms, inputTEsL2, preselectionTEName, None) theChainDef.addSignatureL2([preselectionTEName]) if any("dR" in alg for alg in topoAlgs): inputTEsEF = theChainDef.signatureList[-1]['listOfTriggerElements'] maxdR = -1 mindR = -1 for topo_item in chainDict['topo']: if 'dR' in topo_item: mindR = float(topo_item.split('dR')[0]) maxdR = float(topo_item.split('dR')[1]) log.debug("dR cuts at: %d and %d", mindR, maxdR) if mindR == -1 or maxdR == -1: log.error("No dR chain part found in tau-tau dR Topo cut") from TrigTauHypo.TrigTauHypoConfig2012 import EFTauTopoHypo from TrigTauHypo.TrigTauHypoConf import EFTauTopoFex EFFex = EFTauTopoFex() theVars = ['DRMin', 'DRMax'] theThresh = [mindR * 0.1, maxdR * 0.1] TauTaudR_Hypo = EFTauTopoHypo( "EFTauTopo_" + str(mindR).replace(".", "") + "dR" + str(maxdR).replace(".", ""), theVars, theThresh) log.debug("Input TEs to dR algorithm: %s", inputTEsEF) EFChainName = "EF_" + chainDict['chainName'] theChainDef.addSequence([EFFex, TauTaudR_Hypo], inputTEsEF, EFChainName) theChainDef.addSignature( theChainDef.signatureList[-1]['signature_counter'] + 1, [EFChainName]) return theChainDef
def _addMatching(theChainDef, chainDicts, listOfChainDefs): allInputTEsEF = [] for cD in listOfChainDefs: allInputTEsEF += [ deepcopy(cD.signatureList[-1]['listOfTriggerElements'][0]) ] maxSigCounter = theChainDef.signatureList[-1]['signature_counter'] # ========================================================= # muon input TE to the hypo muonTE = theChainDef.signatureList[3]['listOfTriggerElements'] # ========================================================= #check if jet or bjet to be matched & find hypothreshold chnameToMatch = chainDicts[0]['chainName'].split("_dr")[0] chnameAddPart = chainDicts[0]['chainName'].split("_dr")[1] hypoThresh = [ part.split("j")[1] for part in chnameToMatch.split("_") if "j" in part ][0] + 'GeV' if hypoThresh == '': log.error("No HypoThreshold could be extracted!") if ('_b') in chnameToMatch and ('_b') in chnameAddPart: log.error( "Matching functionality for this chain is not implemented yet: %s " % (chainDicts[0]['chainName'])) # ========================================================= # configure Hypo and jet/bjetTE from TrigBjetHypo.TrigLeptonJetMatchAllTEConfig import getLeptonJetMatchAllTEInstance from TrigBjetHypo.TrigLeptonJetMatchAllTEConfig import LeptonJetMatchAllTE dzmatching = False for topo in chainDicts[0]['topo']: if "dz" in topo: dzmatching = True # obtain deltaR for Hypo configuration deltaR = -1 for topo_item in chainDicts[0]['topo']: if 'dr' in topo_item: deltaR = float(topo_item.split('dr')[1]) / 10. if deltaR == -1: log.error("No DeltaR cut could be extracted!") if dzmatching: # it's a bjet chain # obtain deltaZ for Hypo configuration deltaZ = -1 for topo_item in chainDicts[0]['topo']: if 'dz' in topo_item: deltaZ = float( topo_item.split('dz')[1] ) # Need to modify this to be able to handle dZ values > 9... jetTE = theChainDef.signatureList[-1]['listOfTriggerElements'] pos_sigCounter = -1 if deltaZ == 99: LeptonJetFexAllTE = LeptonJetMatchAllTE( "CloseBy", "RZ", hypoThresh, name="LeptonJetMatchAllTE_CloseBy_RZ_" + str(hypoThresh) + '_dz' + str(int(deltaZ))) else: LeptonJetFexAllTE = getLeptonJetMatchAllTEInstance( "CloseBy", "RZ", hypoThresh) LeptonJetFexAllTE.JetKey = "SplitJet" LeptonJetFexAllTE.DeltaRCut = deltaR LeptonJetFexAllTE.DeltaZCut = deltaZ if ('_anti') in chnameAddPart: log.error( "Matching functionality for this chain is not implemented yet: %s " % (chainDicts[0]['chainName'])) else: # dealing with jets to match pos_sigCounter = 9999 pos_sigCounterlist = [] sigCounter = 9999 sigCounterlist = [] jetTE = '' jetTElist = [] for i, mydict in enumerate(theChainDef.signatureList): for tes in mydict['listOfTriggerElements']: # if isJetTE(tes): if 'noCleaning' in tes or ('HLThypo' in tes and re.match("EF_[_0-9]+", tes)): #print ("WOOF found my TE", tes) #print ("WOOF belongs to sign pos", mydict['signature_counter']) jetTElist.append(tes) sigCounterlist.append(mydict['signature_counter']) pos_sigCounterlist.append(i) # else: # print ("This is not a jet TE?"+ str(tes)) if ('_b') in chnameToMatch: jetTE = theChainDef.signatureList[-1]['listOfTriggerElements'] pos_sigCounter = -1 sigCounter = theChainDef.signatureList[-1]['signature_counter'] if ('_anti') in chnameAddPart: log.error( "Matching functionality for this chain is not implemented yet: %s " % (chainDicts[0]['chainName'])) else: # import pdb;pdb.set_trace() # log.error('PS chain_name ' + theChainDef.chain_name) # log.error('PS jetTElist ' + str(jetTElist)) # log.error('PS sig list ' + str(theChainDef.signatureList)) jetTE = jetTElist[0] pos_sigCounter = pos_sigCounterlist[0] sigCounter = sigCounterlist[0] if pos_sigCounter > 20: log.error( "Cannot determine the correct signature counter for the last jet sequence TE!" ) if jetTE == '': log.error( "Could not find the last jet TE, maybe due to a change in the jet sequence naming convention?" ) LeptonJetFexAllTE = getLeptonJetMatchAllTEInstance( "CloseBy", "R", hypoThresh) LeptonJetFexAllTE.JetKey = "" LeptonJetFexAllTE.DeltaRCut = deltaR # ========================================================= # Topo start from settings EFChainName = "EF_" + chainDicts[0]['chainName'] from TriggerMenu.menu.MenuUtils import setupTopoStartFrom topoThresh = chainDicts[0]['topoThreshold'] topoStartFrom = setupTopoStartFrom(topoThresh, theChainDef) if topoThresh else None if topoStartFrom: EFChainName = EFChainName + '_tsf' # ========================================================= # matching sequence of the chain log.debug("Input TEs to LeptonJet algorithm: %s %s", muonTE, jetTE) theChainDef.addSequence([LeptonJetFexAllTE], [muonTE, jetTE], EFChainName, topo_start_from=topoStartFrom) if pos_sigCounter == -1: theChainDef.addSignature( theChainDef.signatureList[pos_sigCounter]['signature_counter'] + 1, [EFChainName]) elif sigCounter == maxSigCounter: #print ("WOOOOOOF") #print ("WOOF: theChainDef.signatureList[pos_sigCounter]['signature_counter']+1", theChainDef.signatureList[pos_sigCounter]['signature_counter']+1) #print ("WOOF: theChainDef.signatureList[pos_sigCounter-1]['signature_counter']+1", theChainDef.signatureList[pos_sigCounter-1]['signature_counter']+1) #print ("WOOF: pos_sigCounter" , pos_sigCounter) #print ("WOOF: sigCounter" , sigCounter) theChainDef.addSignature( theChainDef.signatureList[pos_sigCounter]['signature_counter'] + 1, [EFChainName]) else: theChainDef.insertSignature(sigCounter + 1, [EFChainName]) #print ("WOOF: theChainDef.signatureList[pos_sigCounter]['signature_counter']+1", theChainDef.signatureList[pos_sigCounter]['signature_counter']+1) #print ("WOOF: theChainDef.signatureList[pos_sigCounter-1]['signature_counter']+1", theChainDef.signatureList[pos_sigCounter-1]['signature_counter']+1) #print ("WOOF: pos_sigCounter" , pos_sigCounter) #print ("WOOF: sigCounter" , sigCounter) #print ("MEOW pos sig counter", pos_sigCounter) #print ("MEOW chain def", theChainDef.signatureList) return theChainDef