Esempio n. 1
0
    def WrapTauRecToolExecHandle(self, tool=None):

        self.TauProcessorAlgHandle().Tools = tool
        from AthenaCommon.AlgSequence import AlgSequence

        topSequence = AlgSequence()

        if jobproperties.Beam.beamType() != "cosmics":
            # Can I move this to different script?
            from AthenaCommon.AppMgr import ToolSvc
            from JetRec.JetRecConf import JetAlgorithm
            jetTrackAlg = JetAlgorithm("JetTrackAlg_forTaus")
            from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool
            TauTVATool = TrackVertexAssociationTool(
                TrackParticleContainer="InDetTrackParticles",
                TrackVertexAssociation="JetTrackVtxAssoc_forTaus",
                VertexContainer="PrimaryVertices",
                MaxTransverseDistance=2.5 * mm,
                #MaxLongitudinalDistance = 2 *mm,
                MaxZ0SinTheta=3.0 * mm,
                #OutputLevel=2
            )
            ToolSvc += TauTVATool
            jetTrackAlg.Tools = [TauTVATool]
            topSequence += jetTrackAlg

            # import tauRec.TauAlgorithmsHolder as taualgs
            # add tauJVF tool to topSequence
            # taualgs.setupTauJVFTool

        topSequence += self.TauProcessorAlgHandle()
Esempio n. 2
0
def addKmeansCollection(nsubjet, recordNameAppendix = "", ToolSvc = ToolSvc, Sequencer = FTAG5Seq):
  global KmeansJetCollection__SubJet

  output = []
  for JetCollectionKmeans in KmeansJetCollection__FatJet:
      # build KmeansbbTagTool instance
      (KmeansbbTagToolInstance, SubjetContainerName) = buildKmeansSubjets(JetCollectionKmeans, nsubjet, recordNameAppendix, ToolSvc)
      KmeansJetCollection__SubJet += [SubjetContainerName]
      output += [SubjetContainerName]

      # build subjet collection through JetRecTool
      from JetRec.JetRecConf import JetRecTool
      jetrec = JetRecTool(
                           name = "JetRecTool_Kmeansbb%i%s_%s" % (nsubjet, recordNameAppendix, JetCollectionKmeans),
                           OutputContainer = JetCollectionKmeans,
                           InputContainer = JetCollectionKmeans,
                           JetModifiers = [KmeansbbTagToolInstance],
                         )

      ToolSvc += jetrec
      Sequencer += JetAlgorithm(
                                name = "JetAlgorithm_Kmeansbb%i%s_%s" % (nsubjet, recordNameAppendix, JetCollectionKmeans),
                                Tools = [jetrec],
                               )

  return output
def replaceBuggyAntiKt10TruthWZJets(algseq, outputGroup='BugFix'):
    if jetFlags.useTruth:

        jetnamebase = 'AntiKt10TruthWZ'
        jetname = jetnamebase + 'Jets'
        algname = 'jetalg' + jetnamebase
        OutputJets.setdefault(outputGroup, []).append(jetname)

        # return if the alg is already scheduled here :
        if algseq is None:
            print 'ExtendedJetCommon: No algsequence passed! Will not schedule', algname
            return
        elif algname in DFJetAlgs:
            if hasattr(algseq, algname):
                print 'ExtendedJetCommon:    Algsequence', algseq, 'already has an instance of', algname
            else:
                print 'ExtendedJetCommon:    Added', algname, 'to sequence', algseq
                algseq += DFJetAlgs[algname]
            return DFJetAlgs[algname]

        if not jetname in jtm.tools:

            finderTool = jtm.addJetFinder(jetname,
                                          'AntiKt',
                                          1.0,
                                          'truthwz',
                                          ptmin=40000,
                                          overwrite=True,
                                          warnIfDuplicate=False)

            from JetRec.JetRecConf import JetAlgorithm
            alg = JetAlgorithm(algname, Tools=[finderTool])
            print 'ExtendedJetCommon:    Added', algname, 'to sequence', algseq
            algseq += alg
            DFJetAlgs[algname] = alg
Esempio n. 4
0
def replaceBuggyAntiKt10TruthWZJets(algseq, outputGroup="BugFix"):
    if jetFlags.useTruth:

        jetnamebase = "AntiKt10TruthWZ"
        jetname = jetnamebase + "Jets"
        algname = "jetalg" + jetnamebase
        OutputJets.setdefault(outputGroup, []).append(jetname)

        # return if the alg is already scheduled here :
        if algseq is None:
            print "No algsequence passed! Will not schedule", algname
            return
        elif algname in DFJetAlgs:
            if hasattr(algseq, algname):
                print "   Algsequence", algseq, "already has an instance of", algname
            else:
                print "   Added", algname, "to sequence", algseq
                algseq += DFJetAlgs[algname]
            return DFJetAlgs[algname]

        if not jetname in jtm.tools:

            finderTool = jtm.addJetFinder(jetname,
                                          "AntiKt",
                                          1.0,
                                          "truthwz",
                                          ptmin=40000,
                                          overwrite=True,
                                          warnIfDuplicate=False)

            from JetRec.JetRecConf import JetAlgorithm
            alg = JetAlgorithm(algname, Tools=[finderTool])
            print "   Added", algname, "to sequence", algseq
            algseq += alg
            DFJetAlgs[algname] = alg
Esempio n. 5
0
def setupTauJVFTool():
    from AthenaCommon.AppMgr import ToolSvc

    """
    #Configures tau track selector tool for TJVA
    from InDetTrackSelectorTool.InDetTrackSelectorToolConf import InDet__InDetDetailedTrackSelectorTool
    InDetTrackSelectorToolForTJVA = InDet__InDetDetailedTrackSelectorTool(name = sPrefix + 'InDetTrackSelectorToolForTJVA',
                                                                pTMin                = 1000.,
                                                                IPd0Max              = 9999.*mm,
                                                                IPz0Max              = 9999.*mm,                                                                 
                                                                nHitPix              = 2,  # PixelHits + PixelDeadSensors
                                                                nHitSct              = 0,  # SCTHits + SCTDeadSensors
                                                                nHitSi               = 7,  # PixelHits + SCTHits + PixelDeadSensors + SCTDeadSensors
                                                                fitChi2OnNdfMax      = 99999,
                                                                TrackSummaryTool     = None,
                                                                Extrapolator         = getAtlasExtrapolator())        
        
    ToolSvc += InDetTrackSelectorToolForTJVA
    """
    from JetRec.JetRecConf import JetAlgorithm
    jetTrackAlg = JetAlgorithm(sPrefix+"JetTrackAlg_forTaus")

    """
    from JetRecTools.JetRecToolsConf import JetTrackSelectionTool
    ToolSvc += JetTrackSelectionTool(InputContainer = _DefaultTrackContainer, 
                                     OutputContainer="JetSelectedTracks_forTaus", 
                                     Selector=InDetTrackSelectorToolForTJVA, 
                                     OutputLevel=2
                                     # what is about ptmin, eta min/max???
                                     )
    """

    from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool
    ToolSvc += TrackVertexAssociationTool(TrackParticleContainer = _DefaultTrackContainer ,
                                          TrackVertexAssociation=sPrefix+"JetTrackVtxAssoc_forTaus", 
                                          VertexContainer= _DefaultVertexContainer,
                                          MaxTransverseDistance = 2.5 *mm,
                                          MaxLongitudinalDistance = 2 *mm, 
                                          #OutputLevel=2
                                          )
    #jetTrackAlg.Tools = [ToolSvc.JetTrackSelectionTool , ToolSvc.TrackVertexAssociationTool ]                                          
    jetTrackAlg.Tools = [ToolSvc.TrackVertexAssociationTool ]                                          
    
    from AthenaCommon.AlgSequence import AlgSequence
    topSequence = AlgSequence()    
    topSequence+=jetTrackAlg
Esempio n. 6
0
def addPFlowJets(inputtype="EM", rsize=0.4, algseq=None, outputGroup="PFlow"):
    from JetRec.JetRecStandard import jtm
    jtm.modifiersMap["mods"] = ["jetfilter", jtm.nsubjettiness, jtm.pull]

    pflowName = "AntiKt" + str(int(
        rsize * 10)) + inputtype + "Pflow"  # input : EM, EMC, LC
    algname = "jetalg" + pflowName
    OutputJets.setdefault(outputGroup, []).append(pflowName)

    # return if the alg is already scheduled here :
    if algseq is None:
        print "No algsequence passed! Will not schedule", algname
        return
    elif cfgKeyStore.isInInput("xAOD::JetContainer", pflowName):
        print "Collection ", algname, "is already in input AOD!"
        return
    elif algname in DFJetAlgs:
        if hasattr(algseq, algname):
            print "   Algsequence", algseq, "already has an instance of", algname
        else:
            print "   Added", algname, "to sequence", algseq
            algseq += DFJetAlgs[algname]
        return DFJetAlgs[algname]

    if inputtype == "EM":
        inputName = "empflow"
    elif inputtype == "EMC":
        inputName = "emcpflow"
    elif inputtype == "LC":
        inputName = "lcpflow"

    if pflowName in jtm.tools:
        pflowjet = jtm.tools[pflowName]
    else:
        pflowjet = jtm.addJetFinder(pflowName + "Jets",
                                    "AntiKt",
                                    rsize,
                                    inputName,
                                    "mods",
                                    ghostArea=0.01,
                                    ptmin=2000,
                                    ptminFilter=7000)

    from JetRec.JetRecConf import JetAlgorithm
    print "Adding PFlow jets : ", pflowName
    alg = JetAlgorithm(algname, Tools=[pflowjet])
    print "   Added", algname, "to sequence", algseq
    algseq += alg
    DFJetAlgs[algname] = alg
    return alg
Esempio n. 7
0
def JetAlgFromTools(rtools, suffix="HI", persistify=True):
    #insert exe tools at front of list, e.g. tracksel and tvassoc for HI etc.
    HIJet_exe_tools = []
    from JetRec.JetRecFlags import jetFlags
    if jetFlags.useTruth() and not jetFlags.Enabled():
        HIJet_exe_tools += HITruthParticleCopy()
    #if jetFlags.useCells():  HIJet_exe_tools += [jtm.missingcells]
    if HIJetFlags.UseHITracks():
        HIJet_exe_tools += [jtm.tracksel_HI, jtm.gtracksel_HI, jtm.tvassoc_HI]
    rtools = HIJet_exe_tools + rtools
    from JetRec.JetRecConf import JetToolRunner
    runner = JetToolRunner("jetrun" + suffix,
                           Tools=rtools,
                           Timer=jetFlags.timeJetToolRunner())
    jtm.add(runner)

    from JetRec.JetRecConf import JetAlgorithm
    theAlg = JetAlgorithm("jetalg" + suffix)
    theAlg.Tools = [runner]
    from AthenaCommon.AlgSequence import AlgSequence
    topsequence = AlgSequence()
    topsequence += theAlg

    from GaudiKernel.Constants import DEBUG
    if jetFlags.debug > 0:

        jtm.setOutputLevel(runner, DEBUG)
        theAlg.OutputLevel = DEBUG

    if jetFlags.debug > 3:
        jtm.setOutputLevel(jtm.jetBuilderWithoutArea, DEBUG)

    if persistify:
        for t in rtools:
            if hasattr(t, "OutputContainer"):
                AddToOutputList(t.OutputContainer)
    return theAlg
Esempio n. 8
0
def buildGenericGroomAlg(jetalg,
                         rsize,
                         inputtype,
                         groomedName,
                         jetToolBuilder,
                         includePreTools=False,
                         algseq=None,
                         outputGroup="CustomJets"):
    algname = "jetalg" + groomedName

    # add these groomed jets to the output (use setdefault() to constuct the list if not existing yet)
    OutputJets.setdefault(outputGroup, []).append(groomedName + "Jets")

    # return if the alg is already scheduled here :
    if algseq is None:
        print "No algsequence passed! Will not schedule", algname
        return
    elif cfgKeyStore.isInInput("xAOD::JetContainer", groomedName):
        print "Collection ", algname, "is already in input AOD!"
        return
    elif algname in DFJetAlgs:
        if hasattr(algseq, algname):
            print "   Algsequence", algseq, "already has an instance of", algname
        else:
            print "   Added", algname, "to sequence", algseq
            algseq += DFJetAlgs[algname]
        return DFJetAlgs[algname]

    from JetRec.JetRecUtils import buildJetContName
    ungroomedname = buildJetContName(jetalg, rsize, inputtype)

    # 1. make sure we have pseudo-jet in our original container
    # this returns a list of the needed tools to do so.
    jetalgTools = reCreatePseudoJets(jetalg, rsize, inputtype)

    # 2nd step run the trimming alg. We can re-use the original largeR jet since we reassociated the PseudoJet already.
    fatjet_trim = jetToolBuilder(groomedName + "Jets", ungroomedname)

    from JetRec.JetRecConf import JetAlgorithm
    if includePreTools:
        # enable track ghost association and JVF
        jetalgTools = [jtm.tracksel, jtm.tvassoc] + jetalgTools

    alg = JetAlgorithm(algname, Tools=jetalgTools + [fatjet_trim])
    DFJetAlgs[algname] = alg

    print "   Added", algname, "to sequence", algseq
    algseq += alg
    return alg
Esempio n. 9
0
def getTVATool():
    _name = sPrefix + 'TVATool'

    if _name in cached_instances:
        return cached_instances[_name]

    from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool
    TVATool = TrackVertexAssociationTool(
        "TVATool_forDiTaus",
        TrackParticleContainer="InDetTrackParticles",
        TrackVertexAssociation="JetTrackVtxAssoc_forDiTaus",
        VertexContainer="PrimaryVertices",
        MaxTransverseDistance=2.5,  # in mm
        MaxLongitudinalDistance=2  # in mm
    )
    from AthenaCommon.AppMgr import ToolSvc
    ToolSvc += TVATool

    from JetRec.JetRecConf import JetAlgorithm
    jetTrackAlg = JetAlgorithm(name=_name)
    jetTrackAlg.Tools = [TVATool]

    cached_instances[_name] = jetTrackAlg
    return jetTrackAlg
Esempio n. 10
0
def addPhysValAODContent(algseq, doJets, doTopoCluster):
    '''
    Schedule the addition of collections needed for validation of
    primary xAODs: AntiKt4TruthJets and LC/EMOriginTopoClusters
    '''

    logger.info(
        '****************** Adding content for AOD PhysVal *****************')

    # Check some flags for steering
    from RecExConfig.AutoConfiguration import IsInInputFile
    requiresTruthJets = IsInInputFile(
        'xAOD::TruthParticleContainer',
        'TruthParticles') and not IsInInputFile('xAOD::JetContainer',
                                                'AntiKt4TruthJets')
    requiresLCOriginTC = not IsInInputFile('xAOD::CaloClusterContainer',
                                           'LCOriginTopoClusters')
    requiresEMOriginTC = not IsInInputFile('xAOD::CaloClusterContainer',
                                           'EMOriginTopoClusters')

    jettools_PhysVal = []
    # Truth jets
    if doJets and requiresTruthJets:
        jettools_PhysVal += addAntiKt4TruthJets(algseq)

    # Origin-corrected topoclusters
    if doTopoCluster and (requiresLCOriginTC or requiresEMOriginTC):
        jettools_PhysVal += addOriginCorrectedClusters(algseq,
                                                       requiresLCOriginTC,
                                                       requiresEMOriginTC)

    # Only add the algorithm if there is a need for it
    if jettools_PhysVal:
        from JetRec.JetRecStandard import jtm
        from JetRec.JetRecConf import JetToolRunner
        jtm += JetToolRunner(
            "jetrun_PhysVal",
            EventShapeTools=[],
            Tools=jettools_PhysVal,
            Timer=0  # No timing information
        )

        from JetRec.JetRecConf import JetAlgorithm
        algseq += JetAlgorithm("jetalgPhysVal", Tools=[jtm.jetrun_PhysVal])

    logger.info(
        '******************              Done              *****************')
Esempio n. 11
0
def addCopyJet(FTAG5Seq, ToolSvc, InputJetCollectionName,
               OutputJetCollectionName, **options):
    doShallowCopy = options.pop("ShallowCopy", False)

    from JetRec.JetRecConf import JetRecTool
    jetrec = JetRecTool(name="JetRecTool_CopyJet_%s_%s" %
                        (InputJetCollectionName, OutputJetCollectionName),
                        OutputContainer=OutputJetCollectionName,
                        InputContainer=InputJetCollectionName,
                        ShallowCopy=doShallowCopy,
                        **options)

    ToolSvc += jetrec
    FTAG5Seq += JetAlgorithm(
        name="JetAlgorithm_CopyJet_%s_%s" %
        (InputJetCollectionName, OutputJetCollectionName),
        Tools=[jetrec],
    )

    return OutputJetCollectionName
Esempio n. 12
0
def setupTJVFTool():
    from AthenaCommon.AppMgr import ToolSvc

    from JetRec.JetRecConf import JetAlgorithm
    jetTrackAlg = JetAlgorithm("JetTrackAlg_forDiTaus")

    from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool
    TVATool = TrackVertexAssociationTool(
        "TVATool_forDiTaus",
        TrackParticleContainer="InDetTrackParticles",
        TrackVertexAssociation="JetTrackVtxAssoc_forDiTaus",
        VertexContainer="PrimaryVertices",
        MaxTransverseDistance=2.5,  # in mm
        MaxLongitudinalDistance=2  # in mm
    )

    ToolSvc += TVATool
    jetTrackAlg.Tools += [TVATool]

    from AthenaCommon.AlgSequence import AlgSequence
    topSequence = AlgSequence()
    topSequence += jetTrackAlg
Esempio n. 13
0
def buildTOPQCA15jets(algseq):
    if not cfgKeyStore.isInInput("xAOD::JetContainer", "CamKt15LCTopoJets"):
        from JetRec.JetRecConf import JetAlgorithm
        jtm.modifiersMap["lctopoCA15"] = list(jtm.modifiersMap["lctopo"])
        if globalflags.DataSource() == 'geant4':
            jtm.modifiersMap["lctopoCA15"].remove('truthassoc')
        if hasattr(jtm, "CamKt15LCTopoJets"):
            TOPQCA15LC = getattr(jtm, "CamKt15LCTopoJets")
        else:
            TOPQCA15LC = jtm.addJetFinder("CamKt15LCTopoJets",
                                          "CamKt",
                                          1.5,
                                          "lctopo",
                                          "lctopoCA15",
                                          ghostArea=0.01,
                                          ptmin=2000,
                                          ptminFilter=100000,
                                          calibOpt="aro")
        if not hasattr(algseq, "jetalgCamKt15LCTopo"):
            TOPQCA15LCalg = JetAlgorithm("jetalgCamKt15LCTopo",
                                         Tools=[TOPQCA15LC])
            algseq += TOPQCA15LCalg
            print("Running jet finding algorithm for CamKt15LCTopoJets")
Esempio n. 14
0
def addCopyJets(NewJetCollectionName,
                OldJetCollectionName,
                algseq=None,
                outputGroup="JetCopy",
                mods=[],
                doShallow=False):
    algname = "CopyJets_%s_%s" % (OldJetCollectionName, NewJetCollectionName)

    if algseq is None:
        print "No algsequence passed! Will not schedule", algname
        return

    jetcopytool = jtm.addJetCopier(NewJetCollectionName,
                                   OldJetCollectionName,
                                   mods,
                                   shallow=doShallow)

    from JetRec.JetRecConf import JetAlgorithm
    alg = JetAlgorithm(algname, Tools=[jetcopytool])
    print "   Added", algname, "to sequence", algseq
    algseq += alg
    DFJetAlgs[algname] = alg

    OutputJets.setdefault(outputGroup, []).append(NewJetCollectionName)
Esempio n. 15
0
def addStandardJets(jetalg,
                    rsize,
                    inputtype,
                    ptmin=2000,
                    ptminFilter=5000,
                    mods="calib",
                    calibOpt="none",
                    ghostArea=0.01,
                    algseq=None,
                    outputGroup="CustomJets",
                    exclusiveSubjetBuilderList=[],
                    **extraOptions):
    ###############################################
    # supported options in extraOptions:
    # jetnamebase
    # variableRMinRadius
    # variableRMassScale
    ###############################################

    # "jetnamebase" can be configured through extraOptions
    if 'jetnamebase' not in extraOptions.keys():
        jetnamebase = "{0}{1}{2}".format(jetalg, int(rsize * 10), inputtype)
    else:
        jetnamebase = extraOptions['jetnamebase']
    jetname = jetnamebase + "Jets"
    algname = "jetalg" + jetnamebase
    OutputJets.setdefault(outputGroup, []).append(jetname)

    # exclusive kt subjet builder list
    if type(mods) is str:
        mods = jtm.modifiersMap[mods]
    for exclusiveSubjetBuilder in exclusiveSubjetBuilderList:
        (subjetfinder, SubjetContainerName) = exclusiveSubjetBuilder(jetname)
        mods += [subjetfinder]
        # add subjet container to the output
        OutputJets.setdefault(outputGroup, []).append(SubjetContainerName)

    # return if the alg is already scheduled here :
    if algseq is None:
        print "No algsequence passed! Will not schedule", algname
        return
    elif cfgKeyStore.isInInput("xAOD::JetContainer", jetname):
        print "Collection ", algname, "is already in input AOD!"
        return
    elif algname in DFJetAlgs:
        if hasattr(algseq, algname):
            print "   Algsequence", algseq, "already has an instance of", algname
        else:
            print "   Added", algname, "to sequence", algseq
            algseq += DFJetAlgs[algname]
        return DFJetAlgs[algname]

    if not jetname in jtm.tools:
        # Set default for the arguments to be passd to addJetFinder
        finderArgs = dict(modifiersin=[], consumers=[])
        finderArgs['ptmin'] = ptmin
        finderArgs['ptminFilter'] = ptminFilter
        finderArgs['ghostArea'] = ghostArea
        # configs for variable-R
        if ("variableRMinRadius"
                in extraOptions.keys()) and ("variableRMassScale"
                                             in extraOptions.keys()):
            print 'INFO: You are running varaible-R jets!'
            finderArgs['variableRMinRadius'] = extraOptions[
                'variableRMinRadius']
            finderArgs['variableRMassScale'] = extraOptions[
                'variableRMassScale']
        # no container exist. simply build a new one.
        if inputtype == "LCTopo":
            finderArgs['modifiersin'] = mods
            finderArgs['calibOpt'] = "none"
        else:
            # be careful here -- when inputtype is not "LCTopo", many modifers in "calib" will not work
            # therefore, it is highly recommended to set mods=[], or something that you know that will work with non-calo type jet
            print 'Warning! Make sure you know what you are doing!'
            print 'Running addStandardJets for', jetname
            print 'Here is a list of modifiers:', mods
            finderArgs['modifiersin'] = mods
        #finderArgs.pop('modifiersin') # leave the default modifiers.

        # map the input to the jtm code for PseudoJetGetter
        getterMap = dict(LCTopo='lctopo',
                         Truth='truth',
                         TruthWZ='truthwz',
                         PV0Track='pv0track')
        # create the finder for the temporary collection.
        finderTool = jtm.addJetFinder(
            jetname,
            jetalg,
            rsize,
            getterMap[inputtype],
            **finderArgs  # pass the prepared arguments
        )

        from JetRec.JetRecConf import JetAlgorithm
        alg = JetAlgorithm(algname, Tools=[finderTool])
        print "   Added", algname, "to sequence", algseq
        algseq += alg
        DFJetAlgs[algname] = alg
Esempio n. 16
0
  rtools += [jtm.tvassoc]
rtools += jtm.jetrecs
from JetRec.JetRecConf import JetToolRunner
jtm += JetToolRunner("jetrun",
         EventShapeTools=evstools,
         Tools=rtools,
         Timer=jetFlags.timeJetToolRunner()
       )
jetrun = jtm.jetrun

# Add the algorithm. It runs the jetrec tools.
from JetRec.JetRecConf import JetAlgorithm

if jetFlags.separateJetAlgs():
    for t in rtools:
        jalg = JetAlgorithm("jetalg"+t.name())
        jalg.Tools = [t]
        job+= jalg
else:
    job += JetAlgorithm("jetalg")
    jetalg = job.jetalg
    jetalg.Tools = [jtm.jetrun]

    if jetFlags.debug > 0:
      jtm.setOutputLevel(jtm.jetrun, DEBUG)
      jetalg.OutputLevel = DEBUG

    if jetFlags.debug > 1:
      for tool in jtm.jetrecs:
        jtm.setOutputLevel(tool, DEBUG)
Esempio n. 17
0
    "Partons",
]
if dfInputIsEVNT:
    # Standard truth jets
    # To recover jet constituents remove the last modifier.
    akt4 = jtm.addJetFinder("AntiKt4TruthJets",
                            "AntiKt",
                            0.4,
                            "truth",
                            modifiersin=[
                                jtm.truthpartondr, jtm.partontruthlabel,
                                jtm.removeconstit, jtm.jetdrlabeler,
                                jtm.trackjetdrlabeler
                            ],
                            ptmin=5000)
    akt4alg = JetAlgorithm("jetalgAntiKt4TruthJets", Tools=[akt4])
    DerivationFrameworkJob += akt4alg

    # WZ Truth Jets
    akt4wz = jtm.addJetFinder("AntiKt4TruthWZJets",
                              "AntiKt",
                              0.4,
                              "truthwz",
                              ptmin=5000,
                              modifiersin=[
                                  jtm.truthpartondr, jtm.partontruthlabel,
                                  jtm.removeconstit
                              ])
    akt4wzalg = JetAlgorithm("jetalgAntiKt4TruthWZJets", Tools=[akt4wz])
    DerivationFrameworkJob += akt4wzalg
    #jtm.addJetFinder("AntiKt6TruthWZJets",  "AntiKt", 0.6,  "truthwz", ptmin= 5000)
Esempio n. 18
0
    ## Large VR truth jets
    jfind_largevr_truth = jtm.addJetFinder("AntiKtVR600Rmax10Rmin2TruthJets",
                                           "AntiKt",
                                           1.0,
                                           "truth",
                                           "largevr_truth_modifiers",
                                           ghostArea=0,
                                           ptmin=40000,
                                           ptminFilter=40000,
                                           variableRMinRadius=0.2,
                                           variableRMassScale=600000,
                                           calibOpt="")

from JetRec.JetRecConf import JetAlgorithm
jetalg_smallvr_lctopo = JetAlgorithm("jfind_smallvr_lctopo",
                                     Tools=[jfind_smallvr_lctopo])
jetalg_largevr_lctopo = JetAlgorithm("jfind_largevr_lctopo",
                                     Tools=[jfind_largevr_lctopo])
jetalg_smallvr_track = JetAlgorithm("jfind_smallvr_track",
                                    Tools=[jfind_smallvr_track])
jetalg_mediumvr_track = JetAlgorithm("jfind_mediumvr_track",
                                     Tools=[jfind_mediumvr_track])
jetalg_largevr_track = JetAlgorithm("jfind_largevr_track",
                                    Tools=[jfind_largevr_track])

if isMC:
    jetalg_smallvr_truth = JetAlgorithm("jfind_smallvr_truth",
                                        Tools=[jfind_smallvr_truth])
    jetalg_largevr_truth = JetAlgorithm("jfind_largevr_truth",
                                        Tools=[jfind_largevr_truth])
Esempio n. 19
0
    def other_postSystemRec(self, topSequence):
        """
        Please seperate out this function into multiple functions
        """
        from AthenaCommon.AppMgr import ToolSvc

        if self.isMC:

            from ParticleJetTools.ParticleJetToolsConf import CopyFlavorLabelTruthParticles
            from ParticleJetTools.ParticleJetToolsConf import ParticleJetDeltaRLabelTool

            ptypes = ["TausFinal", "BHadronsFinal", "CHadronsFinal"]
            for ptype in ptypes:
                AODFix_ctp = CopyFlavorLabelTruthParticles(
                    "AODFix_CopyTruthTag" + ptype)
                AODFix_ctp.ParticleType = ptype
                AODFix_ctp.OutputName = "AODFix_TruthLabel" + ptype
                ToolSvc += AODFix_ctp

            AODFix_JetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_jetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=0.0,
                DRMax=0.3,
                MatchMode="MinDR")
            ToolSvc += AODFix_JetDeltaRLabelTool

            AODFix_FatJetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_fatjetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=0.0,
                DRMax=1.0,
                MatchMode="MinDR")
            ToolSvc += AODFix_FatJetDeltaRLabelTool

            AODFix_TrackJetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_trackjetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=4500.0,
                DRMax=0.3,
                MatchMode="MinDR")

            ToolSvc += AODFix_TrackJetDeltaRLabelTool

            from JetRec.JetRecConf import JetRecTool
            JetRecTool_AntiKt4EMTopo = JetRecTool(
                "AODFix_AntiKt4EMTopoJets",
                InputContainer="AntiKt4EMTopoJets",
                OutputContainer="AntiKt4EMTopoJets",
                JetModifiers=[ToolSvc.AODFix_jetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4EMTopo
            JetRecTool_AntiKt4LCTopo = JetRecTool(
                "AODFix_AntiKt4LCTopoJets",
                InputContainer="AntiKt4LCTopoJets",
                OutputContainer="AntiKt4LCTopoJets",
                JetModifiers=[ToolSvc.AODFix_jetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4LCTopo
            JetRecTool_AntiKt10LCTopo = JetRecTool(
                "AODFix_AntiKt10LCTopoJets",
                InputContainer="AntiKt10LCTopoJets",
                OutputContainer="AntiKt10LCTopoJets",
                JetModifiers=[ToolSvc.AODFix_fatjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt10LCTopo
            JetRecTool_AntiKt2PV0Track = JetRecTool(
                "AODFix_AntiKt2PV0TrackJets",
                InputContainer="AntiKt2PV0TrackJets",
                OutputContainer="AntiKt2PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt2PV0Track
            JetRecTool_AntiKt3PV0Track = JetRecTool(
                "AODFix_AntiKt3PV0TrackJets",
                InputContainer="AntiKt3PV0TrackJets",
                OutputContainer="AntiKt3PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt3PV0Track
            JetRecTool_AntiKt4PV0Track = JetRecTool(
                "AODFix_AntiKt4PV0TrackJets",
                InputContainer="AntiKt4PV0TrackJets",
                OutputContainer="AntiKt4PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4PV0Track

            from JetRec.JetRecConf import JetAlgorithm
            topSequence += JetAlgorithm(
                "jetalgAODFix",
                Tools=[
                    ToolSvc.AODFix_CopyTruthTagCHadronsFinal,
                    ToolSvc.AODFix_CopyTruthTagBHadronsFinal,
                    ToolSvc.AODFix_CopyTruthTagTausFinal,
                    ToolSvc.AODFix_AntiKt2PV0TrackJets,
                    ToolSvc.AODFix_AntiKt3PV0TrackJets,
                    ToolSvc.AODFix_AntiKt4PV0TrackJets,
                    ToolSvc.AODFix_AntiKt4EMTopoJets,
                    ToolSvc.AODFix_AntiKt4LCTopoJets,
                    ToolSvc.AODFix_AntiKt10LCTopoJets
                ])

        JetCollectionList = [
            'AntiKt4EMTopoJets', 'AntiKt4LCTopoJets', 'AntiKt2TrackJets',
            'AntiKt3TrackJets', 'AntiKt4TrackJets'
        ]

        SA = 'AODFix_'
        from BTagging.BTaggingConfiguration import getConfiguration
        BTagConf = getConfiguration("AODFix")
        BTagConf.PrefixxAODBaseName(False)
        BTagConf.PrefixVertexFinderxAODBaseName(False)

        BTagConf.doNotCheckForTaggerObstacles()
        from BTagging.BTaggingConf import Analysis__StandAloneJetBTaggerAlg as StandAloneJetBTaggerAlg

        btag = "BTagging_"
        AuthorSubString = [btag + name[:-4] for name in JetCollectionList]
        for i, jet in enumerate(JetCollectionList):
            try:
                btagger = BTagConf.setupJetBTaggerTool(ToolSvc,
                                                       JetCollection=jet[:-4],
                                                       AddToToolSvc=True,
                                                       SetupScheme="Retag",
                                                       TaggerList=[
                                                           'IP3D', 'MV2c00',
                                                           'MV2c10', 'MV2c20',
                                                           'MV2c100', 'MV2m',
                                                           'MV2c10hp',
                                                           'MV2cl100', 'MVb'
                                                       ])
                jet = jet.replace("Track", "PV0Track")
                SAbtagger = StandAloneJetBTaggerAlg(
                    name=SA + AuthorSubString[i].lower(),
                    JetBTaggerTool=btagger,
                    JetCollectionName=jet,
                )

                topSequence += SAbtagger
            except AttributeError as error:
                print '#BTAG# --> ' + str(error)
                print '#BTAG# --> ' + jet
                print '#BTAG# --> ' + AuthorSubString[i]

        # MET AODFix
        from METReconstruction.METAssocConfig import AssocConfig, getAssociator
        from METReconstruction.METReconstructionConf import METBadTrackEventFilter
        from AthenaCommon.AlgSequence import AthSequencer
        METMapSequence = AthSequencer("MET_LCEM_SelectionSequence_AODFix")
        topSequence += METMapSequence

        from AthenaCommon import CfgMgr
        newtrkseltool = CfgMgr.InDet__InDetTrackSelectionTool(
            "IDTrkSel_METAssoc_AODFix",
            CutLevel="TightPrimary",
            maxZ0SinTheta=3,
            maxD0overSigmaD0=2)
        ToolSvc += newtrkseltool

        METMapSequence += METBadTrackEventFilter(
            "METBadTrackEventFilter_AODFix", TrackSelectorTool=newtrkseltool)

        LCtermlist = ['LCJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
        LCAssociators = [
            getAssociator(AssocConfig(config),
                          suffix='AntiKt4LCTopo',
                          doPFlow=False,
                          trkseltool=newtrkseltool) for config in LCtermlist
        ]
        LCAssocTool = CfgMgr.met__METAssociationTool(
            'MET_AssociationTool_AntiKt4LCTopo_AODFix',
            METAssociators=LCAssociators,
            METSuffix='AntiKt4LCTopo',
            AllowOverwrite=True,
            TCSignalState=1)  # LC clusters
        ToolSvc += LCAssocTool

        EMtermlist = ['EMJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
        EMAssociators = [
            getAssociator(AssocConfig(config),
                          suffix='AntiKt4EMTopo',
                          doPFlow=False,
                          trkseltool=newtrkseltool) for config in EMtermlist
        ]
        EMAssocTool = CfgMgr.met__METAssociationTool(
            'MET_AssociationTool_AntiKt4EMTopo_AODFix',
            METAssociators=EMAssociators,
            METSuffix='AntiKt4EMTopo',
            AllowOverwrite=True,
            TCSignalState=0)  # EM clusters
        ToolSvc += EMAssocTool

        METAssocAlg_LCEM = CfgMgr.met__METRecoAlg(
            name='METAssociation_LCEM_AODFix',
            RecoTools=[LCAssocTool, EMAssocTool])
        METMapSequence += METAssocAlg_LCEM

        from METUtilities.METMakerConfig import getMETMakerAlg
        METMakerAlg_LC = getMETMakerAlg('AntiKt4LCTopo', confsuffix="_AODFix")
        METMakerAlg_LC.AllowOverwrite = True
        METMakerAlg_EM = getMETMakerAlg('AntiKt4EMTopo', confsuffix="_AODFix")
        METMakerAlg_EM.AllowOverwrite = True
        METMapSequence += METMakerAlg_LC
        METMapSequence += METMakerAlg_EM

        #Only run pflow AOD fix if input file contains AntKt4EMPFlowJets - should be the case for all samples, except HI samples
        from RecExConfig.ObjKeyStore import cfgKeyStore
        if cfgKeyStore.isInInputFile("xAOD::JetContainer",
                                     "AntiKt4EMPFlowJets"):

            #Now we need to rerun the particle flow jet finding

            #This configuration should be identical to the AntiKt4EMPflowJets configured in:
            #http://acode-browser2.usatlas.bnl.gov/lxr-rel20/source/atlas/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py
            #with the addJetFinder function (in the svn tag for 20.7)
            particleFlowJetFinder_AntiKt4 = CfgMgr.JetFinder(
                "AntiKt4EMPFlowJetsFinder_AODFix")
            particleFlowJetFinder_AntiKt4.JetAlgorithm = "AntiKt"
            particleFlowJetFinder_AntiKt4.JetRadius = 0.4
            particleFlowJetFinder_AntiKt4.GhostArea = 0.01
            particleFlowJetFinder_AntiKt4.PtMin = 2000

            #Then we setup a jet builder to calculate the areas needed for the rho subtraction
            particleFlowJetBuilder_AntiKt4 = CfgMgr.JetFromPseudojet(
                "jblda_AODFix", Attributes=["ActiveArea", "ActiveArea4vec"])
            ToolSvc += particleFlowJetBuilder_AntiKt4
            particleFlowJetFinder_AntiKt4.JetBuilder = particleFlowJetBuilder_AntiKt4
            ToolSvc += particleFlowJetFinder_AntiKt4

            #Now we setup a JetRecTool which will use the above JetFinder
            particleFlowJetRecTool = CfgMgr.JetRecTool(
                "AntiKt4EMPFlowJets_AODFix")
            particleFlowJetRecTool.JetFinder = particleFlowJetFinder_AntiKt4
            ToolSvc += particleFlowJetRecTool

            jpjretriever = CfgMgr.JetPseudojetRetriever("jpjretriever")
            ToolSvc += jpjretriever

            pflowRetriever = CfgMgr.CP__RetrievePFOTool(
                "pflowretriever_AODFix")
            ToolSvc += pflowRetriever

            trk_trackselloose = CfgMgr.InDet__InDetTrackSelectionTool(
                "trk_trackselloose_AODFix", CutLevel="Loose")
            ToolSvc += trk_trackselloose

            trackselloose = CfgMgr.JetTrackSelectionTool(
                "trackselloose",
                InputContainer="InDetTrackParticles",
                OutputContainer="JetSelectedTracks",
                Selector=trk_trackselloose)
            ToolSvc += trackselloose

            tracksel = CfgMgr.JetTrackSelectionTool(
                "tracksel_AODFix",
                InputContainer="InDetTrackParticles",
                OutputContainer="JetSelectedTracks_AODFix",
                Selector=trk_trackselloose)
            ToolSvc += tracksel

            tighttva = CfgMgr.CP__TightTrackVertexAssociationTool(
                "jetTighTVAtool_AODFix", dzSinTheta_cut=3, doPV=True)
            ToolSvc += tighttva

            tvassoc = CfgMgr.TrackVertexAssociationTool(
                "tvassoc_AODFix",
                TrackParticleContainer="InDetTrackParticles",
                TrackVertexAssociation="JetTrackVtxAssoc_AODFix",
                VertexContainer="PrimaryVertices",
                TrackVertexAssoTool=tighttva,
            )
            ToolSvc += tvassoc

            # Ghost tracks.
            ghostScaleFactor = 1e-40
            gtrackget = CfgMgr.TrackPseudoJetGetter(
                "gtrackget_AODFix",
                InputContainer=tracksel.OutputContainer,
                Label="GhostTrack",
                OutputContainer="PseudoJetGhostTracks_AODFix",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                SkipNegativeEnergy=True,
                GhostScale=ghostScaleFactor)
            ToolSvc += gtrackget

            # Muon segments
            gmusegget = CfgMgr.MuonSegmentPseudoJetGetter(
                "gmusegget_AODFix",
                InputContainer="MuonSegments",
                Label="GhostMuonSegment",
                OutputContainer="PseudoJetGhostMuonSegment_AODFix",
                Pt=1.e-20)
            ToolSvc += gmusegget

            # AntiKt2 track jets.
            gakt2trackget = CfgMgr.PseudoJetGetter(
                "gakt2trackget_AODFix",  # give a unique name
                InputContainer="AntiKt2PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt2TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt2TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt2trackget

            # AntiKt3 track jets.
            gakt3trackget = CfgMgr.PseudoJetGetter(
                "gakt3trackget_AODFix",  # give a unique name
                InputContainer="AntiKt3PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt3TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt3TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt3trackget

            # AntiKt4 track jets.
            gakt4trackget = CfgMgr.PseudoJetGetter(
                "gakt4trackget_AODFix",  # give a unique name
                InputContainer="AntiKt4PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt4TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt4TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt4trackget

            # Truth.
            mctc = None
            truthpartcopy = None
            gtruthget = None
            gtruthgetters = []
            rtools = []
            rtools += [tracksel, tvassoc]
            if self.isMC:
                mctc = CfgMgr.MCTruthClassifier(
                    name="JetMCTruthClassifier_AODFix",
                    ParticleCaloExtensionTool="")
                ToolSvc += mctc

                truthpartcopy = CfgMgr.CopyTruthJetParticles(
                    "truthpartcopy_AODFix",
                    OutputName="JetInputTruthParticles_AODFix",
                    MCTruthClassifier=mctc)
                ToolSvc += truthpartcopy

                gtruthget = CfgMgr.PseudoJetGetter(
                    "gtruthget_AODFix",
                    Label="GhostTruth",
                    InputContainer=truthpartcopy.OutputName,
                    OutputContainer="PseudoJetGhostTruth_AODFix",
                    GhostScale=ghostScaleFactor,
                    SkipNegativeEnergy=True,
                )
                ToolSvc += gtruthget

                # Truth flavor tags.
                truthFlavourTags = [
                    "BHadronsInitial",
                    "BHadronsFinal",
                    "BQuarksFinal",
                    "CHadronsInitial",
                    "CHadronsFinal",
                    "CQuarksFinal",
                    "TausFinal",
                    "WBosons",
                    "ZBosons",
                    "HBosons",
                    "TQuarksFinal",
                    "Partons",
                ]
                for ptype in truthFlavourTags:
                    gtruthgetters.append(
                        CfgMgr.PseudoJetGetter(
                            "gtruthget_" + ptype + "_AODFix",
                            InputContainer="TruthLabel" + ptype + "_AODFix",
                            Label="Ghost" + ptype,
                            OutputContainer="PseudoJetGhost" + ptype +
                            "_AODFix",
                            SkipNegativeEnergy=True,
                            GhostScale=ghostScaleFactor,
                        ))
                    ToolSvc += gtruthgetters[-1]

                    toolname = "CopyTruthTag" + ptype + "_AODFix"
                    print "Scheduling " + toolname
                    ptmin = 5000
                    if ptype == "Partons":
                        ctp = CfgMgr.CopyTruthPartons(toolname)
                    elif ptype in [
                            "WBosons", "ZBosons", "HBosons", "TQuarksFinal"
                    ]:
                        ctp = CfgMgr.CopyBosonTopLabelTruthParticles(toolname)
                        ctp.ParticleType = ptype
                        ptmin = 100000
                    else:
                        ctp = CfgMgr.CopyFlavorLabelTruthParticles(toolname)
                        ctp.ParticleType = ptype
                    ctp.OutputName = "TruthLabel" + ptype + "_AODFix"
                    ctp.PtMin = ptmin
                    ToolSvc += ctp
                    rtools.append(ctp)

                # build truth jet input :
                rtools += [truthpartcopy]

            jetrun = CfgMgr.JetToolRunner(
                "jetrun_AODFix",
                Tools=rtools,
            )
            ToolSvc += jetrun

            #Setup a pseudojetgetter to deal with input objects
            empflowget = CfgMgr.PFlowPseudoJetGetter(
                "empflowget_AODFix",
                Label="EMPFlow",
                OutputContainer="PseudoJetEMPFlow_AODFix",
                RetrievePFOTool=pflowRetriever,
                InputIsEM=True,
                CalibratePFO=False,
                SkipNegativeEnergy=True,
                UseVertices=True)
            ToolSvc += empflowget

            empfgetters = [
                empflowget, gtrackget, gmusegget, gakt2trackget, gakt3trackget,
                gakt4trackget
            ]
            if self.isMC:
                empfgetters += [gtruthget] + gtruthgetters

            particleFlowJetRecTool.PseudoJetGetters = empfgetters
            particleFlowJetRecTool.Overwrite = True
            particleFlowJetRecTool.OutputContainer = "AntiKt4EMPFlowJets"

            #setup calibration tools - only want to do area subtraction (as is done in Tier0)
            jetdefn = particleFlowJetFinder_AntiKt4.JetAlgorithm + str(
                int(10 * particleFlowJetFinder_AntiKt4.JetRadius +
                    0.1)) + empflowget.Label
            pflowJetCalibToolName_AODFix = "calib_" + jetdefn + "_pflow_A_AODFix"
            ToolSvc += CfgMgr.JetCalibrationTool(
                "pflowJetCalibTool_AODFix",
                JetCollection=jetdefn,
                ConfigFile="PFlowJES_September2014.config",
                CalibSequence="JetArea",
                RhoKey="Kt4EMPFlowEventShape")
            particleFlowJetRecTool.JetModifiers = [
                ToolSvc.pflowJetCalibTool_AODFix
            ]

            #now we setup the other modifiers we need
            ToolSvc += CfgMgr.JetFilterTool("jetFilter_AODFix", PtMin=5000)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.jetFilter_AODFix]

            #common_ungroomed_modifiers start here
            ToolSvc += CfgMgr.JetWidthTool("width_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.width_AODFix]

            ToolSvc += CfgMgr.JetIsolationTool(
                "jetisol_AODFix",
                IsolationCalculations=["IsoDelta:2:SumPt", "IsoDelta:3:SumPt"])
            particleFlowJetRecTool.JetModifiers += [ToolSvc.jetisol_AODFix]

            ToolSvc += CfgMgr.KtDeltaRTool("ktdr_AODFix", JetRadius=0.4)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktdr_AODFix]

            ToolSvc += CfgMgr.NSubjettinessTool("nsubjettiness_AODFix",
                                                Alpha=1.0)
            particleFlowJetRecTool.JetModifiers += [
                ToolSvc.nsubjettiness_AODFix
            ]

            ToolSvc += CfgMgr.KTSplittingScaleTool("ktsplitter_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktsplitter_AODFix]

            ToolSvc += CfgMgr.AngularityTool("angularity_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.angularity_AODFix]

            ToolSvc += CfgMgr.DipolarityTool("dipolarity_AODFix",
                                             SubJetRadius=0.3)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.dipolarity_AODFix]

            ToolSvc += CfgMgr.PlanarFlowTool("planarflow_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.planarflow_AODFix]

            ToolSvc += CfgMgr.KtMassDropTool("ktmassdrop_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktmassdrop_AODFix]

            ToolSvc += CfgMgr.EnergyCorrelatorTool("encorr_AODFix", Beta=1.0)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.encorr_AODFix]

            ToolSvc += CfgMgr.CenterOfMassShapesTool("comshapes_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.comshapes_AODFix]

            #common_ungroomed_modifiers that are for MC only

            ## (JM) Now introduced an isMC flag, so can remove this suff.
            # #First we check if the file is MC or data using the metadata (not allowed to use reco flags om AODFix)
            # from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
            # theInputFile_AODFix = athenaCommonFlags.PoolAODInput.get_Value()[0]
            # import PyUtils.AthFile as af
            # haveParticleJetTools_AODFix = False
            # f = af.fopen(theInputFile_AODFix)
            # if 'evt_type' in f.infos.keys():
            #     import re
            #     if re.match(str(f.infos['evt_type'][0]), 'IS_SIMULATION') :
            #         try:
            #             haveParticleJetTools_AODFix = True
            #         except:
            #             haveParticleJetTools_AODFix = False

            #         if haveParticleJetTools_AODFix:
            #             ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel("partontruthlabel_AODFix")
            #             particleFlowJetRecTool.JetModifiers += [ToolSvc.partontruthlabel_AODFix]

            #             ToolSvc += CfgMgr.Analysis__JetQuarkLabel("jetquarklabel_AODFix",McEventCollection = "TruthEvents")
            #             ToolSvc += CfgMgr.Analysis__JetConeLabeling("truthpartondr_AODFix",JetTruthMatchTool = ToolSvc.jetquarklabel_AODFix)
            #             particleFlowJetRecTool.JetModifiers += [ToolSvc.truthpartondr_AODFix]

            #This is the replacement
            if self.isMC:
                ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel(
                    "partontruthlabel_AODFix")
                particleFlowJetRecTool.JetModifiers += [
                    ToolSvc.partontruthlabel_AODFix
                ]

                ToolSvc += CfgMgr.Analysis__JetQuarkLabel(
                    "jetquarklabel_AODFix", McEventCollection="TruthEvents")
                ToolSvc += CfgMgr.Analysis__JetConeLabeling(
                    "truthpartondr_AODFix",
                    JetTruthMatchTool=ToolSvc.jetquarklabel_AODFix)
                particleFlowJetRecTool.JetModifiers += [
                    ToolSvc.truthpartondr_AODFix
                ]
            ## end of JM modificatoin

            #common_ungroomed_modifiers end here

            # Modifiers for topo (and pflow) jets.
            jetens = CfgMgr.JetCaloEnergies("jetens_AODFix")
            ToolSvc += jetens

            larhvcorr = CfgMgr.JetLArHVTool("larhvcorr_AODFix")
            ToolSvc += larhvcorr

            caloqual_cluster = CfgMgr.JetCaloQualityTool(
                "caloqual_cluster_AODFix",
                TimingCuts=[5, 10],
                Calculations=[
                    "LArQuality", "N90Constituents", "FracSamplingMax",
                    "NegativeE", "Timing", "HECQuality", "Centroid",
                    "AverageLArQF", "BchCorrCell"
                ],
            )
            ToolSvc += caloqual_cluster

            # Jet vertex fraction with selection.
            jvf = CfgMgr.JetVertexFractionTool(
                "jvf_AODFix",
                VertexContainer="PrimaryVertices",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackSelector=trackselloose,
                JVFName="JVF")
            ToolSvc += jvf

            # Jet vertex tagger.
            jvt = CfgMgr.JetVertexTaggerTool(
                "jvt_AODFix",
                VertexContainer="PrimaryVertices",
                TrackParticleContainer="InDetTrackParticles",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackSelector=trackselloose,
                JVTName="Jvt",
                K_JVFCorrScale=0.01,
                Z0Cut=3.0,
                PUTrkPtCut=30000.0)
            ToolSvc += jvt

            # Jet track info.
            trkmoms = CfgMgr.JetTrackMomentsTool(
                "trkmoms_AODFix",
                VertexContainer="PrimaryVertices",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackMinPtCuts=[500, 1000],
                TrackSelector=trackselloose)
            ToolSvc += trkmoms

            charge = CfgMgr.JetChargeTool("charge_AODFix", K=1.0)
            ToolSvc += charge

            particleFlowJetRecTool.JetModifiers += [
                jetens, larhvcorr, caloqual_cluster, jvf, jvt, trkmoms, charge
            ]

            if self.isMC:
                truthassoc = CfgMgr.JetPtAssociationTool(
                    "truthassoc_AntiKt4_AODFix",
                    InputContainer="AntiKt4TruthJets",
                    AssociationName="GhostTruth")
                ToolSvc += truthassoc

                jetdrlabeler = CfgMgr.ParticleJetDeltaRLabelTool(
                    "jetdrlabeler_AODFix",
                    LabelName="HadronConeExclTruthLabelID",
                    BLabelName="ConeExclBHadronsFinal",
                    CLabelName="ConeExclCHadronsFinal",
                    TauLabelName="ConeExclTausFinal",
                    BParticleCollection="TruthLabelBHadronsFinal_AODFix",
                    CParticleCollection="TruthLabelCHadronsFinal_AODFix",
                    TauParticleCollection="TruthLabelTausFinal_AODFix",
                    PartPtMin=5000.0,
                    JetPtMin=4500.0,
                    DRMax=0.3,
                    MatchMode="MinDR")
                ToolSvc += jetdrlabeler

                particleFlowJetRecTool.JetModifiers += [
                    truthassoc, jetdrlabeler
                ]

            JetType = 'PFlowJet'
            PFtermlist = ['PFlowJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
            newpfotool = CfgMgr.CP__RetrievePFOTool('MET_PFOTool_AODFix')
            ToolSvc += newpfotool

            PFAssociators = [
                getAssociator(AssocConfig(config),
                              suffix='AntiKt4EMPFlow',
                              doPFlow=True,
                              trkseltool=newtrkseltool,
                              pfotool=newpfotool) for config in PFtermlist
            ]
            PFAssocTool = CfgMgr.met__METAssociationTool(
                'MET_AssociationTool_AntiKt4EMPFlow_AODFix',
                METAssociators=PFAssociators,
                METSuffix='AntiKt4EMPFlow',
                AllowOverwrite=True)
            ToolSvc += PFAssocTool

            METAssocAlg_PFlow = CfgMgr.met__METRecoAlg(
                name='METAssociation_PFlow_AODFix', RecoTools=[PFAssocTool])
            METMakerAlg_PF = getMETMakerAlg('AntiKt4EMPFlow',
                                            confsuffix="_AODFix")
            METMakerAlg_PF.AllowOverwrite = True

            #Set up our own sequence
            ParticleFlowJetSequence = AthSequencer(
                "ParticleFlowSelectionSequence")
            topSequence += ParticleFlowJetSequence

            #Add an event filter to our sequence
            ParticleFlowJetSequence += CfgMgr.ParticleFlowEventFilter_r207(
                "ParticleFlowEventFilter_r207")
            #Add the particle flow jet finding to our sequence
            ParticleFlowJetSequence += CfgMgr.JetAlgorithm(
                "pflowJetAlg_AODFix",
                Tools=[jetrun, ToolSvc.AntiKt4EMPFlowJets_AODFix])
            #Add MET map builder to our sequence
            ParticleFlowJetSequence += METAssocAlg_PFlow
            #Build the reference MET container
            ParticleFlowJetSequence += METMakerAlg_PF
Esempio n. 20
0
theApp.EvtMax =  1

#--------------------------------------------------------------
# Configure algorithm.
#--------------------------------------------------------------

# Allow messge service more than default 500 lines.
ServiceMgr.MessageSvc.infoLimit = 10000

# Full job is a list of algorithms
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()

# Add the algorithm. It runs the demo tools.
from JetRec.JetRecConf import JetAlgorithm
job += JetAlgorithm("jetalg")
jetalg = job.jetalg
jetalg.OutputLevel = INFO

#--------------------------------------------------------------
# Configure tools.
#--------------------------------------------------------------

# Dump before reco.
if 1:
  from JetRec.JetRecConf import JetDumper
  ToolSvc += JetDumper("inpdmp")
  inpdmp = ToolSvc.inpdmp
  inpdmp.ContainerName = "JetClusters"
  inpdmp.Detail = 1
  inpdmp.MaxObject = 20
Esempio n. 21
0
# Variable R track jets
#===================================================================
from DerivationFrameworkExotics.JetDefinitions import *
from JetRec.JetRecStandard import jtm

FTAG5Seq = CfgMgr.AthSequencer("FTAG5Sequence")

jtm.modifiersMap["smallvr_track_modifiers"] = jtm.modifiersMap["pv0track"]
jtm.modifiersMap["largevr_track_modifiers"] = [jtm.ktsplitter] # (nikola: what is this used for?)

jfind_smallvr_track = jtm.addJetFinder("AntiKtVR50Rmax4Rmin0TrackJets", "AntiKt", 0.4, "pv0track", "smallvr_track_modifiers",
                                        ghostArea = 0 , ptmin = 2000, ptminFilter = 7000,
                                        variableRMinRadius = 0, variableRMassScale = 50000, calibOpt = "none")

from JetRec.JetRecConf import JetAlgorithm
jetalg_smallvr_track= JetAlgorithm("jfind_smallvr_track", Tools = [jfind_smallvr_track])

FTAG5Seq += jetalg_smallvr_track

from JetRec.JetRecConf import PseudoJetGetter
jtm += PseudoJetGetter(
     "gvr50rmax4rmin0trackget", # give a unique name
     InputContainer = jetFlags.containerNamePrefix() + "AntiKtVR50Rmax4Rmin0TrackJets", # SG key
     Label = "GhostVR50Rmax4Rmin0TrackJet", # this is the name you'll use to retrieve ghost associated VR track jets
     OutputContainer = "PseudoJetGhostVR50Rmax4Rmin0TrackJet",
     SkipNegativeEnergy = True,
     GhostScale = 1.e-20, # this makes the PseudoJet Ghosts, and thus the reco flow will treat them as such
   )

jtm.gettersMap["lctopo"]+= [jtm.gvr50rmax4rmin0trackget] # has to happen before the trimmed jet gets clustered for the VR track jets to be ghost associated
Esempio n. 22
0
def addJetRecoToAlgSequence(job=None,
                            useTruth=None,
                            eventShapeTools=None,
                            separateJetAlgs=None,
                            debug=None):

    myname = "JetAlgorithm: "

    # We need this to modify the global variable.
    global jetalg

    # Import message level flags.
    from GaudiKernel.Constants import DEBUG

    # Import the jet reconstruction control flags.
    from JetRec.JetRecFlags import jetFlags

    # Import the standard jet tool manager.
    from JetRec.JetRecStandardToolManager import jtm

    # Set sequence and flags as needed.
    if job == None:
        from AthenaCommon.AlgSequence import AlgSequence
        job = AlgSequence()
    if useTruth == None:
        useTruth = jetFlags.useTruth()
    if eventShapeTools == None:
        eventShapeTools = jetFlags.eventShapeTools()
        if eventShapeTools == None:
            eventShapeTools = []
    if separateJetAlgs == None:
        separateJetAlgs = jetFlags.separateJetAlgs()

    # Event shape tools.
    evstools = []
    evsDict = {
        "emtopo": ("EMTopoEventShape", jtm.emget),
        "lctopo": ("LCTopoEventShape", jtm.lcget),
        "empflow": ("EMPFlowEventShape", jtm.empflowget),
        "emcpflow": ("EMCPFlowEventShape", jtm.emcpflowget),
        "lcpflow": ("LCPFlowEventShape", jtm.lcpflowget),
    }

    if jetFlags.useTracks():
        evsDict["emtopo"] = ("EMTopoOriginEventShape", jtm.emoriginget)
        evsDict["lctopo"] = ("LCTopoOriginEventShape", jtm.lcoriginget)
    jetlog.info(myname + "Event shape tools: " + str(eventShapeTools))

    from RecExConfig.AutoConfiguration import IsInInputFile
    for evskey in eventShapeTools:
        from EventShapeTools.EventDensityConfig import configEventDensityTool
        if evskey in evsDict:
            (toolname, getter) = evsDict[evskey]
            if toolname in jtm.tools:
                jetlog.info(myname + "Skipping duplicate event shape: " +
                            toolname)
            else:
                jetlog.info(myname + "Adding event shape " + evskey)
                if not IsInInputFile("xAOD::EventShape", "Kt4" + toolname):
                    jtm += configEventDensityTool(toolname, getter, 0.4)
                    evstools += [jtm.tools[toolname]]
        else:
            jetlog.info(myname + "Invalid event shape key: " + evskey)
            raise Exception

    # Add the tool runner. It runs the jetrec tools.
    rtools = []
    # Add the truth tools.
    if useTruth:
        from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles
        rtools += scheduleCopyTruthParticles()

        # build truth jet input :
        rtools += [jtm.truthpartcopy, jtm.truthpartcopywz]

    ## if jetFlags.useCells():
    ##   rtools += [jtm.missingcells] commented out : incompatible with trigger : ATR-9696
    if jetFlags.useTracks:
        rtools += [
            jtm.tracksel,
            jtm.tvassoc,
            jtm.trackselloose_trackjets,
        ]

    # Add the algorithm. It runs the jetrec tools.
    from JetRec.JetRecConf import JetAlgorithm
    ctools = []
    if jetFlags.useTracks:
        if not IsInInputFile("xAOD::CaloClusterContainer",
                             "LCOriginTopoClusters"):
            ctools += [jtm.JetConstitSeq_LCOrigin]
        if not IsInInputFile("xAOD::CaloClusterContainer",
                             "EMOriginTopoClusters"):
            ctools += [jtm.JetConstitSeq_EMOrigin]
    from JetRec.JetRecConf import JetToolRunner
    runners = []
    if len(ctools) > 0:
        jtm += JetToolRunner("jetconstit",
                             EventShapeTools=[],
                             Tools=ctools,
                             Timer=jetFlags.timeJetToolRunner())
        jtm.jetconstit
        runners = [jtm.jetconstit]

    if jetFlags.separateJetAlgs():

        jtm += JetToolRunner("jetrun",
                             EventShapeTools=evstools,
                             Tools=rtools,
                             Timer=jetFlags.timeJetToolRunner())
        runners += [jetrun]

        job += JetAlgorithm("jetalg")
        jetalg = job.jetalg
        jetalg.Tools = runners

        for t in jtm.jetrecs:
            jalg = JetAlgorithm("jetalg" + t.name())
            jalg.Tools = [t]
            job += jalg

    else:
        from JetRec.JetRecConf import JetToolRunner
        jtm += JetToolRunner("jetrun",
                             EventShapeTools=evstools,
                             Tools=rtools + jtm.jetrecs,
                             Timer=jetFlags.timeJetToolRunner())
        runners += [jtm.jetrun]

        job += JetAlgorithm("jetalg")
        jetalg = job.jetalg
        jetalg.Tools = runners
        if jetFlags.debug > 0:
            jtm.setOutputLevel(jtm.jetrun, DEBUG)
            jetalg.OutputLevel = DEBUG
        if jetFlags.debug > 1:
            for tool in jtm.jetrecs:
                jtm.setOutputLevel(tool, DEBUG)
        if jetFlags.debug > 2:
            for tool in jtm.finders:
                jtm.setOutputLevel(tool, DEBUG)
        if jetFlags.debug > 3:
            jtm.setOutputLevel(jtm.jetBuilderWithArea, DEBUG)
            jtm.setOutputLevel(jtm.jetBuilderWithoutArea, DEBUG)
Esempio n. 23
0
def buildVRJets(sequence,
                do_ghost,
                logger=None,
                doFlipTagger=False,
                training='201810'):

    from AthenaCommon import Logging

    if logger is None:
        logger = Logging.logging.getLogger('VRLogger')

    supported_trainings = ['201810', '201903']
    # Check allowed trainings
    # Is there a better way to do this with a central DB?
    if training not in ['201810', '201903']:
        logger.warning(
            "WARNING: Using an unsupported training tag! This is UNDEFINED and will probably break. Please choose a training tag from"
        )
        logger.warning(supported_trainings)

    from JetRec.JetRecStandard import jtm

    # Making Chris Happy: all VR track-jet b-tagging should have the training campaign label
    trainingTag = '_BTagging%s' % (training)

    VRJetName = "AntiKtVR30Rmax4Rmin02Track%s" % (trainingTag)
    VRGhostLabel = "GhostVR30Rmax4Rmin02TrackJet%s" % (trainingTag)
    VRJetAlg = "AntiKt"
    VRJetRadius = 0.4
    VRJetInputs = 'pv0track'
    VRJetOptions = dict(ghostArea=0,
                        ptmin=4000,
                        variableRMinRadius=0.02,
                        variableRMassScale=30000,
                        calibOpt="none")

    # Change some options if we have do_ghost set to true. Hopefully
    # this will be the only VR collection in the future.
    if do_ghost:
        ghost_suffix = "GhostTag"
        VRJetName += ghost_suffix
        VRGhostLabel += ghost_suffix

    #==========================================================
    # Build VR jets
    #==========================================================

    from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg
    VRJetRecToolName = nameJetsFromAlg(VRJetName)
    VRJetAlgName = "jfind_%s" % (VRJetRecToolName)
    VRJetBTagName = "BTagging_%s" % (VRJetName.replace('BTagging', ''))

    logger.info("VR Btag name: %s" % VRJetBTagName)
    logger.info("VR jet name: %s" % VRJetRecToolName)

    from AthenaCommon.AppMgr import ToolSvc

    #make the btagging tool for VR jets
    from BTagging.BTaggingFlags import BTaggingFlags
    BTaggingFlags.CalibrationChannelAliases += [
        "AntiKtVR30Rmax4Rmin02Track->AntiKtVR30Rmax4Rmin02Track,AntiKt4EMTopo"
    ]
    BTaggingFlags.CalibrationChannelAliases += [
        "%s->AntiKtVR30Rmax4Rmin02Track,AntiKt4EMTopo" % (VRJetName)
    ]
    btag_vrjets = ConfInst.setupJetBTaggerTool(
        ToolSvc,
        JetCollection=VRJetRecToolName,
        AddToToolSvc=True,
        Verbose=True,
        options={
            "name": VRJetBTagName.lower(),
            "BTagName": VRJetBTagName,
            "BTagJFVtxName": "JFVtx",
            "BTagSVName": "SecVtx",
        },
        SetupScheme="",
        TaggerList=BTaggingFlags.ExpertTaggers
        if doFlipTagger else BTaggingFlags.StandardTaggers,
        TrackAssociatorName="GhostTrack" if do_ghost else "MatchedTracks",
    )

    # add Ghost label id
    from ParticleJetTools.ParticleJetToolsConf import (
        ParticleJetGhostLabelTool as GhostLabelTool)
    gl_tool = GhostLabelTool(name=VRJetRecToolName + "_GhostLabeling")
    ToolSvc += gl_tool

    from BTagging.BTaggingConfiguration import defaultTrackAssoc, defaultMuonAssoc

    # Slice the array - this forces a copy so that if we modify it we don't also
    # change the array in jtm.
    pseudoJetGetters = jtm.gettersMap[VRJetInputs][:]

    # We want to include ghost associated tracks in the pv0 tracks so that
    # we can use the looser ghost association criteria for b-tagging.
    if VRJetInputs == "pv0track":
        pseudoJetGetters.append(jtm["gtrackget"])

    if VRJetAlgName in DFJetAlgs:
        logger.info("Algorithm %s already built before" % VRJetAlgName)

        if hasattr(sequence, VRJetAlgName):
            logger.info("Sequence %s already has an instance of algorithm %s" %
                        (sequence, VRJetAlgName))
        else:
            logger.info("Add algorithm %s to sequence %s" %
                        (VRJetAlgName, sequence))
            sequence += DFJetAlgs[VRJetAlgName]
    else:
        logger.info("Create algorithm %s" % VRJetAlgName)

        if hasattr(jtm, VRJetRecToolName):
            logger.info("JetRecTool %s is alredy in jtm.tools in sequence %s" %
                        (VRJetRecToolName, sequence))
        else:
            logger.info("Create JetRecTool %s" % VRJetRecToolName)
            #can only run trackjetdrlabeler with truth labels, so MC only

            mods = [defaultTrackAssoc, defaultMuonAssoc, btag_vrjets]

            if isMC:
                mods += [jtm.trackjetdrlabeler, gl_tool]

            jtm.addJetFinder(VRJetRecToolName,
                             VRJetAlg,
                             VRJetRadius,
                             pseudoJetGetters,
                             modifiersin=mods,
                             ivtxin=0,
                             **VRJetOptions)

        from JetRec.JetRecConf import JetAlgorithm
        jetalg_smallvr30_track = JetAlgorithm(VRJetAlgName,
                                              Tools=[jtm[VRJetRecToolName]])
        sequence += jetalg_smallvr30_track
        DFJetAlgs[VRJetAlgName] = jetalg_smallvr30_track

    #==========================================================
    # Build PseudoJet Getter
    #==========================================================

    pjgettername = VRGhostLabel.lower()
    from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg

    if hasattr(jtm, pjgettername):
        logger.info("Found %s in jtm in sequence %s" %
                    (pjgettername, sequence))
    else:
        logger.info("Add %s to jtm in sequence %s" % (pjgettername, sequence))

        inputContainerName = jetFlags.containerNamePrefix() + nameJetsFromAlg(
            VRJetName)

        from JetRec.JetRecConf import PseudoJetGetter
        jtm += PseudoJetGetter(
            pjgettername,  # give a unique name
            InputContainer=inputContainerName,  # SG key
            Label=
            VRGhostLabel,  # this is the name you'll use to retrieve ghost associated VR track jets
            OutputContainer="PseudoJet" + VRGhostLabel,
            SkipNegativeEnergy=True,
            GhostScale=
            1.e-20,  # this makes the PseudoJet Ghosts, and thus the reco flow will treat them as such
        )
    return VRJetName, VRGhostLabel
Esempio n. 24
0
def linkVRJetsToLargeRJets(sequence, collection, getters):
    """Re-run jet finding for a jet collection using a new list of 
    PseudoJetGetters. These PseudoJetGetters should already have been loaded
    into jtm.
    collection should be the name of the jet collection, which should already
    have been sequenced, so it's jet rec tool will exist in jtm.
    getters should be a map of PseudoJetGetters, each key being the name of the
    (non ghost) collection, with the value being the name of the 
    PseudoJetGetter in jtm.
    Returns the name of the ungroomed collection that is the parent of
    'collection' (this will be the same as 'collection' if this isn't groomed)
    *and* the list of ghost labels (these are the element link names).
  """
    from JetRec.JetRecStandardToolManager import jtm
    import DerivationFrameworkJetEtMiss.JetCommon as JetCommon
    from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg
    logger = Logging.logging.getLogger('HbbTaggerLog')
    # First, retrieve the original JetRecTool - this is the one that made the
    # *ungroomed* jets, not the groomed ones. Ghost association is done to
    # ungroomed objects
    originalJetRecTool = getJetRecTool(collection, getParent=True)
    originalUngroomedName = originalJetRecTool.name()
    ungroomedJetAlg = originalUngroomedName
    if ungroomedJetAlg.endswith("Jets"):
        ungroomedJetAlg = ungroomedJetAlg[:-4]
    originalFinder = jtm[originalJetRecTool.JetFinder.getName()]
    originalGetters = [
        jtm[g.getName()] for g in originalJetRecTool.PseudoJetGetters
    ]
    newGetters = [jtm[g] for g in getters.values()]

    # Next, prepare the names of the new objects we'll need from jtm

    comb_name = "_".join(getters.keys())
    LargeRJetFindingAlg = "jfind_{0}_{1}".format(collection, comb_name).lower()
    LargeRJetPrefix = "{0}_{1}".format(collection, comb_name)
    LargeRJets = nameJetsFromAlg(LargeRJetPrefix)
    LinkTransferAlg = "LinkTransfer_{0}_{1}".format(collection, comb_name)

    # Check to see if this large R jet collection is already known to JetCommon
    if LargeRJetFindingAlg in JetCommon.DFJetAlgs:
        logger.info("Found {0} in DFJetAlgs".format(LargeRJetFindingAlg))
        # Is it in our sequence?
        if hasattr(sequence, LargeRJetFindingAlg):
            logger.info(
                "Algorithm already exists in the input sequence. Will not "
                "add again")
        else:
            logger.info(
                "Adding algorithm into the sequence {0}".format(sequence))
            sequence += JetCommon.DFJetAlgs[LargeRJetFindingAlg]
    else:
        # Check to see if the corresponding JetRecTool already exists
        if hasattr(jtm, LargeRJets):
            logger.info(
                "JetRecTool {0} already exists in jtm".format(LargeRJets))
        else:
            logger.info("Create a new JetRecTool {0}".format(LargeRJets))
            JetCommon.OutputJets.setdefault("CustomJets",
                                            []).append(LargeRJets)
            originalModifiers = [
                jtm[m.getName()] for m in originalJetRecTool.JetModifiers
            ]
            jtm.addJetFinder(
                output=LargeRJets,
                alg=originalFinder.JetAlgorithm,
                radius=originalFinder.JetRadius,
                gettersin=originalGetters + newGetters,
                modifiersin=originalModifiers,
                ghostArea=0,
                ptmin=originalFinder.PtMin,
                variableRMinRadius=originalFinder.VariableRMinRadius,
                variableRMassScale=originalFinder.VariableRMassScale,
                calibOpt="none")
            # Note that we don't need ptminFilter as this was included in the original
            # list of JetModifiers
        logger.info(
            "Creating new jet algorithm {0} and adding it to sequence {1}".
            format(LargeRJetFindingAlg, sequence))
        theJetAlg = JetAlgorithm(LargeRJetFindingAlg, Tools=[jtm[LargeRJets]])
        sequence += theJetAlg
        JetCommon.DFJetAlgs[LargeRJetFindingAlg] = theJetAlg

    # Everything so far has been to create the links on a copy of the ungroomed
    # collection. Now we need to copy those links over to the original ungroomed
    # collection.
    from DerivationFrameworkJetEtMiss.ExtendedJetCommon import getJetExternalAssocTool, applyJetAugmentation
    assocTool = getJetExternalAssocTool(
        ungroomedJetAlg,
        LargeRJetPrefix,
        MomentPrefix='',
        ListOfOldLinkNames=[g.Label for g in newGetters])
    applyJetAugmentation(ungroomedJetAlg, LinkTransferAlg, sequence, assocTool)

    return originalUngroomedName, [g.Label for g in newGetters]
Esempio n. 25
0
#Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# ScheduleCHSPFlowMods.py
#
# Teng Jian Khoo
# July 2017
#
# Apply PFlow p4 corrections (nPFO origin & cPFO weights) and
# Charged Hadron Subtraction with jet constituent modification tools

from JetRec.JetRecStandard import jtm
from JetRec.JetRecConf import JetToolRunner
jtm += JetToolRunner(
    "jetconstitCHSPFlow",
    EventShapeTools=[],
    Tools=[jtm.JetConstitSeq_PFlowCHS],
)

from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()

from JetRec.JetRecConf import JetAlgorithm
job += JetAlgorithm("jetalgCHSPFlow", Tools=[jtm.jetconstitCHSPFlow])

from ThinningUtils.ThinningUtilsConf import ThinNegativeEnergyNeutralPFOsAlg
CHSnPFOsThinAlg = ThinNegativeEnergyNeutralPFOsAlg(
    "ThinNegativeEnergyNCHSeutralPFOsAlg",
    NeutralPFOsKey="CHSNeutralParticleFlowObjects",
    ThinNegativeEnergyNeutralPFOs=True,
    StreamName='StreamAOD')
job += CHSnPFOsThinAlg
Esempio n. 26
0
def addTruthJetsIfNotExising(truth_jets_name):
    '''
    Add algorithm to create the truth jets collection unless the
    collection exists already, or a truth jet finder is already running
    '''
    from RecExConfig.AutoConfiguration import IsInInputFile

    # the jet collection name does not exist in the input file
    # add a jet finder algorithm in front of the monitoring if the algorithm
    # does not yet exist.
    if not IsInInputFile('xAOD::JetContainer', truth_jets_name):
        try:
            from AthenaCommon.Logging import logging
            log = logging.getLogger('InDetPhysValMonitoring/addTruthJets.py')

            from PyUtils.MetaReaderPeeker import convert_itemList, metadata
            eventdata_itemsDic = convert_itemList(layout='dict')
            log.info(
                'DEBUG addTruthJetsIfNotExising {} not in {} [file_type={}]'.
                format(truth_jets_name, eventdata_itemsDic,
                       metadata['file_type']))

            if truth_jets_name in eventdata_itemsDic:
                return
        except:
            pass

        # Access the algorithm sequence:
        from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
        topSequence = AlgSequence()

        # extract the jet finder type and main parameter
        import re
        extract_alg = re.search('^([^0-9]+)([0-9]+)TruthJets', truth_jets_name)
        if extract_alg != None:
            alg_type = extract_alg.group(1)
            alg_param_str = extract_alg.group(2)
        else:
            alg_type = 'AntiKt'
            alg_param_str = 4

        jet_finder_alg_name = "jetalg" + alg_type + alg_param_str + 'TruthJets'

        # add the jet finder unless it exists already in the alg sequence
        from InDetPhysValDecoration import findAlg, findMonMan
        alg_pos = findAlg([jet_finder_alg_name])
        if alg_pos == None:
            from JetRec.JetRecStandard import jtm
            mon_man_index = findMonMan()

            # configure truth jet finding ?
            from JetRec.JetRecFlags import jetFlags
            jetFlags.useTruth = True
            jetFlags.useTracks = False
            jetFlags.truthFlavorTags = [
                "BHadronsInitial",
                "BHadronsFinal",
                "BQuarksFinal",
                "CHadronsInitial",
                "CHadronsFinal",
                "CQuarksFinal",
                "TausFinal",
                "Partons",
            ]

            # tool to create truth jet finding inputs
            truth_part_copy_name = 'truthpartcopy'
            dir(jtm)
            create_truth_jet_input = None
            if not hasattr(jtm, truth_part_copy_name):

                from MCTruthClassifier.MCTruthClassifierConfig import firstSimCreatedBarcode
                from MCTruthClassifier.MCTruthClassifierConf import MCTruthClassifier
                truth_classifier_name = 'JetMCTruthClassifier'
                if not hasattr(jtm, truth_classifier_name):
                    from AthenaCommon.AppMgr import ToolSvc
                    if not hasattr(ToolSvc, truth_classifier_name):
                        truthClassifier = MCTruthClassifier(
                            name=truth_classifier_name,
                            barcodeG4Shift=firstSimCreatedBarcode(),
                            ParticleCaloExtensionTool="")
                    else:
                        truthClassifier = getattr(ToolSvc,
                                                  truth_classifier_name)
                        truthClassifier.barcodeG4Shift = firstSimCreatedBarcode(
                        )
                    jtm += truthClassifier
                else:
                    truthClassifier = getattr(jtm, truth_classifier_name)
                    truthClassifier.barcodeG4Shift = firstSimCreatedBarcode()

                from ParticleJetTools.ParticleJetToolsConf import CopyTruthJetParticles
                create_truth_jet_input = CopyTruthJetParticles(
                    truth_part_copy_name,
                    OutputName="JetInputTruthParticles",
                    MCTruthClassifier=truthClassifier)
                jtm += create_truth_jet_input
            else:
                create_truth_jet_input = getattr(jtm, truth_part_copy_name)

            jet_finder_tool = jtm.addJetFinder(truth_jets_name,
                                               alg_type,
                                               float(alg_param_str) / 10.,
                                               "truth",
                                               ptmin=5000)

            jet_tools = []
            from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles
            jet_tools += scheduleCopyTruthParticles()
            jet_tools += [create_truth_jet_input]
            jet_tools += jtm.jetrecs

            # add the jet finder in front of the monitoring
            from JetRec.JetRecConf import JetAlgorithm
            from JetRec.JetRecConf import JetToolRunner
            jtm += JetToolRunner(
                "jetrun",
                Tools=jet_tools,
                EventShapeTools=[],
                # OutputLevel = 1,
                Timer=jetFlags.timeJetToolRunner())

            # jet_finder_alg = JetAlgorithm(jet_finder_alg_name, jet_tools)
            jet_finder_alg = JetAlgorithm(jet_finder_alg_name)
            # jet_finder_alg.OutputLevel = 1
            jet_finder_alg.Tools = [jtm.jetrun]

            if mon_man_index != None:
                topSequence.insert(mon_man_index, jet_finder_alg)
            else:
                topSequence += jet_finder_alg
Esempio n. 27
0
def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None,
                            separateJetAlgs= None, debug =None):

  myname = "JetAlgorithm: "

  # We need this to modify the global variable.
  global jetalg

  # Import message level flags.
  from GaudiKernel.Constants import DEBUG

  # Import the jet reconstruction control flags.
  from JetRec.JetRecFlags import jetFlags

  # Import the standard jet tool manager.
  from JetRec.JetRecStandardToolManager import jtm

  # Set sequence and flags as needed.
  if job == None:
    from AthenaCommon.AlgSequence import AlgSequence
    job = AlgSequence()
  if useTruth == None:
    useTruth = jetFlags.useTruth()
  if eventShapeTools == None:
    eventShapeTools = jetFlags.eventShapeTools()
    if eventShapeTools == None:
      eventShapeTools = []
  if separateJetAlgs == None:
    separateJetAlgs = jetFlags.separateJetAlgs()


  # Event shape tools.
  evstools = []
  evsDict = {
    "emtopo"   : ("EMTopoEventShape",   jtm.emget),
    "lctopo"   : ("LCTopoEventShape",   jtm.lcget),
    "empflow"  : ("EMPFlowEventShape",  jtm.empflowget),
    "emcpflow" : ("EMCPFlowEventShape", jtm.emcpflowget),
    "lcpflow"  : ("LCPFlowEventShape",  jtm.lcpflowget),
  }
  print myname + "Event shape tools: " + str(eventShapeTools)
  for evskey in eventShapeTools:
    from EventShapeTools.EventDensityConfig import configEventDensityTool
    if evskey in evsDict:
      (toolname, getter) = evsDict[evskey]
      if toolname in jtm.tools:
        print myname + "Skipping duplicate event shape: " + toolname
      else:
        print myname + "Adding event shape " + evskey
        jtm += configEventDensityTool(toolname, getter, 0.4)
        evstools += [jtm.tools[toolname]]
    else:
      print myname + "Invalid event shape key: " + evskey
      raise Exception

  # Add the tool runner. It runs the jetrec tools.
  rtools = []
  # Add the truth tools.
  if useTruth:    
    from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles
    rtools += scheduleCopyTruthParticles()
    
    # build truth jet input :
    rtools += [ jtm.truthpartcopy, jtm.truthpartcopywz ]

  ## if jetFlags.useCells():
  ##   rtools += [jtm.missingcells] commented out : incompatible with trigger : ATR-9696
  if jetFlags.useTracks:
    rtools += [jtm.tracksel,
               jtm.tvassoc,
               jtm.trackselloose_trackjets,
               jtm.JetConstitSeq_LCOrigin,
               jtm.JetConstitSeq_EMOrigin,
               ]
    
  # Add the algorithm. It runs the jetrec tools.
  from JetRec.JetRecConf import JetAlgorithm

  if jetFlags.separateJetAlgs():

    from JetRec.JetRecConf import JetToolRunner
    jtm += JetToolRunner("jetrun",
                         EventShapeTools=evstools,
                         Tools=rtools,
                         Timer=jetFlags.timeJetToolRunner()
                         )
    jetrun = jtm.jetrun

    job += JetAlgorithm("jetalg")
    jetalg = job.jetalg
    jetalg.Tools = [jtm.jetrun]

    for t in jtm.jetrecs:
      # from JetRec.JetRecConf import JetToolRunner
      # jetrun_rec = JetToolRunner("jetrun"+t.name(),
      #                            EventShapeTools=[],
      #                            Tools=[t],
      #                            Timer=jetFlags.timeJetToolRunner()
      #                            )
      # jtm += jetrun_rec
      jalg = JetAlgorithm("jetalg"+t.name())
      jalg.Tools = [t]
      job+= jalg

  else:
    from JetRec.JetRecConf import JetToolRunner
    jtm += JetToolRunner("jetrun",
                         EventShapeTools=evstools,
                         Tools=rtools+jtm.jetrecs,
                         Timer=jetFlags.timeJetToolRunner()
                         )
    jetrun = jtm.jetrun

    job += JetAlgorithm("jetalg")
    jetalg = job.jetalg
    jetalg.Tools = [jtm.jetrun]
    if jetFlags.debug > 0:
      jtm.setOutputLevel(jtm.jetrun, DEBUG)
      jetalg.OutputLevel = DEBUG
    if jetFlags.debug > 1:
      for tool in jtm.jetrecs:
        jtm.setOutputLevel(tool, DEBUG)
    if jetFlags.debug > 2:
      for tool in jtm.finders:
        jtm.setOutputLevel(tool, DEBUG)
    if jetFlags.debug > 3:
      jtm.setOutputLevel(jtm.jetBuilderWithArea, DEBUG)
      jtm.setOutputLevel(jtm.jetBuilderWithoutArea, DEBUG)
Esempio n. 28
0
def addExKtCoM(sequence,
               ToolSvc,
               JetCollectionExCoM,
               nSubjets,
               doTrackSubJet,
               doGhostAssoc=False,
               ExGhostLabels=[
                   "GhostBHadronsFinal", "GhostCHadronsFinal", "GhostTrack"
               ],
               min_subjet_pt_mev=0,
               subjetAlgName="Kt"):
    if (subjetAlgName != "Kt" and subjetAlgName != "CoM"):
        print("WARNING:  Subjet type must be Kt or CoM.  Using Kt as default!")
        subjetAlgName = "Kt"
    from JetRec.JetRecStandard import jtm
    ExCoMJetCollection__SubJet = []

    (ExCoMbbTagToolInstance, SubjetContainerName) = buildExclusiveSubjets(
        ToolSvc, JetCollectionExCoM, subjetAlgName, nSubjets, doGhostAssoc,
        doTrackSubJet, ExGhostLabels, min_subjet_pt_mev)

    ExCoMJetCollection__SubJet += [SubjetContainerName]

    excomELresetName = "ELreset_subjet_%s" % (SubjetContainerName.replace(
        "Jets", ""))
    excomELresetNameLJet = "ELreset_Large_%sjet_%s" % (
        SubjetContainerName.replace(
            "Jets", ""), JetCollectionExCoM.replace("Jets", ""))
    excomAlgName = "jfind_%s" % (SubjetContainerName)
    excomJetRecToolName = "%s" % (SubjetContainerName)
    excomBTagName = "BTagging_%s" % (SubjetContainerName.replace("Jets", ""))

    if excomAlgName in DFJetAlgs:
        print(" Algorithm Ex%s " % subjetAlgName, excomAlgName,
              "already built before sequence ", sequence)

        if hasattr(sequence, excomAlgName):
            print(" sequence Ex%s " % subjetAlgName, sequence,
                  "already has an instance of algorithm", excomAlgName)
        else:
            print(" Add algorithm Ex%s " % subjetAlgName, excomAlgName,
                  "to sequence", sequence)
            sequence += DFJetAlgs[excomAlgName]
            sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
                excomELresetName, SGKeys=[SubjetContainerName + "Aux."])
            sequence += DFJetAlgs[excomAlgName + "_btag"]
            sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
                excomELresetNameLJet, SGKeys=[JetCollectionExCoM + "Aux."])
    else:
        print(" Algorithm Ex%s " % subjetAlgName, excomAlgName,
              " to be built sequence ", sequence)
        if hasattr(jtm, excomJetRecToolName):
            print(" Ex%sJetRecTool " % subjetAlgName, excomJetRecToolName,
                  " already built sequence ", sequence)
            jetrec = jtm[excomJetRecToolName]
        else:
            print(" Ex%s tool " % subjetAlgName, excomJetRecToolName,
                  " to be built sequence ", sequence)
            from JetRec.JetRecConf import JetRecTool
            jetrec = JetRecTool(
                name=excomJetRecToolName,
                OutputContainer=JetCollectionExCoM,
                InputContainer=JetCollectionExCoM,
                JetModifiers=[ExCoMbbTagToolInstance],
            )
            jtm.add(jetrec)
            ToolSvc += jetrec

        excomJetRecBTagToolName = str("%s_sub" % excomJetRecToolName)
        if hasattr(jtm, excomJetRecBTagToolName):
            print(" Ex%sJetRecBTagTool " % subjetAlgName,
                  excomJetRecBTagToolName, " already built sequence ",
                  sequence)
            jetrec_btagging = jtm[excomJetRecBTagToolName]
        else:
            print(" Ex%sJetRecBTagTool " % subjetAlgName,
                  excomJetRecBTagToolName, " to be built sequence ", sequence)

            #make the btagging tool for excom jets
            from BTagging.BTaggingFlags import BTaggingFlags
            btag_excom = ConfInst.setupJetBTaggerTool(
                ToolSvc,
                JetCollection=excomJetRecToolName.replace("Jets", ""),
                AddToToolSvc=True,
                Verbose=True,
                options={
                    "name": excomBTagName.lower(),
                    "BTagName": excomBTagName,
                    "BTagJFVtxName": "JFVtx",
                    "BTagSVName": "SecVtx",
                },
                SetupScheme="",
                TaggerList=BTaggingFlags.StandardTaggers,
                TrackAssociatorName="GhostTrack"
                if doGhostAssoc else "MatchedTracks")
            # running association + b-tagging on subjets now
            from BTagging.BTaggingConfiguration import comTrackAssoc, comMuonAssoc, defaultTrackAssoc, defaultMuonAssoc
            mods = [defaultTrackAssoc, defaultMuonAssoc, btag_excom]
            if (subjetAlgName == "CoM"):
                mods = [comTrackAssoc, comMuonAssoc, btag_excom]
            if isMC:
                mods.append(jtm.jetdrlabeler)

            jetrec_btagging = JetRecTool(name=excomJetRecBTagToolName,
                                         InputContainer=SubjetContainerName,
                                         OutputContainer=SubjetContainerName,
                                         JetModifiers=mods)
            jtm.add(jetrec_btagging)
            ToolSvc += jetrec_btagging

        jetalg_excom = JetAlgorithm(
            name=excomAlgName,
            Tools=[jetrec],
        )
        sequence += jetalg_excom
        DFJetAlgs[excomAlgName] = jetalg_excom

        # Reset EL for ExCoM subjets after all of them are built
        # Otherwise crashing for CoM during TrackToJetAssociation due to failure of finding the large-R parent jet.
        sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
            excomELresetName, SGKeys=[SubjetContainerName + "Aux."])

        jetalg_excom_btag = JetAlgorithm(
            name=excomAlgName + "_btag",
            Tools=[jetrec_btagging],
        )
        sequence += jetalg_excom_btag
        DFJetAlgs[excomAlgName + "_btag"] = jetalg_excom_btag
        sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
            excomELresetNameLJet, SGKeys=[JetCollectionExCoM + "Aux."])

    return ExCoMJetCollection__SubJet
Esempio n. 29
0
def scheduleRTTJetTests():

    global containerToRebuild

    from JetRec.JetRecFlags import jetFlags
    from RecExConfig.RecFlags import rec
    jetFlags.useTruth = rec.doTruth()

    from JetRec.JetRecStandard import jtm
    from JetRec.JetRecConf import JetAlgorithm
    from JetRec.JetRecUtils import interpretJetName

    from JetRec.JetRecStandardToolManager import calib_topo_ungroomed_modifiers, topo_ungroomed_modifiers

    #calibarg = 'calib' if jetFlags.applyCalibrationName()!="none" else None

    #calibarg = 'calib' if jetFlags.applyCalibrationName!= "none" else "none"

    # arguments to give to addJetFinder
    # format is 'input' : dict_of_args
    inputArgs = {
        'LCTopo': dict(
            gettersin='lctopo',
            modifiersin='calib',
            ghostArea=0.01,
        ),
        'EMTopo': dict(
            gettersin='emtopo',
            modifiersin='calib',
            ghostArea=0.01,
        ),
        'ZTrack': {},
    }

    fullnameArgs = {
        "AntiKt4LCTopoJetsTest": dict(ptminFilter=7000, calibOpt='ar'),
        "AntiKt4EMTopoJetsTest": dict(ptminFilter=5000, calibOpt='ar'),
        "AntiKt10LCTopoJetsTest": dict(ptminFilter=50000, calibOpt='a'),
        "CamKt12LCTopoJetsTest": dict(ptminFilter=50000, calibOpt='a'),
    }

    tools = []
    for jname in containerToRebuild:
        # decompose arg name
        finder, mainParam, input = interpretJetName(jname)

        args = fullnameArgs[jname]
        args.update(inputArgs[input])
        # call addJetFinderArgs with the relavant args for this collection
        t = jtm.addJetFinder(jname, finder, mainParam, ptmin=2000, **args)

        tools.append(t)

    from AthenaCommon.AlgSequence import AlgSequence
    topSequence = AlgSequence()

    if jetFlags.useTruth:
        from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles
        tools = [jtm.truthpartcopy, jtm.truthpartcopywz
                 ] + scheduleCopyTruthParticles() + tools

    topSequence += JetAlgorithm("JetAlgorithmTest",
                                Tools=[
                                    jtm.tracksel,
                                    jtm.tvassoc,
                                ] + tools)
Esempio n. 30
0
    "CHadronsInitial",
    "CHadronsFinal",
    "CQuarksFinal",
    "TausFinal",
    "Partons",
]
# Standard truth jets
# To recover jet constituents remove the last modifier.
akt4 = jtm.addJetFinder(
    "AntiKt4TruthJets",
    "AntiKt",
    0.4,
    "truth",
    modifiersin=[jtm.truthpartondr, jtm.partontruthlabel, jtm.removeconstit],
    ptmin=5000)
akt4alg = JetAlgorithm("jetalgAntiKt4TruthJets", Tools=[akt4])
DerivationFrameworkJob += akt4alg

# WZ Truth Jets
#jtm.addJetFinder("AntiKt4TruthWZJets",  "AntiKt", 0.4,  "truthwz", ptmin= 5000)
#jtm.addJetFinder("AntiKt6TruthWZJets",  "AntiKt", 0.6,  "truthwz", ptmin= 5000)
# Other jets
#akt6  = jtm.addJetFinder("AntiKt6TruthJets", "AntiKt", 0.6, "truth", ptmin= 5000)
#akt10 = jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin= 5000)
#akt10trim = jtm.addJetTrimmer("TrimmedAntiKt10TruthJets", rclus=0.3, ptfrac=0.05, input='AntiKt10TruthJets')

# Add truth-based MET algorithm here
import METReconstruction.METConfig_Truth
from METReconstruction.METRecoFlags import metFlags  # not sure if you even need this line
from METReconstruction.METRecoConfig import getMETRecoAlg
metAlg = getMETRecoAlg('METReconstruction')
Esempio n. 31
0
    name="ParticleCaloCellAssociationInDet",
    ParticleCaloExtensionTool=ParticleToCaloExtrapolationTool,
    CaloClusterLocation="TimedCaloCalTopoClusters",
    ClustersInConeTool=CaloClustersInCone,
    ConeSize=0.1,
    UseCovariance=True)
ParticleCaloCellAssociation.OutputLevel = DEBUG
ToolSvc += ParticleCaloCellAssociation
print ParticleCaloCellAssociation

# Access the algorithm sequence:
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()

# Add the algorithm.
jetalg = JetAlgorithm("JetAlg_OriginAndTime")
jetalg.OutputLevel = INFO
jetalg.Tools += [PFSequence]
topSequence += jetalg

from TrackParticleAssociationAlgs.TrackParticleAssociationAlgsConf import TrackParticleClusterAssociationAlg
TrackParticleClusterAssociation = TrackParticleClusterAssociationAlg(
    name="TrackParticleClusterAssociationInDet",
    ParticleCaloClusterAssociationTool=ParticleCaloCellAssociation,
    TrackParticleContainerName="InDetTrackParticles",
    PtCut=400.,
    OutputCollectionPostFix="Test",
    CaloClusterLocation="TimedCaloCalTopoClusters")
# TrackParticleClusterAssociation.OutputLevel = DEBUG
topSequence += TrackParticleClusterAssociation
Esempio n. 32
0
from DerivationFrameworkCore.DerivationFrameworkMaster import *
from DerivationFrameworkJetEtMiss.JetCommon import *

from JetRec.JetRecConf import JetAlgorithm
from DerivationFrameworkJetEtMiss.DFJetMetFlags import *

if dfjmFlags.doJetTrackMomentFix:
    print "Scheduling jet track moment fix: "
    jtm.modifiersMap["jetmomfix"] = [jtm.trkmoms]
else:
    print "Copying jet track moments: "
    jtm.modifiersMap["jetmomfix"] = []

jetmomfix_LC = jtm.addJetCopier("DFJetFix_AntiKt4LCTopoJets", "AntiKt4LCTopoJets", "jetmomfix")
DerivationFrameworkJob += JetAlgorithm("jetalgDFJetFix_AntiKt4LCTopoJets", Tools = [jetmomfix_LC] )

jetmomfix_EM = jtm.addJetCopier("DFJetFix_AntiKt4EMTopoJets", "AntiKt4EMTopoJets", "jetmomfix")
DerivationFrameworkJob += JetAlgorithm("jetalgDFJetFix_AntiKt4EMTopoJets", Tools = [jetmomfix_EM] )

from DerivationFrameworkJetEtMiss.DerivationFrameworkJetEtMissConf import DerivationFramework__JetDecorAlg
DerivationFrameworkJob += DerivationFramework__JetDecorAlg("DecorJet_LC")
DerivationFrameworkJob.DecorJet_LC.InputCollection="DFJetFix_AntiKt4LCTopoJets"
DerivationFrameworkJob.DecorJet_LC.MomentsToCopy=[
    "vector<int>#NumTrkPt500@NumTrkPt500_IDLoose","vector<float>#SumPtTrkPt500@SumPtTrkPt500_IDLoose","vector<float>#TrackWidthPt500@TrackWidthPt500_IDLoose",
    "vector<int>#NumTrkPt1000@NumTrkPt1000_IDLoose","vector<float>#SumPtTrkPt1000@SumPtTrkPt1000_IDLoose","vector<float>#TrackWidthPt1000@TrackWidthPt1000_IDLoose"]

DerivationFrameworkJob += DerivationFramework__JetDecorAlg("DecorJet_EM")
DerivationFrameworkJob.DecorJet_EM.InputCollection="DFJetFix_AntiKt4EMTopoJets"
DerivationFrameworkJob.DecorJet_EM.MomentsToCopy=[
    "vector<int>#NumTrkPt500@NumTrkPt500_IDLoose","vector<float>#SumPtTrkPt500@SumPtTrkPt500_IDLoose","vector<float>#TrackWidthPt500@TrackWidthPt500_IDLoose",