示例#1
0
def myDvConfig1(theChainDef, chainDict, inputTEsEF, numberOfSubChainDicts=1):
    print "*******WARNING********"
    print "This Configuration should not be used!!"
    print "Use instead the '_split' version of the chain"
    print "*****END-WARNING******"
    L2ChainName = "L2_" + chainDict['chainName']
    EFChainName = "EF_" + chainDict['chainName']
    HLTChainName = "HLT_" + chainDict['chainName']

    chainParts = chainDict['chainParts']
    btagthresh = chainParts['threshold']
    btagmult = chainParts['multiplicity']
    btagcut = chainParts['bTag']
    btagcut = btagcut[1:]
    btracking = chainParts['bTracking']

    #import fexes/hypos
    # -- Using al the TE separately
    from TrigBjetHypo.TrigEFBjetSequenceAllTEConfig import getEFBjetAllTEInstance
    ef_bjetSequence = getEFBjetAllTEInstance()

    from TrigBjetHypo.TrigBjetEtHypoConfig import getBjetEtHypoInstance
    ef_ethypo_startseq = getBjetEtHypoInstance("EF", "StartSequence", "35GeV")

    from InDetTrigRecExample.EFInDetConfig import TrigEFIDSequence
    if 'EFID' in btracking:
        ef_bjet_tracks = TrigEFIDSequence("Bjet", "bjet",
                                          "InsideOut").getSequence()
    else:
        from TrigFastTrackFinder.TrigFastTrackFinder_Config import TrigFastTrackFinder_Jet
        theTrigFastTrackFinder_Jet = [TrigFastTrackFinder_Jet()]
        from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
        theFastTrackFinderxAOD = TrigInDetSequence("Bjet", "bjet",
                                                   "FastxAOD").getSequence()
        ef_bjet_tracks = TrigEFIDSequence("Bjet", "bjet",
                                          "DataPrep").getSequence()
        ef_bjet_tracks += theTrigFastTrackFinder_Jet
        ef_bjet_tracks += theFastTrackFinderxAOD
        ef_bjet_tracks += TrigEFIDSequence("Bjet", "bjet",
                                           "InsideOutMerged").getSequence()

    from TrigT2HistoPrmVtx.TrigT2HistoPrmVtxAllTEConfig import EFHistoPrmVtxAllTE_Jet
    from TrigT2HistoPrmVtx.TrigT2HistoPrmVtxComboConfig import EFHistoPrmVtxCombo_Jet

    from InDetTrigVxSecondary.InDetTrigVxSecondary_LoadTools import TrigVxSecondary_EF
    ef_VxSecondary_EF = TrigVxSecondary_EF()

    from TrigBjetHypo.TrigBjetEtHypoConfig import getBjetEtHypoInstance
    ef_EtHypo_Btagging = getBjetEtHypoInstance("EF", "Btagging",
                                               btagthresh + "GeV")

    # DV FEX
    from TrigBjetHypo.TrigDvFexConfig import getDvFexInstance
    ef_dvfex = getDvFexInstance("EF", "EFID")
    # dv hypo
    from TrigBjetHypo.TrigDvHypoConfig import getDvHypoInstance
    ef_hypo = getDvHypoInstance("EF")
    #if ('boffperf' in chainParts['bTag']):
    #    from TrigBjetHypo.TrigBtagFexConfig import getBtagFexInstance
    #    ef_bjet = getBtagFexInstance("EF","2012","EFID")
    #else:
    #    from TrigBjetHypo.TrigBjetFexConfig  import getBjetFexInstance
    #    ef_bjet = getBjetFexInstance("EF","2012","EFID")
    #
    #if ('bperf' in chainParts['bTag'] or 'boffperf' in chainParts['bTag']):
    #    from TrigBjetHypo.TrigBjetHypoConfig import getBjetHypoNoCutInstance
    #    ef_hypo = getBjetHypoNoCutInstance("EF")
    #else:
    #    from TrigBjetHypo.TrigBjetHypoConfig import getBjetHypoInstance
    #    ef_hypo = getBjetHypoInstance("EF","2012", btagcut)

    #------- 2012 EF Sequences based on j35 intput TE-------
    # TE naming
    ef2 = 'HLT_BjetSeed'
    ef3 = 'HLT_BjetSeed_EtCut%sGeV' % btagthresh
    if ('EFID' in chainParts['bTracking']):
        ef4 = 'HLT_BjetSeed_EtCut%sGeV_EFID' % btagthresh
        ef5 = 'HLT_BjetSeed_EtCut%sGeV_AllTEPrmVtx_EFID' % btagthresh
        ef6 = 'HLT_BjetSeed_EtCut%sGeV_ComboPrmVtx_EFID' % btagthresh
    else:
        ef4 = 'HLT_BjetSeed_EtCut%sGeV_IDTrig' % btagthresh
        ef5 = 'HLT_BjetSeed_EtCut%sGeV_AllTEPrmVtx_IDTrig' % btagthresh
        ef6 = 'HLT_BjetSeed_EtCut%sGeV_ComboPrmVtx_IDTrig' % btagthresh
    if (btagmult == '1'):
        ef7 = 'EF_b%s_%s_%s_VxSecondaryAndBTagHypo' % (
            btagthresh,
            btagcut,
            chainParts['chainPartName'].replace("_" + chainParts['bTracking'],
                                                ""),
        )
    else:
        ef7 = 'EF_%sb%s_%s_%s_VxSecondaryAndBTagHypo' % (
            btagmult, btagthresh, btagcut, chainParts['chainPartName'].replace(
                "_" + chainParts['bTracking'], ""))

    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)
    lastTEout = "EF_" + chainParts[
        'chainPartName'] if numberOfSubChainDicts > 1 else EFChainName
    theChainDef.addSequence([ef_dvfex, ef_hypo], ef7, lastTEout)

    theChainDef.addSignature(
        theChainDef.signatureList[-1]['signature_counter'] + 1,
        [lastTEout] * int(btagmult))

    return theChainDef
示例#2
0
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
示例#3
0
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
示例#4
0
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