示例#1
0
def make_VxOnJetAxis_D3PDObject(
        name,
        prefix,
        object_name,
        sgkey,
        label=JetTagD3PDKeys.JFVxOnJetAxisGetterLabel(),
        allowMissing=False,
        **kw):

    getter = D3PDMakerCoreComps.SGDataVectorGetterTool(
        name + '_Getter',
        SGKey=sgkey,
        TypeName='JetTagVxOnJetAxisDataHolder',
        Label=label)

    defs = kw

    for k in defs.keys():
        if not hasattr(D3PDMakerCoreComps.VectorFillerTool, k):
            del defs[k]

    if not defs.has_key("SaveMetadata"):
        defs["SaveMetadata"] = D3PDMakerFlags.SaveObjectMetadata()

    return D3PDMakerCoreComps.VectorFillerTool(name,
                                               Prefix=prefix,
                                               Getter=getter,
                                               ObjectName=object_name,
                                               AllowMissing=allowMissing,
                                               **defs)
def _jetFilterAlgHook(c, prefix, sgkey, JetContainer, **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())

    # Is the container already in SG?
    if cfgKeyStore.isInInput('JetContainer', sgkey):
        return

    # Is the algorithm already in the sequence?
    algname = sgkey + JetTagD3PDKeys.FilteredJetMakerAlgPostfix()
    if hasattr(preseq, algname):
        return

    # select valid argument for JetTagJetFilterAlg
    filterargs = kw
    for k in filterargs.keys():
        if not hasattr(JetTagD3PDMaker.JetTagJetFilterAlg, k):
            del filterargs[k]

    del filterargs['name']

    ### if some argument do not exist set them to the flag values
    if not 'PtMinCut' in filterargs:
        filterargs['PtMinCut'] = JetTagD3PDFlags.JetFilterPtMinCut()
    if not 'EtaCut' in filterargs:
        filterargs['EtaCut'] = JetTagD3PDFlags.JetFilterEtaCut()
    if not 'UseEMScale' in filterargs:
        filterargs['UseEMScale'] = JetTagD3PDFlags.JetFilterUseEMScale()

    preseq += JetTagD3PDMaker.JetTagJetFilterAlg(algname,
                                                 FilteredJetContainer=sgkey,
                                                 JetContainer=JetContainer,
                                                 **filterargs)

    return
示例#3
0
def _jetTwoTrackVertexTagAlgHook(
        c,
        prefix,
        sgkey,
        jetCollections,
        InfoName=JetTagD3PDFlags.JetFitterVertexFinderObjects(),
        **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())

    # Is the container already in SG?
    if cfgKeyStore.isInInput('JetTagTwoTrackVertexDataHolder', sgkey):
        return

    # Is the algorithm already in the sequence?
    algname = sgkey + JetTagD3PDKeys.JFTwoTrackVertexMakerAlgPostfix()
    if hasattr(preseq, algname):
        return

    filterargs = kw
    for k in filterargs.keys():
        if not hasattr(JetTagD3PDMaker.JetTagJetFitterDataToSGAlg, k):
            del filterargs[k]

    del filterargs['name']
    preseq += JetTagD3PDMaker.JetTagJetFitterDataToSGAlg(
        algname,
        TwoTrackVertexName=sgkey,
        FillTwoTrackVertex=True,
        JetCollections=jetCollections,
        InfoName=InfoName,
        **filterargs)

    return
示例#4
0
def getJetTagVxOnJetAxisD3PDObject(
        level, jetCollections, sgkey=JetTagD3PDKeys.JFVxOnJetAxisDataSGKey(),
        **kw):

    return VxOnJetAxisD3PDObject(level=level,
                                 jetCollections=jetCollections,
                                 sgkey=sgkey,
                                 **kw)
示例#5
0
    def addToAlg(self,alg):
               
        alg += self.MyJetD3PDObject(0, prefix='jet_' + self.parentJets + '_', sgkey=self.parentJets+'Jets', exclude=self.commonExcludeList, include = self.commonIncludeList + self.VtxInclude + self.JetQualInclude)
 
        for idx,gr in enumerate(self.groomedJetsList):
                        
            kw = {}
            includelist = []
            includelist_unique = []
            
            if 'Trim' in gr:
                includelist_unique += ['TrimConfigMoments']
                
            elif 'Filt' in gr and 'Subjets' not in gr:
                includelist += ['FiltMoments']
                includelist_unique += ['FiltConfigMoments']
                if len(self.groomedJetsList) > idx+1 and 'Subjets' in self.groomedJetsList[idx+1]:
                    includelist += ['blockbtag'+self.groomedJetsList[idx+1], self.groomedJetsList[idx+1]+'blockindex']
                    
            elif 'Subjets' in gr:
                includelist += [JetTagD3PDKeys.BTagWeightsBlockName()]                
                includelist += [JetTagD3PDKeys.JetTrackAssocBlockName()] 
                includelist += [JetTagD3PDKeys.JetTrackBlockName()] 
                includelist += [JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()] 
                includelist += [JetTagD3PDKeys.IPInfoPlusTrackBlockName()] 
                
                kw[JetTagD3PDKeys.JetTrackAssocBlockName()+'_target']= "trk" 
                kw[JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk" 
                
            alg += self.MyGroomedJetD3PDObject(0, prefix='jet_' + self.parentJets + gr + '_', sgkey=self.parentJets + gr +'Jets', include = includelist + self.commonIncludeList,exclude=self.commonExcludeList,**kw)
        
            alg += self.MyGroomedJetCollectionD3PDObject( 0, prefix='jet_' + self.parentJets + gr + '_config_', sgkey=self.parentJets + gr +'Jets', include = includelist_unique)

        return
示例#6
0
def getJetTagTwoTrackVertexD3PDObject(
        level,
        jetCollections,
        sgkey=JetTagD3PDKeys.JFTwoTrackVertexDataSGKey(),
        **kw):

    return JetTagTwoTrackVertexD3PDObject(level=level,
                                          jetCollections=jetCollections,
                                          sgkey=sgkey,
                                          **kw)
示例#7
0
def getJetTagTrackD3PDObject(level=20, **kw):

    if not rec.doTruth:
        TrackD3PDFlags.doTruth = False

    if TruthD3PDFlags.GenParticleAssocLabel() == None or TruthD3PDFlags.GenParticleAssocLabel() == "":
        TrackD3PDFlags.doTruth = False
        
 
    JetTagTrackParticleD3PDObject = xAODTrackD3PDObject(_label=JetTagD3PDKeys.TrackGetterLabel(),
                                                        _prefix=JetTagD3PDKeys.TrackPrefix(),
                                                        _sgkey=JetTagD3PDFlags.TrackParticleSGKey(),
                                                        vertexSGKey=JetTagD3PDFlags.PrimaryVertexSGKey(),
                                                        vertexTarget=JetTagD3PDKeys.PrimaryVertexGetterLabel(),
                                                        vertexPrefix=JetTagD3PDKeys.PrimaryVertexPrefix(),
                                                        flags=TrackD3PDFlags)

    from AthenaCommon.AppMgr import ToolSvc
    from InDetTrackSelectorTool.InDetTrackSelectorToolConf import InDet__InDetTrackSelectorTool
    jetTagD3PDInDetTrackSelectorTool = InDet__InDetTrackSelectorTool("JetTagD3PDInDetTrackSelectorTool")
    jetTagD3PDInDetTrackSelectorTool.minPt = JetTagD3PDFlags.TrackPtCut()
    jetTagD3PDInDetTrackSelectorTool.IPz0Max = 99999.
    jetTagD3PDInDetTrackSelectorTool.maxZ0 = 99999.
    jetTagD3PDInDetTrackSelectorTool.maxD0 = 99999.
    jetTagD3PDInDetTrackSelectorTool.maxD0overSigmaD0 = 99999.
    jetTagD3PDInDetTrackSelectorTool.numberOfPixelHits = -99
    jetTagD3PDInDetTrackSelectorTool.numberOfInnermostPixelLayerHits = -99
    jetTagD3PDInDetTrackSelectorTool.Extrapolator = ToolSvc.InDetExtrapolator 
    jetTagD3PDInDetTrackSelectorTool.TrackSummaryTool = ToolSvc.InDetTrackSummaryTool
    ToolSvc+=jetTagD3PDInDetTrackSelectorTool

    from InDetD3PDMaker import TrackParticleGetterTool
    jetTagD3PDTrackGetterTool = TrackParticleGetterTool("jetTagD3PDTrackGetterTool")
    jetTagD3PDTrackGetterTool.VertexSGKey = JetTagD3PDFlags.PrimaryVertexSGKey() ## no need to resolve for now 
    jetTagD3PDTrackGetterTool.TrackSelector = jetTagD3PDInDetTrackSelectorTool
    jetTagD3PDTrackGetterTool.Label = JetTagD3PDKeys.TrackGetterLabel()
    jetTagD3PDTrackGetterTool.SGKey = JetTagD3PDFlags.TrackParticleSGKey()
    jetTagD3PDTrackGetterTool.TypeName = 'Rec::TrackParticleContainer'

    
    return JetTagTrackParticleD3PDObject(level=level,
                                         getter=jetTagD3PDTrackGetterTool, **kw)
class WriteBTAGGHOSTD3PD(JobProperty):
    """Produce the BTAG D3PD."""
    statusOn = True
    allowedTypes = ['bool']
    StoredValue = False
    StreamName = 'StreamNTUP_BTAGGHOST'
    FileName = ''
    isVirtual = False
    DPDMakerScript = "JetTagD3PDMaker/JetTagD3PDGHOST_prodJobOFragment.py"
    TreeNames = [JetTagD3PDKeys.D3PDTupleName()]
    SubSteps = ['a2d', 'e2d']
def _modifyMuonObject(MuonD3PDObject):
    if not MuonD3PDObject.allBlocknames().has_key(
            "BtagMuonTrackMatchingBlock"):
        if JetTagD3PDFlags.TrackAssocLabel() != "":
            from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
            import MuonD3PDMaker
            mtassoc = IndexAssociation(
                MuonD3PDObject,
                MuonD3PDMaker.MuonTrackParticleAssociationTool,
                JetTagD3PDFlags.TrackAssocLabel(),
                level=500,
                prefix=JetTagD3PDKeys.MuonInDetTrackAssocPrefix(),
                blockname="BtagMuonTrackMatchingBlock",
                Type='InDet')
示例#10
0
def makeJetTagPhotonInJetObject(name,
                                prefix,
                                object_name,
                                label=JetTagD3PDKeys.PhotonInJetGetterLabel(),
                                jetCollections=[]):

    from JetTagD3PDMaker import JetTagPhotonInJetGetterTool
    getter = JetTagPhotonInJetGetterTool(name + '_Getter',
                                         Label=label,
                                         JetCollections=jetCollections)

    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    return  D3PDMakerCoreComps.VectorFillerTool (name, Prefix = prefix, Getter = getter,
                                                 ObjectName = object_name,
                                                 SaveMetadata = \
                                                 D3PDMakerFlags.SaveObjectMetadata())
示例#11
0
    def addToAlg(self, alg):
        outputJetsName = self.parentJets
        if (self.parentJets.find("JS") > -1):
            #outputJetsName = self.parentJets.replace("JS", "")
            pass

        if ('LCTopo' in self.parentJets) and (not hasattr(
                alg, 'ElecTopoClusterAssoc_Filler')):
            alg += self.MyJetAssocD3PDObject(0)

        jet_suffix = 'Jets'
        if 'Subjets' in self.parentJets:
            jet_suffix = 'JetsReTagged'  # replacing by NewJets
            #jet_suffix = 'NewJets'
        alg += self.MyJetD3PDObject(
            0,
            prefix='jet_' + outputJetsName.replace("JS", "") + '_',
            sgkey=self.parentJets + jet_suffix,
            exclude=self.commonExcludeList,
            include=self.commonIncludeList + self.VtxInclude +
            self.JetQualInclude + [
                'elecblockindex', 'muonblockindex', 'LCJESBlock',
                'OriginIndexBlock'
            ])

        for idx, gr in enumerate(self.groomedJetsList):

            kw = {}
            includelist = []
            includelist_unique = []

            if 'Trim' in gr and 'Subjets' not in gr:
                includelist_unique += ['TrimConfigMoments', 'blockindex']
                if [x for x in self.AreaCorr if x in gr]:
                    includelist += ['AreaCorrectedMoments']
                if len(self.groomedJetsList
                       ) > idx + 1 and 'Subjets' in self.groomedJetsList[idx +
                                                                         1]:
                    includelist += [
                        self.groomedJetsList[idx + 1] + 'blockindex'
                    ]
                    #if 'LCTopo' in self.parentJets:
                    #    includelist += ['blockbtag'+self.groomedJetsList[idx+1]]

            elif 'Filt' in gr and 'Subjets' not in gr:
                includelist += ['FiltMoments']
                includelist_unique += ['FiltConfigMoments']
                #if len(self.groomedJetsList) > idx+1 and 'Subjets' in self.groomedJetsList[idx+1]:
                #    includelist += ['blockbtag'+self.groomedJetsList[idx+1], self.groomedJetsList[idx+1]+'blockindex']

            elif 'Subjets' in gr:
                includelist += ['minSplitR']
                if 'LCTopo' in self.parentJets:
                    includelist += [
                        JetTagD3PDKeys.TruthInfoBlockName(),
                        JetTagD3PDKeys.BTagWeightsBlockName()
                    ]
                    #kw[JetTagD3PDKeys.JetTrackAssocBlockName()+'_target']= "trk"
                    #kw[JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk"

            alg += self.MyGroomedJetD3PDObject(
                0,
                prefix='jet_' + outputJetsName.replace("JS", "") + gr + '_',
                sgkey=self.parentJets + gr + 'Jets',
                include=includelist + self.commonIncludeList + [
                    'OriginIndexBlock', 'FiltMoments', 'LCJESBlock',
                    'minSplitR', 'elecblockindex', 'muonblockindex'
                ],
                exclude=self.commonExcludeList,
                **kw)

            alg += self.MyGroomedJetCollectionD3PDObject(
                0,
                prefix='jet_' + outputJetsName.replace("JS", "") + gr +
                '_config_',
                sgkey=self.parentJets + gr + 'Jets',
                include=includelist_unique)

        return
    TrackD3PDFlags.storeBLayerHitsOnTrack = False
TrackD3PDFlags.storeSCTHitsOnTrack = False
TrackD3PDFlags.storeTRTHitsOnTrack = False
TrackD3PDFlags.storeBLayerOutliersOnTrack = False
TrackD3PDFlags.storePixelOutliersOnTrack = False
TrackD3PDFlags.storeSCTOutliersOnTrack = False
TrackD3PDFlags.storeTRTOutliersOnTrack = False
TrackD3PDFlags.storeBLayerHolesOnTrack = False
TrackD3PDFlags.storePixelHolesOnTrack = False
TrackD3PDFlags.storeSCTHolesOnTrack = False
TrackD3PDFlags.storeTRTHolesOnTrack = False
TrackD3PDFlags.storeVertexAssociation = True
TrackD3PDFlags.storeTrackPredictionAtBLayer = False

### configure association labels
JetTagD3PDFlags.TrackAssocLabel = JetTagD3PDKeys.TrackGetterLabel()
JetTagD3PDFlags.MuonAssocLabel = JetTagD3PDKeys.MuonInJetGetterLabel()
JetTagD3PDFlags.Muon2AssocLabel = JetTagD3PDKeys.Muon2InJetGetterLabel()
JetTagD3PDFlags.ElectronAssocLabel = JetTagD3PDKeys.ElectronInJetGetterLabel()
#JetTagD3PDFlags.PhotonAssocLabel = JetTagD3PDKeys.PhotonInJetGetterLabel()
JetTagD3PDFlags.JFVxOnJetAxisAssocLabel = JetTagD3PDKeys.JFVxOnJetAxisGetterLabel(
)
JetTagD3PDFlags.JFTwoTrackVertexAssocLabel = JetTagD3PDKeys.JFTwoTrackVertexGetterLabel(
)
TruthD3PDFlags.GenParticleAssocLabel = TruthD3PDKeys.GenParticleGetterLabel()
TruthD3PDFlags.GenVertexAssocLabel = TruthD3PDKeys.GenVertexGetterLabel()
TruthD3PDFlags.GenEventAssocLabel = TruthD3PDKeys.GenEventGetterLabel()
TruthD3PDFlags.TruthTrackAssocLabel = TruthD3PDKeys.TruthTrackGetterLabel()
JetTagD3PDFlags.MSVVtxInfoAssocLabel = JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel(
)
def CommonD3PDMakerFlagsSetDefaults():
    flags = CommonD3PDMakerFlags
    flags.electronInclude.set_Value([
        'TrkFitQuality', 'Vertex', 'Isolation_500MeV', 'MaxEcell', 'Iso',
        'IsoPtCorrected', 'PAU', 'PAUVariables', 'Pointing', 'ClusterKin',
        'HadLeakage', 'Layer1Shape', 'Layer2Shape', 'Samplings',
        'EMTrackFitDetailsRefit', 'EMTrackFitDetailsRefitCov', 'miniiso10',
        'miniiso15'
    ])

    flags.photonInclude.set_Value([
        'MaxEcell', 'Pointing', 'EMTrackFitDetailsBrem',
        'EMTrackFitDetailsRefit', 'UDTruthFlags'
    ])

    flags.muonInclude.set_Value([
        "L1InfoIndex", "Isolation_500MeV", "Isolation_elstyletracks",
        "miniiso10", "miniiso15", "ParametersAtPV",
        "IDTrackDiagonalCovarianceAtPV", "PrimaryTrackDiagonalCovarianceAtPV"
    ])

    flags.tauInclude.set_Value([
        'TauLeadTrack', 'OtherTrk00', 'OtherTrkTJVA', 'OtherTrkPV',
        'OtherIDHits', 'TauCalcVars'
    ])

    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
    #flags.smallJetInclude.set_Value([JetTagD3PDKeys.BTagWeightsBlockName(), JetTagD3PDKeys.TruthInfoBlockName(),
    #                                 JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
    #                                 JetTagD3PDKeys.SVInfoPlusBlockName(),JetTagD3PDKeys.SV0InfoPlusBlockName(),
    #                                 JetTagD3PDKeys.JetFitterInfoBaseBlockName(),JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
    #                                 JetTagD3PDKeys.SoftMuonInfoMuonBlockName(),JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(),
    #                                 JetTagD3PDKeys.MultiSVInfoPlusBlockName(),
    #                                 JetTagD3PDKeys.IP2DInfoBaseBlockName(),JetTagD3PDKeys.IP2DIPInfoBaseBlockName(),
    #                                 JetTagD3PDKeys.IP3DInfoBaseBlockName(),JetTagD3PDKeys.IP3DIPInfoBaseBlockName(),
    #                                 JetTagD3PDKeys.SV1InfoBaseBlockName(),JetTagD3PDKeys.SV2InfoBaseBlockName(),
    #                                 JetTagD3PDKeys.JetFitterTagInfoBlockName(),JetTagD3PDKeys.SoftMuonChi2InfoMuonBlockName(),
    #                                 JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName(),JetTagD3PDKeys.IPInfoPlusTrackBlockName(),
    #                                 JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName(),
    #                                 JetTagD3PDFlags.StdInfoInclude(),
    #                                 'Uncertainties','BeamBackground','ConstituentScale','Constituents','Samplings','AssocTrackCont',
    #                                 'JetVertexFraction','JVtx','TracksMoments',
    #                                 'Kinematics','DQMoments','EMFraction','JESMoments','EMScale','CaloQual',
    #                                 'JetRoIword','CaloClusterNavigableConstituentAssociationTool','TrackAssocblockindex','JetLabel',
    #                                 'Special','TrackMF'])
    flags.eljetInclude.set_Value([
        'AssocTrackCont',
        JetTagD3PDKeys.BTagWeightsBlockName(), 'JetVertexFraction', 'JVtx',
        JetTagD3PDKeys.TruthInfoBlockName()
    ])

    #tmpMEtInclude = CommonD3PDMakerFlagsSetMEtInclude()
    #flags.missingEtInclude.set_Value(tmpMEtInclude)

    #tmpMEtExclude = CommonD3PDMakerFlagsSetMEtExclude()
    #flags.missingEtExclude.set_Value(tmpMEtExclude)

    tmpHadronicMEtInclude = CommonD3PDMakerFlagsSetHadronicMEtInclude()
    flags.hadronicMissingEtInclude.set_Value(tmpHadronicMEtInclude)

    tmpTruthHadronicMEtInclude = CommonD3PDMakerFlagsSetTruthHadronicMEtInclude(
    )
    flags.truthHadronicMissingEtInclude.set_Value(tmpTruthHadronicMEtInclude)
示例#14
0
def SMWZD3PD (alg = None,
              file = 'smwz.root',
              tuplename = 'physics',
              streamname = 'd3pdstream',
              doSoftQCD = False,
              doThirdMuonChain = True,
              stdElectronContainer = D3PDMakerFlags.ElectronSGKey(),
              gsfElectronContainer = D3PDMakerFlags.GSFElectronSGKey(),
              muonContainer        = 'None', # can be 'Muons' for third muon chain
              stacoMuonContainer   = 'StacoMuonCollection',
              muidMuonContainer    = 'MuidMuonCollection',
              caloMuonContainer    = 'CaloMuonCollection',
              photonContainer      = D3PDMakerFlags.PhotonSGKey(),
              tauContainer         = D3PDMakerFlags.TauSGKey(),
              jetEM4Container      = 'AntiKt4TopoEMJets', #Commented by Bertrand
              jetEM6Container      = 'AntiKt6TopoEMJets',
              jetLC4Container      = 'AntiKt4LCTopoJets',
              jetLC6Container      = 'AntiKt6LCTopoJets',
              #jetEM4Container      = 'AntiKt4TopoEMJetsReTagged',
              #jetEM6Container      = 'AntiKt6TopoEMJetsReTagged',
              #jetLC4Container      = 'AntiKt4LCTopoJetsReTagged',
              #jetLC6Container      = 'AntiKt6LCTopoJetsReTagged',
              jetDetails           = 3, # for the moment only level 2 and 3 are defined
              METDetails           = 3, # for the moment only level 2 and 3 are defined
              **kw):

    if doThirdMuonChain and muonContainer == 'None':
        muonContainer = 'Muons'

    # define associations
    
    if not PhotonD3PDObject.allBlocknames().has_key('RecoveryMatch'):
        from PhotonD3PDMaker.PhotonRecoveryAssociation import PhotonRecoveryAssociation
        if (stdElectronContainer != 'None'):
            PhotonRecoveryAssoc = PhotonRecoveryAssociation(PhotonD3PDObject,
                                                            'ElectronContainer',
                                                            stdElectronContainer,
                                                            prefix = 'el_',
                                                            blockname = 'RecoveryMatch',
                                                            target = 'ph_ElectronRecovered_')

    # define track and cluster filters

    preseq = AlgSequence (D3PDMakerFlags.PreD3PDAlgSeqName())

    if not hasattr( preseq, "GoodTracks" ):
        filter1 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='GoodTracks',
                                     ptCut=0.,nSCTPix=4)
        preseq += filter1

    if not hasattr( preseq, "HighPtTracks" ):
        filter2 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='HighPtTracks',
                                     ptCut=4000.,nSCTPix=4)
        preseq += filter2
    
    if not hasattr( preseq, "HighPtClusters" ):
        filter3 = makeClusterFilter(InputName  = D3PDMakerFlags.ClusterSGKey(),
                                    OutputName = 'HighPtClusters',
                                    ptCut=10000.)
        preseq += filter3

    if not hasattr( preseq, "HighPtEMClusters" ):
        filter4 = makeClusterFilter(InputName  = D3PDMakerFlags.EMTopoClusterSGKey(),
                                    OutputName = 'HighPtEMClusters',
                                    ptCut=10000.)
        preseq += filter4


    # perform recoil calculation

    import HadronicRecoil.Configurables as hrc
    preseq = hrc.add_hadronic_recoil_filters(preseq)


    # beam background stuff

    from RecBackgroundAlgs.RecBackgroundAlgsConf import BeamBackgroundFiller
    if not hasattr( preseq, "BeamBackgroundFiller" ):
        BeamBackgroundFiller=BeamBackgroundFiller()
        preseq += BeamBackgroundFiller



    # now configure the D3PD
    
    if not alg:
        alg = MSMgr.NewRootStream(StreamName = streamname, FileName = file, TreeName = tuplename)
        
    
    alg += EventInfoD3PDObject        (**_args (10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject (**_args (10, 'LArCollisionTime', kw))

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata (alg)

    from BackgroundD3PDMaker.BeamBackgroundD3PDObject import BeamBackgroundD3PDObject
    from BackgroundD3PDMaker.BackgroundWordD3PDObject import BackgroundWordD3PDObject
    alg += BackgroundWordD3PDObject (**_args(0, 'BkgWord', kw))
    alg += BeamBackgroundD3PDObject(1)

    
    # Electron/Photon blocks
    
    if (stdElectronContainer != 'None'):
        alg += ElectronD3PDObject         (**_args (10, 'Electron', kw, sgkey = stdElectronContainer))
        
    if (gsfElectronContainer != 'None') and testSGKey ('ElectronContainer', gsfElectronContainer):
        alg += GSFElectronD3PDObject  (**_args (10, 'GSFElectron', kw,
                                                sgkey = gsfElectronContainer,
                                                prefix = 'el_gsf_'))

    if (photonContainer != 'None'):
        alg += PhotonD3PDObject           (**_args (10, 'Photon', kw, sgkey = photonContainer))
            
    
    # Muon blocks

### Third muon chain variables!
    if (muonContainer != 'None'):
        alg += MuonD3PDObject             (**_args (10, 'Muon', kw,
                                                    sgkey=muonContainer, prefix='mu_',
                                                    include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                               "L2CBInfoIndex", "L1InfoIndex"],
                                                    exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                    allowMissing = True ))
### Third muon chain variables!

    if (muidMuonContainer != 'None'):
        alg += MuonD3PDObject             (**_args (10, 'MuidMuon', kw,
                                                    sgkey=muidMuonContainer, prefix='mu_muid_',
                                                    include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                               "L2CBInfoIndex", "L1InfoIndex"],
                                                    exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                    allowMissing = True ))

    if (stacoMuonContainer != 'None'):
        alg += MuonD3PDObject             (**_args (10, 'StacoMuon', kw,
                                                    sgkey=stacoMuonContainer, prefix='mu_staco_',
                                                    include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                               "L2CBInfoIndex", "L1InfoIndex"],
                                                    exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                    allowMissing = True ))

    if (caloMuonContainer != 'None'):
        alg += MuonD3PDObject             (**_args (10, 'CaloMuon', kw,
                                                    sgkey=caloMuonContainer, prefix='mu_calo_',
                                                    include = ["MuonHitSummary", "Authors", "Likelihood",
                                                               "Isolation", "CaloEnergyLoss", "Quality"] ))
    
    # Tau block
    
    if (tauContainer != 'None'):
        alg += TauD3PDObject              (**_args ( 1, 'Tau', kw, sgkey = tauContainer))
    

    # Jet blocks
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys

    ## add MSV target to the jetd3pd object properties 
    if not kw.has_key ('AK4TopoEMJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target'):
        kw['AK4TopoEMJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target']= JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()
    if not kw.has_key ('AK6TopoEMJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target'):
        kw['AK6TopoEMJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target']= JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()

    ## add track index for IPInfoPlus
    if not kw.has_key ('AK4TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk"
    ## add track index for SVInfoPlus
    if not kw.has_key ('AK4TopoEMJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4TopoEMJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6TopoEMJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6TopoEMJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target']= "trk"
    ## add track index for SV0InfoPlus
    if not kw.has_key ('AK4TopoEMJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4TopoEMJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6TopoEMJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6TopoEMJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target']= "trk"

  
      ## add MSV target to the jetd3pd object properties 
    if not kw.has_key ('AK4LCTopoJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target'):
        kw['AK4LCTopoJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target']= JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()
    if not kw.has_key ('AK6LCTopoJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target'):
        kw['AK6LCTopoJet_'+JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName()+'_target']= JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()

    ## add track index for IPInfoPlus
    if not kw.has_key ('AK4LCTopoJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4LCTopoJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6LCTopoJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6LCTopoJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk"
    ## add track index for SVInfoPlus
    if not kw.has_key ('AK4LCTopoJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4LCTopoJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6LCTopoJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6LCTopoJet_'+JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName()+'_target']= "trk"
    ## add track index for SV0InfoPlus
    if not kw.has_key ('AK4LCTopoJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target'):
        kw['AK4LCTopoJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target']= "trk"
    if not kw.has_key ('AK6LCTopoJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target'):
        kw['AK6LCTopoJet_'+JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName()+'_target']= "trk"

    if jetDetails == 3:
        jetInclude = JetTagD3PDFlags.StdInfoInclude()+[JetTagD3PDKeys.MultiSVInfoPlusBlockName()]
        jetInclude += [JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(), JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName()]
    else:
        jetInclude = [ JetTagD3PDKeys.BTagWeightsBlockName(), JetTagD3PDKeys.TruthInfoBlockName() ]


    if (jetEM4Container != 'None'):
        alg += JetD3PDObject              (**_args ( 4, 'AK4TopoEMJet', kw,
                                                     sgkey=jetEM4Container, prefix='jet_AntiKt4TopoEM_',
                                                     include = jetInclude+['BeamBackground','ConstituentScale','TracksMoments'],
                                                     JetVertexFraction_FromUD=False,
                                                     JetVertexFraction_FillFullJVF=False,
                                                     allowMissing = True))
    
    if (jetEM6Container != 'None'):
        alg += JetD3PDObject              (**_args ( 4, 'AK6TopoEMJet', kw,
                                                     sgkey=jetEM6Container, prefix='jet_AntiKt6TopoEM_',
                                                     include = jetInclude+['BeamBackground','ConstituentScale','TracksMoments'],
                                                     JetVertexFraction_FromUD=False,
                                                     JetVertexFraction_FillFullJVF=False,
                                                     allowMissing = True))

    if (jetLC4Container != 'None'):
        alg += JetD3PDObject              (**_args ( 4, 'AK4LCTopoJet', kw,
                                                     sgkey=jetLC4Container, prefix='jet_AntiKt4LCTopo_',
                                                     include = jetInclude+['BeamBackground','ConstituentScale','TracksMoments'],
                                                     JetVertexFraction_FromUD=False,
                                                     JetVertexFraction_FillFullJVF=False,
                                                     allowMissing = True))
    
    if (jetLC6Container != 'None'):
        alg += JetD3PDObject              (**_args ( 4, 'AK6LCTopoJet', kw,
                                                     sgkey=jetLC6Container, prefix='jet_AntiKt6LCTopo_',
                                                     include = jetInclude+['BeamBackground','ConstituentScale','TracksMoments'],
                                                     JetVertexFraction_FromUD=False,
                                                     JetVertexFraction_FillFullJVF=False,
                                                     allowMissing = True))

        
    ### add the MSV block
    MSVJetCollections = []
    if (jetEM4Container != 'None'):
        MSVJetCollections += [jetEM4Container]
    if (jetEM6Container != 'None'):
        MSVJetCollections += [jetEM6Container]
    if (jetLC4Container != 'None'):
        MSVJetCollections += [jetLC4Container]
    if (jetLC6Container != 'None'):
        MSVJetCollections += [jetLC6Container]
    ### link multisv to tracks
    if not kw.has_key ('msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target'):
        kw['msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target']= "trk"

    from JetTagD3PDMaker.JetTagMSVVtxInJetD3PDObject import getJetTagMSVVtxInfoInJetD3PDObject
    alg += getJetTagMSVVtxInfoInJetD3PDObject(**_args(1,"msvvtxinfo", kw,
                                                      jetCollections=MSVJetCollections)
                                                )
 
    from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
    alg += HforD3PDObject(**_args (0, 'HforInfo', kw))


    # MET blocks
    # a whole mess to remove x,y components separately for all flavours

    if METDetails >= 3:
        alg += MissingETD3PDObject        (**_args (10, 'MissingET', kw,
                                                exclude=['MET_Base', 'MET_Base0', 'MET_Truth_Int',
                                                         'MET_RefFinal_Comps','MET_Calib_Comps','MET_CellOut_Comps',
                                                         'MET_CorrTopo_Comps','MET_Cryo_Comps','MET_CryoCone_Comps',
                                                         'MET_Final_Comps','MET_LocHadTopo_Comps',
                                                         'MET_LocHadTopoObj_Comps','MET_Muid_Comps',
                                                         'MET_Muid_Spectro_Comps','MET_Muid_Track_Comps',
                                                         'MET_MuonBoy_Comps','MET_MuonBoy_Spectro_Comps',
                                                         'MET_MuonBoy_Track_Comps','MET_MuonMuid_Comps',
                                                         'MET_Muon_Comps','MET_Muon_Isol_Muid_Comps',
                                                         'MET_Muon_Isol_Staco_Comps','MET_Muon_NonIsol_Muid_Comps',
                                                         'MET_Muon_NonIsol_Staco_Comps','MET_Muon_Total_Muid_Comps',
                                                         'MET_Muon_Total_Staco_Comps','MET_RefEle_Comps',
                                                         'MET_RefEle_em_Comps','MET_RefGamma_Comps',
                                                         'MET_RefGamma_em_Comps','MET_RefJet_Comps',
                                                         'MET_RefJet_em_Comps','MET_RefMuon_Comps',
                                                         'MET_RefMuon_Muid_Comps','MET_RefMuon_Staco_Comps',
                                                         'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Staco_Comps',
                                                         'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_Comps',
                                                         'MET_RefMuon_em_Comps','MET_RefTau_Comps',
                                                         'MET_RefTau_em_Comps','MET_SoftJets_Comps',
                                                         'MET_SoftJets_em_Comps','MET_Topo_Comps',
                                                         'MET_TopoObj_Comps','MET_Track_Comps','MET_Comps',
                                                         'MET_Track_Weights','MET_Cluster_Weights'],
                                                allowMissing=True))
    elif METDetails > 0:
        alg += MissingETD3PDObject   (**_args (10, 'MissingET', kw,
                                           exclude=['MET_Base','MET_Base0','MET_Truth',
                                                    'MET_CellOut_Comps','MET_CellOut_Regions',
                                                    'MET_CellOut_em_Comps','MET_CellOut_em_Regions',
                                                    'MET_CellOut_Eflow_Comps','MET_CellOut_Eflow_Regions',
                                                    'MET_Calib',
                                                    'MET_CorrTopo',
                                                    'MET_Cryo',
                                                    'MET_CryoCone',
                                                    'MET_Final',
                                                    'MET_LocHadTopo_Comps',
                                                    'MET_LocHadTopoObj',
                                                    'MET_Muid',
                                                    'MET_Muid_Spectro',
                                                    'MET_Muid_Track',
                                                    'MET_MuonBoy_Regions',
                                                    'MET_MuonBoy_Spectro',
                                                    'MET_MuonBoy_Track',
                                                    'MET_MuonMuid',
                                                    'MET_Muon',
                                                    'MET_Muon_Isol_Muid',
                                                    'MET_Muon_Isol_Staco',
                                                    'MET_Muon_NonIsol_Muid',
                                                    'MET_Muon_NonIsol_Staco',
                                                    'MET_Muon_Total_Muid',
                                                    'MET_Muon_Total_Staco',
                                                    'MET_RefEle_Comps','MET_RefEle_Regions',
                                                    'MET_RefEle_em_Comps','MET_RefEle_em_Regions',
                                                    'MET_RefGamma_Comps','MET_RefGamma_Regions',
                                                    'MET_RefGamma_em_Comps','MET_RefGamma_em_Regions',
                                                    'MET_RefJet_Comps','MET_RefJet_Regions',
                                                    'MET_RefJet_em_Comps','MET_RefJet_em_Regions',
                                                    'MET_RefMuon_Comps','MET_RefMuon_Regions',
                                                    'MET_RefMuon_Muid_Comps','MET_RefMuon_Muid_Regions',
                                                    'MET_RefMuon_Staco_Comps','MET_RefMuon_Staco_Regions',
                                                    'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Muid_Regions',
                                                    'MET_RefMuon_Track_Staco_Comps','MET_RefMuon_Track_Staco_Regions',
                                                    'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_em_Regions',
                                                    'MET_RefMuon_Track_Comps','MET_RefMuon_Track_Regions',
                                                    'MET_RefMuon_em_Comps','MET_RefMuon_em_Regions',
                                                    'MET_RefTau_Comps','MET_RefTau_Regions',
                                                    'MET_RefTau_em_Comps','MET_RefTau_em_Regions',
                                                    'MET_SoftJets_Comps','MET_SoftJets_Regions',
                                                    'MET_SoftJets_em_Comps','MET_SoftJets_em_Regions',
                                                    'MET_Topo',
                                                    'MET_TopoObj_Comps','MET_TopoObj_Regions',
                                                    'MET_Track_Comps','MET_Track_Regions',
                                                    'MET_Track_Weights','MET_Cluster_Weights',
                                                    'MET_Comps'
                                                    ],
                                           allowMissing=True ))


    if METDetails > 0:
        add_met (alg)


    # track and cluster blocks

    # ... all clusters, very low LOD
    
    alg += ClusterD3PDObject          (**_args ( 0, 'Clusters1', kw,
                                                 exclude='SamplingBasics'))

    # ... higher LOD for pt>10 GeV
    
    alg += ClusterD3PDObject          (**_args ( 2, 'Clusters2', kw,
                                                 sgkey  = 'HighPtClusters',
                                                 prefix = 'clpt10_'))
    
    alg += ClusterD3PDObject          (**_args ( 3, 'Clusters3', kw,
                                                 sgkey  = 'HighPtEMClusters',
                                                 prefix = 'emclpt10_'))

    from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject    

    # ... good tracks only (nSCT>3; no pt cut)

    # turn on detailed track info if writing SoftQCD version of D3PD
    if doSoftQCD :

        from TrackD3PDMaker.TrackD3PDMakerFlags                import TrackD3PDFlags as softQcdFlags

        softQcdFlags.doTruth = True
        softQcdFlags.storeDetailedTruth = False
        softQcdFlags.storeDiagonalCovarianceAsErrors = True
        softQcdFlags.storeHitTruthMatching = True
        softQcdFlags.storePixelHitsOnTrack = False
        softQcdFlags.storePixelHolesOnTrack = False
        softQcdFlags.storePixelOutliersOnTrack = False
        softQcdFlags.storeSCTHitsOnTrack = False
        softQcdFlags.storeSCTHolesOnTrack = False
        softQcdFlags.storeSCTOutliersOnTrack = False
        softQcdFlags.storeTRTHitsOnTrack = False
        softQcdFlags.storeTRTHolesOnTrack = False
        softQcdFlags.storeTRTOutliersOnTrack = False
        softQcdFlags.storeTrackFitQuality = True
        softQcdFlags.storeTrackInfo = True
        softQcdFlags.storeTrackMomentum = True
        softQcdFlags.storeTrackPredictionAtBLayer = True
        softQcdFlags.storeTrackSummary = True
        softQcdFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        softQcdFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        softQcdFlags.trackParametersAtPrimaryVertexLevelOfDetails = 2 

        SoftQCDTrackParticleD3PDObject = TrackD3PDObject(_label='trk',
                                                         _prefix='trk_',
                                                         _sgkey='GoodTracks',
                                                         typeName='Rec::TrackParticleContainer',
                                                         truthMapKey='TrackParticleTruthCollection',
                                                         SGKeyForTruth=D3PDMakerFlags.TrackSGKey(),
                                                         flags=softQcdFlags)

        alg += SoftQCDTrackParticleD3PDObject(**_args ( 3, 'Tracks1', kw,
                                                        sgkey  = 'GoodTracks',
                                                        label  = 'trk',
                                                        prefix = 'trk_'))

    else :

        # ... use standard level of track info for 'GoodTracks'

        alg += TrackParticleD3PDObject    (**_args ( 3, 'Tracks1', kw,
                                                     sgkey  = 'GoodTracks',
                                                     label  = 'trk',
                                                     prefix = 'trk_'))

        # ... high-pt tracks (nSCT>3; pt>5 GeV)

        from TrackD3PDMaker.TrackD3PDMakerFlags                import TrackD3PDFlags as highPtFlags
        highPtFlags.doTruth = True
        highPtFlags.storeDiagonalCovarianceAsErrors = True
        highPtFlags.storeHitTruthMatching = True
        highPtFlags.storePixelHitsOnTrack = False
        highPtFlags.storePixelHolesOnTrack = False
        highPtFlags.storePixelOutliersOnTrack = False
        highPtFlags.storeSCTHitsOnTrack = False
        highPtFlags.storeSCTHolesOnTrack = False
        highPtFlags.storeSCTOutliersOnTrack = False
        highPtFlags.storeTRTHitsOnTrack = False
        highPtFlags.storeTRTHolesOnTrack = False
        highPtFlags.storeTRTOutliersOnTrack = False
        highPtFlags.storeTrackFitQuality = True
        highPtFlags.storeTrackMomentum = True
        highPtFlags.storeTrackSummary = True
        highPtFlags.storeTrackSummary.IDOutliers = True
        highPtFlags.storeTrackSummary.PixelInfoPlus = True
        highPtFlags.storeTrackSummary.SCTInfoPlus = True
        highPtFlags.storeTrackSummary.TRTInfoPlus = True
        highPtFlags.storeTrackSummary.InfoPlus = True
        highPtFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3  

        HighPtTrackParticleD3PDObject = TrackD3PDObject(_label='trkpt4',
                                                        _prefix='trkpt4_',
                                                        _sgkey='HighPtTracks',
                                                        typeName='Rec::TrackParticleContainer',
                                                        truthMapKey='TrackParticleTruthCollection',
                                                        SGKeyForTruth=D3PDMakerFlags.TrackSGKey(),
                                                        flags=highPtFlags)

        alg += HighPtTrackParticleD3PDObject(**_args ( 3, 'Tracks2', kw,
                                                     sgkey  = 'HighPtTracks',
                                                     label  = 'trkpt4',
                                                     prefix = 'trkpt4_'))

    
    # Primary vertex block - May be missing in single-beam data.

    alg += PrimaryVertexD3PDObject (**_args (1, 'PrimaryVertex', kw,
                                             allowMissing = True,
                                             sgkey = D3PDMakerFlags.VertexSGKey(),
                                             prefix = 'vxp_'))
    
    # MBTS 

    alg += MBTSD3PDObject             (**_args (10, 'MBTS', kw))
    alg += MBTSTimeD3PDObject         (**_args (10, 'MBTSTime', kw))
    alg += MBTSTriggerBitsD3PDObject  (**_args (10, 'MBTSTriggerBits', kw))
    #alg += CollisionDecisionD3PDObject(**_args (10, 'CollisionDecision', kw))


    ### EventShape variables  Bertrand
    alg += EventShapeD3PDObject(**_args(0, 'rho', kw))

        
    # Truth

    if rec.doTruth():

        from TruthD3PDMaker.TruthParticleD3PDObject            import TruthParticleD3PDObject
        alg += TruthParticleD3PDObject(**_args ( 1, 'TruthParticle', kw))

        from MuonD3PDMaker.TruthMuonD3PDObject                 import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject    (**_args ( 2, 'TruthMuon', kw))


        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool

        # ... remove empty GenEvents

        smwzGenEvtFilterTool = D3PD__GenObjectsFilterTool( "smwzGenEvtFilterTool" )
        ToolSvc += smwzGenEvtFilterTool
        smwzGenEvtFilterTool.RemoveDummyEvents = True
        smwzGenEvtFilterTool.RemoveInTimePileUp = True
        smwzGenEvtFilterTool.Remove2BCPileUp = True
        smwzGenEvtFilterTool.Remove800nsPileUp = True
        smwzGenEvtFilterTool.RemoveCavernBkg = True
        smwzGenEvtFilterTool.RemoveEmptyEvents = True

        from TruthD3PDMaker.GenEventD3PDObject                 import GenEventD3PDObject
        alg += GenEventD3PDObject     (**_args ( 0, 'GenEvent', kw, filter = smwzGenEvtFilterTool ))


        # ... TruthJets
        if not testSGKey ('JetCollection', 'AntiKt6TruthJets'):
            make_StandardJetGetter('AntiKt', 0.6, 'Truth')

        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJet', kw,
                                                 sgkey='AntiKt4TruthJets',prefix='jet_AntiKt4Truth_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJet', kw,
                                                 sgkey='AntiKt6TruthJets', prefix='jet_AntiKt6Truth_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJetALL', kw,
                                                 sgkey='AntiKt4TruthJets_ALL', prefix='jet_AntiKt4TruthALL_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJetALL', kw,
                                                 sgkey='AntiKt6TruthJets_ALL', prefix='jet_AntiKt6TruthALL_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJetWZ', kw,
                                                 sgkey='AntiKt4TruthJets_WZ', prefix='jet_AntiKt4TruthWZ_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJetWZ', kw,
                                                 sgkey='AntiKt6TruthJets_WZ', prefix='jet_AntiKt6TruthWZ_',
                                                 allowMissing = True))
        

        # ... heavy flavor truth information

        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool
        smwzhfGenVtxFilterTool = D3PD__GenObjectsFilterTool( "SMWZHFGenVtxFilterTool" )
        ToolSvc += smwzhfGenVtxFilterTool

        smwzhfGenVtxFilterTool.RemoveInTimePileUp = False
        smwzhfGenVtxFilterTool.Remove2BCPileUp = True
        smwzhfGenVtxFilterTool.Remove800nsPileUp = True
        smwzhfGenVtxFilterTool.RemoveCavernBkg =  True
        smwzhfGenVtxFilterTool.RemoveEmptyEvents = True
        smwzhfGenVtxFilterTool.RemoveDummyEvents = True
        smwzhfGenVtxFilterTool.RemoveUnrequestedParticles=True
        smwzhfGenVtxFilterTool.KeepBCHadrons=True

        from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject
        alg += GenVertexD3PDObject( **_args(0, "hfgenvertex", kw, prefix='mchfvtx_',
                                            filter = smwzhfGenVtxFilterTool )
                                      )

        smwzhfGenPartFilterTool = D3PD__GenObjectsFilterTool( "SMWZHFGenPartFilterTool" )
        ToolSvc += smwzhfGenPartFilterTool

        smwzhfGenPartFilterTool.RemoveInTimePileUp = False
        smwzhfGenPartFilterTool.Remove2BCPileUp = True
        smwzhfGenPartFilterTool.Remove800nsPileUp = True
        smwzhfGenPartFilterTool.RemoveCavernBkg =  True
        smwzhfGenPartFilterTool.RemoveEmptyEvents = True
        smwzhfGenPartFilterTool.RemoveDummyEvents = True
        smwzhfGenPartFilterTool.RemoveUnrequestedParticles=True
        smwzhfGenPartFilterTool.KeepBCQuarks=True
        smwzhfGenPartFilterTool.KeepBCQuarkAncestors=True
        smwzhfGenPartFilterTool.KeepBCHadrons=True
        smwzhfGenPartFilterTool.KeepBCHadronDecayChain=True
        smwzhfGenPartFilterTool.BCHadronsDescendantsPtCut=200
        smwzhfGenPartFilterTool.BCHadronsDescendantsBarcodeCut=300000
        smwzhfGenPartFilterTool.BCHadronsDescendantsEtaCut=5

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject( **_args(10, "hfgenparticle", kw, prefix='mchfpart_',
                                              filter = smwzhfGenPartFilterTool,
                                              GenParticle_WriteMotherType=False,
                                              GenParticle_WriteMotherBarcode=False
                                              )
                                        )

        # ...  leptonic W/Z truth information

        smwzlepwzGenPartFilterTool = D3PD__GenObjectsFilterTool( "SMWZLepWZGenPartFilterTool" )
        ToolSvc += smwzlepwzGenPartFilterTool

        smwzlepwzGenPartFilterTool.RemoveInTimePileUp = True
        smwzlepwzGenPartFilterTool.Remove2BCPileUp = True
        smwzlepwzGenPartFilterTool.Remove800nsPileUp = True
        smwzlepwzGenPartFilterTool.RemoveCavernBkg =  True
        smwzlepwzGenPartFilterTool.RemoveEmptyEvents = True
        smwzlepwzGenPartFilterTool.RemoveDummyEvents = True
        smwzlepwzGenPartFilterTool.RemoveUnrequestedParticles=True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosons=True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonDecayChains=True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonsParents=True

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject( **_args(10, "lepwzgenparticle", kw, prefix='mclepwzpart_',
                                              filter = smwzlepwzGenPartFilterTool,
                                              label = "LepWZTruthD3PDObject",
                                              exclude = ["GenPartProdVertexAssoc","GenPartDecayVertexAssoc"],
                                              GenParticle_WriteMotherType=False,
                                              GenParticle_WriteMotherBarcode=False,
                                              GenPartMotherAssoc_target="LepWZTruthD3PDObject",
                                              GenPartChildAssoc_target="LepWZTruthD3PDObject"
                                              )
                                        )


    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)
    
    
    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += SMWZTriggerBitsD3PDObject      (**_args (10, 'SMWZTriggerBits', kw))
        
        # Trigger Decision + metadata

        alg += TrigDecisionD3PDObject  (**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)
        
        # Bunch group info

        alg += BGCodeD3PDObject (**_args (2, 'BGCode', kw))

        # Egamma and Mu
        
        TrigEgammaD3PDObjects (alg, 1)
        TrigMuonD3PDObjects( alg, 1)

        # MET
        
        TrigMETD3PDObjects (alg, 2)

        # The BJet information:

        TrigBJetD3PDObjects(alg,10, False, False, True, True, True)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

    if D3PDMakerFlags.FilterCollCand():
        from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
        alg.filterSeq += CollisionFilterAlg (tuplename + '_CollCandFilter')

    return alg
示例#15
0
def AddBTaggingInfo(obj, level = 0, block_prefix = ""):

    obj.defineBlock(level,block_prefix+JetTagD3PDKeys.BTagWeightsBlockName(),
                              JetTagD3PDMaker.JetTagBTagWeightsFillerTool,
                              prefix=JetTagD3PDKeys.BTagWeightsPrefix(),
                              TaggerNames=JetTagD3PDFlags.Taggers())
    TrackD3PDFlags.storeBLayerHitsOnTrack = False
TrackD3PDFlags.storeSCTHitsOnTrack = False
TrackD3PDFlags.storeTRTHitsOnTrack = False
TrackD3PDFlags.storeBLayerOutliersOnTrack = False
TrackD3PDFlags.storePixelOutliersOnTrack = False
TrackD3PDFlags.storeSCTOutliersOnTrack = False
TrackD3PDFlags.storeTRTOutliersOnTrack = False
TrackD3PDFlags.storeBLayerHolesOnTrack = False
TrackD3PDFlags.storePixelHolesOnTrack = False
TrackD3PDFlags.storeSCTHolesOnTrack = False
TrackD3PDFlags.storeTRTHolesOnTrack = False
TrackD3PDFlags.storeVertexAssociation = True
TrackD3PDFlags.storeTrackPredictionAtBLayer = False

### configure association labels
JetTagD3PDFlags.TrackAssocLabel = JetTagD3PDKeys.TrackGetterLabel()
JetTagD3PDFlags.MuonAssocLabel = JetTagD3PDKeys.MuonInJetGetterLabel()
JetTagD3PDFlags.Muon2AssocLabel = JetTagD3PDKeys.Muon2InJetGetterLabel()
JetTagD3PDFlags.ElectronAssocLabel = JetTagD3PDKeys.ElectronInJetGetterLabel()
#JetTagD3PDFlags.PhotonAssocLabel = JetTagD3PDKeys.PhotonInJetGetterLabel()
#JetTagD3PDFlags.JFVxOnJetAxisAssocLabel = JetTagD3PDKeys.JFVxOnJetAxisGetterLabel()
#JetTagD3PDFlags.JFTwoTrackVertexAssocLabel = JetTagD3PDKeys.JFTwoTrackVertexGetterLabel()
TruthD3PDFlags.GenParticleAssocLabel = TruthD3PDKeys.GenParticleGetterLabel()
TruthD3PDFlags.GenVertexAssocLabel = ""
TruthD3PDFlags.GenEventAssocLabel = TruthD3PDKeys.GenEventGetterLabel()
TruthD3PDFlags.TruthTrackAssocLabel = ""
JetTagD3PDFlags.MSVVtxInfoAssocLabel = JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel(
)

### configure jet tag flags
JetTagD3PDFlags.SkimD3PD = True
示例#17
0
        if not hasattr(D3PDMakerCoreComps.VectorFillerTool, k):
            del defs[k]

    if not defs.has_key("SaveMetadata"):
        defs["SaveMetadata"] = D3PDMakerFlags.SaveObjectMetadata()

    return D3PDMakerCoreComps.VectorFillerTool(name,
                                               Prefix=prefix,
                                               Getter=getter,
                                               ObjectName=object_name,
                                               AllowMissing=allowMissing,
                                               **defs)


JetTagTwoTrackVertexD3PDObject = D3PDObject(
    make_TwoTrackVertex_D3PDObject, JetTagD3PDKeys.JFTwoTrackVertexPrefix(),
    'JetTagTwoTrackVertexD3PDObject')

JetTagTwoTrackVertexD3PDObject.defineHook(_jetTwoTrackVertexTagAlgHook)

JetTagTwoTrackVertexD3PDObject.defineBlock(
    0, '', JetTagD3PDMaker.JetTagTwoTrackVertexFillerTool)

if JetTagD3PDFlags.TrackAssocLabel() != "":


    JetTagTwoTrackVertexTrackAssoc = IndexMultiAssociation(\
        JetTagTwoTrackVertexD3PDObject,
        JetTagD3PDMaker.JetTagTwoTrackVertexTrackAssociationTool,
        JetTagD3PDFlags.TrackAssocLabel(),
        level=0,
示例#18
0
from AthenaCommon.AppMgr import ToolSvc

from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys
from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
from RecExConfig.RecFlags import rec


### hack to make it work until remi fixes the label in BuildVertexD3PDObject
JetTagD3PDKeys.PrimaryVertexGetterLabel = JetTagD3PDKeys.PrimaryVertexPrefix()

### switch on second muon
from BTagging.BTaggingFlags import BTaggingFlags
if BTaggingFlags.SecondSoftMu:
    JetTagD3PDFlags.AddSecondMuonCollection=True

### which ntuple configuration to load?
if JetTagD3PDFlags.NtupleType() == "":
    print "custom configuration used for JetTagD3PD"
if JetTagD3PDFlags.NtupleType() == "Debug":
    include("JetTagD3PDMaker/DebugNtuple_LoadConfig.py")
    print "Debug configuration used for JetTagD3PD"
if JetTagD3PDFlags.NtupleType() == "Full":
    include("JetTagD3PDMaker/FullNtuple_LoadConfig.py")
    print "Full configuration used for JetTagD3PD"
if JetTagD3PDFlags.NtupleType() == "Efficiency":
    include("JetTagD3PDMaker/EffNtuple_LoadConfig.py")
    print "Efficiency configuration used for JetTagD3PD"
    
## create the D3PD alg
import D3PDMakerCoreComps
alg = D3PDMakerCoreComps.MakerAlg(JetTagD3PDKeys.D3PDAlgName(), topSequence,
示例#19
0
        jetCollections=[]):

    from JetTagD3PDMaker import JetTagElectronInJetGetterTool
    getter = JetTagElectronInJetGetterTool(name + '_Getter',
                                           Label=label,
                                           JetCollections=jetCollections)

    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    return  D3PDMakerCoreComps.VectorFillerTool (name, Prefix = prefix, Getter = getter,
                                                 ObjectName = object_name,
                                                 SaveMetadata = \
                                                 D3PDMakerFlags.SaveObjectMetadata())


JetTagElectronInJetD3PDObject = D3PDObject(
    makeJetTagElectronInJetObject, JetTagD3PDKeys.ElectronInJetPrefix(),
    'JetTagElectronInJetD3PDObject')

JetTagElectronInJetD3PDObject.defineBlock(
    0,
    'Kinematics',
    EventCommonD3PDMaker.FourMomFillerTool,
    WriteRect=True,
    WriteE=True,
    WriteM=True)

JetTagElectronInJetD3PDObject.defineBlock(
    0, 'Authors', egammaD3PDMaker.egammaAuthorFillerTool)

JetTagElectronInJetD3PDObject.defineBlock(0,
                                          'IsEMCuts',
    from JetTagD3PDMaker import JetTagMuonInJetGetterTool
    getter = JetTagMuonInJetGetterTool(name + '_Getter',
                                       Label=label,
                                       JetCollections=jetCollections,
                                       MuonsName=muonsName)

    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    return  D3PDMakerCoreComps.VectorFillerTool (name, Prefix = prefix, Getter = getter,
                                                 ObjectName = object_name,
                                                 SaveMetadata = \
                                                 D3PDMakerFlags.SaveObjectMetadata())


JetTagMuonInJetD3PDObject = D3PDObject(makeJetTagMuonInJetObject,
                                       JetTagD3PDKeys.MuonInJetPrefix(),
                                       'JetTagMuonInJetD3PDObject')

JetTagMuonInJetD3PDObject.defineBlock(0,
                                      'Kinematics',
                                      EventCommonD3PDMaker.FourMomFillerTool,
                                      WriteRect=True,
                                      WriteE=True,
                                      WriteM=True)

JetTagMuonInJetD3PDObject.defineBlock(0, 'Authors',
                                      MuonD3PDMaker.MuonAuthorFillerTool)

JetTagMuonInJetD3PDObject.defineBlock(0, 'TrkMatchQuality',
                                      MuonD3PDMaker.MuonMatchQualityFillerTool)
示例#21
0
def BTaggingD3PD(alg=None,
                 file=JetTagD3PDKeys.D3PDFileName(),
                 algname=JetTagD3PDKeys.D3PDAlgName(),
                 **kw):

    print "printing additional d3pd properties from dictionary"
    print kw

    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(JetTagD3PDKeys.D3PDAlgName(),
                                  JetTagD3PDKeys.D3PDFileName(),
                                  JetTagD3PDKeys.D3PDTupleName())

    selectedJetCollections = []

    if len(JetTagD3PDFlags.JetCollections()) != 0:

        from JetTagD3PDMaker.JetTagJetD3PDObject import getJetTagJetD3PDObject
        for jetcoll in JetTagD3PDFlags.JetCollections():
            filteredcoll = jetcoll + JetTagD3PDKeys.FilteredJetCollectionPostfix(
            )
            ### you can add specific selection for a certain jet collection as argument to the function bellow
            ### otherwise the one specified by JetTagD3PDFlags will be used
            alg += getJetTagJetD3PDObject(**_args(
                jetcoll, kw, filteredsgkey=filteredcoll, origsgkey=jetcoll))
            selectedJetCollections.append(filteredcoll)
    else:
        print "Warning: you didn't specify any jet collection for the JetTag D3PD"

    if len(selectedJetCollections) != 0:

        ### add muon in jets object
        if JetTagD3PDFlags.AddMuonInJetsObject():
            from JetTagD3PDMaker.JetTagMuonInJetD3PDObject import getJetTagMuonInJetObject
            alg += getJetTagMuonInJetObject(
                **_args("muon1injet",
                        kw,
                        level=10,
                        jetCollections=selectedJetCollections))

            if JetTagD3PDFlags.AddSecondMuonCollection():
                alg += getJetTagMuonInJetObject(
                    **_args("muon2injet",
                            kw,
                            level=10,
                            jetCollections=selectedJetCollections,
                            prefix=JetTagD3PDKeys.Muon2InJetPrefix(),
                            object_name='JetTagMuon2InJetD3PDObject',
                            label=JetTagD3PDKeys.Muon2InJetGetterLabel(),
                            muonsName="SecondMuons"))

    ### add electron in jets object
        if JetTagD3PDFlags.AddElectronInJetsObject():
            from JetTagD3PDMaker.JetTagElectronInJetD3PDObject import getJetTagElectronInJetD3PDObject
            alg += getJetTagElectronInJetD3PDObject(
                **_args("electroninjet",
                        kw,
                        level=10,
                        jetCollections=selectedJetCollections))

    ### add photon in jets object
        if JetTagD3PDFlags.AddPhotonInJetsObject():
            from JetTagD3PDMaker.JetTagPhotonInJetD3PDObject import getJetTagPhotonInJetD3PDObject
            alg += getJetTagPhotonInJetD3PDObject(
                **_args("photoninjet",
                        kw,
                        level=10,
                        jetCollections=selectedJetCollections))

    ### add VxOnJetAxis object
        if JetTagD3PDFlags.AddVxOnJetAxisInJetsObject():
            from JetTagD3PDMaker.JetTagVxOnJetAxisD3PDObject import getJetTagVxOnJetAxisD3PDObject
            alg += getJetTagVxOnJetAxisD3PDObject(
                **_args("vxonjetaxis",
                        kw,
                        level=0,
                        jetCollections=selectedJetCollections))

    ### add TwoTrackVertex object
        if JetTagD3PDFlags.AddTwoTrackVertexInJetsObject():
            from JetTagD3PDMaker.JetTagTwoTrackVertexD3PDObject import getJetTagTwoTrackVertexD3PDObject
            alg += getJetTagTwoTrackVertexD3PDObject(
                **_args("twotrackvertex",
                        kw,
                        level=0,
                        jetCollections=selectedJetCollections))

    ### add MSVVtxInfo object
        if JetTagD3PDFlags.AddMSVVtxInfoInJetsObject():
            from JetTagD3PDMaker.JetTagMSVVtxInJetD3PDObject import getJetTagMSVVtxInfoInJetD3PDObject
            alg += getJetTagMSVVtxInfoInJetD3PDObject(
                **_args("msvvtxinfo",
                        kw,
                        level=1,
                        jetCollections=selectedJetCollections))

### add event info object
    if JetTagD3PDFlags.AddEventInfoObject():
        from JetTagD3PDMaker.JetTagEventInfoD3PDObject import getJetTagEventInfoD3PDObject
        alg += getJetTagEventInfoD3PDObject(**_args("eventinfo", kw, level=1))

### add pileup event info object
    if rec.doTruth and JetTagD3PDFlags.AddPileUpEventInfoObject():
        from TruthD3PDMaker.PileUpInfoD3PDObject import PileUpInfoD3PDObject
        alg += PileUpInfoD3PDObject(0,
                                    "pileupinfo",
                                    "pileupinfo_",
                                    allowMissing=True)

### add track object
    if JetTagD3PDFlags.AddTrackObject():
        from JetTagD3PDMaker.JetTagTrackD3PDObject import getJetTagTrackD3PDObject
        alg += getJetTagTrackD3PDObject(**_args("track", kw))

### add MET objects
    for MET in JetTagD3PDFlags.METObjects():
        from JetTagD3PDMaker.JetTagMETD3PDObject import getJetTagMETD3PDObject
        alg += getJetTagMETD3PDObject(**_args(MET, kw, sgkey=MET))

### add event shape objects
    from QcdD3PDMaker.QcdEventShapeD3PDObject import EventShapeD3PDObject
    alg += EventShapeD3PDObject(level=0)

    ### add pixel clusters object
    if JetTagD3PDFlags.AddPixelClusterObject():
        from JetTagD3PDMaker.JetTagClustersD3PDObject import getJetTagClusterD3PDObject
        alg += getJetTagClusterD3PDObject(**_args("pixelcluster", kw, level=0))

### add primary vertex object
    if JetTagD3PDFlags.AddPrimaryVertexObject():
        from JetTagD3PDMaker.JetTagPrimaryVertexD3PDObject import getJetTagPrimaryVertexD3PDObject
        alg += getJetTagPrimaryVertexD3PDObject(**_args("pv", kw))

### add beam spot object
    if JetTagD3PDFlags.AddBeamSpotObject():
        from TrackD3PDMaker.BeamSpotD3PDObject import BeamSpotD3PDObject
        alg += BeamSpotD3PDObject(10)

### add muid object
    if JetTagD3PDFlags.AddMuonMuidObject():
        from MuonD3PDMaker.MuonD3PDObject import MuonD3PDObject
        _modifyMuonObject(MuonD3PDObject)
        alg += MuonD3PDObject(**_args(
            'MuonMuid',
            kw,
            level=10,
            sgkey='MuidMuonCollection',
            prefix='mu_muid_',
            allowMissing=True,
            exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
            include=[
                "BtagMuonTrackMatchingBlock", "EFCBInfoIndex", "EFMGInfoIndex",
                "EFMEInfoIndex", "L2CBInfoIndex", "L1InfoIndex"
            ]))

    if JetTagD3PDFlags.AddMuonStacoObject():
        from MuonD3PDMaker.MuonD3PDObject import MuonD3PDObject
        _modifyMuonObject(MuonD3PDObject)
        alg += MuonD3PDObject(**_args(
            'MuonStaco',
            kw,
            level=10,
            sgkey='StacoMuonCollection',
            prefix='mu_staco_',
            allowMissing=True,
            exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
            include=[
                "BtagMuonTrackMatchingBlock", "EFCBInfoIndex", "EFMGInfoIndex",
                "EFMEInfoIndex", "L2CBInfoIndex", "L1InfoIndex"
            ]))

### add truth info with a filter

    if rec.doTruth and JetTagD3PDFlags.AddGenObjects():

        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool
        jetTagGenObjectsFilterTool = D3PD__GenObjectsFilterTool(
            "JetTagGenObjectsFilterTool")
        ToolSvc += jetTagGenObjectsFilterTool

        jetTagGenObjectsFilterTool.SelectTruthTracks = False
        jetTagGenObjectsFilterTool.PtMin = JetTagD3PDFlags.MCPtMinCut()
        jetTagGenObjectsFilterTool.EtaMax = JetTagD3PDFlags.MCEtaCut()
        jetTagGenObjectsFilterTool.RemoveEmptyEvents = not JetTagD3PDFlags.MCEmptyEvents(
        )
        jetTagGenObjectsFilterTool.RemoveDummyEvents = not JetTagD3PDFlags.MCDummyEvents(
        )

        if not JetTagD3PDFlags.MCPileUp():
            jetTagGenObjectsFilterTool.RemoveInTimePileUp = True
            jetTagGenObjectsFilterTool.Remove2BCPileUp = True
            jetTagGenObjectsFilterTool.Remove800nsPileUp = True
            jetTagGenObjectsFilterTool.RemoveCavernBkg = True
            jetTagGenObjectsFilterTool.RemoveEmptyEvents = True
            jetTagGenObjectsFilterTool.RemoveDummyEvents = True

        if JetTagD3PDFlags.AddGenEventObjects():
            from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
            alg += GenEventD3PDObject(**_args("genevent", kw, level=10,
                                              filter = jetTagGenObjectsFilterTool,
                                              pileup_CollectionGetterRegistry=\
                                                  alg.name()+'_CollectionGetterRegistry'
                                              )
                                        )

        if JetTagD3PDFlags.AddGenVertexObjects():
            from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject
            alg += GenVertexD3PDObject(**_args(
                "genvertex", kw, level=10, filter=jetTagGenObjectsFilterTool))

        if JetTagD3PDFlags.AddGenParticleObjects():
            from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
            alg += GenParticleD3PDObject(**_args(
                "genparticle", kw, level=10,
                filter=jetTagGenObjectsFilterTool))

        if JetTagD3PDFlags.AddTruthTrackObjects():
            jetTagTruthTrackObjectsFilterTool = D3PD__GenObjectsFilterTool(
                "JetTagTruthTrackObjectsFilterTool")
            ToolSvc += jetTagTruthTrackObjectsFilterTool

            jetTagTruthTrackObjectsFilterTool.SelectTruthTracks = True

            jetTagTruthTrackObjectsFilterTool.PtMin = JetTagD3PDFlags.MCPtMinCut(
            )
            jetTagTruthTrackObjectsFilterTool.EtaMax = JetTagD3PDFlags.MCEtaCut(
            )
            jetTagTruthTrackObjectsFilterTool.RemoveEmptyEvents = not JetTagD3PDFlags.MCEmptyEvents(
            )
            jetTagTruthTrackObjectsFilterTool.RemoveDummyEvents = not JetTagD3PDFlags.MCDummyEvents(
            )

            if not JetTagD3PDFlags.MCPileUp():
                jetTagTruthTrackObjectsFilterTool.RemoveInTimePileUp = True
                jetTagTruthTrackObjectsFilterTool.Remove2BCPileUp = True
                jetTagTruthTrackObjectsFilterTool.Remove800nsPileUp = True
                jetTagTruthTrackObjectsFilterTool.RemoveCavernBkg = True
                jetTagTruthTrackObjectsFilterTool.RemoveEmptyEvents = True
                jetTagTruthTrackObjectsFilterTool.RemoveDummyEvents = True

            from TruthD3PDMaker.GenParticleD3PDObject import GenTruthTrackD3PDObject
            alg += GenTruthTrackD3PDObject(
                **_args("truthtrack",
                        kw,
                        level=10,
                        filter=jetTagTruthTrackObjectsFilterTool))

### add trigger
    if JetTagD3PDFlags.AddTriggerObject():
        from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
        alg += TrigDecisionD3PDObject(**_args("trigdecision", kw, level=2))
        from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata
        addTrigConfMetadata(alg)

        if JetTagD3PDFlags.AddTriggerBits():
            from JetTagD3PDMaker.JetTagTriggerBitsD3PDObject import getJetTagTriggerBitsD3PDObject
            alg += getJetTagTriggerBitsD3PDObject(
                JetTagD3PDFlags.TriggerBitsList())

        if JetTagD3PDFlags.AddJetTriggerObject():
            from TrigJetD3PDMaker.TrigJetD3PD import TrigJetD3PDObjects
            TrigJetD3PDObjects(alg,
                               level=10,
                               addNaviInfo=True,
                               addConfigInfo=False)

        if JetTagD3PDFlags.AddBJetTriggerObject():

            from TrigBJetD3PDMaker.TrigBJetD3PD import TrigBJetD3PDObjects
            bjettriglevel = 1
            if JetTagD3PDFlags.AddTrigL2IDTracks(
            ) or JetTagD3PDFlags.AddTrigEFIDTracks():
                bjettriglevel = 11
            TrigBJetD3PDObjects(alg,
                                level=bjettriglevel,
                                doAddL2ID=JetTagD3PDFlags.AddTrigL2IDTracks(),
                                doAddEFID=JetTagD3PDFlags.AddTrigEFIDTracks())

    if JetTagD3PDFlags.AddPixCond():
        if hasattr(ServiceMgr, "PixelConditionsSummarySvc"):
            from JetTagD3PDMaker.JetTagPixModCondD3PDObject import getJetTagPixModCondD3PDObject
            alg += getJetTagPixModCondD3PDObject(
                PixSummarySvc=ServiceMgr.PixelConditionsSummarySvc)
        else:
            print "Warning: JetTagPixModCondD3PDObject requested but PixelConditionsSummarySvc not configured"

    #### add fat jets and subjets
    if JetTagD3PDFlags.AddFatJets():
        from JetTagD3PDMaker.JetTagJSD3PDObjects import JSD3PD_Tool
        for xx in JetTagD3PDKeys.FatJetsList():
            if xx[0] != None and xx[1] != None:
                jsD3PD = JSD3PD_Tool(xx)
                jsD3PD.addToAlg(alg)

### add skiming
    if JetTagD3PDFlags.SkimD3PD():

        __muonAssocObjects = ["Muons"]
        if JetTagD3PDFlags.AddSecondMuonCollection():
            __muonAssocObjects = ["Muons", "Muons2"]

        from JetTagD3PDMaker.JetTagD3PDMakerConf import D3PD__JetTagD3PDEventFilter
        JetTagD3PDEventFilter = D3PD__JetTagD3PDEventFilter(
            "JetTagD3PDEventFilter",
            UseMuonFilter=JetTagD3PDFlags.UseMuonEventFilter(),
            UseJetFilter=JetTagD3PDFlags.UseJetEventFilter(),
            JetCollections=selectedJetCollections,
            JetPtCut=JetTagD3PDFlags.FilterJetPtCut(),
            JetEtaCut=JetTagD3PDFlags.FilterJetEtaCut(),
            JetWithMuonPtCut=JetTagD3PDFlags.FilterJetWithMuonPtCut(),
            SoftMuonPtCut=JetTagD3PDFlags.FilterMuonInJetPtCut(),
            MinNumberOfJets=JetTagD3PDFlags.FilterMinNJets(),
            MinNumberOfJetsWithMuon=JetTagD3PDFlags.FilterMinNJetsMuon(),
            MuonAssocObjects=__muonAssocObjects,
            MuonCollections=JetTagD3PDFlags.FilterMuonCollections(),
            MuonPtCut=JetTagD3PDFlags.FilterMuonPtCut(),
            MuonEtaCut=JetTagD3PDFlags.FilterMuonEtaCut(),
            MuonIsTightCut=JetTagD3PDFlags.FilterMuonTightCut(),
            MinNumberOfMuons=JetTagD3PDFlags.FilterMinNumberOfMuons())

        alg.filterSeq += JetTagD3PDEventFilter

        from EventCommonD3PDMaker.LBMetadataConfig import LBMetadataConfig
        alg.MetadataTools += [LBMetadataConfig()]

    return alg
class JetJFTwoTrackVertexAssocSGKey(JobProperty):
    """ storegate key of the JetVxOnJetAxis data object to associate jets with
    """
    statusOn=True
    allowedTypes=['str']
    StoredValue=JetTagD3PDKeys.JFTwoTrackVertexDataSGKey()
def VertexGroupD3PD(alg=None,
                    file=VertexD3PDAnalysisKeys.D3PDFileName(),
                    treeName=VertexD3PDAnalysisKeys.D3PDTreeName(),
                    **kw):

    print '[TrackD3PDMaker.VertexGroupD3PD] Vertex group D3PD settings:'
    print 'VertexD3PDAnalysisFlags'
    print VertexD3PDAnalysisFlags
    print 'VertexD3PDAnalysisKeys'
    print VertexD3PDAnalysisKeys

    if not alg:
        ## Create a new algorithm
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(treeName, file)

    ## General event information (custom options prefix: 'ei_')
    if VertexD3PDAnalysisFlags.useEventInfo():
        from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject
        alg += EventInfoD3PDObject(**_args('ei_', kw, level=0, prefix='ei_'))

    ## Trigger information (custom options prefix: 'trig_')
    if VertexD3PDAnalysisFlags.useTrigger():
        from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
        cfg = TriggerConfigGetter("ReadPool")
        from TriggerD3PDMaker.defineTriggerBits import defineTriggerBits
        from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata
        from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
        alg += TrigDecisionD3PDObject(**_args('trig_', kw, level=2))
        addTrigConfMetadata(alg)
    if VertexD3PDAnalysisFlags.useTriggerRaw():
        from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
        cfg = TriggerConfigGetter("ReadPool")
        from TriggerD3PDMaker.defineTriggerBits import defineTriggerBits
        from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata
        #Setup custom D3PD object with raw trigger info only (e.g. calibration_vdM streams)
        from D3PDMakerCoreComps.D3PDObject import make_Void_D3PDObject
        import TriggerD3PDMaker
        TrigDecisionD3PDObjectRaw = make_Void_D3PDObject(
            "trigRaw_",
            "TrigDecisionD3PDObjectRaw",
            default_name="TrigDecisionFillerRaw")
        if not VertexD3PDAnalysisFlags.useTrigger():
            TrigDecisionD3PDObjectRaw.defineBlock(
                0,
                "TriggerRawInfo",
                TriggerD3PDMaker.TrigDecisionFillerTool,
                SaveLVL1Raw=True,
                SaveHLTRaw=True,
                SaveBGCode=True)
        else:
            TrigDecisionD3PDObjectRaw.defineBlock(
                0,
                "TriggerRawInfo",
                TriggerD3PDMaker.TrigDecisionFillerTool,
                SaveHLTRaw=True,
                SaveBGCode=True)
        #Finally add object to algorithms
        alg += TrigDecisionD3PDObjectRaw(**_args('trig_', kw, level=0))
        if not VertexD3PDAnalysisFlags.useTrigger():
            #unless we've already added it, add meta-data as well
            addTrigConfMetadata(alg)

    ## Beam background information (custom options prefix: 'bkg_')
    if VertexD3PDAnalysisFlags.useBackgroundWord():
        from BackgroundD3PDMaker.BackgroundWordD3PDObject import BackgroundWordD3PDObject
        alg += BackgroundWordD3PDObject(**_args('bkg_', kw, level=0))

    ## Tracks and V0 information (custom options prefix: 'trk_', and 'v0_')
    if VertexD3PDAnalysisFlags.useTracks():
        labelDefaultVtx = VertexD3PDAnalysisKeys.LabelDefaultVtx()
        prefixDefaultVtx = labelDefaultVtx + '_'  #Add trailing '_'

        import TrackD3PDMaker
        from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags
        from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject
        from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
        from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags
        from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys
        VtxD3PD_Track_Exclude = ['vx_weight']
        TrackD3PDMaker.PerigeeUnbiasedIPAtPVFillerTool.DoBiased = False  #Switch off biased perigee
        TrackParticleD3PDObjectForVertex = TrackD3PDObject(
            _label='trk',
            _prefix='trk_',
            _sgkey=D3PDMakerFlags.TrackSGKey(),
            _object_name='TrackParticleD3PDObjectForVertex',
            typeName='Rec::TrackParticleContainer',
            vertexTarget=labelDefaultVtx,
            vertexPrefix=prefixDefaultVtx,
            vertexSGKey='VxPrimaryCandidate',
            truthTarget=TruthD3PDFlags.GenParticleAssocLabel(),
            truthPrefix=TruthD3PDKeys.GenParticlePrefix(),
            detailedTruthPrefix='',  # 'mc_detailed_'
            SGKeyForTruth=D3PDMakerFlags.TrackSGKey(),
            truthMapKey='TrackParticleTruthCollection',
            detailedTruthMapKey='',  #'DetailedTrackTruth'
            flags=TrackD3PDFlags)
        alg += TrackParticleD3PDObjectForVertex(
            **_args('trk_', kw, level=8, exclude=VtxD3PD_Track_Exclude))

    if VertexD3PDAnalysisFlags.useSecondaryVertex():
        from TrackD3PDMaker.V0D3PDObject import V0D3PDObject
        alg += V0D3PDObject(**_args('v0_', kw, level=10))

    ## Store beamspot information (custom option perfix: 'bs_')
    if VertexD3PDAnalysisFlags.useBeamspot():
        from TrackD3PDMaker.BeamSpotD3PDObject import BeamSpotD3PDObject
        alg += BeamSpotD3PDObject(**_args('bs_', kw, level=0))

    ## Store vertex information (custom options prefix: 'vtx_' or 'vtx' for BuildVertexD3PDObject)
    from TrackD3PDMaker.VertexD3PDObject import PrimaryVertexD3PDObject
    from TrackD3PDMaker.VertexD3PDObject import BuildVertexD3PDObject
    from InDetRecExample.InDetKeys import InDetKeys
    from InDetRecExample.InDetJobProperties import InDetFlags
    #First dump existing content
    labelDefaultVtx = VertexD3PDAnalysisKeys.LabelDefaultVtx()
    prefixDefaultVtx = labelDefaultVtx + '_'  #Add trailing '_'
    VtxDefaultD3PDObj = BuildVertexD3PDObject(
        **_args('vtx',
                kw,
                _prefix=prefixDefaultVtx,
                _label=labelDefaultVtx,
                _sgkey=InDetKeys.PrimaryVertices(),
                trackTarget='trk',
                trackPrefix='trk_',
                trackType='Rec::TrackParticleContainer'))
    alg += VtxDefaultD3PDObj(**_args('vtx_', kw, level=10))
    #Then also dump the other vertex collections
    if VertexD3PDAnalysisFlags.useAllVertexCollections:
        #Use non BC and split collections (sorry, no customization of parameters here)
        if not InDetFlags.doSplitVertexFindingForMonitoring():
            #raise NameError('Requesting split vertices but algorith has not run!')
            #pass
            print(
                '[TrackD3PDMaker.VertexGroupD3PD] WARNING: Requested split vertices, but algorithm has not run! Skipped.'
            )
        else:
            SplitPrimaryVertexD3PDObject = BuildVertexD3PDObject(
                _prefix='vxsplit_',
                _label='vxsplit',
                _sgkey=InDetKeys.PrimaryVerticesSplitStream(),
                trackTarget='trk',
                trackPrefix='trk_',
                trackType='Rec::TrackParticleContainer')
            alg += SplitPrimaryVertexD3PDObject(8)

        #Then store also non beamspot constrained ones
        if not InDetFlags.doVertexFindingForMonitoring():
            #raise NameError('Requesting NBC vertices but algorith has not run!')
            #pass
            print(
                '[TrackD3PDMaker.VertexGroupD3PD] WARNING: Requested non beamspot constrained vertices, but algorithm has not run! Skipped.'
            )
        else:
            NoBeamConstraintPrimaryVertexD3PDObject = BuildVertexD3PDObject(
                _prefix='vxnbc_',
                _label='vxnbc',
                _sgkey=InDetKeys.PrimaryVerticesWithoutBeamConstraint(),
                trackTarget='trk',
                trackPrefix='trk_',
                trackType='Rec::TrackParticleContainer')
            alg += NoBeamConstraintPrimaryVertexD3PDObject(8)

    ## Store truth-level information (custom options prefix: 'tuthVtx_', 'truthEvt_', 'truthPart_')
    if VertexD3PDAnalysisFlags.useTruth():
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool
        trackGenObjectsFilterTool = D3PD__GenObjectsFilterTool(
            "trackGenObjectsFilterTool")
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += trackGenObjectsFilterTool

        if (VertexD3PDAnalysisFlags.filterTightTruth()):
            trackGenObjectsFilterTool.SelectTruthTracks = True
            trackGenObjectsFilterTool.PtMin = VertexD3PDAnalysisKeys.TruthTrackCutPtMin(
            )
            trackGenObjectsFilterTool.EtaMax = VertexD3PDAnalysisKeys.TruthTrackCutEtaMax(
            )
            trackGenObjectsFilterTool.RemoveEmptyEvents = True
            trackGenObjectsFilterTool.RemoveDummyEvents = True
            trackGenObjectsFilterTool.RemoveInTimePileUp = False
            trackGenObjectsFilterTool.Remove2BCPileUp = True
            trackGenObjectsFilterTool.Remove800nsPileUp = True
            trackGenObjectsFilterTool.RemoveCavernBkg = False
            trackGenObjectsFilterTool.AddOnlyFirstVertex = VertexD3PDAnalysisKeys.TruthAddOnlyFirstVertex(
            )
        else:
            #Use a more inclusive truth policy
            trackGenObjectsFilterTool.SelectTruthTracks = False
            trackGenObjectsFilterTool.PtMin = VertexD3PDAnalysisKeys.TruthTrackCutPtMin(
            )
            trackGenObjectsFilterTool.EtaMax = VertexD3PDAnalysisKeys.TruthTrackCutEtaMax(
            )
            trackGenObjectsFilterTool.RemoveEmptyEvents = True
            trackGenObjectsFilterTool.RemoveDummyEvents = True
            trackGenObjectsFilterTool.AddOnlyFirstVertex = VertexD3PDAnalysisKeys.TruthAddOnlyFirstVertex(
            )

        from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
        alg += GenEventD3PDObject(
            **_args('truthEvt_',
                    kw,
                    level=10,
                    filter=trackGenObjectsFilterTool,
                    pileup_CollectionGetterRegistry=alg.name() +
                    '_CollectionGetterRegistry'))

        from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject
        alg += GenVertexD3PDObject(**_args(
            'truthVtx_', kw, level=1, filter=trackGenObjectsFilterTool))

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject(**_args(
            'truthPart_', kw, level=10, filter=trackGenObjectsFilterTool))

        from TruthD3PDMaker.GenParticleD3PDObject import GenTruthTrackD3PDObject
        alg += GenTruthTrackD3PDObject(**_args('truthTrack_', kw, level=0))

    ## Dump higher level objects
    # Missing Energy (custom options prefix with VertexD3PDAnalysisKeys.MetCollections+'_')
    if VertexD3PDAnalysisFlags.useMET():
        for MET in VertexD3PDAnalysisKeys.MetCollections():
            VtxD3PD_Met_Key = MET
            VtxD3PD_Met_Prefix = MET.replace('_', '') + '_'
            VtxD3PD_Met_Level = 0  #Only basic info
            VtxD3PD_Met_Exclude = ['MET_Regions', 'L1_', 'L2_', 'EF_']
            from MissingETD3PDMaker.MissingETD3PDObject import RefFinalMETD3PDObject
            VtxD3PD_Met_Obj = RefFinalMETD3PDObject(
                **_args(MET + '_',
                        kw,
                        level=VtxD3PD_Met_Level,
                        sgkey=VtxD3PD_Met_Key,
                        prefix=VtxD3PD_Met_Prefix,
                        exclude=VtxD3PD_Met_Exclude))
            alg += VtxD3PD_Met_Obj

    #Muons (custom options prefix VtxD3PD_Muon_Prefix -- see below [e.g. muid_, staco_, ...])
    if VertexD3PDAnalysisFlags.useMuons():
        from MuonD3PDMaker.MuonD3PDObject import MuonD3PDObject
        for Muon in VertexD3PDAnalysisKeys.MuonCollections():
            VtxD3PD_Muon_Key = Muon
            VtxD3PD_Muon_Prefix = Muon + '_'
            if VtxD3PD_Muon_Key == 'MuidMuonCollection':
                VtxD3PD_Muon_Prefix = 'muid_'
            elif VtxD3PD_Muon_Key == 'StacoMuonCollection':
                VtxD3PD_Muon_Prefix = 'staco_'

            VtxD3PD_Muon_Level = 0  #Only basic info
            VtxD3PD_Muon_Exclude = [
                'EFCBInfo', 'EFMGInfo', 'EFMEInfo', 'L2CBInfo', 'L1Info',
                'L1_', 'L2_', 'EF_'
            ]
            VtxD3PD_Muon_Obj = MuonD3PDObject(
                **_args(VtxD3PD_Muon_Prefix,
                        kw,
                        level=VtxD3PD_Muon_Level,
                        sgkey=VtxD3PD_Muon_Key,
                        prefix=VtxD3PD_Muon_Prefix,
                        allowMissing=True,
                        exclude=VtxD3PD_Muon_Exclude))
            alg += VtxD3PD_Muon_Obj

    #Electrons (custom options prefix: 'el_')
    if VertexD3PDAnalysisFlags.useElectrons():
        from egammaD3PDMaker.ElectronD3PDObject import ElectronD3PDObject
        alg += ElectronD3PDObject(**_args('el_', kw, prefix='el_', level=0))

    #Photons (custom options prefix: 'ph_')
    if VertexD3PDAnalysisFlags.usePhotons():
        from egammaD3PDMaker.PhotonD3PDObject import PhotonD3PDObject
        alg += PhotonD3PDObject(**_args('ph_', kw, prefix='ph_', level=0))

    #Jets, JVF, b-jets (custom options prefix: 'jet_')
    if VertexD3PDAnalysisFlags.useJets():
        from JetD3PDMaker.JetD3PDObject import JetD3PDObject
        from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys
        from JetTagD3PDMaker.AddBTagD3PDInfo import addBTagInfoToJetObject
        addBTagInfoToJetObject(JetD3PDObject, btagLevelOffset=0)
        VtxD3PD_Jet_Include = [
            'Kinematics', 'JetVertexFraction', 'JVtx', 'EMFraction',
            'TrueFlavorComponents',
            JetTagD3PDKeys.BTagWeightsBlockName()
        ]
        for JET in VertexD3PDAnalysisKeys.JetCollections():
            VtxD3PD_Jet_Prefix = JET.replace('_', '') + '_'
            if len(VertexD3PDAnalysisKeys.JetCollections()) == 1:
                #only 1 element, simplify prefix
                VtxD3PD_Jet_Prefix = 'jet_'
            alg += JetD3PDObject(**_args('jet_',
                                         kw,
                                         sgkey=JET,
                                         prefix=VtxD3PD_Jet_Prefix,
                                         level=0,
                                         include=VtxD3PD_Jet_Include))

    #Taus
    if VertexD3PDAnalysisFlags.useTaus():
        from TauD3PDMaker.TauD3PDObject import TauD3PDObject
        VtxD3PD_Tau_Include = ['TauPriVtx']
        alg += TauD3PDObject(**_args(
            'tau_', kw, prefix='tau_', level=0, include=VtxD3PD_Tau_Include))

    ## Return algorithm
    return alg
示例#24
0
def ZPrimeMMD3PD(alg=None,
                 file='smwz.root',
                 tuplename='physics',
                 streamname='d3pdstream',
                 doSoftQCD=False,
                 doThirdMuonChain=True,
                 **kw):

    # define associations

    if not PhotonD3PDObject.allBlocknames().has_key('RecoveryMatch'):
        from PhotonD3PDMaker.PhotonRecoveryAssociation import PhotonRecoveryAssociation
        PhotonRecoveryAssoc = PhotonRecoveryAssociation(
            PhotonD3PDObject,
            'ElectronContainer',
            D3PDMakerFlags.ElectronSGKey(),
            prefix='el_',
            blockname='RecoveryMatch',
            target='ph_ElectronRecovered_')

    # define track and cluster filters

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())

    if not hasattr(preseq, "GoodTracks"):
        filter1 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='GoodTracks',
                                     ptCut=0.,
                                     nSCTPix=4)
        preseq += filter1

    if not hasattr(preseq, "HighPtTracks"):
        filter2 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='HighPtTracks',
                                     ptCut=4000.,
                                     nSCTPix=4)
        preseq += filter2

    if not hasattr(preseq, "HighPtClusters"):
        filter3 = makeClusterFilter(InputName=D3PDMakerFlags.ClusterSGKey(),
                                    OutputName='HighPtClusters',
                                    ptCut=10000.)
        preseq += filter3

    if not hasattr(preseq, "HighPtEMClusters"):
        filter4 = makeClusterFilter(
            InputName=D3PDMakerFlags.EMTopoClusterSGKey(),
            OutputName='HighPtEMClusters',
            ptCut=10000.)
        preseq += filter4

    # perform recoil calculation

    import HadronicRecoil.Configurables as hrc
    preseq = hrc.add_hadronic_recoil_filters(preseq)

    # now configure the D3PD

    if not alg:
        alg = MSMgr.NewRootStream(StreamName=streamname,
                                  FileName=file,
                                  TreeName=tuplename)

    alg += EventInfoD3PDObject(**_args(10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject(**_args(10, 'LArCollisionTime', kw))

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    # Electron/Photon blocks

    alg += ElectronD3PDObject(**_args(10, 'Electron', kw))

    if testSGKey('ElectronContainer', D3PDMakerFlags.GSFElectronSGKey()):
        alg += GSFElectronD3PDObject(
            **_args(10,
                    'GSFElectron',
                    kw,
                    sgkey=D3PDMakerFlags.GSFElectronSGKey(),
                    prefix='el_gsf_'))

    alg += PhotonD3PDObject(**_args(10, 'Photon', kw))

    # Muon blocks

    ### add the scattering significance filler - to be removed when added in the MuonD3PDMaker
    if not MuonD3PDObject.allBlocknames().has_key(
            "MuonScatteringAngleSignificance"):
        from AthenaCommon.AppMgr import ToolSvc
        muonScatteringSigTool = None
        if hasattr(ToolSvc, "MuonScatteringSigTool"):
            muonScatteringSigTool = ToolSvc.MuonScatteringSigTool
        from JetTagD3PDMaker import MuonScatteringAngleSignificanceFillerTool
        MuonD3PDObject.defineBlock(100,
                                   "MuonScatteringAngleSignificance",
                                   MuonScatteringAngleSignificanceFillerTool,
                                   ScatteringSigTool=muonScatteringSigTool)

### Third muon chain variables!
    if doThirdMuonChain:
        if cfgKeyStore.isInInput("Analysis::MuonContainer", "Muons"):
            alg += MuonD3PDObject(**_args(
                10,
                'Muon',
                kw,
                sgkey='Muons',
                prefix='mu_',
                include=[
                    "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                    "L2CBInfoIndex", "L1InfoIndex",
                    "MuonScatteringAngleSignificance"
                ],
                exclude=[
                    "EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"
                ],
                allowMissing=True))
### Third muon chain variables!

    if cfgKeyStore.isInInput("Analysis::MuonContainer", "MuidMuonCollection"):
        alg += MuonD3PDObject(**_args(
            10,
            'MuidMuon',
            kw,
            sgkey='MuidMuonCollection',
            prefix='mu_muid_',
            include=[
                "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                "L2CBInfoIndex", "L1InfoIndex",
                "MuonScatteringAngleSignificance"
            ],
            exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
            allowMissing=True))

    if cfgKeyStore.isInInput("Analysis::MuonContainer", "StacoMuonCollection"):
        alg += MuonD3PDObject(**_args(
            10,
            'StacoMuon',
            kw,
            sgkey='StacoMuonCollection',
            prefix='mu_staco_',
            include=[
                "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                "L2CBInfoIndex", "L1InfoIndex",
                "MuonScatteringAngleSignificance"
            ],
            exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
            allowMissing=True))

    if cfgKeyStore.isInInput("Analysis::MuonContainer", "CaloMuonCollection"):
        alg += MuonD3PDObject(
            **_args(0,
                    'CaloMuon',
                    kw,
                    sgkey='CaloMuonCollection',
                    prefix='mu_calo_',
                    include=[
                        "MuonHitSummary", "Authors", "Likelihood", "Isolation",
                        "CaloEnergyLoss", "Quality"
                    ]))

    # Tau block

    alg += TauD3PDObject(**_args(1, 'Tau', kw))

    # Jet blocks

    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys

    ## add MSV target to the jetd3pd object properties
    if not kw.has_key('AK4TopoEMJet_' +
                      JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName() +
                      '_target'):
        kw['AK4TopoEMJet_' +
           JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName() +
           '_target'] = JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()
    if not kw.has_key('AK6TopoEMJet_' +
                      JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName() +
                      '_target'):
        kw['AK6TopoEMJet_' +
           JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName() +
           '_target'] = JetTagD3PDKeys.MSVVtxInfoInJetGetterLabel()

    ## add track index for IPInfoPlus
    if not kw.has_key('AK4TopoEMJet_' +
                      JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK4TopoEMJet_' + JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AK6TopoEMJet_' +
                      JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK6TopoEMJet_' + JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName() +
           '_target'] = "trk"
    ## add track index for SVInfoPlus
    if not kw.has_key('AK4TopoEMJet_' +
                      JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK4TopoEMJet_' + JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AK6TopoEMJet_' +
                      JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK6TopoEMJet_' + JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName() +
           '_target'] = "trk"
    ## add track index for SV0InfoPlus
    if not kw.has_key('AK4TopoEMJet_' +
                      JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK4TopoEMJet_' + JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AK6TopoEMJet_' +
                      JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName() +
                      '_target'):
        kw['AK6TopoEMJet_' + JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName() +
           '_target'] = "trk"

    alg += JetD3PDObject(**_args(3,
                                 'AK4TopoEMJet',
                                 kw,
                                 sgkey='AntiKt4TopoEMJets',
                                 prefix='jet_AntiKt4TopoEM_',
                                 include=JetTagD3PDFlags.StdInfoInclude() +
                                 [JetTagD3PDKeys.MultiSVInfoPlusBlockName()],
                                 JetVertexFraction_FromUD=True,
                                 JetVertexFraction_FillFullJVF=True,
                                 allowMissing=True))

    alg += JetD3PDObject(**_args(3,
                                 'AK6TopoEMJet',
                                 kw,
                                 sgkey='AntiKt6TopoEMJets',
                                 prefix='jet_AntiKt6TopoEM_',
                                 include=JetTagD3PDFlags.StdInfoInclude() +
                                 [JetTagD3PDKeys.MultiSVInfoPlusBlockName()],
                                 JetVertexFraction_FromUD=True,
                                 JetVertexFraction_FillFullJVF=True,
                                 allowMissing=True))

    alg += JetD3PDObject(**_args(3,
                                 'AK4LCTopoJet',
                                 kw,
                                 sgkey='AntiKt4LCTopoJets',
                                 prefix='jet_AntiKt4LCTopo_',
                                 JetVertexFraction_FromUD=True,
                                 JetVertexFraction_FillFullJVF=True,
                                 allowMissing=True))

    alg += JetD3PDObject(**_args(3,
                                 'AK6LCTopoJet',
                                 kw,
                                 sgkey='AntiKt6LCTopoJets',
                                 prefix='jet_AntiKt6LCTopo_',
                                 JetVertexFraction_FromUD=True,
                                 JetVertexFraction_FillFullJVF=True,
                                 allowMissing=True))

    ### add the MSV block
    MSVJetCollections = ['AntiKt4TopoEMJets', 'AntiKt6TopoEMJets']
    ### link multisv to tracks
    if not kw.has_key('msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target'):
        kw['msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target'] = "trk"

    from JetTagD3PDMaker.JetTagMSVVtxInJetD3PDObject import getJetTagMSVVtxInfoInJetD3PDObject
    alg += getJetTagMSVVtxInfoInJetD3PDObject(
        **_args(1, "msvvtxinfo", kw, jetCollections=MSVJetCollections))

    from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
    alg += HforD3PDObject(**_args(0, 'HforInfo', kw))

    # EventShape variables
    alg += EventShapeD3PDObject(**_args(0, 'rho', kw))

    # MET blocks
    # a whole mess to remove x,y components separately for all flavours

    alg += MissingETD3PDObject(**_args(
        10,
        'MissingET',
        kw,
        exclude=[
            'MET_Base', 'MET_Base0', 'MET_Truth_Int', 'MET_RefFinal_Comps',
            'MET_Calib_Comps', 'MET_CellOut_Comps', 'MET_CorrTopo_Comps',
            'MET_Cryo_Comps', 'MET_CryoCone_Comps', 'MET_Final_Comps',
            'MET_LocHadTopo_Comps', 'MET_LocHadTopoObj_Comps',
            'MET_Muid_Comps', 'MET_Muid_Spectro_Comps', 'MET_Muid_Track_Comps',
            'MET_MuonBoy_Comps', 'MET_MuonBoy_Spectro_Comps',
            'MET_MuonBoy_Track_Comps', 'MET_MuonMuid_Comps', 'MET_Muon_Comps',
            'MET_Muon_Isol_Muid_Comps', 'MET_Muon_Isol_Staco_Comps',
            'MET_Muon_NonIsol_Muid_Comps', 'MET_Muon_NonIsol_Staco_Comps',
            'MET_Muon_Total_Muid_Comps', 'MET_Muon_Total_Staco_Comps',
            'MET_RefEle_Comps', 'MET_RefEle_em_Comps', 'MET_RefGamma_Comps',
            'MET_RefGamma_em_Comps', 'MET_RefJet_Comps', 'MET_RefJet_em_Comps',
            'MET_RefMuon_Comps', 'MET_RefMuon_Muid_Comps',
            'MET_RefMuon_Staco_Comps', 'MET_RefMuon_Track_Muid_Comps',
            'MET_RefMuon_Track_Staco_Comps', 'MET_RefMuon_Track_em_Comps',
            'MET_RefMuon_Track_Comps', 'MET_RefMuon_em_Comps',
            'MET_RefTau_Comps', 'MET_RefTau_em_Comps', 'MET_SoftJets_Comps',
            'MET_SoftJets_em_Comps', 'MET_Topo_Comps', 'MET_TopoObj_Comps',
            'MET_Track_Comps', 'MET_Comps', 'MET_Track_Weights',
            'MET_Cluster_Weights'
            'MET_RefFinal_STVF', 'MET_RefJet_JVF', 'MET_RefJet_JVFCut',
            'MET_CellOut_Eflow_STVF', 'MET_CellOut_Eflow_JetArea'
        ],
        allowMissing=True))

    # ... DR = 0.15

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_15",
                               prefix="hr_roughRecoil_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_15",
                               prefix="hr_ueCorrection_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_15",
                               prefix="hr_corrRecoil_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_15",
                               prefix="hr_MET_15",
                               exclude=['MET_Regions', 'MET_Comps'])

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_Eflow_15",
                               prefix="hr_roughRecoil_Eflow_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_Eflow_15",
                               prefix="hr_ueCorrection_Eflow_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_Eflow_15",
                               prefix="hr_corrRecoil_Eflow_15",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_Eflow_15",
                               prefix="hr_MET_Eflow_15",
                               exclude=['MET_Regions', 'MET_Comps'])

    # ... DR = 0.20

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_20",
                               prefix="hr_roughRecoil_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_20",
                               prefix="hr_ueCorrection_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_20",
                               prefix="hr_corrRecoil_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_20",
                               prefix="hr_MET_20",
                               exclude=['MET_Regions', 'MET_Comps'])

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_track_20",
                               prefix="hr_roughRecoil_track_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_track_20",
                               prefix="hr_ueCorrection_track_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_track_20",
                               prefix="hr_corrRecoil_track_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_track_20",
                               prefix="hr_MET_track_20",
                               exclude=['MET_Regions', 'MET_Comps'])

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_clusNoTrack_20",
                               prefix="hr_roughRecoil_clusNoTrack_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_clusNoTrack_20",
                               prefix="hr_ueCorrection_clusNoTrack_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_clusNoTrack_20",
                               prefix="hr_corrRecoil_clusNoTrack_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_clusNoTrack_20",
                               prefix="hr_MET_clusNoTrack_20",
                               exclude=['MET_Regions', 'MET_Comps'])

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_Eflow_20",
                               prefix="hr_roughRecoil_Eflow_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_Eflow_20",
                               prefix="hr_ueCorrection_Eflow_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_Eflow_20",
                               prefix="hr_corrRecoil_Eflow_20",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_Eflow_20",
                               prefix="hr_MET_Eflow_20",
                               exclude=['MET_Regions', 'MET_Comps'])

    # ... DR = 0.25

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_25",
                               prefix="hr_roughRecoil_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_25",
                               prefix="hr_ueCorrection_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_25",
                               prefix="hr_corrRecoil_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_25",
                               prefix="hr_MET_25",
                               exclude=['MET_Regions', 'MET_Comps'])

    alg += MissingETD3PDObject(0,
                               sgkey="RoughRecoil_Eflow_25",
                               prefix="hr_roughRecoil_Eflow_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="ueCorrection_Eflow_25",
                               prefix="hr_ueCorrection_Eflow_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="RefinedRecoil_Eflow_25",
                               prefix="hr_corrRecoil_Eflow_25",
                               exclude=['MET_Regions', 'MET_Comps'])
    alg += MissingETD3PDObject(0,
                               sgkey="MET_HR_Eflow_25",
                               prefix="hr_MET_Eflow_25",
                               exclude=['MET_Regions', 'MET_Comps'])

    # track and cluster blocks

    # ... all clusters, very low LOD

    alg += ClusterD3PDObject(
        **_args(0, 'Clusters1', kw, exclude='SamplingBasics'))

    # ... higher LOD for pt>10 GeV

    alg += ClusterD3PDObject(
        **_args(2, 'Clusters2', kw, sgkey='HighPtClusters', prefix='clpt10_'))

    alg += ClusterD3PDObject(**_args(
        3, 'Clusters3', kw, sgkey='HighPtEMClusters', prefix='emclpt10_'))

    from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject

    # ... good tracks only (nSCT>3; no pt cut)

    # turn on detailed track info if writing SoftQCD version of D3PD
    if doSoftQCD:

        from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags as softQcdFlags

        softQcdFlags.doTruth = True
        softQcdFlags.storeDetailedTruth = False
        softQcdFlags.storeDiagonalCovarianceAsErrors = True
        softQcdFlags.storeHitTruthMatching = True
        softQcdFlags.storePixelHitsOnTrack = False
        softQcdFlags.storePixelHolesOnTrack = False
        softQcdFlags.storePixelOutliersOnTrack = False
        softQcdFlags.storeSCTHitsOnTrack = False
        softQcdFlags.storeSCTHolesOnTrack = False
        softQcdFlags.storeSCTOutliersOnTrack = False
        softQcdFlags.storeTRTHitsOnTrack = False
        softQcdFlags.storeTRTHolesOnTrack = False
        softQcdFlags.storeTRTOutliersOnTrack = False
        softQcdFlags.storeTrackFitQuality = True
        softQcdFlags.storeTrackInfo = True
        softQcdFlags.storeTrackMomentum = True
        softQcdFlags.storeTrackPredictionAtBLayer = True
        softQcdFlags.storeTrackSummary = True
        softQcdFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        softQcdFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        softQcdFlags.trackParametersAtPrimaryVertexLevelOfDetails = 2

        SoftQCDTrackParticleD3PDObject = TrackD3PDObject(
            _label='trk',
            _prefix='trk_',
            _sgkey='GoodTracks',
            typeName='Rec::TrackParticleContainer',
            flags=softQcdFlags)

        alg += SoftQCDTrackParticleD3PDObject(**_args(
            3, 'Tracks1', kw, sgkey='GoodTracks', label='trk', prefix='trk_'))

    else:

        # ... use standard level of track info for 'GoodTracks'

        alg += TrackParticleD3PDObject(**_args(
            3, 'Tracks1', kw, sgkey='GoodTracks', label='trk', prefix='trk_'))

        # ... high-pt tracks (nSCT>3; pt>5 GeV)

        from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags as highPtFlags
        highPtFlags.doTruth = True
        highPtFlags.storeDiagonalCovarianceAsErrors = True
        highPtFlags.storeHitTruthMatching = True
        highPtFlags.storePixelHitsOnTrack = False
        highPtFlags.storePixelHolesOnTrack = False
        highPtFlags.storePixelOutliersOnTrack = False
        highPtFlags.storeSCTHitsOnTrack = False
        highPtFlags.storeSCTHolesOnTrack = False
        highPtFlags.storeSCTOutliersOnTrack = False
        highPtFlags.storeTRTHitsOnTrack = False
        highPtFlags.storeTRTHolesOnTrack = False
        highPtFlags.storeTRTOutliersOnTrack = False
        highPtFlags.storeTrackFitQuality = True
        highPtFlags.storeTrackMomentum = True
        highPtFlags.storeTrackSummary = True
        highPtFlags.storeTrackSummary.IDOutliers = True
        highPtFlags.storeTrackSummary.PixelInfoPlus = True
        highPtFlags.storeTrackSummary.SCTInfoPlus = True
        highPtFlags.storeTrackSummary.TRTInfoPlus = True
        highPtFlags.storeTrackSummary.InfoPlus = True
        highPtFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3

        HighPtTrackParticleD3PDObject = TrackD3PDObject(
            _label='trkpt4',
            _prefix='trkpt4_',
            _sgkey='HighPtTracks',
            typeName='Rec::TrackParticleContainer',
            flags=highPtFlags)

        alg += HighPtTrackParticleD3PDObject(**_args(3,
                                                     'Tracks2',
                                                     kw,
                                                     sgkey='HighPtTracks',
                                                     label='trkpt4',
                                                     prefix='trkpt4_'))

    # Primary vertex block - May be missing in single-beam data.

    alg += PrimaryVertexD3PDObject(**_args(1,
                                           'PrimaryVertex',
                                           kw,
                                           allowMissing=True,
                                           sgkey=D3PDMakerFlags.VertexSGKey(),
                                           prefix='vxp_'))

    # MBTS

    alg += MBTSD3PDObject(**_args(10, 'MBTS', kw))
    alg += MBTSTimeD3PDObject(**_args(10, 'MBTSTime', kw))
    alg += MBTSTriggerBitsD3PDObject(**_args(10, 'MBTSTriggerBits', kw))
    #alg += CollisionDecisionD3PDObject(**_args (10, 'CollisionDecision', kw))

    # Truth

    if rec.doTruth():

        from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject

        alg += TruthMuonD3PDObject(**_args(2, 'TruthMuon', kw))
        alg += GenEventD3PDObject(**_args(1, 'GenEvent', kw))
        alg += TruthParticleD3PDObject(**_args(1, 'TruthParticle', kw))

        # TruthJets
        alg += JetD3PDObject(**_args(1,
                                     'AK4TruthJet',
                                     kw,
                                     sgkey='AntiKt4TruthJets',
                                     prefix='jet_AntiKt4Truth_',
                                     allowMissing=True))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJet',
                                     kw,
                                     sgkey='AntiKt6TruthJets',
                                     prefix='jet_AntiKt6Truth_',
                                     allowMissing=True))
        alg += JetD3PDObject(**_args(1,
                                     'AK4TruthJetALL',
                                     kw,
                                     sgkey='AntiKt4TruthJets_ALL',
                                     prefix='jet_AntiKt4TruthALL_',
                                     allowMissing=True))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJetALL',
                                     kw,
                                     sgkey='AntiKt6TruthJets_ALL',
                                     prefix='jet_AntiKt6TruthALL_',
                                     allowMissing=True))
        alg += JetD3PDObject(**_args(1,
                                     'AK4TruthJetWZ',
                                     kw,
                                     sgkey='AntiKt4TruthJets_WZ',
                                     prefix='jet_AntiKt4TruthWZ_',
                                     allowMissing=True))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJetWZ',
                                     kw,
                                     sgkey='AntiKt6TruthJets_WZ',
                                     prefix='jet_AntiKt6TruthWZ_',
                                     allowMissing=True))

        ### heavy flavor truth information
        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool
        smwzhfGenVtxFilterTool = D3PD__GenObjectsFilterTool(
            "SMWZHFGenVtxFilterTool")
        ToolSvc += smwzhfGenVtxFilterTool

        smwzhfGenVtxFilterTool.RemoveInTimePileUp = False
        smwzhfGenVtxFilterTool.Remove2BCPileUp = True
        smwzhfGenVtxFilterTool.Remove800nsPileUp = True
        smwzhfGenVtxFilterTool.RemoveCavernBkg = True
        smwzhfGenVtxFilterTool.RemoveEmptyEvents = True
        smwzhfGenVtxFilterTool.RemoveDummyEvents = True
        smwzhfGenVtxFilterTool.RemoveUnrequestedParticles = True
        smwzhfGenVtxFilterTool.KeepBCHadrons = True

        from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject
        alg += GenVertexD3PDObject(**_args(0,
                                           "hfgenvertex",
                                           kw,
                                           prefix='mchfvtx_',
                                           filter=smwzhfGenVtxFilterTool))

        smwzhfGenPartFilterTool = D3PD__GenObjectsFilterTool(
            "SMWZHFGenPartFilterTool")
        ToolSvc += smwzhfGenPartFilterTool

        smwzhfGenPartFilterTool.RemoveInTimePileUp = False
        smwzhfGenPartFilterTool.Remove2BCPileUp = True
        smwzhfGenPartFilterTool.Remove800nsPileUp = True
        smwzhfGenPartFilterTool.RemoveCavernBkg = True
        smwzhfGenPartFilterTool.RemoveEmptyEvents = True
        smwzhfGenPartFilterTool.RemoveDummyEvents = True
        smwzhfGenPartFilterTool.RemoveUnrequestedParticles = True
        smwzhfGenPartFilterTool.KeepBCQuarks = True
        smwzhfGenPartFilterTool.KeepBCQuarkAncestors = True
        smwzhfGenPartFilterTool.KeepBCHadrons = True
        smwzhfGenPartFilterTool.KeepBCHadronDecayChain = True
        smwzhfGenPartFilterTool.BCHadronsDescendantsPtCut = 200
        smwzhfGenPartFilterTool.BCHadronsDescendantsBarcodeCut = 300000
        smwzhfGenPartFilterTool.BCHadronsDescendantsEtaCut = 5

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject(
            **_args(10,
                    "hfgenparticle",
                    kw,
                    prefix='mchfpart_',
                    filter=smwzhfGenPartFilterTool,
                    GenParticle_WriteMotherType=False,
                    GenParticle_WriteMotherBarcode=False))

        ### leptonic W/Z truth information
        smwzlepwzGenPartFilterTool = D3PD__GenObjectsFilterTool(
            "SMWZLepWZGenPartFilterTool")
        ToolSvc += smwzlepwzGenPartFilterTool

        smwzlepwzGenPartFilterTool.RemoveInTimePileUp = True
        smwzlepwzGenPartFilterTool.Remove2BCPileUp = True
        smwzlepwzGenPartFilterTool.Remove800nsPileUp = True
        smwzlepwzGenPartFilterTool.RemoveCavernBkg = True
        smwzlepwzGenPartFilterTool.RemoveEmptyEvents = True
        smwzlepwzGenPartFilterTool.RemoveDummyEvents = True
        smwzlepwzGenPartFilterTool.RemoveUnrequestedParticles = True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosons = True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonDecayChains = True
        smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonsParents = True

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject(**_args(
            10,
            "lepwzgenparticle",
            kw,
            prefix='mclepwzpart_',
            filter=smwzlepwzGenPartFilterTool,
            label="LepWZTruthD3PDObject",
            exclude=["GenPartProdVertexAssoc", "GenPartDecayVertexAssoc"],
            GenParticle_WriteMotherType=False,
            GenParticle_WriteMotherBarcode=False,
            GenPartMotherAssoc_target="LepWZTruthD3PDObject",
            GenPartChildAssoc_target="LepWZTruthD3PDObject"))

    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)

    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += ZPrimeMMTriggerBitsD3PDObject(
            **_args(10, 'ZPrimeMMTriggerBits', kw))

        # Trigger Decision + metadata

        alg += TrigDecisionD3PDObject(**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        # Bunch group info

        alg += BGCodeD3PDObject(**_args(2, 'BGCode', kw))

        # Egamma and Mu

        TrigEgammaD3PDObjects(alg, 1)
        TrigMuonD3PDObjects(alg, 1)

        # Esum

        alg += EnergySumROID3PDObject(
            **_args(2, 'EnergySumROI', kw, prefix="trig_L1_esum_"))

        # The LVL2 information:

        alg += TrigMETD3PDObject(**_args(
            2, 'TrigMETL2', kw, prefix="trig_L2_met_",
            sgkey="HLT_T2MissingET"))
        # The EF information:

        alg += TrigMETD3PDObject(**_args(2,
                                         'TrigMETEF',
                                         kw,
                                         prefix="trig_EF_met_",
                                         sgkey="HLT_TrigEFMissingET"))

        # The BJet information:
        TrigBJetD3PDObjects(alg, 10, False, False, True, True, True)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

    if D3PDMakerFlags.FilterCollCand():
        from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
        alg.filterSeq += CollisionFilterAlg(tuplename + '_CollCandFilter')

    return alg
示例#25
0
def HSG5D3PD (alg = None,
              file = 'hsg5.root',
              tuplename = 'physics',
              streamname = 'd3pdstream',
              flags=HSG5Flags,
              **kw):

    if flags.doTaus():
        # tau
        from TauD3PDMaker.TauD3PDObject                        import TauD3PDObject

    # define associations
    if flags.doPhotons() and not PhotonD3PDObject.allBlocknames().has_key('RecoveryMatch'):
        from PhotonD3PDMaker.PhotonRecoveryAssociation import PhotonRecoveryAssociation
        PhotonRecoveryAssoc = PhotonRecoveryAssociation(PhotonD3PDObject,
                                                        'ElectronContainer',
                                                        D3PDMakerFlags.ElectronSGKey(),
                                                        prefix = 'el_',
                                                        blockname = 'RecoveryMatch',
                                                        target = 'ph_ElectronRecovered_')
        

    # define track and cluster filters

    preseq = AlgSequence (D3PDMakerFlags.PreD3PDAlgSeqName())

    if flags.doGoodTracks() and not hasattr( preseq, "GoodTracks" ):
        filter1 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='GoodTracks',
                                     ptCut=0.,nSCTPix=4)
        preseq += filter1
                    
    if flags.doHighPtTracks() and not hasattr( preseq, "HighPtTracks" ):
        filter2 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                     OutputTracksName='HighPtTracks',
                                     ptCut=5000.,nSCTPix=4)
        preseq += filter2


    if flags.doHighPtClusters() and not hasattr( preseq, "HighPtClusters" ):
        filter3 = makeClusterFilter(InputName  = D3PDMakerFlags.ClusterSGKey(),
                                    OutputName = 'HighPtClusters',
                                    ptCut=10000.)
        preseq += filter3

    if flags.doHighPtEMClusters() and not hasattr( preseq, "HighPtEMClusters" ):
        filter4 = makeClusterFilter(InputName  = D3PDMakerFlags.EMTopoClusterSGKey(),
                                    OutputName = 'HighPtEMClusters',
                                    ptCut=10000.)
        preseq += filter4

    # perform recoil calculation
     
    if flags.doHadronicRecoil(): 
        from HadronicRecoil.HadronicRecoilConf import HadronicRecoil__ElectronSelector
        from HadronicRecoil.HadronicRecoilConf import HadronicRecoil__MuonSelector
        from HadronicRecoil.HadronicRecoilConf import HadronicRecoil__EflowSelector
        from HadronicRecoil.HadronicRecoilConf import HadronicRecoil__RecoilCalculation
        from HadronicRecoil.HadronicRecoilConf import HadronicRecoil__EflowRecoil
        
        if not hasattr( preseq, "HadronicRecoil::ElectronSelector" ):
            preseq += HadronicRecoil__ElectronSelector()
        if not hasattr( preseq, "HadronicRecoil::MuonSelector" ):
            preseq += HadronicRecoil__MuonSelector()
        if not hasattr( preseq, "HadronicRecoil::EflowSelector" ):
            preseq += HadronicRecoil__EflowSelector()
        if not hasattr( preseq, "HadronicRecoil::RecoilCalculation" ):
            preseq += HadronicRecoil__RecoilCalculation( ConeSizes = [0.20] )
        if not hasattr( preseq, "EflowRecoil_20" ):
            preseq += HadronicRecoil__EflowRecoil("EflowRecoil_20", 
                                                  TrackRough       = "RoughRecoil_track_20", 
                                                  TrackUE          = "ueCorrection_track_20", 
                                                  TrackRef         = "RefinedRecoil_track_20", 
                                                  ClusNoTrackRough = "RoughRecoil_clusNoTrack_20", 
                                                  ClusNoTrackUE    = "ueCorrection_clusNoTrack_20", 
                                                  ClusNoTrackRef   = "RefinedRecoil_clusNoTrack_20", 
                                                  RoughRecoil_out  = "RoughRecoil_Eflow_20", 
                                                  ueCorrection_out = "ueCorrection_Eflow_20", 
                                                  RefinedRecoil_out= "RefinedRecoil_Eflow_20", 
                                                  MET_out          = "MET_HR_Eflow_20" ) 
            
    # now configure the D3PD
    
    if not alg:
        alg = MSMgr.NewRootStream(StreamName = streamname, FileName = file, TreeName = tuplename)

    
    alg += EventInfoD3PDObject        (**_args (10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject (**_args (10, 'LArCollisionTime', kw))

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata (alg)

    # Eta rings of energy
    # FIXME brian crashing aod running
    if not rec.readAOD:
        from CaloD3PDMaker.RapgapD3PDObject       import EtaRingsNonTileD3PDObject
        from CaloD3PDMaker.RapgapD3PDObject       import EtaRingsD3PDObject

        alg += EtaRingsNonTileD3PDObject  ( **_args ( 0, 'EtaRings', kw) )
        alg += EtaRingsD3PDObject         ( **_args ( 0, 'EtaRings', kw) )
    
    # Electron/Photon blocks
    
    alg += ElectronD3PDObject         (**_args (10, 'Electron', kw))

    if testSGKey ('ElectronContainer', D3PDMakerFlags.GSFElectronSGKey()):
        alg += GSFElectronD3PDObject  (**_args (10, 'GSFElectron', kw,
                                                sgkey = D3PDMakerFlags.GSFElectronSGKey(),
                                                prefix = 'el_gsf_'))

    if flags.doPhotons():
        print "adding photons"
        alg += PhotonD3PDObject           (**_args (10, 'Photon', kw))


    # Muon blocks

     ### add the scattering significance filler - to be removed when added in the MuonD3PDMaker
    if not MuonD3PDObject.allBlocknames().has_key("MuonScatteringAngleSignificance"):
        from AthenaCommon.AppMgr import ToolSvc
        muonScatteringSigTool=None
        if hasattr(ToolSvc, "MuonScatteringSigTool"):
            muonScatteringSigTool=ToolSvc.MuonScatteringSigTool
        from JetTagD3PDMaker import MuonScatteringAngleSignificanceFillerTool
        MuonD3PDObject.defineBlock (100, "MuonScatteringAngleSignificance",
                                    MuonScatteringAngleSignificanceFillerTool,
                                    ScatteringSigTool=muonScatteringSigTool)

    alg += MuonD3PDObject             (**_args (10, 'MuidMuon', kw,
                                                sgkey='MuidMuonCollection', prefix='mu_muid_',
                                                include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                           "L2CBInfoIndex", "L1InfoIndex"],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True ))

    alg += MuonD3PDObject             (**_args (10, 'StacoMuon', kw,
                                                sgkey='StacoMuonCollection', prefix='mu_staco_',
                                                include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                           "L2CBInfoIndex", "L1InfoIndex"],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True ))
    
    from AthenaCommon.KeyStore import CfgItemList
    if CfgItemList("KeyStore_inputFile").has_item("Analysis::MuonContainer#Muons"):
        alg += MuonD3PDObject             (**_args (10, 'Muons', kw,
                                                    sgkey='Muons', prefix='mu_muons_',
                                                    include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex",
                                                               "L2CBInfoIndex", "L1InfoIndex"],
                                                    exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                    allowMissing = True ))

    alg += MuonD3PDObject             (**_args (0, 'CaloMuon', kw, sgkey='CaloMuonCollection', prefix='mu_calo_',
                                                include = ["MuonHitSummary", "Authors", "Likelihood",
                                                           "Isolation", "CaloEnergyLoss", "Quality"] ))
    
    # Tau block

    if flags.doTaus():
        alg += TauD3PDObject              (**_args ( 1, 'Tau', kw))



     # track and cluster blocks

    # ... all clusters, very low LOD
    
    alg += ClusterD3PDObject          (**_args ( 0, 'Clusters1', kw,
                                                 exclude='SamplingBasics'))

    # ... higher LOD for pt>10 GeV
    if flags.doHighPtClusters():
        alg += ClusterD3PDObject          (**_args ( 2, 'Clusters2', kw,
                                                     sgkey  = 'HighPtClusters',
                                                     prefix = 'clpt10_'))

    if flags.doHighPtEMClusters():    
        alg += ClusterD3PDObject          (**_args ( 3, 'Clusters3', kw,
                                                     sgkey  = 'HighPtEMClusters',
                                                     prefix = 'emclpt10_'))

    from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject    

    # ... good tracks only (nSCT>3; no pt cut)

    # use standard level of track info for 'GoodTracks'

    if flags.doGoodTracks():
        # use standard level of track info for 'GoodTracks'
        alg += TrackParticleD3PDObject    (**_args ( 3, 'Tracks1', kw,
                                                     sgkey  = 'GoodTracks',
                                                     label  = 'trk',
                                                     prefix = 'trk_'))
            
        # ... high-pt tracks (nSCT>3; pt>5 GeV)
            
    if flags.doHighPtTracks():
        
        from TrackD3PDMaker.TrackD3PDMakerFlags                import TrackD3PDFlags as highPtFlags
        highPtFlags.doTruth = True
        highPtFlags.storeDiagonalCovarianceAsErrors = True
        highPtFlags.storeHitTruthMatching = True
        highPtFlags.storePixelHitsOnTrack = False
        highPtFlags.storePixelHolesOnTrack = False
        highPtFlags.storePixelOutliersOnTrack = False
        highPtFlags.storeSCTHitsOnTrack = False
        highPtFlags.storeSCTHolesOnTrack = False
        highPtFlags.storeSCTOutliersOnTrack = False
        highPtFlags.storeTRTHitsOnTrack = False
        highPtFlags.storeTRTHolesOnTrack = False
        highPtFlags.storeTRTOutliersOnTrack = False
        highPtFlags.storeTrackFitQuality = True
        highPtFlags.storeTrackMomentum = True
        highPtFlags.storeTrackSummary = True
        highPtFlags.storeTrackSummary.IDOutliers = True
        highPtFlags.storeTrackSummary.PixelInfoPlus = True
        highPtFlags.storeTrackSummary.SCTInfoPlus = True
        highPtFlags.storeTrackSummary.TRTInfoPlus = True
        highPtFlags.storeTrackSummary.InfoPlus = True
        highPtFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3  

        HighPtTrackParticleD3PDObject = TrackD3PDObject(_label='trkpt5',
                                                        _prefix='trkpt5_',
                                                        _sgkey='HighPtTracks',
                                                        typeName='Rec::TrackParticleContainer',
                                                        flags=highPtFlags)
            
        alg += HighPtTrackParticleD3PDObject(**_args ( 3, 'Tracks2', kw,
                                                       sgkey  = 'HighPtTracks',
                                                       label  = 'trkpt5',
                                                       prefix = 'trkpt5_'))

  
    # Jet blocks
    
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags

    # include list modified for HSG5D3PD
    
    includelist = JetTagD3PDFlags.StdInfoInclude()

    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys
    includelist += [JetTagD3PDKeys.BTagWeightsBlockName()]
    #includelist += [JetTagD3PDKeys.JetFitterInfoBaseBlockName()] 
    #includelist += [JetTagD3PDKeys.JetFitterTagInfoBlockName()] 
    #includelist += [JetTagD3PDKeys.IP3DInfoBaseBlockName()] 
    #includelist += [JetTagD3PDKeys.IP3DIPInfoBaseBlockName()] 
    #includelist += [JetTagD3PDKeys.JetFitterCombInfoBaseBlockName()] 
    includelist += [JetTagD3PDKeys.JetTrackAssocBlockName()] 
    includelist += [JetTagD3PDKeys.JetTrackBlockName()] 
    includelist += [JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()] 
    includelist += [JetTagD3PDKeys.IPInfoPlusTrackBlockName()] 
    includelist += ['ConstituentScale']
    
    jetkw = kw
    if not jetkw.has_key ( 'AK4TopoEMJet_'+JetTagD3PDKeys.JetTrackAssocBlockName()+'_target'):
        jetkw['AK4TopoEMJet_'+JetTagD3PDKeys.JetTrackAssocBlockName()+'_target']= "trk" 
    if not jetkw.has_key ( 'AK4TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target'):
        jetkw['AK4TopoEMJet_'+JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName()+'_target']= "trk" 

    alg += JetD3PDObject              (**_args ( 3, 'AK4TopoEMJet', jetkw,
                                                 sgkey='AntiKt4TopoEMJets', prefix='jet_AntiKt4TopoEM_',
                                                 include = includelist,
                                                 JetVertexFraction_FromUD=True,
                                                 JetVertexFraction_FillFullJVF=True,
                                                 allowMissing = True))

    alg += JetD3PDObject              (**_args ( 3, 'AK6TopoEMJet', kw,
                                                 sgkey='AntiKt6TopoEMJets', prefix='jet_AntiKt6TopoEM_',
                                                 include = [JetTagD3PDFlags.StdInfoInclude(),'ConstituentScale'],
                                                 JetVertexFraction_FromUD=True,
                                                 JetVertexFraction_FillFullJVF=True,
                                                 allowMissing = True))

    alg += JetD3PDObject              (**_args ( 3, 'AK4LCTopoJet', kw,
                                                 sgkey='AntiKt4LCTopoJets', prefix='jet_AntiKt4LCTopo_',
                                                 exclude=['Layer'],
                                                 include=['ConstituentScale'],
                                                 JetVertexFraction_FromUD=True,
                                                 JetVertexFraction_FillFullJVF=True,
                                                 allowMissing = True))
    
    alg += JetD3PDObject              (**_args ( 3, 'AK6LCTopoJet', kw,
                                                 sgkey='AntiKt6LCTopoJets', prefix='jet_AntiKt6LCTopo_',
                                                 exclude=['Layer'],
                                                 include=['ConstituentScale'],
                                                 JetVertexFraction_FromUD=True,
                                                 JetVertexFraction_FillFullJVF=True,
                                                 allowMissing = True))


    from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
    alg += HforD3PDObject(**_args (0, 'HforInfo', kw))


    # MET blocks
    # a whole mess to remove x,y components separately for all flavours

    if flags.doAllMissingET() :
        alg += MissingETD3PDObject        (**_args (10, 'MissingET', kw,
                                                    exclude=['MET_Base', 'MET_Base0', 'MET_Truth_Int',
                                                             'MET_RefFinal_Comps','MET_Calib_Comps','MET_CellOut_Comps',
                                                             'MET_CorrTopo_Comps','MET_Cryo_Comps','MET_CryoCone_Comps',
                                                             'MET_Final_Comps','MET_LocHadTopo_Comps',
                                                             'MET_LocHadTopoObj_Comps',
                                                             'MET_Muid_Comps','MET_Muid_Spectro_Comps','MET_Muid_Track_Comps',
                                                             'MET_MuonBoy_Comps','MET_MuonBoy_Spectro_Comps','MET_MuonBoy_Track_Comps',
                                                             'MET_Muons_Comps','MET_Muons_Spectro_Comps','MET_Muons_Track_Comps',
                                                             'MET_MuonMuid_Comps',
                                                             'MET_Muon_Comps','MET_Muon_Isol_Muid_Comps',
                                                             'MET_Muon_Isol_Staco_Comps','MET_Muon_NonIsol_Muid_Comps',
                                                             'MET_Muon_NonIsol_Staco_Comps','MET_Muon_Total_Muid_Comps',
                                                             'MET_Muon_Total_Staco_Comps','MET_RefEle_Comps',
                                                             'MET_RefEle_em_Comps','MET_RefGamma_Comps',
                                                             'MET_RefGamma_em_Comps','MET_RefJet_Comps',
                                                             'MET_RefJet_em_Comps','MET_RefMuon_Comps',
                                                             'MET_RefMuon_Muid_Comps','MET_RefMons_Comps','MET_RefMuon_Staco_Comps',
                                                             'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Staco_Comps',
                                                             'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_Comps',
                                                             'MET_RefMuons_Track_Comps',
                                                             'MET_RefMuon_em_Comps','MET_RefTau_Comps',
                                                             'MET_RefTau_em_Comps','MET_SoftJets_Comps',
                                                             'MET_SoftJets_em_Comps','MET_Topo_Comps',
                                                             'MET_TopoObj_Comps','MET_Track_Comps','MET_Comps',
                                                             'MET_Track_Weights','MET_Cluster_Weights'],
                                                    allowMissing=True))
    else :
        alg += MissingETD3PDObject(0, sgkey = "MET_RefFinal",                prefix = "MET_RefFinal")

        # MuonBoy terms used in RefFinal
        alg += MissingETD3PDObject(0, sgkey = "MET_MuonBoy",                 prefix = "MET_MuonBoy")
        alg += MissingETD3PDObject(0, sgkey = "MET_RefMuon",                 prefix = "MET_RefMuon")
        alg += MissingETD3PDObject(0, sgkey = "MET_CellOut_Eflow",           prefix = "MET_CellOut_Eflow")

        # terms needed to calculate RefFinal with Muid instead of Staco
        alg += MissingETD3PDObject(0, sgkey = "MET_RefMuon_Muid",            prefix = "MET_RefMuon_Muid")
        alg += MissingETD3PDObject(0, sgkey = "MET_MuonMuid",                prefix = "MET_MuonMuid")
        alg += MissingETD3PDObject(0, sgkey = "MET_Muid",                    prefix = "MET_Muid")
        alg += MissingETD3PDObject(0, sgkey = "MET_CellOut_Eflow_Muid",      prefix = "MET_CellOut_Eflow_Muid")

        # terms needed to calculate RefFinal with third chain instead of Staco
        from AthenaCommon.KeyStore import CfgItemList
        keystore = CfgItemList("KeyStore_inputFile")
        if keystore.has_item("MissingET#MET_Muons"):
            alg += MissingETD3PDObject(0, sgkey = "MET_Muons",                    prefix = "MET_Muons")
        if keystore.has_item("MissingET#MET_RefMuons"):
            alg += MissingETD3PDObject(0, sgkey = "MET_RefMuons",                 prefix = "MET_RefMuons")
        if keystore.has_item("MissingET#MET_CellOut_Eflow_Muons"):
            alg += MissingETD3PDObject(0, sgkey = "MET_CellOut_Eflow_Muons",      prefix = "MET_CellOut_Eflow_Muons")
        
        # I have no idea what these are for
        alg += MissingETD3PDObject(0, sgkey = "MET_SoftJets",                prefix = "MET_SoftJets")
        alg += MissingETD3PDObject(0, sgkey = "MET_RefFinal_em",             prefix = "MET_RefFinal_em")
        alg += MissingETD3PDObject(0, sgkey = "MET_CellOut_em",              prefix = "MET_CellOut_em")
        alg += MissingETD3PDObject(0, sgkey = "MET_SoftJets_em",             prefix = "MET_SoftJets_em")
                   

    # HadronicRecoil blocks

    if flags.doHadronicRecoil():
        alg += ElectronD3PDObject(0,  sgkey = "HR_selectedElectrons",       prefix = "hr_el_")
        alg += MuonD3PDObject( 0,     sgkey = "HR_selectedMuons",           prefix = "hr_mu_" )
        
        alg += MissingETD3PDObject(0, sgkey = "RoughRecoil_20",                prefix = "hr_roughRecoil_20", 
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "ueCorrection_20",               prefix = "hr_ueCorrection_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "RefinedRecoil_20",              prefix = "hr_corrRecoil_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "MET_HR_20",                     prefix = "hr_MET_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        
        alg += MissingETD3PDObject(0, sgkey = "RoughRecoil_track_20",          prefix = "hr_roughRecoil_track_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "ueCorrection_track_20",         prefix = "hr_ueCorrection_track_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "RefinedRecoil_track_20",        prefix = "hr_corrRecoil_track_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "MET_HR_track_20",               prefix = "hr_MET_track_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        
        alg += MissingETD3PDObject(0, sgkey = "RoughRecoil_clusNoTrack_20",    prefix = "hr_roughRecoil_clusNoTrack_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "ueCorrection_clusNoTrack_20",   prefix = "hr_ueCorrection_clusNoTrack_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "RefinedRecoil_clusNoTrack_20",  prefix = "hr_corrRecoil_clusNoTrack_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "MET_HR_clusNoTrack_20",         prefix = "hr_MET_clusNoTrack_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        
        alg += MissingETD3PDObject(0, sgkey = "RoughRecoil_Eflow_20",          prefix = "hr_roughRecoil_Eflow_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "ueCorrection_Eflow_20",         prefix = "hr_ueCorrection_Eflow_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "RefinedRecoil_Eflow_20",        prefix = "hr_corrRecoil_Eflow_20",
                                   exclude=['MET_Regions','MET_Comps'] )  
        alg += MissingETD3PDObject(0, sgkey = "MET_HR_Eflow_20",               prefix = "hr_MET_Eflow_20", 
                                   exclude=['MET_Regions','MET_Comps'] )  


    """
    # track and cluster blocks

    # ... all clusters, very low LOD
    
    alg += ClusterD3PDObject          (**_args ( 0, 'Clusters1', kw,
                                                 exclude='SamplingBasics'))

    # ... higher LOD for pt>10 GeV
    if flags.doHighPtClusters():
        alg += ClusterD3PDObject          (**_args ( 2, 'Clusters2', kw,
                                                     sgkey  = 'HighPtClusters',
                                                     prefix = 'clpt10_'))

    if flags.doHighPtEMClusters():    
        alg += ClusterD3PDObject          (**_args ( 3, 'Clusters3', kw,
                                                     sgkey  = 'HighPtEMClusters',
                                                     prefix = 'emclpt10_'))

    from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject    

    # ... good tracks only (nSCT>3; no pt cut)

    # use standard level of track info for 'GoodTracks'

    if flags.doGoodTracks():
        # use standard level of track info for 'GoodTracks'
        alg += TrackParticleD3PDObject    (**_args ( 3, 'Tracks1', kw,
                                                     sgkey  = 'GoodTracks',
                                                     label  = 'trk',
                                                     prefix = 'trk_'))
            
        # ... high-pt tracks (nSCT>3; pt>5 GeV)
            
    if flags.doHighPtTracks():
        
        from TrackD3PDMaker.TrackD3PDMakerFlags                import TrackD3PDFlags as highPtFlags
        highPtFlags.doTruth = True
        highPtFlags.storeDiagonalCovarianceAsErrors = True
        highPtFlags.storeHitTruthMatching = True
        highPtFlags.storePixelHitsOnTrack = False
        highPtFlags.storePixelHolesOnTrack = False
        highPtFlags.storePixelOutliersOnTrack = False
        highPtFlags.storeSCTHitsOnTrack = False
        highPtFlags.storeSCTHolesOnTrack = False
        highPtFlags.storeSCTOutliersOnTrack = False
        highPtFlags.storeTRTHitsOnTrack = False
        highPtFlags.storeTRTHolesOnTrack = False
        highPtFlags.storeTRTOutliersOnTrack = False
        highPtFlags.storeTrackFitQuality = True
        highPtFlags.storeTrackMomentum = True
        highPtFlags.storeTrackSummary = True
        highPtFlags.storeTrackSummary.IDOutliers = True
        highPtFlags.storeTrackSummary.PixelInfoPlus = True
        highPtFlags.storeTrackSummary.SCTInfoPlus = True
        highPtFlags.storeTrackSummary.TRTInfoPlus = True
        highPtFlags.storeTrackSummary.InfoPlus = True
        highPtFlags.trackParametersAtBeamSpotLevelOfDetails = 0
        highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
        highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3  

        HighPtTrackParticleD3PDObject = TrackD3PDObject(_label='trkpt5',
                                                        _prefix='trkpt5_',
                                                        _sgkey='HighPtTracks',
                                                        typeName='Rec::TrackParticleContainer',
                                                        flags=highPtFlags)
            
        alg += HighPtTrackParticleD3PDObject(**_args ( 3, 'Tracks2', kw,
                                                       sgkey  = 'HighPtTracks',
                                                       label  = 'trkpt5',
                                                       prefix = 'trkpt5_'))
    """       
    
    # Primary vertex block - May be missing in single-beam data.

    alg += PrimaryVertexD3PDObject (**_args (1, 'PrimaryVertex', kw,
                                             allowMissing = True,
                                             sgkey = D3PDMakerFlags.VertexSGKey(),
                                             prefix = 'vxp_'))
            
    # MBTS 
            
    alg += MBTSD3PDObject             (**_args (10, 'MBTS', kw))
    alg += MBTSTimeD3PDObject         (**_args (10, 'MBTSTime', kw))
    alg += MBTSTriggerBitsD3PDObject  (**_args (10, 'MBTSTriggerBits', kw))
    #alg += CollisionDecisionD3PDObject(**_args (10, 'CollisionDecision', kw))
    
    # Truth

    if rec.doTruth():

        from TruthD3PDMaker.TruthParticleD3PDObject            import TruthParticleD3PDObject
        from MuonD3PDMaker.TruthMuonD3PDObject                 import TruthMuonD3PDObject

        alg += TruthMuonD3PDObject    (**_args ( 2, 'TruthMuon', kw))
        alg += GenEventD3PDObject     (**_args ( 1, 'GenEvent', kw))
        alg += TruthParticleD3PDObject(**_args ( 1, 'TruthParticle', kw))

        # TruthJets
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJet', kw,
                                                 sgkey='AntiKt4TruthJets',prefix='jet_AntiKt4Truth_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJet', kw,
                                                 sgkey='AntiKt6TruthJets', prefix='jet_AntiKt6Truth_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJetALL', kw,
                                                 sgkey='AntiKt4TruthJets_ALL', prefix='jet_AntiKt4TruthALL_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJetALL', kw,
                                                 sgkey='AntiKt6TruthJets_ALL', prefix='jet_AntiKt6TruthALL_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJetWZ', kw,
                                                 sgkey='AntiKt4TruthJets_WZ', prefix='jet_AntiKt4TruthWZ_',
                                                 allowMissing = True))
        alg += JetD3PDObject          (**_args ( 1, 'AK6TruthJetWZ', kw,
                                                 sgkey='AntiKt6TruthJets_WZ', prefix='jet_AntiKt6TruthWZ_',
                                                 allowMissing = True))
        

    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)
    

    from TrigMissingETD3PDMaker.TrigMETD3PD import TrigMETD3PDObjects
    TrigMETD3PDObjects(alg,10)
    
    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += SMWZTriggerBitsD3PDObject      (**_args (10, 'SMWZTriggerBits', kw))
        
        # Trigger Decision + metadata

        alg += TrigDecisionD3PDObject  (**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)
        
        # Bunch group info

        alg += BGCodeD3PDObject (**_args (2, 'BGCode', kw))

        # Egamma and Mu
        
        TrigEgammaD3PDObjects (alg, 1)
        TrigMuonD3PDObjects( alg, 1)

        # Esum

        #alg += EnergySumROID3PDObject(**_args (2, 'EnergySumROI', kw,
        #                                       prefix = "trig_L1_esum_"))

        # The LVL2 information:

        #alg += TrigMETD3PDObject(**_args( 2, 'TrigMETL2', kw,
        #                                  prefix = "trig_L2_met_",
        #                                  sgkey = "HLT_T2MissingET" ))
        # The EF information:

        #alg += TrigMETD3PDObject(**_args ( 2, 'TrigMETEF', kw,
        #                                   prefix = "trig_EF_met_",
        #                                   sgkey = "HLT_TrigEFMissingET" ))

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

# Invoke routine to write GSCFactor and WidthFraction jet moments

    #addSTRUCTCalib('AntiKt4LCTopoJets', input='Topo', mainParam=0.4)
    #addSTRUCTCalib('AntiKt6LCTopoJets', input='Topo', mainParam=0.6)
    #addSTRUCTCalib('AntiKt4TopoEMJets', input='Topo', mainParam=0.4)
    #addSTRUCTCalib('AntiKt6TopoEMJets', input='Topo', mainParam=0.6)
    
    if D3PDMakerFlags.FilterCollCand():
        from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
        alg.filterSeq += CollisionFilterAlg (tuplename + '_CollCandFilter')

    return alg
示例#26
0
def addJetsInfo(alg=None,
                file='physics.root',
                tuplename='physics',
                tmpFlag=True,
                **kw):

    print "adding Jets info..."

    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file)

    flags = CommonD3PDMakerFlags

    #ExtendedJetD3PDObject = JetD3PDObject.copy()

    # add track index for track jets
    if not kw.has_key('AntiKt4Track_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt4Track_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AntiKt3Track_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt3Track_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AntiKt2Track_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt2Track_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('Kt3Track_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
                      '_target'):
        kw['Kt3Track_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AntiKt4TopoEMJets_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt4TopoEMJets_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AntiKt4LCTopoJets_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt4LCTopoJets_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"
    if not kw.has_key('AntiKt5LCTopo_' +
                      JetTagD3PDKeys.JetTrackAssocBlockName() + '_target'):
        kw['AntiKt5LCTopo_' + JetTagD3PDKeys.JetTrackAssocBlockName() +
           '_target'] = "trk"

    AddConstitIndex(ExtendedJetD3PDObject,
                    typename='CaloCluster',
                    target='cl_lc_',
                    level=99)
    AddTrackAssocIndex(ExtendedJetD3PDObject, level=99)
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags

    # Jet information
    jetInclude = flags.smallJetInclude()
    jetIncludeTrack = jetInclude[:]
    jetIncludeTrack += [
        'Rec::TrackParticleNavigableConstituentAssociationTool', 'WIDTH',
        'DQMoments'
    ]
    jetIncludeTower = jetInclude[:]
    jetIncludeTower += ['JVtx', 'JetVertexFraction']
    jetInclude += [
        'Samplings', 'CaloClusterNavigableConstituentAssociationTool',
        'TrackAssocblockindex', 'TracksMoments', 'Special', 'TrackMF',
        'JetClusterMoment'
    ]
    jetIncludeLC = jetInclude[:]
    jetIncludeLC += ['ConstituentScale']
    jetIncludeALL = jetInclude[:]

    btagging_blocks = [
        JetTagD3PDKeys.BTagWeightsBlockName(),
        JetTagD3PDKeys.TruthInfoBlockName(),
        JetTagD3PDKeys.IP2DInfoBaseBlockName(),
        JetTagD3PDKeys.IP2DIPInfoBaseBlockName(),
        JetTagD3PDKeys.IP3DInfoBaseBlockName(),
        JetTagD3PDKeys.IP3DIPInfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterInfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterTagInfoBlockName(),
        JetTagD3PDKeys.SVInfoPlusBlockName(),
        JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
        "JetTag_Gaia",
        JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),  # "JetTag_GaiaNeg",]
        JetTagD3PDKeys.JetJFTwoTrackVertexAssocBlockName(),
        JetTagD3PDKeys.JetFitterVxAssocBlockName(),
        JetTagD3PDKeys.SV1InfoBaseBlockName(),
        JetTagD3PDKeys.SV0InfoPlusBlockName()
    ]

    #jetIncludeALL += btagging_blocks
    jetIncludeALL += [
        'Uncertainties', 'BeamBackground', 'JetVertexFraction', 'CaloQual'
    ]

    jetIncludeALL_LC = jetIncludeALL[:]
    jetIncludeALL_LC += ['ConstituentScale']

    jetExclude = flags.smallJetExclude()[:]
    jetExclude += ['JES', 'JESMoments', 'Layer']

    alg += ExtendedJetD3PDObject(**_args(
        3,
        'AntiKt4TopoEMJets',
        kw,
        #sgkey='AntiKt4TopoEMJetsReTagged', prefix='jet_AntiKt4TopoEM_',
        sgkey='AntiKt4TopoEMNewJets',
        prefix='jet_AntiKt4TopoEM_',
        include=jetIncludeALL + ['SplitInfo', 'ConstituentScale'] +
        btagging_blocks,
        exclude=jetExclude,
        JetVertexFraction_FromUD=True,
        JetVertexFraction_FillFullJVF=True,
        #AssocTrackCont_target="trk",
        JetTag_SoftMuonChi2InfoMuonAssoc_target="mu_staco_",
        allowMissing=True))

    #alg += ExtendedJetD3PDObject              (**_args ( 3, 'AntiKt6TopoEMJets', kw,
    #                                             sgkey='AntiKt6TopoEMNewJets', prefix='jet_AntiKt6TopoEM_',
    #                                             include = jetIncludeALL+['SplitInfo'],
    #                                             exclude = jetExclude,
    #                                             JetVertexFraction_FromUD=True,
    #                                             JetVertexFraction_FillFullJVF=True,
    #                                             allowMissing = True))

    alg += ExtendedJetD3PDObject(
        **_args(3,
                'AntiKt4LCTopoJets',
                kw,
                sgkey='AntiKt4LCTopoNewJets',
                prefix='jet_AntiKt4LCTopo_',
                include=jetIncludeALL_LC + ['SplitInfo'] + btagging_blocks,
                exclude=jetExclude,
                JetVertexFraction_FromUD=True,
                JetVertexFraction_FillFullJVF=True,
                JetTag_SoftMuonChi2InfoMuonAssoc_target="mu_staco_",
                allowMissing=True))

    #alg += ExtendedJetD3PDObject              (**_args ( 3, 'AntiKt6LCTopoJets', kw,
    #                                             sgkey='AntiKt6LCTopoNewJets', prefix='jet_AntiKt6LCTopo_',
    #                                             include = jetIncludeALL_LC+['SplitInfo'],
    #                                             exclude = jetExclude,
    #                                             JetVertexFraction_FromUD=True,
    #                                             JetVertexFraction_FillFullJVF=True,
    #                                             allowMissing = True))

    alg += ExtendedJetD3PDObject(
        **_args(2,
                'JetElectronContainer90',
                kw,
                sgkey='JetElectronContainer90',
                prefix='eljet_',
                include=flags.eljetInclude(),
                exclude=[
                    'Constituents', 'ConstituentScale', 'JetShape', 'WIDTH',
                    'DQMoments', 'ActiveArea', 'OriginCorrection'
                ],
                allowMissing=True))

    ### add the MSV block
    MSVJetCollections = []
    MSVJetCollections += ['AntiKt4TopoEMNewJets', 'AntiKt4LCTopoNewJets'
                          ]  #, 'AntiKt6LCTopoNewJets', 'AntiKt6TopoEMNewJets']

    ### link multisv to tracks
    if not kw.has_key('msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target'):
        kw['msvvtxinfo_JetTag_JetMultiSVVtxAssoc_target'] = "trk"
    #from JetTagD3PDMaker.JetTagMSVVtxInJetD3PDObject import getJetTagMSVVtxInfoInJetD3PDObject
    alg += getJetTagMSVVtxInfoInJetD3PDObject(
        **_args(1, "msvvtxinfo", kw, jetCollections=MSVJetCollections))

    # add TwoTrackVertex object
    alg += getJetTagTwoTrackVertexD3PDObject(level=0,
                                             jetCollections=MSVJetCollections)

    if rec.doTruth():
        AddConstitTruthIndex(ExtendedJetD3PDObject,
                             typename='TruthParticle',
                             target='mc_',
                             level=99)

# below all for QCD group

#TopoJets (EM, GCW)

# lowPt jets
    if flags.doRecJet() and flags.doTopoEMLowPtJet() and objKeyStore.isInInput(
            "CaloClusterContainer", "CaloCalTopoCluster"):
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt4TopoEMLowPt',
                    kw,
                    prefix='jet_AntiKt4TopoEMLowPt_',
                    sgkey='AntiKt4TopoEMLowPtJets',
                    include=jetInclude,
                    exclude=jetExclude,
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))

        #alg += ExtendedJetD3PDObject (**_args(flags.smallJetLevel(), 'AntiKt6TopoEMLowPt', kw, prefix = 'jet_AntiKt6TopoEMLowPt_', sgkey = 'AntiKt6TopoEMLowPtJets',
        #                              include = jetInclude, exclude = jetExclude, JetVertexFraction_FromUD=True,
        #                              JetVertexFraction_FillFullJVF=True))

    # Tower Jets (EM)
    if flags.doTowerJet() and rec.readAOD():
        #alg += ExtendedJetD3PDObject (**_args(flags.towerJetLevel(), 'AntiKt6Tower', kw, prefix = 'jet_AntiKt6Tower_', sgkey = 'AntiKt6TowerAODJets',
        #                              include = jetIncludeTower, exclude = jetExclude, JetVertexFraction_FromUD=True, JetVertexFraction_FillFullJVF=True))
        pass

    # additional: TowerEM
    if not rec.readAOD() and flags.doRecJet() and flags.doTowerEMJet():
        alg += ExtendedJetD3PDObject(
            **_args(flags.towerJetLevel(),
                    'AntiKt4TowerEM',
                    kw,
                    prefix='jet_AntiKt4TowerEMNew_',
                    sgkey='AntiKt4TowerEMNewJets',
                    include=jetIncludeTower,
                    exclude=jetExclude,
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))
        #alg += ExtendedJetD3PDObject (**_args(flags.towerJetLevel(), 'AntiKt6TowerEM', kw, prefix = 'jet_AntiKt6TowerEMNew_', sgkey = 'AntiKt6TowerEMNewJets',
        #                              include = jetIncludeTower, exclude = jetExclude, JetVertexFraction_FromUD=True, JetVertexFraction_FillFullJVF=True))

    # additional: LCTopo addional R-sizes
    if flags.doRecJet() and flags.doLCTopoJet() and objKeyStore.isInInput(
            "CaloClusterContainer", "CaloCalTopoCluster"):
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt5LCTopo',
                    kw,
                    prefix='jet_AntiKt5LCTopo_',
                    sgkey='AntiKt5LCTopoNewJets',
                    include=btagging_blocks,
                    exclude=jetExclude + ['DQMoments'],
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))
        #alg += ExtendedJetD3PDObject (**_args(flags.smallJetLevel(), 'AntiKt7LCTopo', kw, prefix = 'jet_AntiKt7LCTopo_', sgkey = 'AntiKt7LCTopoNewJets',
        #                              exclude = jetExclude+['DQMoments'], JetVertexFraction_FromUD=True, JetVertexFraction_FillFullJVF=True))
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt2LCTopo',
                    kw,
                    prefix='jet_AntiKt2LCTopo_',
                    sgkey='AntiKt2LCTopoNewJets',
                    exclude=jetExclude + ['DQMoments'],
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt3LCTopo',
                    kw,
                    prefix='jet_AntiKt3LCTopo_',
                    sgkey='AntiKt3LCTopoNewJets',
                    exclude=jetExclude + ['DQMoments'],
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))

    # additional: LCTopoLowPt
    if flags.doRecJet() and flags.doLCTopoLowPtJet() and objKeyStore.isInInput(
            "CaloClusterContainer", "CaloCalTopoCluster"):
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt4LCTopoLowPt',
                    kw,
                    prefix='jet_AntiKt4LCTopoLowPt_',
                    sgkey='AntiKt4LCTopoLowPtJets',
                    include=jetIncludeLC,
                    exclude=jetExclude,
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))

        #alg += ExtendedJetD3PDObject (**_args(flags.smallJetLevel(), 'AntiKt6LCTopoLowPt', kw, prefix = 'jet_AntiKt6LCTopoLowPt_', sgkey = 'AntiKt6LCTopoLowPtJets',
        #                              include = jetIncludeLC, exclude = jetExclude, JetVertexFraction_FromUD=True, JetVertexFraction_FillFullJVF=True))

    # additional: LCTopo CB
    if flags.doRecJet() and flags.doLCTopoCBJet() and objKeyStore.isInInput(
            "CaloClusterContainer", "CaloCalTopoCluster"):
        alg += ExtendedJetD3PDObject(
            **_args(flags.smallJetLevel(),
                    'AntiKt4LCTopoCB',
                    kw,
                    prefix='jet_AntiKt4LCTopoCB_',
                    sgkey='AntiKt4LCTopoCBJets',
                    include=jetIncludeLC,
                    exclude=jetExclude,
                    JetVertexFraction_FromUD=True,
                    JetVertexFraction_FillFullJVF=True))

        #alg += ExtendedJetD3PDObject (**_args(flags.smallJetLevel(), 'AntiKt6LCTopoCB', kw, prefix = 'jet_AntiKt6LCTopoCB_', sgkey = 'AntiKt6LCTopoCBJets',
        #                              include = jetIncludeLC, exclude = jetExclude, JetVertexFraction_FromUD=True, JetVertexFraction_FillFullJVF=True))

    # GhostJets
    if ((not flags.doRecJet())
            or flags.doRecJetOnlyAdditional()) and rec.readAOD():
        if flags.doGhostJet():
            #alg += ExtendedJetD3PDObject (**_args(0, 'AntiKt6GhostTower', kw, prefix = 'jet_AntiKt6GhostTower_', sgkey = 'AntiKt6GhostTowerAODJets',
            #                              include = jetIncludeTower, exclude = jetExclude))
            pass
    else:
        if not rec.readAOD() and flags.doRecJet() and flags.doGhostJet():
            alg += ExtendedJetD3PDObject(
                **_args(0,
                        'AntiKt4GhostTowerNew',
                        kw,
                        prefix='jet_AntiKt4GhostTowerNew_',
                        sgkey='AntiKt4GhostTowerNewJets',
                        include=jetIncludeTower,
                        exclude=jetExclude))

            #alg += ExtendedJetD3PDObject (**_args(0, 'AntiKt6GhostTowerNew', kw, prefix = 'jet_AntiKt6GhostTowerNew_', sgkey = 'AntiKt6GhostTowerNewJets',
            #                              include = jetIncludeTower, exclude = jetExclude))

    # TrackJets

    trackjets_btag_include = btagging_blocks
    jetExcludeTrack = jetExclude[:]
    #jetExcludeTrack += ['JetSamplingsFrac','EMFraction','ActiveArea','JES','JESMoments','EMScale']

    AddConstitIndex(ExtendedJetD3PDObject,
                    typename='Rec::TrackParticle',
                    target='trk',
                    level=99)
    if flags.doRecJet() and flags.doTrackJet():
        alg += ExtendedJetD3PDObject(
            **_args(0,
                    'AntiKt4Track',
                    kw,
                    prefix='jet_AntiKt4Track_',
                    sgkey='AntiKt4TrackJets',
                    include=jetIncludeTrack +
                    ['SplitInfo', 'substructureblocks'] +
                    trackjets_btag_include,
                    exclude=jetExcludeTrack,
                    JetVertexFraction_FromUD=False,
                    JetVertexFraction_FillFullJVF=False))

        #alg += ExtendedJetD3PDObject (**_args(0, 'AntiKt6Track', kw, prefix = 'jet_AntiKt6Track_', sgkey = 'AntiKt6TrackJets',
        #                              include = jetIncludeTrack, exclude = jetExcludeTrack, JetVertexFraction_FromUD=False, JetVertexFraction_FillFullJVF=False))

        #alg += ExtendedJetD3PDObject (**_args(0, 'AntiKt5Track', kw, prefix = 'jet_AntiKt5Track_', sgkey = 'AntiKt5TrackJets',
        #                              include = jetIncludeTrack, exclude = jetExcludeTrack, JetVertexFraction_FromUD=False, JetVertexFraction_FillFullJVF=False))

        #alg += ExtendedJetD3PDObject (**_args(0, 'AntiKt7Track', kw, prefix = 'jet_AntiKt7Track_', sgkey = 'AntiKt7TrackJets',
        #                              include = jetIncludeTrack, exclude = jetExcludeTrack, JetVertexFraction_FromUD=False, JetVertexFraction_FillFullJVF=False))

        alg += ExtendedJetD3PDObject(
            **_args(0,
                    'AntiKt2Track',
                    kw,
                    prefix='jet_AntiKt2Track_',
                    sgkey='AntiKt2TrackJets',
                    include=jetIncludeTrack + trackjets_btag_include,
                    exclude=jetExcludeTrack,
                    JetVertexFraction_FromUD=False,
                    JetVertexFraction_FillFullJVF=False))

        alg += ExtendedJetD3PDObject(
            **_args(0,
                    'AntiKt3Track',
                    kw,
                    prefix='jet_AntiKt3Track_',
                    sgkey='AntiKt3TrackJets',
                    include=jetIncludeTrack + trackjets_btag_include,
                    exclude=jetExcludeTrack,
                    JetVertexFraction_FromUD=False,
                    JetVertexFraction_FillFullJVF=False))

        alg += ExtendedJetD3PDObject(
            **_args(0,
                    'Kt3Track',
                    kw,
                    prefix='jet_Kt3Track_',
                    sgkey='Kt3TrackJets',
                    include=jetIncludeTrack + trackjets_btag_include,
                    exclude=jetExcludeTrack,
                    JetVertexFraction_FromUD=False,
                    JetVertexFraction_FillFullJVF=False))

    # Truth
    if rec.doTruth():
        D3PDMakerFlags.TruthWriteHadrons.set_Value_and_Lock(True)
        #if ( stdTruthParticleContainer != 'None'):
        #    alg += TruthParticleD3PDObject (**_args(1, 'TruthParticle', kw, sgkey = stdTruthParticleContainer, prefix='mcQCD_', exclude=['child_TruthParticleChildAssociation','parent_TruthParticleParentAssociation']))
        truthjetInclude = flags.truthJetInclude()
        truthjetInclude += [
            'TruthParticleNavigableConstituentAssociationTool', 'WIDTH'
        ]

        if flags.doTruthJet():
            if flags.doRecTruthJet():
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt4TruthNew',
                            kw,
                            sgkey='AntiKt4TruthNewJets',
                            prefix='AntiKt4Truth_',
                            include=truthjetInclude +
                            [JetTagD3PDKeys.TruthInfoBlockName()],
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt6TruthNew', kw, sgkey='AntiKt6TruthNewJets', prefix='AntiKt6Truth_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt4TruthWithNu',
                            kw,
                            sgkey='AntiKt4TruthWithNuJets',
                            prefix='AntiKt4TruthWithNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt6TruthWithNu', kw, sgkey='AntiKt6TruthWithNuJets', prefix='AntiKt6TruthWithNu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt4TruthWithMuNu',
                            kw,
                            sgkey='AntiKt4TruthWithMuNuJets',
                            prefix='AntiKt4TruthWithMuNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt6TruthWithMuNu', kw, sgkey='AntiKt6TruthWithMuNuJets', prefix='AntiKt6TruthWithMuNu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt4TruthWithMu',
                            kw,
                            sgkey='AntiKt4TruthWithMuJets',
                            prefix='AntiKt4TruthWithMu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt6TruthWithMu', kw, sgkey='AntiKt6TruthWithMuJets', prefix='AntiKt6TruthWithMu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))

                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt5TruthNew',
                            kw,
                            sgkey='AntiKt5TruthNewJets',
                            prefix='AntiKt5Truth_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt7TruthNew', kw, sgkey='AntiKt7TruthNewJets', prefix='AntiKt7Truth_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt5TruthWithNu',
                            kw,
                            sgkey='AntiKt5TruthWithNuJets',
                            prefix='AntiKt5TruthWithNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt7TruthWithNu', kw, sgkey='AntiKt7TruthWithNuJets', prefix='AntiKt7TruthWithNu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt5TruthWithMuNu',
                            kw,
                            sgkey='AntiKt5TruthWithMuNuJets',
                            prefix='AntiKt5TruthWithMuNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt7TruthWithMuNu', kw, sgkey='AntiKt7TruthWithMuNuJets', prefix='AntiKt7TruthWithMuNu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt5TruthWithMu',
                            kw,
                            sgkey='AntiKt5TruthWithMuJets',
                            prefix='AntiKt5TruthWithMu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                #alg += ExtendedJetD3PDObject (**_args(flags.truthJetLevel(), 'AntiKt7TruthWithMu', kw, sgkey='AntiKt7TruthWithMuJets', prefix='AntiKt7TruthWithMu_',
                #                              include=truthjetInclude, exclude=flags.truthJetExclude()))

                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt2TruthNew',
                            kw,
                            sgkey='AntiKt2TruthNewJets',
                            prefix='AntiKt2Truth_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt3TruthNew',
                            kw,
                            sgkey='AntiKt3TruthNewJets',
                            prefix='AntiKt3Truth_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt2TruthWithNu',
                            kw,
                            sgkey='AntiKt2TruthWithNuJets',
                            prefix='AntiKt2TruthWithNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt3TruthWithNu',
                            kw,
                            sgkey='AntiKt3TruthWithNuJets',
                            prefix='AntiKt3TruthWithNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt2TruthWithMuNu',
                            kw,
                            sgkey='AntiKt2TruthWithMuNuJets',
                            prefix='AntiKt2TruthWithMuNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt3TruthWithMuNu',
                            kw,
                            sgkey='AntiKt3TruthWithMuNuJets',
                            prefix='AntiKt3TruthWithMuNu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt2TruthWithMu',
                            kw,
                            sgkey='AntiKt2TruthWithMuJets',
                            prefix='AntiKt2TruthWithMu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'AntiKt3TruthWithMu',
                            kw,
                            sgkey='AntiKt3TruthWithMuJets',
                            prefix='AntiKt3TruthWithMu_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))

                # truth WZ jets
                alg += JetD3PDObject(**_args(1,
                                             'AK4TruthJetWZ',
                                             kw,
                                             sgkey='AntiKt4TruthJets_WZ',
                                             prefix='jet_AntiKt4TruthWZ_',
                                             allowMissing=True))

        if flags.doTruthPileupJet():
            if objKeyStore.isInInput("JetCollection",
                                     "InTimeAntiKt4TruthJets"):
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'InTimeAntiKt4Truth',
                            kw,
                            sgkey='InTimeAntiKt4TruthJets',
                            prefix='InTimeAntiKt4Truth_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
            if objKeyStore.isInInput("JetCollection",
                                     "OutOfTimeAntiKt4TruthJets"):
                alg += ExtendedJetD3PDObject(
                    **_args(flags.truthJetLevel(),
                            'OutOfTimeAntiKt4Truth',
                            kw,
                            sgkey='OutOfTimeAntiKt4TruthJets',
                            prefix='OutOfTimeAntiKt4Truth_',
                            include=truthjetInclude,
                            exclude=flags.truthJetExclude()))
            pass

    return alg
示例#27
0
def SMWZLightD3PD (alg                  = None,
                   file                 = 'smlight.root',
                   tuplename            = 'physics',
                   streamname           = 'd3pdstream',
                   stdElectronContainer = 'None',
                   gsfElectronContainer = 'None',
                   stacoMuonContainer   = 'None',
                   muidMuonContainer    = 'None',
                   photonContainer      = 'None',
                   jetContainer         = 'None',
                   clusterContainer     = 'None',
                   tauContainer         = 'None',
                   trackContainer       = 'None',
                   **kw):


    preseq = AlgSequence (D3PDMakerFlags.PreD3PDAlgSeqName())

    # perform recoil calculation

    import HadronicRecoil.Configurables as hrc
    preseq = hrc.add_hadronic_recoil_filters(preseq)


    # configure the D3PD
    
    if not alg:
        alg = MSMgr.NewRootStream(StreamName = streamname, FileName = file, TreeName = tuplename)
        
    
    alg += EventInfoD3PDObject        (**_args (10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject (**_args (10, 'LArCollisionTime', kw))

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata (alg)

    
    # Electron/Photon blocks
    
    if stdElectronContainer != 'None':
        alg += ElectronD3PDObject         (**_args (10, 'Electron', kw,
                                                    sgkey = stdElectronContainer,
                                                    prefix = 'el_',
                                                    exclude = ['EMTrackFit','EMTrackFitDetailsBrem',
                                                               'EMTrackFitDetailsRefit',
                                                               'EMTrackFitDetailsRefitCov'],
                                                    allowMissing = True ))

    if (gsfElectronContainer != 'None') and testSGKey ('ElectronContainer', gsfElectronContainer):
        alg += GSFElectronD3PDObject  (**_args (1, 'GSFElectron', kw,
                                                sgkey = gsfElectronContainer,
                                                prefix = 'el_gsf_',
                                                exclude = ['EMTrackFit','EMTrackFitDetailsBrem',
                                                           'EMTrackFitDetailsRefit',
                                                           'EMTrackFitDetailsRefitCov'],
                                                allowMissing = True ))

    D3PDMakerFlags.DoPAU = False
    if photonContainer != 'None':
        alg += PhotonD3PDObject           (**_args (10, 'Photon', kw,
                                                    sgkey = photonContainer,
                                                    prefix = 'ph_',
                                                    exclude = ['OQRecalc'],
                                                    allowMissing = True ))

    
    # Muon blocks

    # ... add the scattering significance filler - to be removed when added in the MuonD3PDMaker
    if not MuonD3PDObject.allBlocknames().has_key("MuonScatteringAngleSignificance"):
        from AthenaCommon.AppMgr import ToolSvc
        muonScatteringSigTool=None
        if hasattr(ToolSvc, "MuonScatteringSigTool"):
            muonScatteringSigTool=ToolSvc.MuonScatteringSigTool
        from JetTagD3PDMaker import MuonScatteringAngleSignificanceFillerTool
        MuonD3PDObject.defineBlock (100, "MuonScatteringAngleSignificance",
                                    MuonScatteringAngleSignificanceFillerTool,
                                    ScatteringSigTool=muonScatteringSigTool)
        
    if stacoMuonContainer != 'None':
        alg += MuonD3PDObject             (**_args (10, 'StacoMuon', kw,
                                                    sgkey=stacoMuonContainer,
                                                    prefix='mu_staco_',
                                                    include = ['EFCBInfoIndex', 'EFMGInfoIndex', 'EFMEInfoIndex',
                                                               'MuonScatteringAngleSignificance'],
                                                    exclude = ['EFCBInfo', 'EFMGInfo', 'EFMEInfo',
                                                               'L2CBInfo', 'L1Info',
                                                               'MuonTimingFillerTool'],
                                                    allowMissing = True ))
    
    if muidMuonContainer != 'None':
        alg += MuonD3PDObject             (**_args (10, 'MuidMuon', kw,
                                                    sgkey=muidMuonContainer,
                                                    prefix='mu_muid_',
                                                    include = ['EFCBInfoIndex', 'EFMGInfoIndex', 'EFMEInfoIndex',
                                                               'MuonScatteringAngleSignificance'],
                                                    exclude = ['EFCBInfo', 'EFMGInfo', 'EFMEInfo',
                                                               'L2CBInfo', 'L1Info',
                                                               'MuonTimingFillerTool'],
                                                    allowMissing = True ))
    
    # Jet block
    
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys
    
    if jetContainer != 'None':
        alg += JetD3PDObject              (**_args ( 3, 'AK4TopoEMJet', kw,
                                                     sgkey=jetContainer,
                                                     allowMissing=True,
                                                     prefix='jet_AntiKt4TopoEM_',
                                                     JetVertexFraction_FromUD=True,
                                                     JetVertexFraction_FillFullJVF=True,
                                                     include = [ JetTagD3PDKeys.BTagWeightsBlockName(),
                                                                 JetTagD3PDKeys.TruthInfoBlockName() ] ))


    # Tau block

    if tauContainer != 'None':
        alg += TauD3PDObject              (**_args ( 0, 'Tau', kw,
                                                     allowMissing=True,
                                                     sgkey=tauContainer ))

    
    # HF overlap removal (ALPGEN)

    from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
    alg += HforD3PDObject(**_args (0, 'HforInfo', kw))


    # MET blocks
    # a whole mess to remove x,y components separately for all flavours

    alg += MissingETD3PDObject   (**_args (10, 'MissingET', kw,
                                           exclude=['MET_Base','MET_Base0','MET_Truth',
                                                    'MET_RefFinal_Comps','MET_RefFinal_Regions',
                                                    'MET_LocHadTopo_Comps','MET_LocHadTopo_Regions',
                                                    'MET_CellOut_Comps','MET_CellOut_Regions',
                                                    'MET_Calib',
                                                    'MET_CorrTopo',
                                                    'MET_Cryo',
                                                    'MET_CryoCone',
                                                    'MET_Final',
                                                    'MET_LocHadTopoObj',
                                                    'MET_Muid',
                                                    'MET_Muid_Spectro',
                                                    'MET_Muid_Track',
                                                    'MET_MuonBoy',
                                                    'MET_MuonBoy_Spectro',
                                                    'MET_MuonBoy_Track',
                                                    'MET_MuonMuid',
                                                    'MET_Muon',
                                                    'MET_Muon_Isol_Muid',
                                                    'MET_Muon_Isol_Staco',
                                                    'MET_Muon_NonIsol_Muid',
                                                    'MET_Muon_NonIsol_Staco',
                                                    'MET_Muon_Total_Muid',
                                                    'MET_Muon_Total_Staco',
                                                    'MET_RefEle_Comps','MET_RefEle_Regions',
                                                    'MET_RefEle_em_Comps','MET_RefEle_em_Regions',
                                                    'MET_RefGamma_Comps','MET_RefGamma_Regions',
                                                    'MET_RefGamma_em_Comps','MET_RefGamma_em_Regions',
                                                    'MET_RefJet_Comps','MET_RefJet_Regions',
                                                    'MET_RefJet_em_Comps','MET_RefJet_em_Regions',
                                                    'MET_RefMuon_Comps','MET_RefMuon_Regions',
                                                    'MET_RefMuon_Muid_Comps','MET_RefMuon_Muid_Regions',
                                                    'MET_RefMuon_Staco_Comps','MET_RefMuon_Staco_Regions',
                                                    'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Muid_Regions',
                                                    'MET_RefMuon_Track_Staco_Comps','MET_RefMuon_Track_Staco_Regions',
                                                    'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_em_Regions',
                                                    'MET_RefMuon_Track_Comps','MET_RefMuon_Track_Regions',
                                                    'MET_RefMuon_em_Comps','MET_RefMuon_em_Regions',
                                                    'MET_RefTau_Comps','MET_RefTau_Regions',
                                                    'MET_RefTau_em_Comps','MET_RefTau_em_Regions',
                                                    'MET_SoftJets_Comps','MET_SoftJets_Regions',
                                                    'MET_SoftJets_em_Comps','MET_SoftJets_em_Regions',
                                                    'MET_Topo',
                                                    'MET_TopoObj_Comps','MET_TopoObj_Regions',
                                                    'MET_Track_Comps','MET_Track_Regions',
                                                    'MET_Comps',
                                                    'MET_Track_Weights','MET_Cluster_Weights',
                                                    'MET_Regions','MET_Composition'],
                                           allowMissing=True ))


    # HadronicRecoil blocks

    alg += ElectronD3PDObject(0,  sgkey = 'HR_selectedElectrons', prefix = 'hr_el_',allowMissing=True )
    alg += MuonD3PDObject( 0,     sgkey = 'HR_selectedMuons',     prefix = 'hr_mu_', allowMissing=True )

    # ... DR = 0.15
 
    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_15',                prefix = 'hr_roughRecoil_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_15',               prefix = 'hr_ueCorrection_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_15',              prefix = 'hr_corrRecoil_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_15',                     prefix = 'hr_MET_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
 
    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_Eflow_15',          prefix = 'hr_roughRecoil_Eflow_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_Eflow_15',         prefix = 'hr_ueCorrection_Eflow_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_Eflow_15',        prefix = 'hr_corrRecoil_Eflow_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_Eflow_15',               prefix = 'hr_MET_Eflow_15',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True ) 

    alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_track_15",          prefix = "hr_roughRecoil_track_15",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_track_15",         prefix = "hr_ueCorrection_track_15",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_track_15",        prefix = "hr_corrRecoil_track_15",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "MET_HR_track_15",               prefix = "hr_MET_track_15",
                                exclude=['MET_Regions','MET_Comps'] ) 

    # ... DR = 0.20

    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_20',                prefix = 'hr_roughRecoil_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_20',               prefix = 'hr_ueCorrection_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_20',              prefix = 'hr_corrRecoil_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_20',                     prefix = 'hr_MET_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
 
    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_track_20',          prefix = 'hr_roughRecoil_track_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_track_20',         prefix = 'hr_ueCorrection_track_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_track_20',        prefix = 'hr_corrRecoil_track_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_track_20',               prefix = 'hr_MET_track_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )    

    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_clusNoTrack_20',    prefix = 'hr_roughRecoil_clusNoTrack_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_clusNoTrack_20',   prefix = 'hr_ueCorrection_clusNoTrack_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_clusNoTrack_20',  prefix = 'hr_corrRecoil_clusNoTrack_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_clusNoTrack_20',         prefix = 'hr_MET_clusNoTrack_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )  

    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_Eflow_20',          prefix = 'hr_roughRecoil_Eflow_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_Eflow_20',         prefix = 'hr_ueCorrection_Eflow_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_Eflow_20',        prefix = 'hr_corrRecoil_Eflow_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_Eflow_20',               prefix = 'hr_MET_Eflow_20',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )

    # ... DR = 0.25

    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_25',                prefix = 'hr_roughRecoil_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_25',               prefix = 'hr_ueCorrection_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_25',              prefix = 'hr_corrRecoil_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_25',                     prefix = 'hr_MET_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )

    alg += MissingETD3PDObject( 0, sgkey = 'RoughRecoil_Eflow_25',          prefix = 'hr_roughRecoil_Eflow_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'ueCorrection_Eflow_25',         prefix = 'hr_ueCorrection_Eflow_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'RefinedRecoil_Eflow_25',        prefix = 'hr_corrRecoil_Eflow_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
    alg += MissingETD3PDObject( 0, sgkey = 'MET_HR_Eflow_25',               prefix = 'hr_MET_Eflow_25',
                                exclude=['MET_Regions','MET_Comps'],
                                allowMissing=True )
 
    alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_track_25",          prefix = "hr_roughRecoil_track_25",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_track_25",         prefix = "hr_ueCorrection_track_25",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_track_25",        prefix = "hr_corrRecoil_track_25",
                                exclude=['MET_Regions','MET_Comps'] )
    alg += MissingETD3PDObject( 0, sgkey = "MET_HR_track_25",               prefix = "hr_MET_track_25",
                                exclude=['MET_Regions','MET_Comps'] )


    # HR using truth leptons
    if rec.doTruth():
        
        ## ... DR = 0.15               
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_15",
                                    prefix = "hr_roughRecoil_trLep_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_15",
                                    prefix = "hr_ueCorrection_trLep_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_15",
                                    prefix = "hr_corrRecoil_trLep_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_15",
                                    prefix = "hr_MET_trLep_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_Eflow_15",
                                    prefix = "hr_roughRecoil_trLep_Eflow_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_Eflow_15",
                                    prefix = "hr_ueCorrection_trLep_Eflow_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_15",
                                    prefix = "hr_corrRecoil_trLep_Eflow_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_15",
                                    prefix = "hr_MET_trLep_Eflow_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_track_15",
                                    prefix = "hr_roughRecoil_trLep_track_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_track_15",
                                    prefix = "hr_ueCorrection_trLep_track_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_15",
                                    prefix = "hr_corrRecoil_trLep_track_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_15",
                                    prefix = "hr_MET_trLep_track_15",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        ## ... DR = 0.20
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_20",
                                    prefix = "hr_roughRecoil_trLep_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_20",
                                    prefix = "hr_ueCorrection_trLep_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_20",
                                    prefix = "hr_corrRecoil_trLep_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_20",
                                    prefix = "hr_MET_trLep_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_Eflow_20",
                                    prefix = "hr_roughRecoil_trLep_Eflow_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_Eflow_20",
                                    prefix = "hr_ueCorrection_trLep_Eflow_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_20",
                                    prefix = "hr_corrRecoil_trLep_Eflow_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_20",
                                    prefix = "hr_MET_trLep_Eflow_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_track_20",
                                    prefix = "hr_roughRecoil_trLep_track_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_track_20",
                                    prefix = "hr_ueCorrection_trLep_track_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_20",
                                    prefix = "hr_corrRecoil_trLep_track_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_20",
                                    prefix = "hr_MET_trLep_track_20",
                                    exclude=['MET_Regions','MET_Comps'] )
        
         ## ... DR = 0.25
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_25",
                                    prefix = "hr_roughRecoil_trLep_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_25",
                                    prefix = "hr_ueCorrection_trLep_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_25",
                                    prefix = "hr_corrRecoil_trLep_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_25",
                                    prefix = "hr_MET_trLep_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_Eflow_25",
                                    prefix = "hr_roughRecoil_trLep_Eflow_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_Eflow_25",
                                    prefix = "hr_ueCorrection_trLep_Eflow_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_25",
                                    prefix = "hr_corrRecoil_trLep_Eflow_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_Eflow_25",
                                    prefix = "hr_MET_trLep_Eflow_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        
        alg += MissingETD3PDObject( 0, sgkey = "RoughRecoil_TruthLep_track_25",
                                    prefix = "hr_roughRecoil_trLep_track_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "ueCorrection_TruthLep_track_25",
                                    prefix = "hr_ueCorrection_trLep_track_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_25",
                                    prefix = "hr_corrRecoil_trLep_track_25",
                                    exclude=['MET_Regions','MET_Comps'] )
        alg += MissingETD3PDObject( 0, sgkey = "RefinedRecoil_TruthLep_track_25",
                                    prefix = "hr_MET_trLep_track_25",
                                    exclude=['MET_Regions','MET_Comps'] )


    # Cluster block

    # ... all clusters, very low LOD

    if clusterContainer != 'None':
        alg += ClusterD3PDObject          (**_args ( 0, 'Clusters', kw,
                                                     sgkey = clusterContainer,
                                                     exclude='SamplingBasics',
                                                     allowMissing=True ))


    # Track block

    # ... good tracks only (nSCT>=6; no pt cut)

    if trackContainer != 'None':
        alg += TrackParticleD3PDObject (**_args ( 3, 'Tracks', kw,
                                                  sgkey  = trackContainer,
                                                  label  = 'trk',
                                                  prefix = 'trk_',
                                                  allowMissing=True ))

    
    # Primary vertex block - May be missing in single-beam data.

    alg += PrimaryVertexD3PDObject (**_args (1, 'PrimaryVertex', kw,
                                             sgkey = D3PDMakerFlags.VertexSGKey(),
                                             prefix = 'vxp_',
                                             allowMissing=True ))
    
    # Truth

    if rec.doTruth():

        from TruthD3PDMaker.TruthParticleD3PDObject            import TruthParticleD3PDObject
        from MuonD3PDMaker.TruthMuonD3PDObject                 import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject    (**_args ( 2, 'TruthMuon', kw))

        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool

        # ... remove empty GenEvents

        smlightGenEvtFilterTool = D3PD__GenObjectsFilterTool( "smlightGenEvtFilterTool" )
        ToolSvc += smlightGenEvtFilterTool
        smlightGenEvtFilterTool.RemoveDummyEvents = True
        smlightGenEvtFilterTool.RemoveInTimePileUp = True
        smlightGenEvtFilterTool.Remove2BCPileUp = True
        smlightGenEvtFilterTool.Remove800nsPileUp = True
        smlightGenEvtFilterTool.RemoveCavernBkg = True
        smlightGenEvtFilterTool.RemoveEmptyEvents = True

        from TruthD3PDMaker.GenEventD3PDObject                 import GenEventD3PDObject
        alg += GenEventD3PDObject     (**_args ( 0, 'GenEvent', kw, filter = smlightGenEvtFilterTool ))

        

        # ... leptonic W/Z truth information

        smlightLepWZFilterTool = D3PD__GenObjectsFilterTool( "smlightLepWZFilterTool" )
        ToolSvc += smlightLepWZFilterTool

        smlightLepWZFilterTool.RemoveInTimePileUp = True
        smlightLepWZFilterTool.Remove2BCPileUp = True
        smlightLepWZFilterTool.Remove800nsPileUp = True
        smlightLepWZFilterTool.RemoveCavernBkg =  True
        smlightLepWZFilterTool.RemoveEmptyEvents = True
        smlightLepWZFilterTool.RemoveDummyEvents = True
        smlightLepWZFilterTool.RemoveUnrequestedParticles=True
        smlightLepWZFilterTool.KeepLeptonicWZBosons=True
        smlightLepWZFilterTool.KeepLeptonicWZBosonDecayChains=True
        smlightLepWZFilterTool.KeepLeptonicWZBosonsParents=True

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject( **_args(10, "lepwzgenparticle", kw, prefix='mclepwzpart_',
                                              filter = smlightLepWZFilterTool,
                                              label = "LepWZTruthD3PDObject",
                                              exclude = ["GenPartProdVertexAssoc","GenPartDecayVertexAssoc"],
                                              GenParticle_WriteMotherType=False,
                                              GenParticle_WriteMotherBarcode=False,
                                              GenPartMotherAssoc_target="LepWZTruthD3PDObject",
                                              GenPartChildAssoc_target="LepWZTruthD3PDObject"
                                              )
                                      )


    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)
    
    
    # Trigger

    if D3PDMakerFlags.DoTrigger():

#        RedefineTriggerBits(alg, 'EF*')
#        alg += SMWZLightTriggerBitsD3PDObject      (**_args (10, 'SMWZLightTriggerBits', kw))

        # metadata

        addTrigConfMetadata(alg)
        
        # Bunch group info

        alg += BGCodeD3PDObject (**_args (2, 'BGCode', kw))

        # Egamma EF information
        
        alg += EFElectronD3PDObject(0, name='trig_EF_el_', 
                                    sgkey='HLT_egamma_Electrons,HLT_egamma',
                                    prefix='trig_EF_el_',
                                    exclude=['Author','IsEM','IsEMCuts'],
                                    include=['Triggers'],
                                    allowMissing = True)
        
#        alg += EFPhotonD3PDObject(0, name='trig_EF_ph_', 
#                                  sgkey='HLT_egamma_Photons,HLT_egamma',
#                                  prefix='trig_EF_ph_',
#                                  exclude=['Author','Conversion0','IsEM','IsEMCuts'],
#                                  include=['Triggers'],
#                                  allowMissing = True)        

        # Muon EF information
        
        alg += TrigMuonEFInfoD3PDObject(0,
                                        include=['Decision'],
                                        exclude=['TrackDetails','SpectrometerTrackBasics','ExtrapolatedTrackBasics'],
                                        allowMissing = True)
        
        alg += TrigMuonEFInfoD3PDObject(0,
                                        name = "trig_EF_trigmugirl_",
                                        sgkey = "HLT_eMuonEFInfo",
                                        prefix = "trig_EF_trigmugirl_",
                                        exclude=['TrackDetails','SpectrometerTrackBasics','ExtrapolatedTrackBasics'],
                                        include=['Decision'],
                                        allowMissing = True)
        
        # MET EF information

#        alg += TrigMETD3PDObject(**_args ( 0, 'TrigMETEF', kw,
#                                           prefix = "trig_EF_met_",
#                                           sgkey = "HLT_TrigEFMissingET" ))
        

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

    if D3PDMakerFlags.FilterCollCand():
        from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
        alg.filterSeq += CollisionFilterAlg (tuplename + '_CollCandFilter')

    return alg
示例#28
0
        jetCollections=[]):

    from JetTagD3PDMaker import JetTagMSVVtxInfoGetterTool
    getter = JetTagMSVVtxInfoGetterTool(name + '_Getter',
                                        Label=label,
                                        JetCollections=jetCollections)

    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    return  D3PDMakerCoreComps.VectorFillerTool (name, Prefix = prefix, Getter = getter,
                                                 ObjectName = object_name,
                                                 SaveMetadata = \
                                                 D3PDMakerFlags.SaveObjectMetadata())


JetTagMSVVtxInfoInJetD3PDObject = D3PDObject(
    makeJetTagMSVVtxInJetObject, JetTagD3PDKeys.MSVVtxInfoInJetPrefix(),
    'JetTagMSVVtxInfoInJetD3PDObject')

JetTagMSVVtxInfoInJetD3PDObject.defineBlock(
    0, 'MSVVtxInfo', JetTagD3PDMaker.JetTagMSVVtxInfoFillerTool)


def _jetTagMultiSVAssocLevel(reqlev, args):
    if not args.has_key('target'):
        return False
    return True


MSVVtxInfoAssoc = IndexMultiAssociation(
    JetTagMSVVtxInfoInJetD3PDObject,
    JetTagD3PDMaker.JetTagMSVVtxInfoTrackAssociationTool,
class StdInfoInclude(JobProperty):
    """ Standard include blocks needed by physics groups
    """
    statusOn=True
    allowedTypes=['list']
    StoredValue=[
        JetTagD3PDKeys.BTagWeightsBlockName(),
        JetTagD3PDKeys.TruthInfoBlockName(),
        JetTagD3PDKeys.PUTruthInfoBlockName(),
        JetTagD3PDKeys.IP2DInfoBaseBlockName(),
        JetTagD3PDKeys.IP2DIPInfoBaseBlockName(),
        JetTagD3PDKeys.IP3DInfoBaseBlockName(),
        JetTagD3PDKeys.IP3DIPInfoBaseBlockName(),
        JetTagD3PDKeys.SV1InfoBaseBlockName(),
        JetTagD3PDKeys.SV2InfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterInfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
        JetTagD3PDKeys.JetFitterTagInfoBlockName(),
        JetTagD3PDKeys.IPInfoPlusTrackBlockName(),
        JetTagD3PDKeys.SVInfoPlusBlockName(),
        JetTagD3PDKeys.SV0InfoPlusBlockName()
        ]
示例#30
0
                                jetCollections=[]):

    from JetTagD3PDMaker import JetTagPhotonInJetGetterTool
    getter = JetTagPhotonInJetGetterTool(name + '_Getter',
                                         Label=label,
                                         JetCollections=jetCollections)

    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    return  D3PDMakerCoreComps.VectorFillerTool (name, Prefix = prefix, Getter = getter,
                                                 ObjectName = object_name,
                                                 SaveMetadata = \
                                                 D3PDMakerFlags.SaveObjectMetadata())


JetTagPhotonInJetD3PDObject = D3PDObject(makeJetTagPhotonInJetObject,
                                         JetTagD3PDKeys.PhotonInJetPrefix(),
                                         'JetTagPhotonInJetD3PDObject')

JetTagPhotonInJetD3PDObject.defineBlock(0,
                                        'Kinematics',
                                        EventCommonD3PDMaker.FourMomFillerTool,
                                        WriteRect=True,
                                        WriteE=True,
                                        WriteM=True)

JetTagPhotonInJetD3PDObject.defineBlock(0, 'Authors',
                                        egammaD3PDMaker.egammaAuthorFillerTool)

#
## get the PhotonInJetObject
## jet collections to be used should be specified