コード例 #1
0
def addMETTruthMap(jetcoll='AntiKt4EMTopo', configlist="CustomMET"):
    assocname = 'Truth_' + jetcoll
    customMETConfigs.setdefault(configlist, {})
    if not assocname in customMETConfigs[configlist]:
        from METReconstruction.METAssocConfig import METAssocConfig, AssocConfig
        cfg_truthassoc = METAssocConfig(
            assocname, [AssocConfig('Truth', jetcoll + 'Jets')],
            doPFlow=False,
            doTruth=True)
        customMETConfigs[configlist][cfg_truthassoc.suffix] = cfg_truthassoc
コード例 #2
0
def scheduleMETCustomVertex(vxColl,
                            jetcoll='AntiKt4EMTopo',
                            configlist="CustomMET",
                            outputlist="CustomMET"):
    from METReconstruction.METAssocConfig import METAssocConfig, AssocConfig
    jettype = {
        'AntiKt4EMTopo': 'EMJet',
        'AntiKt4LCTopo': 'LCJet',
        'AntiKt4EMPFlow': 'PFlowJet'
    }
    associators = [
        AssocConfig(jettype[jetcoll]),
        AssocConfig('Muon'),
        AssocConfig('Ele'),
        AssocConfig('Gamma'),
        AssocConfig('Tau'),
        AssocConfig('Soft')
    ]
    cfg = METAssocConfig(
        jetcoll + vxColl,
        associators,
        jetcoll == 'AntiKt4EMPFlow'  # doPFlow
    )
    for assoc in cfg.assoclist:
        assoc.PrimVxColl = vxColl + 'PrimaryVertices'

    customMETConfigs.setdefault(configlist, {})[cfg.suffix] = cfg

    maplist.append(cfg.suffix)
    METLists.setdefault(outputlist, []).append(cfg.suffix)
コード例 #3
0
def scheduleMETCustomTrkSel(
    trkseltool,
    metname,
    jetcoll='AntiKt4EMTopo',
    configlist="CustomMET",
    outputlist="CustomMET",
):
    from METReconstruction.METAssocConfig import METAssocConfig, AssocConfig
    jettype = {
        'AntiKt4EMTopo': 'EMJet',
        'AntiKt4LCTopo': 'LCJet',
        'AntiKt4EMPFlow': 'PFlowJet'
    }
    associators = [
        AssocConfig(jettype[jetcoll]),
        AssocConfig('Muon'),
        AssocConfig('Ele'),
        AssocConfig('Gamma'),
        AssocConfig('Tau'),
        AssocConfig('Soft')
    ]

    cfg = METAssocConfig(
        suffix=jetcoll + metname,
        buildconfigs=associators,
        doPFlow=(jetcoll == 'AntiKt4EMPFlow'),  # doPFlow
        trksel=trkseltool)

    customMETConfigs.setdefault(configlist, {})[cfg.suffix] = cfg

    maplist.append(cfg.suffix)
    METLists.setdefault(outputlist, []).append(cfg.suffix)
コード例 #4
0
    'Truth',
    [BuildConfig('NonInt'),
     BuildConfig('Int'),
     BuildConfig('IntOut')],
    doRegions=True)

metFlags.METConfigs()[cfg_truth.suffix] = cfg_truth
metFlags.METOutputList().append(cfg_truth.suffix)
metFlags.METOutputList().append(cfg_truth.suffix + "Regions")

## Truth association maps

############################################################################
# AntiKt4LCTopo
cfg_truthassoc_akt4lc = METAssocConfig(
    'Truth_AntiKt4LCTopo', [AssocConfig('Truth', 'AntiKt4LCTopoJets')],
    doTruth=True)

metFlags.METAssocConfigs()[
    cfg_truthassoc_akt4lc.suffix] = cfg_truthassoc_akt4lc
metFlags.METAssocOutputList().append(cfg_truthassoc_akt4lc.suffix)

############################################################################
# AntiKt4EMTopo
cfg_truthassoc_akt4em = METAssocConfig(
    'Truth_AntiKt4EMTopo', [AssocConfig('Truth', 'AntiKt4EMTopoJets')],
    doTruth=True)

metFlags.METAssocConfigs()[
    cfg_truthassoc_akt4em.suffix] = cfg_truthassoc_akt4em
#metFlags.METAssocOutputList().append(cfg_truthassoc_akt4em.suffix)
コード例 #5
0
# Include, and then set up the jet analysis algorithm sequence:
from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence
jetSequence = makeJetAnalysisSequence( dataType, jetContainer, deepCopyOutput = True, shallowViewOutput = False , runFJvtUpdate = False , runFJvtSelection = False )
jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' )
print( jetSequence ) # For debugging

SeqPHYSLITE += jetSequence

# Make sure the MET knows what we've done
# First we need to rebuild charged pflow objects
from eflowRec.ScheduleCHSPFlowMods import scheduleCHSPFlowMods
scheduleCHSPFlowMods(SeqPHYSLITE)
# Now build MET from our analysis objects
from DerivationFrameworkJetEtMiss import METCommon
from METReconstruction.METAssocConfig import METAssocConfig,AssocConfig
associators = [AssocConfig('PFlowJet', 'AnalysisJets'),
               AssocConfig('Muon', 'AnalysisMuons'),
               AssocConfig('Ele', 'AnalysisElectrons'),
               AssocConfig('Gamma', 'AnalysisPhotons'),
               AssocConfig('Tau', 'AnalysisTauJets'),
               AssocConfig('Soft', '')]
PHYSLITE_cfg = METAssocConfig('AnalysisMET',
                              associators,
                              doPFlow=True)
METCommon.customMETConfigs.setdefault('AnalysisMET',{})[PHYSLITE_cfg.suffix] = PHYSLITE_cfg
scheduleMETAssocAlg(sequence=SeqPHYSLITE,configlist="AnalysisMET")

#====================================================================
# TRIGGER CONTENT
#====================================================================
# See https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerAPI
コード例 #6
0
#         # 500249532,
#         # 498552012,
#         # 8093981,
#         # 7747623,
#         # 9713934,
#         ])
topSequence += filterseq

############################################################################
# Set up an extra associator for testing
from METReconstruction.METRecoFlags import metFlags
from METReconstruction.METAssocConfig import AssocConfig, METAssocConfig
JetType = 'EMJet'

associators = [
    AssocConfig(JetType),
    AssocConfig('Muon'),
    AssocConfig('Ele'),
    AssocConfig('Gamma'),
    AssocConfig('Tau'),
    AssocConfig('Soft')
]
cfg_akt4em = METAssocConfig('NewAntiKt4EMTopo',
                            associators,
                            doPFlow=False,
                            doOriginCorrClus=True)

metFlags.METAssocConfigs()[cfg_akt4em.suffix] = cfg_akt4em
metFlags.METAssocOutputList().append(cfg_akt4em.suffix)

############################################################################
コード例 #7
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
コード例 #8
0
# Set up default configurations
#import METReconstruction.METConfig_Associator

#include('RecExCond/AllDet_detDescr.py')
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()


############################################################################
# Set up an extra associator for testing
from METReconstruction.METRecoFlags import metFlags
from METReconstruction.METAssocConfig import AssocConfig, METAssocConfig
JetType = 'EMJet'
#todo check pflow

associators = [AssocConfig(JetType),
               AssocConfig('Muon'),
               AssocConfig('Ele'),
               AssocConfig('Gamma'),
               AssocConfig('Tau'),
               AssocConfig('Soft')]
cfg_akt4em = METAssocConfig('NewAntiKt4EMTopo',
                            associators,
                            doPFlow=False
                            )
for assoc in cfg_akt4em.assoclist:
    assoc.IgnoreJetConst = True
    assoc.ForwardColl = "CellTowers"

associators2 = [AssocConfig(JetType),
               AssocConfig('Muon'),
コード例 #9
0
from METReconstruction.METRecoFlags import metFlags

# ############################################################################
# # AntiKt4LCTopo
# cfg_truthassoc_akt4lc = METAssocConfig('Truth_AntiKt4LCTopo',
#                                        [AssocConfig('Truth','AntiKt4LCTopoJets')],
#                                        doTruth=True
#                                        )

# metFlags.METAssocConfigs()[cfg_truthassoc_akt4lc.suffix] = cfg_truthassoc_akt4lc
# metFlags.METAssocOutputList().append(cfg_truthassoc_akt4lc.suffix)

############################################################################
# AntiKt4EMTopo
cfg_truthassoc_akt4em = METAssocConfig(
    'Truth_AntiKt4EMTopo', [AssocConfig('Truth', 'AntiKt4EMTopoJets')],
    doTruth=True)

metFlags.METAssocConfigs()[
    cfg_truthassoc_akt4em.suffix] = cfg_truthassoc_akt4em
metFlags.METAssocOutputList().append(cfg_truthassoc_akt4em.suffix)

# JetType = 'EMJet'
# associators = [AssocConfig(JetType),
#                AssocConfig('Muon'),
#                AssocConfig('Ele'),
#                AssocConfig('Gamma'),
#                AssocConfig('Tau'),
#                AssocConfig('Soft')]

# cfg_assoc_akt4em = METAssocConfig('NewAntiKt4EMTopo',