Exemplo n.º 1
0
def generateChainDefs(chainDict):
    """Delegate the creation of ChainDef instnaces to JetDEf,
    then add in  the top information."""
    
    jetgroup_chain = True
    chainName = chainDict['chainName']
    #print 'processing chain part 1 start', chainName
    theChainDef = generateHLTChainDef(chainDict)
    #print 'processing chain part 2 end', chainName

    listOfChainDicts = splitChainDict(chainDict)

    topoAlgs = []
    for subCD in listOfChainDicts:  
        allTopoAlgs = subCD['chainParts']['topo']
        for ta in allTopoAlgs:
            topoAlgs.append(ta)

    # test new jet algorithm and configuration PS 15/9/2016
    # now use new jet algorthm TrigHLTJetHypo2 as standard,
    # and have the test chains use th run 1 hypo for comaprison PS 04/10/2016

    if ('muvtx' in topoAlgs) or ('llp' in topoAlgs):

        logJet.info("Adding topo to jet chain")
        try:
            theChainDef = _addTopoInfo(theChainDef, chainDict, topoAlgs)
        except Exception, e:
            tb = exc2string2()
            theChainDef = process_exception(e, tb, chainName)

        jetgroup_chain = False
Exemplo n.º 2
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    myProvider = TauHypoProvider()

    for subChainDict in listOfChainDicts:
        if "IdTest" in subChainDict["chainParts"]["addInfo"]:
            Tau = L2EFChain_tau_IdTest(subChainDict, myProvider)
        else:
            Tau = L2EFChain_tau(subChainDict, myProvider)

        listOfChainDefs += [Tau.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    #add support for topological algorithms
    if chainDict["topo"]:
        log.info("Adding Tau Topological Algorithm(s) to chain")
        theChainDef = _addTopoInfo(theChainDef, chainDict)

    return theChainDef
Exemplo n.º 3
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    subChainDict = listOfChainDicts[0] # take only the first
    TestChain = L2EFChain_test(subChainDict)
            
    theChainDef = TestChain.generateHLTChainDef()

    return theChainDef
Exemplo n.º 4
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        Beamspot = L2EFChain_Beamspot(subChainDict)
        listOfChainDefs += [Beamspot.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 5
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        Monitoring = L2EFChain_Monitoring(subChainDict)
        listOfChainDefs += [Monitoring.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 6
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        Calib = L2EFChain_CalibTemplate(subChainDict)

        listOfChainDefs += [Calib.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 7
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        EnhancedBias = L2EFChain_EnhancedBiasTemplate(subChainDict)

        listOfChainDefs += [EnhancedBias.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 8
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        Streaming = L2EFChain_SeededStreamerTemplate(subChainDict)

        listOfChainDefs += [Streaming.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 9
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        MissingET = L2EFChain_met(subChainDict)

        listOfChainDefs += [MissingET.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    return theChainDef
Exemplo n.º 10
0
def generateChainDefs(chainDict):

    print 'generateHeavyIonChainDefs, input dict', chainDict

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []
    
    for subChainDict in listOfChainDicts:      
        HeavyIon = L2EFChain_HI(subChainDict)
        
        listOfChainDefs += [HeavyIon.generateHLTChainDef()]
        
    if len(listOfChainDefs)>1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]        
    
    return theChainDef
Exemplo n.º 11
0
def generateChainDefs(chainDict):
    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:      
        Cosmic = L2EFChain_CosmicTemplate(subChainDict)
            
        listOfChainDefs += [Cosmic.generateHLTChainDef()]
    
    if len(listOfChainDefs)>1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    #if chainDict["topo"]:
    #    theChainDef = _addTopoInfo(theChainDef,chainDict)    

    return theChainDef
Exemplo n.º 12
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:
        AFP = L2EFChain_afp(subChainDict)

        listOfChainDefs += [AFP.generateHLTChainDef()]

    if len(listOfChainDefs) > 1:
        listOfChainDefs = [mergeChainDefs(listOfChainDefs)]
    else:
        listOfChainDefs = [listOfChainDefs[0]]

    listOfChainDefs.reverse()

    return listOfChainDefs
Exemplo n.º 13
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:
        electron_seq = EgammaSequence(subChainDict)
        log.debug('Egamma Sequence: %s', electron_seq)
        Electron = L2EFChain_e(subChainDict, electron_seq)

        listOfChainDefs += [Electron.generateHLTChainDef()]
    if len(listOfChainDefs) > 1:
        theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    if chainDict["topo"]:
        theChainDef = _addTopoInfo(theChainDef, chainDict)

    return theChainDef
Exemplo n.º 14
0
def generateChainDefs(chainDict):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    for subChainDict in listOfChainDicts:

        MissingET = L2EFChain_met(subChainDict)

        listOfChainDefs += [MissingET.generateHLTChainDef()]

    if "v6" in TriggerFlags.triggerMenuSetup(
    ) or "v5" in TriggerFlags.triggerMenuSetup():
        if len(listOfChainDefs) > 1:
            listOfChainDefs = [mergeChainDefs(listOfChainDefs)]
        else:
            listOfChainDefs = [listOfChainDefs[0]]

    listOfChainDefs.reverse()

    return listOfChainDefs
Exemplo n.º 15
0
def generateChainDefs(chainDict):
    """Delegate the creation of ChainDef instnaces to JetDEf,
    then add in  the top information."""
    
    jetgroup_chain = True
    chainName = chainDict['chainName']
    #print 'processing chain part 1 start', chainName
    theChainDef = generateHLTChainDef(chainDict)
    #print 'processing chain part 2 end', chainName

    listOfChainDicts = splitChainDict(chainDict)

    topoAlgs = []
    for subCD in listOfChainDicts:  
        allTopoAlgs = subCD['chainParts']['topo']
        for ta in allTopoAlgs:
            topoAlgs.append(ta)

    # test new jet algorithm and configuration PS 15/9/2016
    # now use new jet algorthm TrigHLTJetHypo2 as standard,
    # and have the test chains use th run 1 hypo for comaprison PS 04/10/2016

    if ('muvtx' in topoAlgs) or ('llp' in topoAlgs):

        logJet.info("Adding topo to jet chain")
        try:
            theChainDef = _addTopoInfo(theChainDef, chainDict, topoAlgs)
        except Exception as e:
            import traceback
            tb = traceback.format_exc()
            theChainDef = process_exception(e, tb, chainName)

        jetgroup_chain = False

    no_instantiation_flag = 'JETDEF_NO_INSTANTIATION' in os.environ
    dump_chain = 'JETDEF_DEBUG2' in os.environ
    if (not jetgroup_chain) and dump_chain:
        dump_chaindef(chainDict, theChainDef, None, no_instantiation_flag)

    return theChainDef
Exemplo n.º 16
0
    def setup_xeXX(self):

        ##EF only chain, run FEB or topo_cluster
        ##NoAlg at L2
        ##if at a certain point different steps are used at EF, 
        ## we need a way to encode the information of the threshold at both the two steps
        ##could be a dict here, or adding something to the SignatureDictionary
        
        threshold   = int(self.chainPart['threshold'])
        calibration = self.chainPart['calib']
        jetCalib    = self.chainPart['jetCalib']
        L2recoAlg   = self.chainPart['L2recoAlg']
        EFrecoAlg   = self.chainPart['EFrecoAlg']
        EFmuon      = self.chainPart['EFmuonCorr']
        addInfo     = self.chainPart["addInfo"]

        # tcpufit is the run 3 name for pufit
        if EFrecoAlg == "tcpufit":
            EFrecoAlg = "pufit"

        #--------------------------------------
        #obtaining the muon sequences & signature:
        #--------------------------------------
        log.debug("Creating muon sequence")
        
        chain = ['mu8', 'L1_MU6',  [], ["Main"], ['RATE:SingleMuon', 'BW:Muon'], -1]

        theDictFromChainName = DictFromChainName.DictFromChainName()
        muonChainDict = theDictFromChainName.getChainDict(chain)
        listOfChainDicts = splitChainDict(muonChainDict)
        muDict = listOfChainDicts[0]
        muDict['chainCounter'] = 9150
        muonthing = L2EFChain_mu(muDict, False, ['8GeV']) 
        muonSeed = muonthing.EFsignatureList[-1][0][0]

        for seq in muonthing.L2sequenceList:
             self.L2sequenceList += [seq]
        for seq in muonthing.EFsequenceList:
             self.EFsequenceList += [seq]
 

        ########### Imports for hypos and fexes  ###########
        ##L1 MET 
        theL2Fex     = L2MissingET_Fex()
        theL2MuonFex = L2TrigMissingETMuon_Fex()

        mucorr=  '_wMu' if EFmuon else ''          
        ##MET with topo-cluster
        if EFrecoAlg=='tc' or EFrecoAlg=='pueta' or EFrecoAlg=='pufit' or EFrecoAlg=='mht' or EFrecoAlg=='trkmht' or EFrecoAlg=='pufittrack' or EFrecoAlg=='trktc':

            ##Topo-cluster
            if EFrecoAlg=='tc':
                #MET fex
                theEFMETFex     = EFMissingET_Fex_topoClusters()                         
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topocl()        

                #TC hypo
                #mucorr=  '_wMu' if EFmuon else ''      

                if self.chainPart['trigType'] == "xs":
                    theEFMETHypo = EFMetHypoXS_2sided('EFMetHypo_xs_2sided_%i%s' % (threshold, mucorr),ef_thr=float(threshold)*0.1)
                elif  self.chainPart['trigType'] == "te":
                    theEFMETHypo = EFMetHypoTE('EFMetHypo_te%d' % threshold,ef_thr=float(threshold)*GeV)
                else:               
                    theEFMETHypo = EFMetHypoTCXE('EFMetHypo_TC_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV)  
                
            if EFrecoAlg=='pufit':

                doLArH11off=False
                doLArH12off=False
                LArTag=''
                if "LArH11off" in addInfo: 
                    doLArH11off = True
                    LArTag += '_LArH11off'
                if "LArH12off" in addInfo:
                    doLArH12off = True
                    LArTag += '_LArH12off'
                if "METphi" in addInfo: 
                    LArTag += '_METphi'

                jpt_thr = '-1'
                if len(addInfo.split('Jpt'))==2: jpt_thr = addInfo.split('Jpt')[1] 

                if "Jpt" in addInfo:
                    LArTag += '_Jpt'+jpt_thr

                #MET fex
                theEFMETFex = EFMissingET_Fex_topoClustersPUC("EFMissingET_Fex_topoClustersPUC%s"%(addInfo),doLArH11off,doLArH12off,float(jpt_thr)) 
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topoclPUC()
                mucorr= '_wMu' if EFmuon else '' 

                theEFMETHypo = EFMetHypoTCPUCXE('EFMetHypo_TCPUC'+LArTag+'_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV,labelMET=addInfo)


            if EFrecoAlg=='pufittrack':
                calibCorr = ('_{0}'.format(calibration) if calibration != METChainParts_Default['calib'] else '') + ('_{0}'.format(jetCalib) if jetCalib != METChainParts_Default['jetCalib'] else '')
                #MET fex
                #print ("PUFITTRACK XXXXXXXXXX")
                #print (calibCorr)
                theEFMETFex = EFMissingET_Fex_topoClustersTracksPUC("EFMissingET_Fex_topoClustersTracksPUC{0}".format(calibCorr), extraCalib=calibCorr)
                #print ("PUFITTRACK XXXXXXXXXX")
                #print (theEFMETFex)
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topoclPUC()
                #print (theEFMETMuonFex)
                mucorr= '_wMu' if EFmuon else ''
                #theEFMETHypo = EFMetHypoTCTrkPUCXE('EFMetHypo_TCTrkPUC_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV)
                theEFMETHypo = EFMetHypoTCTrkPUCXE('EFMetHypo_TCTrkPUC_xe%s_tc%s%s%s'%(threshold,jetCalib,calibration,mucorr),ef_thr=float(threshold)*GeV, extraCalib=calibCorr)

            ##MET based on trigger jets
            if EFrecoAlg=='mht':
                calibCorr = ('_{0}'.format(calibration) if calibration != METChainParts_Default['calib'] else '') + ('_{0}'.format(jetCalib) if jetCalib != METChainParts_Default['jetCalib'] else '')

                #MET fex
                theEFMETFex = EFMissingET_Fex_Jets("EFMissingET_Fex_Jets{0}".format(calibCorr), extraCalib=calibCorr )
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_Jets("EFTrigMissingETMuon_Fex_Jets{0}".format(calibCorr) )
                #mucorr= '_wMu' if EFmuon else ''
                theEFMETHypo = EFMetHypoJetsXE('EFMetHypo_Jets_xe%s_tc%s%s%s'%(threshold,jetCalib,calibration,mucorr),ef_thr=float(threshold)*GeV, extraCalib=calibCorr)


             ##MET based on trigger jets
            if EFrecoAlg=='trkmht':
                #MET fex                                                                                                                                                    
                theEFMETFex = EFMissingET_Fex_TrackAndJets()                                                                                                                
                #Muon correction fex                                                                                                                                        
                ## this will be added later                                                                                                                                 
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_Jets()                                                                                                            
                #mucorr= '_wMu' if EFmuon else ''                                                                                                                           
                theEFMETHypo = EFMetHypoTrackAndJetsXE('EFMetHypo_TrackAndJets_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV)

                
            if EFrecoAlg=='trktc':
                #MET fex                                                                                                                                                    
                theEFMETFex = EFMissingET_Fex_TrackAndClusters()                                                                                                                
                #Muon correction fex                                                                                                                                        
                ## this will never be used                                                                                                                                 
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topocl()                                                                                                            
                #mucorr= '_wMu' if EFmuon else ''                                                                                                                           
                theEFMETHypo = EFMetHypoTrackAndClustersXE('EFMetHypo_TrackAndClusters_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV)

       
            ##Topo-cluster with Pile-up suppression
            if EFrecoAlg=='pueta':
                #MET fex
                theEFMETFex = EFMissingET_Fex_topoClustersPS() 
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topoclPS()        

                theEFMETHypo = EFMetHypoTCPSXE('EFMetHypo_TCPS_xe%s_tc%s%s'%(threshold,calibration,mucorr),ef_thr=float(threshold)*GeV)



        ##2-SidedNoise Cell
        elif EFrecoAlg=='cell':
            #MET fex
            theEFMETFex = EFMissingET_Fex_2sidednoiseSupp()

            #Muon correction fex
            theEFMETMuonFex = EFTrigMissingETMuon_Fex()        
            
            #Hypo
            if self.chainPart['trigType'] == "xs":
                theEFMETHypo = EFMetHypoXS_2sided('EFMetHypo_xs_2sided_%d%s' % (threshold, mucorr),ef_thr=float(threshold)*0.1)                    
            elif  self.chainPart['trigType'] == "te":
                theEFMETHypo = EFMetHypoTE('EFMetHypo_te%d'% threshold,ef_thr=threshold*GeV)
            else:               
                LArTag=''
                if "LArH11off" in addInfo: LArTag += '_LArH11off'
                if "LArH12off" in addInfo: LArTag += '_LArH12off'
                if "METphi" in addInfo: LArTag += '_METphi'
                theEFMETHypo = EFMetHypoXE('EFMetHypo'+LArTag+'_xe%s%s'%(threshold,mucorr),ef_thr=float(threshold)*GeV)  

        else:
            log.warning("MET EF algorithm not recognised")
        
        #----------------------------------------------------
        # Obtaining the needed jet TEs from the jet code and b-jet code 
        #----------------------------------------------------
        from TriggerJobOpts.TriggerFlags import TriggerFlags
        
        from TriggerMenu.bjet.generateBjetChainDefs import generateChainDefs as generateBjetChainDefs
    
        chain = ['j0_{0}_{1}'.format(calibration, jetCalib), '', [], ["Main"], ['RATE:SingleJet', 'BW:Jet'], -1]

        theDictFromChainName = DictFromChainName.DictFromChainName()
        jetChainDict = theDictFromChainName.getChainDict(chain)
        
        jetChainDict['chainCounter'] = 9151
        jetChainDef = generateHLTChainDef(jetChainDict)
        #This is a dummy b-jet chain, with a threshold at 20 GeV at the uncalibrated scale. It computes the tracks within each jet RoI. 
        #Change the calibration by changing 'nojcalib' to the desired calibration scale. 
        #For pufittrack, we found that the performance was superior using uncalibrated jets. 
        dummy_bjet_chain = ['j20_{0}_{1}_boffperf_split'.format(calibration, jetCalib),  '', [], ["Main"], ['RATE:SingleBJet', 'BW:BJet'], -1]
        bjet_chain_dict = theDictFromChainName.getChainDict(dummy_bjet_chain)
        bjet_chain_dict["chainCounter"] = 9152
        bjet_chain_dict['topoThreshold'] = None
        bjet_chain_def = generateBjetChainDefs(bjet_chain_dict)
       
        #for i in range(3):
        #    m_input[i] = jetChainDef.sequenceList[i]['input']
        #    m_output[i]= jetChainDef.sequenceList[i]['output']
        #    m_algo[i] =jetChainDef.sequenceList[i]['algorithm']

        #obtaining DummyUnseededAllTEAlgo/RoiCreator 
        input0=jetChainDef.sequenceList[0]['input']
        output0 =jetChainDef.sequenceList[0]['output']
        algo0 =jetChainDef.sequenceList[0]['algorithm']
        
        #obtaing TrigCaloCellMaker/FS 
        input1=jetChainDef.sequenceList[1]['input']
        output1 =jetChainDef.sequenceList[1]['output']
        algo1 =jetChainDef.sequenceList[1]['algorithm']
        
        #obtaining TrigCaloClusterMaker
        input2=jetChainDef.sequenceList[2]['input']
        output2 =jetChainDef.sequenceList[2]['output']
        algo2 =jetChainDef.sequenceList[2]['algorithm']

        #obtaining TrigHLTEnergyDensity
        input3=jetChainDef.sequenceList[3]['input']
        output3 =jetChainDef.sequenceList[3]['output']
        algo3 =jetChainDef.sequenceList[3]['algorithm']

        #obtaining TrigHLTJetRecFromCluster
        input4=jetChainDef.sequenceList[4]['input']
        output4 =jetChainDef.sequenceList[4]['output']
        algo4 =jetChainDef.sequenceList[4]['algorithm']

        #---End of obtaining jet TEs------------------------------
                   
        ########### Sequences ###########
        
        #Run L2-like algos only for l2fsperf and L2FS chains
        if L2recoAlg=="l2fsperf" or L2recoAlg=="L2FS":

            ##L1 MET
            self.L2sequenceList += [[ self.l2_input_tes,              [theL2Fex],                      'L2_xe_step1']]
            ##Moun Correction to L1 MET
            self.L2sequenceList += [[ ['L2_xe_step1', muonSeed],  [theL2MuonFex],                  'L2_xe_step2']]

        # --- EF ---                

        # cell preselection (v7 onwards only)
        # First check if we're in a multipart chain (for now assume that we don't apply the preselection for these)
        isMulitpartChain = self.chainPart['chainPartName'] != self.chainDict['chainName']
        if EFrecoAlg != 'cell' and 'v6' not in TriggerFlags.triggerMenuSetup() and 'v5' not in TriggerFlags.triggerMenuSetup() and not isMulitpartChain:
        # if EFrecoAlg != 'cell' and TriggerFlags.run2Config() != '2016' and not isMulitpartChain:
          # a few parameters
          cellPresel_minL1Threshold = 50
          cellPresel_threshold = 50
          # work out what the L1 threshold is
          import re
          match = re.match(r"L1_XE(\d+)", self.chainDict['L1item'])
          if match:
            if int(match.group(1) ) >= cellPresel_minL1Threshold:
              cellPreselectionFex = EFMissingET_Fex_2sidednoiseSupp()
              cellPreselectionMuonFex = EFTrigMissingETMuon_Fex()
              cellPreselectionHypo = EFMetHypoXE('EFMetHypo_xe{0}_presel'.format(cellPresel_threshold), ef_thr = float(cellPresel_threshold) * GeV)

              self.EFsequenceList += [[ [''], [cellPreselectionFex], 'EF_xe{0}_step1'.format(cellPresel_threshold) ]]
              self.EFsequenceList += [[ ['EF_xe{0}_step1'.format(cellPresel_threshold), muonSeed], [cellPreselectionMuonFex, cellPreselectionHypo], 'EF_xe{0}_step2'.format(cellPresel_threshold) ]]
              
              self.EFsignatureList += [ [['EF_xe{0}_step1'.format(cellPresel_threshold)]] ]
              self.EFsignatureList += [ [['EF_xe{0}_step2'.format(cellPresel_threshold)]] ]
          else:
            log.info("Pure MET chain doesn't have an L1_XE seed! Will not apply the cell preselection")


        #topocluster
        if EFrecoAlg=='tc' or EFrecoAlg=='pueta' or EFrecoAlg=='pufit':
            self.EFsequenceList +=[[ input0,algo0,  output0 ]]            
            self.EFsequenceList +=[[ input1,algo1,  output1 ]]            
            self.EFsequenceList +=[[ input2,algo2,  output2 ]]           
            self.EFsequenceList +=[[ input3,algo3,  output3 ]]            
            self.EFsequenceList +=[[ input4,algo4,  output4 ]]
            self.EFsequenceList +=[[ [output3,output4],          [theEFMETFex],  'EF_xe_step1' ]]            
            self.EFsequenceList +=[[ ['EF_xe_step1',muonSeed],     [theEFMETMuonFex, theEFMETHypo],  'EF_xe_step2' ]]


        elif EFrecoAlg=='pufittrack':
            def makelist(x):
                return x if isinstance(x, list) else [x]
            self.EFsequenceList += [ [ x['input'], makelist(x['algorithm']), x['output'] ] for x in bjet_chain_def.sequenceList[:-2] ]
#            for x in bjet_chain_def.sequenceList[:-2]:
#                print (x)
#            print (self.EFsequenceList[4][2], "Clusters, output EF_FSTopoClusters")
#            print (self.EFsequenceList[6][2], "Jets, output EF_8389636500743033767_jetrec_a4tclcwnojcalibFS")
#            print (self.EFsequenceList[-1][2], "Tracks, output HLT_j20_eta_jsplit_IDTrig")
#            print (self.EFsequenceList[-5][2], "Vertex, output HLT_superIDTrig_prmVtx")
#            Fill the sequence with clusters, jets, tracks, vertices 
            self.EFsequenceList += [[ [self.EFsequenceList[4][2],self.EFsequenceList[6][2],self.EFsequenceList[-1][2],self.EFsequenceList[-5][2]], [theEFMETFex], 'EF_xe_step1' ]]  
            self.EFsequenceList += [[ ['EF_xe_step1',muonSeed], [theEFMETMuonFex, theEFMETHypo], 'EF_xe_step2' ]]

        #trigger-jet based MET
        elif EFrecoAlg=='mht': 
            self.EFsequenceList +=[[ input0,algo0,  output0 ]]            
            self.EFsequenceList +=[[ input1,algo1,  output1 ]]            
            self.EFsequenceList +=[[ input2,algo2,  output2 ]]           
            self.EFsequenceList +=[[ input3,algo3,  output3 ]]            
            self.EFsequenceList +=[[ input4,algo4,  output4 ]]            
            self.EFsequenceList +=[[ [output4], [theEFMETFex], 'EF_xe_step1' ]]
            self.EFsequenceList +=[[ ['EF_xe_step1',muonSeed], [theEFMETMuonFex, theEFMETHypo], 'EF_xe_step2' ]]
            if "FStracks" in addInfo:
                from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
                trk_algs = TrigInDetSequence("FullScan", "fullScan", "IDTrig", sequenceFlavour=["FTF"]).getSequence()
                print (trk_algs[0])
                dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
                self.EFsequenceList +=[[ [''], [dummyAlg]+trk_algs[0], 'EF_xe_step3' ]]

        elif EFrecoAlg=='trkmht':
            self.EFsequenceList +=[[ input0,algo0,  output0 ]]
            self.EFsequenceList +=[[ input1,algo1,  output1 ]]
            self.EFsequenceList +=[[ input2,algo2,  output2 ]]
            self.EFsequenceList +=[[ input3,algo3,  output3 ]]
            self.EFsequenceList +=[[ input4,algo4,  output4 ]]

            #adding FullScan tracks
            from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
            trk_algs = TrigInDetSequence("FullScan", "fullScan", "IDTrig", sequenceFlavour=["FTF"]).getSequence()
            dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
            self.EFsequenceList +=[[ [''], [dummyAlg]+trk_algs[0], 'EF_xe_step0' ]]

            self.EFsequenceList +=[[ [output4,'EF_xe_step0',muonSeed], [theEFMETFex], 'EF_xe_step1' ]]                                                                               
            self.EFsequenceList +=[[ ['EF_xe_step1',muonSeed], [theEFMETMuonFex, theEFMETHypo], 'EF_xe_step2' ]]   


        elif EFrecoAlg=='trktc':
            self.EFsequenceList +=[[ input0,algo0,  output0 ]]
            self.EFsequenceList +=[[ input1,algo1,  output1 ]]
            self.EFsequenceList +=[[ input2,algo2,  output2 ]]
            self.EFsequenceList +=[[ input3,algo3,  output3 ]]
            #self.EFsequenceList +=[[ input4,algo4,  output4 ]]

            ##adding FullScan tracks
            from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
            trk_algs = TrigInDetSequence("FullScan", "fullScan", "IDTrig", sequenceFlavour=["FTF"]).getSequence()
            dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
            self.EFsequenceList +=[[ [''], [dummyAlg]+trk_algs[0], 'EF_xe_step0' ]]

            self.EFsequenceList +=[[ [output3,'EF_xe_step0',muonSeed], [theEFMETFex], 'EF_xe_step1' ]]                                                                               
            self.EFsequenceList +=[[ ['EF_xe_step1',muonSeed], [theEFMETMuonFex, theEFMETHypo], 'EF_xe_step2' ]]   


        #cell based MET
        elif EFrecoAlg=='cell':
            self.EFsequenceList +=[[ [''],          [theEFMETFex],  'EF_xe_step1' ]]  
            self.EFsequenceList +=[[ ['EF_xe_step1',muonSeed],     [theEFMETMuonFex, theEFMETHypo],  'EF_xe_step2' ]]
            
            
        ########### Signatures ###########
        if L2recoAlg=="l2fsperf" or  L2recoAlg=="L2FS" :
            self.L2signatureList += [ [['L2_xe_step1']] ]
            self.L2signatureList += [ [['L2_xe_step2']] ]

        if EFrecoAlg=="trkmht" or EFrecoAlg=="trktc" :
            self.EFsignatureList += [ [['EF_xe_step0']] ]   

        self.EFsignatureList += [ [['EF_xe_step1']] ]
        self.EFsignatureList += [ [['EF_xe_step2']] ]
        if "FStracks" in addInfo:
            self.EFsignatureList += [ [['EF_xe_step3']] ]
        

        ########### TE renaming ###########
        self.TErenamingDict = {}
            
        if L2recoAlg=="l2fsperf" or  L2recoAlg=="L2FS" :
            self.TErenamingDict['L2_xe_step1']= mergeRemovingOverlap('L2_', self.sig_id_noMult+'_step1')
            self.TErenamingDict['L2_xe_step2']= mergeRemovingOverlap('L2_', self.sig_id_noMult+'_step2')

        if EFrecoAlg=='trkmht' or EFrecoAlg=='trktc':
            self.TErenamingDict['EF_xe_step0']= mergeRemovingOverlap('EF_', self.sig_id_noMult+"_step0")                                                                    
        #if EFrecoAlg=='pufittrack':
        #    self.TErenamingDict['EF_xe_step0']= mergeRemovingOverlap('EF_', self.sig_id_noMult+"_step0")
            
        self.TErenamingDict['EF_xe_step1']= mergeRemovingOverlap('EF_', self.sig_id_noMult+'_step1')
        if "FStracks" in addInfo:
            self.TErenamingDict['EF_xe_step2']= mergeRemovingOverlap('EF_', self.sig_id_noMult+"_step2")
            self.TErenamingDict['EF_xe_step3']= mergeRemovingOverlap('EF_', self.sig_id_noMult)
        else:
            self.TErenamingDict['EF_xe_step2']= mergeRemovingOverlap('EF_', self.sig_id_noMult)
Exemplo n.º 17
0
def generateChainDefs(chainDict, thisIsBphysChain=False):

    listOfChainDicts = splitChainDict(chainDict)
    listOfChainDefs = []

    asymDiMuonChain = False
    if (len(listOfChainDicts) > 1): asymDiMuonChain = True
    else: asymDiMuonChain = False

    asymMultiMuonChain = False
    if (len(listOfChainDicts) > 1 and "noL1" not in chainDict["chainName"]
            and sum(
                map(int, [
                    subChainDict["chainParts"]["multiplicity"]
                    for subChainDict in listOfChainDicts
                ])) > 1):
        asymMultiMuonChain = True

    modifyNscanInputTE = False
    modifyCalotagInputTE = False

    for subChainDict in listOfChainDicts:
        if "IdTest" in subChainDict["chainParts"]["addInfo"]:
            Muon = L2EFChain_mu_IdTest(subChainDict, asymDiMuonChain)
        else:
            #If FS muon, needs total counts of muons in chain
            if 'noL1' in subChainDict["chainParts"]["extra"]:
                AllMuons = GetAllMuonThresholds(chainDict)
            elif subChainDict["chainParts"][
                    "reccalibInfo"] == "btrk" or 'btrk' in subChainDict[
                        "chainParts"]["extra"]:
                AllMuons = GetAllMuonThresholds(chainDict)
            else:
                AllMuons = []

            Muon = L2EFChain_mu(subChainDict, asymDiMuonChain,
                                asymMultiMuonChain, AllMuons, thisIsBphysChain)

        listOfChainDefs += [Muon.generateHLTChainDef()]

        #only needed for nscan
        if "nscan" in subChainDict["chainParts"]['FSinfo']:
            modifyNscanInputTE = True
        if "calotag" in subChainDict["chainParts"]['FSinfo']:
            modifyCalotagInputTE = True

    if len(listOfChainDefs) > 1:
        if ('mergingStrategy' in chainDict.keys()):
            theChainDef = mergeChainDefs(listOfChainDefs,
                                         chainDict["mergingStrategy"],
                                         chainDict["mergingOffset"])
        else:
            theChainDef = mergeChainDefs(listOfChainDefs)
    else:
        theChainDef = listOfChainDefs[0]

    # needed for nscan to replace the placeholder TE with the L2TE of the other chain
    if (modifyNscanInputTE == True):
        theChainDef = _modifyTEinChainDef(theChainDef, chainDict)
    if (modifyCalotagInputTE == True):
        theChainDef = _modifyTEinChainDef(theChainDef, chainDict)

    #if chainDict["topo"]:
    #    theChainDef = _addTopoInfo(theChainDef,chainDict)

    if (len(listOfChainDicts) > 1):
        nomucomb_asymmetric = True
        for ii in range(len(listOfChainDicts)):
            if listOfChainDicts[ii]['chainParts']['reccalibInfo'] != 'nomucomb':
                nomucomb_asymmetric = False
        if nomucomb_asymmetric == True:
            theChainDef = _AsymmChainConfig(theChainDef, chainDict)

    return theChainDef
Exemplo n.º 18
0
def _AsymmChainConfig(theChainDef, chainDict):
    maxL2SignatureIndex = -1
    for signatureIndex, signature in enumerate(theChainDef.signatureList):
        print "DEBUG1 : check0 : ", signature
        if signature['listOfTriggerElements'][0][0:2] == "L2":
            maxL2SignatureIndex = max(maxL2SignatureIndex, signatureIndex)

    inputTEsL2 = theChainDef.signatureList[maxL2SignatureIndex][
        'listOfTriggerElements']
    inputTEsEF = theChainDef.signatureList[-1]['listOfTriggerElements']

    idmultiArr = []
    listOfChainDicts = splitChainDict(chainDict)
    totalmulti = 0
    for subChainDict in listOfChainDicts:
        if subChainDict['chainParts']['reccalibInfo'] == "nomucomb":
            totalmulti += int(subChainDict['chainParts']['multiplicity'])
            idmultiArr += [
                "%03i_AA_%03i" %
                (int(subChainDict['chainParts']['threshold']),
                 int(subChainDict['chainParts']['multiplicity']))
            ]

    idmultiArr.sort()
    totalmulti_lowest = 0
    totalmulti_2ndlow = 0
    for ii in range(len(idmultiArr)):
        multi = idmultiArr[ii].split("_AA_")[1]
        totalmulti_lowest += int(multi)
        if ii > 0: totalmulti_2ndlow += int(multi)

    idmultiArr2 = []
    for ii in range(len(idmultiArr)):
        thre = idmultiArr[ii].split("_AA_")[0]
        multi = idmultiArr[ii].split("_AA_")[1]
        if ii == 0: idmultiArr2 += ["%ipt%i" % (totalmulti_lowest, int(thre))]
        if ii == 1: idmultiArr2 += ["%ipt%i" % (totalmulti_2ndlow, int(thre))]
        if ii == 2: idmultiArr2 += ["%ipt%i" % (int(multi), int(thre))]
        if ii > 2: print "ERROR : not supported"

    idmulti = "_".join(idmultiArr2)

    from TrigMuonHypo.TrigMuonHypoConfig import TrigMuonIDTrackMultiHypoConfig
    theTrigMuonIDTrackMultiHypoConfig_FTF = TrigMuonIDTrackMultiHypoConfig(
        idmulti, "FTF")
    theTrigMuonIDTrackMultiHypoConfig_Muon = TrigMuonIDTrackMultiHypoConfig(
        idmulti, "Muon")

    L2TEname = "L2_idtrkmulti_" + idmulti + "_nomucomb_" + chainDict['L1item']

    theChainDef.addSequence([theTrigMuonIDTrackMultiHypoConfig_FTF],
                            inputTEsL2, L2TEname)
    theChainDef.addSignatureL2([L2TEname])

    EFTEname = "EF_mutrkmulti_" + idmulti + "_nomucomb_" + chainDict['L1item']
    theChainDef.addSequence([theTrigMuonIDTrackMultiHypoConfig_Muon],
                            inputTEsEF, EFTEname)
    theChainDef.addSignature(
        theChainDef.signatureList[-1]['signature_counter'] + 1, [EFTEname])

    return theChainDef
Exemplo n.º 19
0
    def setup_xeXX(self):

        ##EF only chain, run FEB or topo_cluster
        ##NoAlg at L2
        ##if at a certain point different steps are used at EF,
        ## we need a way to encode the information of the threshold at both the two steps
        ##could be a dict here, or adding something to the SignatureDictionary

        threshold = int(self.chainPart['threshold'])
        calibration = self.chainPart['calib']
        jetCalib = self.chainPart['jetCalib']
        L2recoAlg = self.chainPart['L2recoAlg']
        EFrecoAlg = self.chainPart['EFrecoAlg']
        EFmuon = self.chainPart['EFmuonCorr']
        addInfo = self.chainPart["addInfo"]

        #--------------------------------------
        #obtaining the muon sequences & signature:
        #--------------------------------------
        log.debug("Creating muon sequence")

        chain = [
            'mu8', 'L1_MU6', [], ["Main"], ['RATE:SingleMuon', 'BW:Muon'], -1
        ]

        theDictFromChainName = DictFromChainName.DictFromChainName()
        muonChainDict = theDictFromChainName.getChainDict(chain)
        listOfChainDicts = splitChainDict(muonChainDict)
        muDict = listOfChainDicts[0]
        muDict['chainCounter'] = 9150
        muonthing = L2EFChain_mu(muDict, False, ['8GeV'])
        muonSeed = muonthing.EFsignatureList[-1][0][0]

        for seq in muonthing.L2sequenceList:
            self.L2sequenceList += [seq]
        for seq in muonthing.EFsequenceList:
            self.EFsequenceList += [seq]

        ########### Imports for hypos and fexes  ###########
        ##L1 MET
        theL2Fex = L2MissingET_Fex()
        theL2MuonFex = L2TrigMissingETMuon_Fex()

        mucorr = '_wMu' if EFmuon else ''
        ##MET with topo-cluster
        if EFrecoAlg == 'tc' or EFrecoAlg == 'pueta' or EFrecoAlg == 'pufit' or EFrecoAlg == 'mht' or EFrecoAlg == 'trkmht':

            ##Topo-cluster
            if EFrecoAlg == 'tc':
                #MET fex
                theEFMETFex = EFMissingET_Fex_topoClusters()
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topocl()

                #TC hypo
                #mucorr=  '_wMu' if EFmuon else ''

                if self.chainPart['trigType'] == "xs":
                    theEFMETHypo = EFMetHypoXS_2sided(
                        'EFMetHypo_xs_2sided_%i%s' % (threshold, mucorr),
                        ef_thr=float(threshold) * 0.1)
                elif self.chainPart['trigType'] == "te":
                    theEFMETHypo = EFMetHypoTE('EFMetHypo_te%d' % threshold,
                                               ef_thr=float(threshold) * GeV)
                else:
                    theEFMETHypo = EFMetHypoTCXE(
                        'EFMetHypo_TC_xe%s_tc%s%s' %
                        (threshold, calibration, mucorr),
                        ef_thr=float(threshold) * GeV)

            if EFrecoAlg == 'pufit':
                #MET fex
                theEFMETFex = EFMissingET_Fex_topoClustersPUC()
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topoclPUC()
                mucorr = '_wMu' if EFmuon else ''
                theEFMETHypo = EFMetHypoTCPUCXE(
                    'EFMetHypo_TCPUC_xe%s_tc%s%s' %
                    (threshold, calibration, mucorr),
                    ef_thr=float(threshold) * GeV)

            ##MET based on trigger jets
            if EFrecoAlg == 'mht':
                calibCorr = ('_{0}'.format(calibration) if
                             calibration != METChainParts_Default['calib'] else
                             '') + ('_{0}'.format(jetCalib) if jetCalib !=
                                    METChainParts_Default['jetCalib'] else '')

                #MET fex
                theEFMETFex = EFMissingET_Fex_Jets(
                    "EFMissingET_Fex_Jets{0}".format(calibCorr),
                    extraCalib=calibCorr)
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_Jets(
                    "EFTrigMissingETMuon_Fex_Jets{0}".format(calibCorr))
                #mucorr= '_wMu' if EFmuon else ''
                theEFMETHypo = EFMetHypoJetsXE(
                    'EFMetHypo_Jets_xe%s_tc%s%s%s' %
                    (threshold, jetCalib, calibration, mucorr),
                    ef_thr=float(threshold) * GeV,
                    extraCalib=calibCorr)

            ##MET based on trigger jets
            if EFrecoAlg == 'trkmht':
                #MET fex
                if "FTK" in addInfo:
                    theEFMETFex = EFMissingET_Fex_FTKTrackAndJets()
                else:
                    theEFMETFex = EFMissingET_Fex_TrackAndJets()
                #Muon correction fex
                ## this will be added later
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_Jets()
                #mucorr= '_wMu' if EFmuon else ''
                if "FTK" in addInfo:
                    theEFMETHypo = EFMetHypoFTKTrackAndJetsXE(
                        'EFMetHypo_FTKTrackAndJets_xe%s_tc%s%s' %
                        (threshold, calibration, mucorr),
                        ef_thr=float(threshold) * GeV)
                else:
                    theEFMETHypo = EFMetHypoTrackAndJetsXE(
                        'EFMetHypo_TrackAndJets_xe%s_tc%s%s' %
                        (threshold, calibration, mucorr),
                        ef_thr=float(threshold) * GeV)

            ##Topo-cluster with Pile-up suppression
            if EFrecoAlg == 'pueta':
                #MET fex
                theEFMETFex = EFMissingET_Fex_topoClustersPS()
                #Muon correction fex
                theEFMETMuonFex = EFTrigMissingETMuon_Fex_topoclPS()

                theEFMETHypo = EFMetHypoTCPSXE(
                    'EFMetHypo_TCPS_xe%s_tc%s%s' %
                    (threshold, calibration, mucorr),
                    ef_thr=float(threshold) * GeV)

        ##2-SidedNoise Cell
        elif EFrecoAlg == 'cell':
            #MET fex
            theEFMETFex = EFMissingET_Fex_2sidednoiseSupp()

            #Muon correction fex
            theEFMETMuonFex = EFTrigMissingETMuon_Fex()

            #Hypo
            if self.chainPart['trigType'] == "xs":
                theEFMETHypo = EFMetHypoXS_2sided(
                    'EFMetHypo_xs_2sided_%d%s' % (threshold, mucorr),
                    ef_thr=float(threshold) * 0.1)
            elif self.chainPart['trigType'] == "te":
                theEFMETHypo = EFMetHypoTE('EFMetHypo_te%d' % threshold,
                                           ef_thr=threshold * GeV)
            else:
                theEFMETHypo = EFMetHypoXE('EFMetHypo_xe%s%s' %
                                           (threshold, mucorr),
                                           ef_thr=float(threshold) * GeV)

        else:
            log.warning("MET EF algorithm not recognised")

        #----------------------------------------------------
        # Obtaining the needed jet TEs from the jet code
        #----------------------------------------------------
        from TriggerJobOpts.TriggerFlags import TriggerFlags

        chain = [
            'j0_{0}_{1}'.format(calibration, jetCalib), '', [], ["Main"],
            ['RATE:SingleJet', 'BW:Jet'], -1
        ]

        theDictFromChainName = DictFromChainName.DictFromChainName()
        jetChainDict = theDictFromChainName.getChainDict(chain)

        jetChainDict['chainCounter'] = 9151
        jetChainDef = generateHLTChainDef(jetChainDict)

        #for i in range(3):
        #    m_input[i] = jetChainDef.sequenceList[i]['input']
        #    m_output[i]= jetChainDef.sequenceList[i]['output']
        #    m_algo[i] =jetChainDef.sequenceList[i]['algorithm']

        #obtaining DummyUnseededAllTEAlgo/RoiCreator
        input0 = jetChainDef.sequenceList[0]['input']
        output0 = jetChainDef.sequenceList[0]['output']
        algo0 = jetChainDef.sequenceList[0]['algorithm']

        #obtaing TrigCaloCellMaker/FS
        input1 = jetChainDef.sequenceList[1]['input']
        output1 = jetChainDef.sequenceList[1]['output']
        algo1 = jetChainDef.sequenceList[1]['algorithm']

        #obtaining TrigCaloClusterMaker
        input2 = jetChainDef.sequenceList[2]['input']
        output2 = jetChainDef.sequenceList[2]['output']
        algo2 = jetChainDef.sequenceList[2]['algorithm']

        #obtaining TrigHLTEnergyDensity
        input3 = jetChainDef.sequenceList[3]['input']
        output3 = jetChainDef.sequenceList[3]['output']
        algo3 = jetChainDef.sequenceList[3]['algorithm']

        #obtaining TrigHLTJetRecFromCluster
        input4 = jetChainDef.sequenceList[4]['input']
        output4 = jetChainDef.sequenceList[4]['output']
        algo4 = jetChainDef.sequenceList[4]['algorithm']

        #---End of obtaining jet TEs------------------------------

        ########### Sequences ###########

        #Run L2-like algos only for l2fsperf and L2FS chains
        if L2recoAlg == "l2fsperf" or L2recoAlg == "L2FS":

            ##L1 MET
            self.L2sequenceList += [[
                self.l2_input_tes, [theL2Fex], 'L2_xe_step1'
            ]]
            ##Moun Correction to L1 MET
            self.L2sequenceList += [[['L2_xe_step1', muonSeed], [theL2MuonFex],
                                     'L2_xe_step2']]

        # --- EF ---

        # cell preselection (v7 onwards only)
        # First check if we're in a multipart chain (for now assume that we don't apply the preselection for these)
        isMulitpartChain = self.chainPart['chainPartName'] != self.chainDict[
            'chainName']
        if EFrecoAlg != 'cell' and 'v6' not in TriggerFlags.triggerMenuSetup(
        ) and 'v5' not in TriggerFlags.triggerMenuSetup(
        ) and not isMulitpartChain:
            # if EFrecoAlg != 'cell' and TriggerFlags.run2Config() != '2016' and not isMulitpartChain:
            # a few parameters
            cellPresel_minL1Threshold = 50
            cellPresel_threshold = 50
            # work out what the L1 threshold is
            import re
            match = re.match("L1_XE(\d+)", self.chainDict['L1item'])
            if match:
                if int(match.group(1)) >= cellPresel_minL1Threshold:
                    cellPreselectionFex = EFMissingET_Fex_2sidednoiseSupp()
                    cellPreselectionMuonFex = EFTrigMissingETMuon_Fex()
                    cellPreselectionHypo = EFMetHypoXE(
                        'EFMetHypo_xe{0}_presel'.format(cellPresel_threshold),
                        ef_thr=float(cellPresel_threshold) * GeV)

                    self.EFsequenceList += [[[''], [
                        cellPreselectionFex
                    ], 'EF_xe{0}_step1'.format(cellPresel_threshold)]]
                    self.EFsequenceList += [[[
                        'EF_xe{0}_step1'.format(cellPresel_threshold), muonSeed
                    ], [cellPreselectionMuonFex, cellPreselectionHypo
                        ], 'EF_xe{0}_step2'.format(cellPresel_threshold)]]

                    self.EFsignatureList += [[[
                        'EF_xe{0}_step1'.format(cellPresel_threshold)
                    ]]]
                    self.EFsignatureList += [[[
                        'EF_xe{0}_step2'.format(cellPresel_threshold)
                    ]]]
            else:
                log.info(
                    "Pure MET chain doesn't have an L1_XE seed! Will not apply the cell preselection"
                )

        #topocluster
        if EFrecoAlg == 'tc' or EFrecoAlg == 'pueta' or EFrecoAlg == 'pufit':
            self.EFsequenceList += [[input0, algo0, output0]]
            self.EFsequenceList += [[input1, algo1, output1]]
            self.EFsequenceList += [[input2, algo2, output2]]
            self.EFsequenceList += [[input3, algo3, output3]]
            self.EFsequenceList += [[[output3], [theEFMETFex], 'EF_xe_step1']]
            self.EFsequenceList += [[['EF_xe_step1', muonSeed],
                                     [theEFMETMuonFex, theEFMETHypo],
                                     'EF_xe_step2']]

        #trigger-jet based MET
        elif EFrecoAlg == 'mht':
            self.EFsequenceList += [[input0, algo0, output0]]
            self.EFsequenceList += [[input1, algo1, output1]]
            self.EFsequenceList += [[input2, algo2, output2]]
            self.EFsequenceList += [[input3, algo3, output3]]
            self.EFsequenceList += [[input4, algo4, output4]]
            self.EFsequenceList += [[[output4], [theEFMETFex], 'EF_xe_step1']]
            self.EFsequenceList += [[['EF_xe_step1', muonSeed],
                                     [theEFMETMuonFex, theEFMETHypo],
                                     'EF_xe_step2']]
            if "FStracks" in addInfo:
                from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
                trk_algs = TrigInDetSequence("FullScan",
                                             "fullScan",
                                             "IDTrig",
                                             sequenceFlavour=["FTF"
                                                              ]).getSequence()
                print "XXXXXXXXXXXXXXXXXX"
                print trk_algs[0]
                dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
                self.EFsequenceList += [[[''], [dummyAlg] + trk_algs[0],
                                         'EF_xe_step3']]

        elif EFrecoAlg == 'trkmht':
            self.EFsequenceList += [[input0, algo0, output0]]
            self.EFsequenceList += [[input1, algo1, output1]]
            self.EFsequenceList += [[input2, algo2, output2]]
            self.EFsequenceList += [[input3, algo3, output3]]
            self.EFsequenceList += [[input4, algo4, output4]]

            ##adding FTK tracks in the sequence,
            ##if not, adding FullScan tracks
            if "FTK" in addInfo:
                from TrigInDetConf.TrigInDetFTKSequence import TrigInDetFTKSequence
                trk_algs = TrigInDetFTKSequence(
                    "FullScan", "fullScan",
                    sequenceFlavour=["FTKVtx"]).getSequence()
                dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
                self.EFsequenceList += [[[''], [dummyAlg] + trk_algs[0] +
                                         trk_algs[1], 'EF_xe_step0']]

            else:
                from TrigInDetConf.TrigInDetSequence import TrigInDetSequence
                trk_algs = TrigInDetSequence("FullScan",
                                             "fullScan",
                                             "IDTrig",
                                             sequenceFlavour=["FTF"
                                                              ]).getSequence()
                dummyAlg = PESA__DummyUnseededAllTEAlgo("EF_DummyFEX_xe")
                self.EFsequenceList += [[[''], [dummyAlg] + trk_algs[0],
                                         'EF_xe_step0']]

            self.EFsequenceList += [[[output4, 'EF_xe_step0', muonSeed],
                                     [theEFMETFex], 'EF_xe_step1']]
            self.EFsequenceList += [[['EF_xe_step1', muonSeed],
                                     [theEFMETMuonFex, theEFMETHypo],
                                     'EF_xe_step2']]

        #cell based MET
        elif EFrecoAlg == 'cell':
            self.EFsequenceList += [[[''], [theEFMETFex], 'EF_xe_step1']]
            self.EFsequenceList += [[['EF_xe_step1', muonSeed],
                                     [theEFMETMuonFex, theEFMETHypo],
                                     'EF_xe_step2']]

        ########### Signatures ###########
        if L2recoAlg == "l2fsperf" or L2recoAlg == "L2FS":
            self.L2signatureList += [[['L2_xe_step1']]]
            self.L2signatureList += [[['L2_xe_step2']]]

        if EFrecoAlg == "trkmht":
            self.EFsignatureList += [[['EF_xe_step0']]]

        self.EFsignatureList += [[['EF_xe_step1']]]
        self.EFsignatureList += [[['EF_xe_step2']]]
        if "FStracks" in addInfo:
            self.EFsignatureList += [[['EF_xe_step3']]]

        ########### TE renaming ###########
        self.TErenamingDict = {}

        if L2recoAlg == "l2fsperf" or L2recoAlg == "L2FS":
            self.TErenamingDict['L2_xe_step1'] = mergeRemovingOverlap(
                'L2_', self.sig_id_noMult + '_step1')
            self.TErenamingDict['L2_xe_step2'] = mergeRemovingOverlap(
                'L2_', self.sig_id_noMult + '_step2')

        if EFrecoAlg == 'trkmht':
            self.TErenamingDict['EF_xe_step0'] = mergeRemovingOverlap(
                'EF_', self.sig_id_noMult + "_step0")

        self.TErenamingDict['EF_xe_step1'] = mergeRemovingOverlap(
            'EF_', self.sig_id_noMult + '_step1')
        if "FStracks" in addInfo:
            self.TErenamingDict['EF_xe_step2'] = mergeRemovingOverlap(
                'EF_', self.sig_id_noMult + "_step2")
            self.TErenamingDict['EF_xe_step3'] = mergeRemovingOverlap(
                'EF_', self.sig_id_noMult)
        else:
            self.TErenamingDict['EF_xe_step2'] = mergeRemovingOverlap(
                'EF_', self.sig_id_noMult)
Exemplo n.º 20
0
def generateChainDefs(chainDict):
    #log.setLevel(0)
    log.debug("In generateChainDefs")

    chainDict_orig = deepcopy(chainDict)
    # PrettyPrinter is rather expensive so make sure we don't invoke it unless in DEBUG
    if log.isEnabledFor(logging.DEBUG):
        log.debug("Initial b-jet chainDict: \n %s", pp.pformat(chainDict))

    #----------------------------------------------------------------------------
    # --- preparing the dictionary for jet chain generation ---
    n_chainParts = len(chainDict['chainParts'])

    if (n_chainParts > 1):
        jetchainDict = _prepareJetChainDict(chainDict)
    elif (n_chainParts == 1):
        log.debug('Only one chain part dictionary for this chain.')
        jetchainDict = chainDict
    else:
        raise RuntimeError('No chain parts found for chain %s' %
                           (chainDict['chainName']))
    #----------------------------------------------------------------------------

    #----------------------------------------------------------------------------
    # --- obtain jet chain def used as inputTE for first btag sequence ---
    thejThrChainDef = get_j35_ChainDef()
    if ('j0_bperf' in chainDict['chainName']):
        thejThrChainDef['L1item'] = 'L1_J10'
        thejThrChainDef['chainName'] = 'j0'
        for part in thejThrChainDef['chainParts']:
            part['chainPartName'] = 'j0'
            part['threshold'] = '0'
        if ('L1MU10' in chainDict['chainName']):
            thejThrChainDef['L1item'] = 'L1_MU10'
        if ('L1RD0_EMPTY' in chainDict['chainName']):
            thejThrChainDef['L1item'] = 'L1_RD0_EMPTY'

    theBJChainDef = genJetChainDefs(thejThrChainDef)
    log.debug("ChainDef for b-jet chain: \n %s", theBJChainDef)
    #----------------------------------------------------------------------------

    #----------------------------------------------------------------------------
    # --- build the jet chain, then pass JetChainDef and bjetchainDictionaries to build bjet chains ---
    log.debug("getting the Jet Chain Defs")
    theAllJetChainDef = genJetChainDefs(jetchainDict)
    log.debug("Jet ChainDef for b-jet chain: \n %s", theAllJetChainDef)
    #----------------------------------------------------------------------------

    #----------------------------------------------------------------------------
    # --- now merge chain defs so that last TE is from jet serving as input to bjet seq ---
    # DO NOT CHANGE THE MERGING ORDER PLEASE, OTHERWISE WRONG INPUT IS SELECTED
    log.debug("Trying to merge chainDef for b-jet chain: \n ")
    theJetChainDef = mergeChainDefs([theAllJetChainDef, theBJChainDef],
                                    'serial', -1, False)
    log.debug("Merged chainDef for b-jet chain: \n %s", theJetChainDef)
    #----------------------------------------------------------------------------

    #----------------------------------------------------------------------------
    # --- filtering b-tagged jets chainParts ---
    listofChainDicts = splitChainDict(chainDict_orig)
    if log.isEnabledFor(logging.DEBUG):
        log.debug("Split b-jet chainDict: \n %s", pp.pformat(listofChainDicts))

    bjetchainDicts = [
        cdict for cdict in listofChainDicts if cdict['chainParts']['bTag']
    ]
    if log.isEnabledFor(logging.DEBUG):
        log.debug("Final b-jet chainDict: \n %s", pp.pformat(bjetchainDicts))

    #
    # Basic properties of the chain, these are used to decide if we use the new AllTE configuration
    #
    isSplitChain = (not chainDict['chainName'].find("split") == -1)
    isRunITagger = (not chainDict['chainName'].find("btight") == -1
                    or not chainDict['chainName'].find("bmedium") == -1
                    or not chainDict['chainName'].find("bloose") == -1)
    is2015Tagger = (not chainDict['chainName'].find("bmv2c20") == -1
                    or not chainDict['chainName'].find("bperf") == -1)
    isMuDr = (not chainDict['chainName'].find("mu") == -1
              and not chainDict['chainName'].find("_dr") == -1)
    isMuDz = (not chainDict['chainName'].find("mu") == -1
              and not chainDict['chainName'].find("_dz") == -1)
    isIsoLep = (not chainDict['chainName'].find("ivarmedium") == -1
                or not chainDict['chainName'].find("ivarloose") == -1)
    isSingleJet = ((len(chainDict['chainParts']) == 1)
                   and (int(chainDict['chainParts'][0]['multiplicity']) == 1))

    #
    # Only run the All TE on split chains
    #
    doAllTEConfig = isSplitChain

    #
    # Do not need to run AllTE on single jet chains
    #
    if isSingleJet: doAllTEConfig = False

    #
    #  New AllTE config currently supported on new mv2c10 taggers
    #
    if isRunITagger or is2015Tagger: doAllTEConfig = False

    #
    # Need all the ouput bjet TEs to properly match to muons
    #  so dont use all TE here either
    #
    if isMuDz or isMuDr or isIsoLep: doAllTEConfig = False

    if doAllTEConfig:
        log.debug("Doing new buildBjetChainsAllTE")
        theFinalChainDef = buildBjetChainsAllTE(theJetChainDef, bjetchainDicts)
    else:
        log.debug("Doing buildBjetChains")
        theListOfChainDefs = []
        for subChainDict in bjetchainDicts:
            theJetChainDef1 = deepcopy(theJetChainDef)
            theBjetChainDef = buildBjetChains(theJetChainDef1, subChainDict,
                                              len(bjetchainDicts))
            theListOfChainDefs += [theBjetChainDef]

        if log.isEnabledFor(logging.DEBUG):
            log.debug(
                "----------------- Beginning of final individual chainDefs for b-jet chains printout -----------------"
            )
            for chainDef in theListOfChainDefs:
                log.debug('%s', chainDef)
            log.debug(
                "----------------- End of final individual chainDefs for b-jet chains printout -----------------"
            )

        if len(theListOfChainDefs) > 1:
            theFinalChainDef = mergeChainDefs(theListOfChainDefs,
                                              strategy="parallel",
                                              offset=-1,
                                              preserveL2EFOrder=True,
                                              removeDuplicateTEs=True,
                                              noMergeBJet=True)
        else:
            theFinalChainDef = theListOfChainDefs[0]

    log.debug(
        "----------------- Beginning of final merged chainDefs for b-jet chains printout -----------------"
    )
    log.debug('%s', theFinalChainDef)
    log.debug(
        "----------------- End of final merged chainDefs for b-jet chains printout -----------------"
    )

    return theFinalChainDef