예제 #1
0
def JetTileD3PD(file,
                level=4,
                tuplename='MyTuple',
                seq=topSequence,
                D3PDSvc='D3PD::RootD3PDSvc',
                streamNameRoot=None,
                **kw):

    alg = D3PDMakerCoreComps.MakerAlg(tuplename,
                                      seq,
                                      file=file,
                                      D3PDSvc=D3PDSvc,
                                      streamNameRoot=streamNameRoot)

    JetIncludes = ['AssocTrackCont']

    alg += EventInfoD3PDObject(**_args(level, 'EventInfo', kw))

    alg += JetTileD3PDObject(**_args(
        level, inputSGkey, kw, sgkey=inputSGkey, prefix='AntiKt4Topo_'))

    from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    alg += BGCodeD3PDObject(**_args(2, 'BGCode', kw))
    addBunchStructureMetadata(alg)

    from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
    from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata

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

    if D3PDMakerFlags.DoTrigger():
        alg += jetMETTriggerBitsD3PDObject(level)

    from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags
    TrackD3PDFlags.storeVertexTrackIndexAssociation.set_Value_and_Lock(False)
    TrackD3PDFlags.storeVertexTrackAssociation.set_Value_and_Lock(False)
    TrackD3PDFlags.storeVertexFitQuality.set_Value_and_Lock(False)

    from TrackD3PDMaker.xAODVertexD3PDObject import PrimaryxAODVertexD3PDObject
    alg += PrimaryxAODVertexD3PDObject(
        **_args(0,
                'PrimaryVertex',
                kw,
                allowMissing=True,
                sgkey=D3PDMakerFlags.VertexSGKey(),
                prefix='vxp_'))

    if rec.doTruth():
        alg += GenEventD3PDObject(**_args(1, 'GenEvent', kw))
        alg += TruthParticleD3PDObject(**_args(1, 'TruthParticle', kw))
        alg += JetTileD3PDObject(**_args(1,
                                         'AntiKt4TruthJets',
                                         kw,
                                         sgkey='AntiKt4TruthJets',
                                         prefix='AntiKt4Truth_'))

    alg.MetadataTools += [LBMetadataConfig()]
    return alg
예제 #2
0
def physicsD3PD(alg=None,
                trigalg=None,
                file='physics.root',
                tuplename='physics',
                **kw):

    # Core algorithm
    # By default the user of this function should have created an algorithm already.
    # But for backwards compatibility let the function create its own algorithm if
    # needed...
    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file)

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

    # Segregate trigger decision flags in a separate tree.
    if not trigalg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        trigalg = MSMgr.NewRootStream(tuplename + ':' + tuplename + 'TrigDec',
                                      FileName=file,
                                      TreeName=tuplename + 'TrigDec')
    trigalg += EventInfoD3PDObject(0)
    alg.Stream.trigDecisionTree = trigalg

    # Add bunch structure metadata.
    from TriggerD3PDMaker.BunchStructureMetadata \
         import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    # Make track jets, but we can only do this if we have vertices.
    if testSGKey('VxContainer', 'VxPrimaryCandidate'):
        from D3PDMakerConfig.createTrackJets import createTrackJets
        createTrackJets(AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()))
        alg += JetD3PDObject(**_args(
            -1, 'TrackJet', kw, prefix='trackjet_', sgkey='AntiKtZ5TrackJets'))
        k = 'Electron_EgammaTrackJetSignedIPAndPTRel_target'
        if not kw.has_key(k):
            kw[k] = 'trackjet_'

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

    # Electron/Photon blocks

    alg += ElectronD3PDObject(
        **_args(10,
                'Electron',
                kw,
                EgammaJetSignedIPAndPTRel_target='jet_antikt4h1topo_'))
    alg += PhotonD3PDObject(
        **_args(10, 'Photon', kw, ConversionVertexTrackIndex_target='trk'))
    if testSGKey('ElectronContainer', D3PDMakerFlags.GSFElectronSGKey()):
        alg += GSFElectronD3PDObject(
            **_args(level,
                    'GSFElectron',
                    kw,
                    sgkey=D3PDMakerFlags.GSFElectronSGKey(),
                    prefix='el_gsf_'))

    # Muon blocks

    alg += MuonD3PDObject(**_args(10,
                                  'MuidMuon',
                                  kw,
                                  sgkey='MuidMuonCollection',
                                  prefix='mu_muid_',
                                  allowMissing=True))
    alg += MuonD3PDObject(**_args(10,
                                  'StacoMuon',
                                  kw,
                                  sgkey='StacoMuonCollection',
                                  prefix='mu_staco_',
                                  allowMissing=True))
    alg += MuonD3PDObject(**_args(
        10, 'Muons', kw, sgkey='Muons', prefix='mu_', allowMissing=True))

    # Tau block

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

    # Jet blocks

    alg += JetD3PDObject(**_args(9,
                                 'AK4TopoJet',
                                 kw,
                                 sgkey='AntiKt4TopoEMJets,' +
                                 'AntiKt4TopoJets,' + 'AntiKt4H1TopoJets',
                                 prefix='jet_antikt4h1topo_',
                                 ConstitIndex_Target='cl_',
                                 exclude=['Constituents'],
                                 allowMissing=True))
    alg += JetD3PDObject(**_args(6,
                                 'AK4TowerJet',
                                 kw,
                                 sgkey='AntiKt4TowerAODJets,' +
                                 'AntiKt4TowerJets,' + 'AntiKt4H1TowerJets',
                                 prefix='jet_antikt4h1tower_',
                                 exclude=['Constituents'],
                                 allowMissing=True))
    alg += JetD3PDObject(**_args(6,
                                 'AK6TowerJet',
                                 kw,
                                 sgkey='AntiKt6TowerAODJets,' +
                                 'AntiKt6TowerJets,' + 'AntiKt6H1TowerJets',
                                 prefix='jet_antikt6h1tower_',
                                 exclude=['Constituents'],
                                 allowMissing=True))
    #alg += JetD3PDObject              (**_args ( 9, 'AK4TopoJetLC', kw,
    #                                             sgkey='AntiKt4LCTopoJets', prefix='jet_antikt4lctopo_'))
    #alg += JetD3PDObject              (**_args ( 9, 'AK6TopoJetLC', kw,
    #                                             sgkey='AntiKt6LCTopoMyJets', prefix='jet_antikt6lctopo_'))
    #alg += JetD3PDObject              (**_args ( 9, 'AK6TopoJetH1', kw,
    #                                             sgkey='AntiKt6H1TopoMyJets', prefix='jet_antikt6h1topo_'))

    # MET blocks

    alg += MissingETD3PDObject(**_args(10, 'MissingET', kw, allowMissing=True))
    alg += MissingETGoodnessD3PDObject(**_args(2, 'METGoodness', kw))

    # track and cluster blocks

    alg += ClusterD3PDObject(**_args(1, 'Cluster', kw))
    alg += EMClusterD3PDObject(**_args(2, 'EMCluster', kw))

    # Many of these are just being set to the defaults --- that's because
    # they're being changed in TrigEgamma...
    alg += TrackParticleD3PDObject(
        **_args(3,
                'TrackParticle',
                kw,
                TruthParticleTarget='mc_',
                storeTruthInfo=True,
                trackParametersAtGlobalPerigeeLevelOfDetails=3,
                storeDiagonalCovarianceAsErrors=True))

    # 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))

    # ZDC
    alg += ZDCTriggerBitsD3PDObject(**_args(10, 'ZDCTriggerBits', kw))

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

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

    # Truth

    if rec.doTruth():
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject(**_args(2, 'TruthMuon', kw))
        alg += GenEventD3PDObject(**_args(1, 'GenEvent', kw))
        alg += TruthParticleD3PDObject(**_args(1, 'TruthParticle', kw))
        alg += JetD3PDObject(**_args(3,
                                     'AK4TruthJet',
                                     kw,
                                     sgkey='AntiKt4TruthJets',
                                     prefix='jet_antikt4truth_',
                                     allowMissing=True))
        #alg += JetD3PDObject          (**_args ( 3, 'AK6Ttruth', kw,
        #                                         sgkey='AntiKt6TruthJets',
        #                                         prefix='jet_antikt6truth_'))

    # Trigger

    if D3PDMakerFlags.DoTrigger():
        from TriggerD3PDMaker.TrigDecisionD3PDObject \
             import TrigDecisionD3PDObject
        alg += TrigDecisionD3PDObject(**_args(2, 'TrigDecision', kw))
        TrigEgammaD3PDObjects(alg, **_args(1, 'TrigEgamma', kw))

        alg += egammaTriggerBitsD3PDObject(**_args(2, 'EgammaTriggerBits', kw))
        alg += MuonTriggerBitsD3PDObject(**_args(2, 'MuonTriggerBits', kw))
        alg += METD3PDTriggerBitsObject(**_args(2, 'METTriggerBits', kw))

        from TriggerD3PDMaker.EnergySumROID3PDObject import EnergySumROID3PDObject
        from TrigMissingETD3PDMaker.TrigMETD3PDObject import TrigMETD3PDObject

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

        # 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"))

        from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
        alg += BGCodeD3PDObject(**_args(2, 'BGCode', kw))

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #3
0
def MinBiasD3PD(d3pdalg=None,
                file='minbias.root',
                tuplename='MinBiasD3PD',
                streamname='d3pdstream',
                **kw):

    # MinBias flags
    from MinBiasD3PDMaker.MinBiasD3PDMakerFlags import minbiasD3PDflags
    from IOVDbSvc.CondDB import conddb
    from AthenaCommon.GlobalFlags import globalflags

    if minbiasD3PDflags.doPixelTracklets():
        MinBiasD3PDStream_msg.info(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TRACKLETS")
        pass

    ## Don't do truth on data
    if globalflags.DataSource == 'data':
        minbiasD3PDflags.doMBTruth = False
        pass

    #--------------------------------------------------------------
    # Configure Beam spot service
    #--------------------------------------------------------------


#   from AthenaCommon.GlobalFlags import globalflags
#   if globalflags.DataSource == 'data':
#      include("InDetBeamSpotService/BeamCondSvc.py")
#      conddb.addOverride("/Indet/Beampos",
#minbiasD3PDflags.BSDBFolderName())
#      pass

#--------------------------------------------------------------
# Configure the MinBiasD3PDMaker
#--------------------------------------------------------------

    import TrackD3PDMaker
    import TrigMbD3PDMaker
    import TriggerD3PDMaker
    import D3PDMakerCoreComps
    import EventCommonD3PDMaker

    ## Event Info
    from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject

    ## Trigger part
    from TrigMbD3PDMaker.BcmRdoD3PDObject import BcmRdoD3PDObject
    from TrigMbD3PDMaker.CtpRdoD3PDObject import CtpRdoD3PDObject
    from TrigMbD3PDMaker.CtpDecisionD3PDObject import CtpDecisionD3PDObject
    from TrigMbD3PDMaker.MbtsContainerD3PDObject import MbtsContainerD3PDObject
    from TrigMbD3PDMaker.MbtsLvl2D3PDObject import MbtsLvl2D3PDObject
    from TrigMbD3PDMaker.SpLvl2D3PDObject import SpLvl2D3PDObject
    from TrigMbD3PDMaker.TrtLvl2D3PDObject import TrtLvl2D3PDObject
    from TrigMbD3PDMaker.TrkCntsEfD3PDObject import TrkCntsEfD3PDObject
    from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
    from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata

    ## Tracking part
    #-- TrackD3PDMaker Flags
    from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags
    TrackD3PDFlags.doTruth.set_Value_and_Lock(minbiasD3PDflags.doMBTruth())
    TrackD3PDFlags.storeDiagonalCovarianceAsErrors.set_Value_and_Lock(True)
    TrackD3PDFlags.storeHitTruthMatching.set_Value_and_Lock(
        minbiasD3PDflags.doMBTruth())
    TrackD3PDFlags.storeDetailedTruth.set_Value_and_Lock(
        minbiasD3PDflags.doMBTruth())
    TrackD3PDFlags.storePullsAndResiduals.set_Value_and_Lock(False)
    TrackD3PDFlags.storeBLayerHitsOnTrack.set_Value_and_Lock(False)
    TrackD3PDFlags.storePixelHitsOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeSCTHitsOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTRTHitsOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeBLayerOutliersOnTrack.set_Value_and_Lock(False)
    TrackD3PDFlags.storePixelOutliersOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeSCTOutliersOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTRTOutliersOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeBLayerHolesOnTrack.set_Value_and_Lock(False)
    TrackD3PDFlags.storePixelHolesOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeSCTHolesOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTRTHolesOnTrack.set_Value_and_Lock(True)
    TrackD3PDFlags.storeVertexAssociation.set_Value_and_Lock(False)
    TrackD3PDFlags.storeTrackPredictionAtBLayer.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTrackInfo.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTrackFitQuality.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTrackSummary.set_Value_and_Lock(True)
    TrackD3PDFlags.storeTrackSummary.IDHits = True
    TrackD3PDFlags.storeTrackSummary.IDHoles = True
    TrackD3PDFlags.storeTrackSummary.IDSharedHits = True
    TrackD3PDFlags.storeTrackSummary.IDOutliers = True
    TrackD3PDFlags.storeTrackSummary.PixelInfoPlus = False
    TrackD3PDFlags.storeTrackSummary.SCTInfoPlus = False
    TrackD3PDFlags.storeTrackSummary.TRTInfoPlus = False
    TrackD3PDFlags.storeTrackSummary.InfoPlus = False
    TrackD3PDFlags.storeTrackSummary.MuonHits = False
    TrackD3PDFlags.storeTrackSummary.MuonHoles = False
    TrackD3PDFlags.storeTrackSummary.ExpectBLayer = True
    TrackD3PDFlags.storeTrackSummary.HitSum = True
    TrackD3PDFlags.storeTrackSummary.HoleSum = True
    TrackD3PDFlags.storeTrackSummary.HitPattern = True
    TrackD3PDFlags.storeTrackSummary.SiHits = False
    TrackD3PDFlags.storeTrackSummary.TRTRatio = False
    TrackD3PDFlags.storeTrackSummary.PixeldEdx = True  #  HI
    TrackD3PDFlags.storeTrackSummary.ElectronPID = False
    TrackD3PDFlags.trackParametersAtGlobalPerigeeLevelOfDetails.set_Value_and_Lock(
        3)
    TrackD3PDFlags.trackParametersAtPrimaryVertexLevelOfDetails.set_Value_and_Lock(
        3)
    TrackD3PDFlags.trackParametersAtBeamSpotLevelOfDetails.set_Value_and_Lock(
        3)
    TrackD3PDFlags.storeTrackUnbiasedIPAtPV.set_Value_and_Lock(False)
    TrackD3PDFlags.storeTrackMomentum.set_Value_and_Lock(True)
    TrackD3PDFlags.vertexPositionLevelOfDetails.set_Value_and_Lock(3)
    TrackD3PDFlags.storeVertexFitQuality.set_Value_and_Lock(True)
    TrackD3PDFlags.storeVertexKinematics.set_Value_and_Lock(True)
    TrackD3PDFlags.storeVertexPurity.set_Value_and_Lock(
        minbiasD3PDflags.doMBTruth())
    TrackD3PDFlags.storeVertexTrackAssociation.set_Value_and_Lock(False)
    TrackD3PDFlags.storeVertexTrackIndexAssociation.set_Value_and_Lock(True)

    #-- Enhanced vertex info configuration
    from TrackD3PDMaker.VertexD3PDAnalysisFlags import VertexD3PDAnalysisFlags
    VertexD3PDAnalysisFlags.useEventInfo = False  # No Evt Info reread in Vtx
    VertexD3PDAnalysisFlags.useTruth = minbiasD3PDflags.doMBTruth()
    VertexD3PDAnalysisFlags.useAllVertexCollections = True
    VertexD3PDAnalysisFlags.useTracks = False  #Already included in the MinBias D3PD
    VertexD3PDAnalysisFlags.useBeamspot = False  # Already included in the MinBias D3PD
    VertexD3PDAnalysisFlags.useBackgroundWord = True  # Components mostly included, just to be safe
    VertexD3PDAnalysisFlags.useTrigger = False  # Already included in the MinBias D3PD
    VertexD3PDAnalysisFlags.useSecondaryVertex = False
    VertexD3PDAnalysisFlags.useMET = False
    VertexD3PDAnalysisFlags.useElectrons = False
    VertexD3PDAnalysisFlags.useMuons = False
    VertexD3PDAnalysisFlags.usePhotons = False
    VertexD3PDAnalysisFlags.useJets = False
    VertexD3PDAnalysisFlags.useTaus = False

    #-- TrackD3PDMaker configuration
    from TrackD3PDMaker.TruthTrackD3PDObject import TruthTrackD3PDObject
    from TrackD3PDMaker.TruthVertexD3PDObject import TruthVertexD3PDObject
    from TrackD3PDMaker.TrackD3PDObject import TrackParticleD3PDObject
    from TrackD3PDMaker.TrackD3PDObject import PixelTrackD3PDObject
    from TrackD3PDMaker.TrackD3PDObject import SCTTrackD3PDObject
    from TrackD3PDMaker.TrackD3PDObject import TRTTrackD3PDObject
    from TrackD3PDMaker.TrackD3PDObject import ResolvedTracksD3PDObject
    from TrackD3PDMaker.VertexD3PDObject import PrimaryVertexD3PDObject
    from TrackD3PDMaker.VertexD3PDObject import BuildVertexD3PDObject
    SecVertexD3PDObject = BuildVertexD3PDObject(
        _prefix='secVx_',
        _label='secVx',
        _sgkey='SecVertices',
        trackTarget='trk',
        trackPrefix='trk_',
        trackType='Rec::TrackParticleContainer')
    from TrackD3PDMaker.V0D3PDObject import V0D3PDObject
    from TrackD3PDMaker.BeamSpotD3PDObject import BeamSpotD3PDObject

    ## MinBias part
    from MinBiasD3PDMaker.UnassociatedHitsD3PDObject import UnassociatedHitsD3PDObject

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

    ## Add blocks to the tree
    # d3pdalg += EventInfoD3PDObject(10, prefix='ei_')
    d3pdalg += EventInfoD3PDObject(10)
    d3pdalg += TrackParticleD3PDObject(10)
    d3pdalg += PrimaryVertexD3PDObject(10)
    if minbiasD3PDflags.doBeamSpot():
        d3pdalg += BeamSpotD3PDObject(10)
    if minbiasD3PDflags.doUnassociatedHits():
        d3pdalg += UnassociatedHitsD3PDObject(10)
    if minbiasD3PDflags.doTrigger():
        d3pdalg += CtpRdoD3PDObject(10)
        d3pdalg += CtpDecisionD3PDObject(10)
        d3pdalg += MbtsContainerD3PDObject(10)
        d3pdalg += TrigDecisionD3PDObject(10)
        addTrigConfMetadata(d3pdalg)
    if minbiasD3PDflags.doDetailedTrigger():
        d3pdalg += BcmRdoD3PDObject(10)
        d3pdalg += MbtsLvl2D3PDObject(10)
        d3pdalg += SpLvl2D3PDObject(10)
        d3pdalg += TrtLvl2D3PDObject(10)
        d3pdalg += TrkCntsEfD3PDObject(10)
    if minbiasD3PDflags.doMBTruth():
        d3pdalg += TruthTrackD3PDObject(10)
        d3pdalg += TruthVertexD3PDObject(10)
    if minbiasD3PDflags.doPixelTracklets():
        d3pdalg += PixelTrackD3PDObject(10)
    if minbiasD3PDflags.doSCTTracklets():
        d3pdalg += SCTTrackD3PDObject(10)
    if minbiasD3PDflags.doTRTTracklets():
        d3pdalg += TRTTrackD3PDObject(10)
    if minbiasD3PDflags.doResolvedTracklets():
        d3pdalg += ResolvedTracksD3PDObject(10)
    if minbiasD3PDflags.doV0s():
        d3pdalg += V0D3PDObject(10, sgkey="V0Candidates")
        d3pdalg += SecVertexD3PDObject(10)

    if minbiasD3PDflags.doLucid():
        from TrigMbD3PDMaker.LucidRawD3PDObject import LucidRawD3PDObject
        d3pdalg += LucidRawD3PDObject(10)
        if globalflags.DataSource == 'geant4':
            from TrigMbD3PDMaker.LucidDigitD3PDObject import LucidDigitD3PDObject
            d3pdalg += LucidDigitD3PDObject(10)

    if minbiasD3PDflags.doZDC() and globalflags.DataSource == "data":
        ##ZDC object
        from ForwardDetectorsD3PDMaker.ZdcD3PDObject import ZdcD3PDObject
        from ForwardDetectorsD3PDMaker.ZdcDigitsD3PDObject import ZdcDigitsD3PDObject
        d3pdalg += ZdcD3PDObject(10)
        d3pdalg += ZdcDigitsD3PDObject(10)

    from CaloD3PDMaker.MBTSTimeD3PDObject import MBTSTimeD3PDObject
    d3pdalg += MBTSTimeD3PDObject(10)

    from TrackD3PDMaker.VertexGroupD3PD import VertexGroupD3PD
    VertexGroupD3PD(d3pdalg)

    def _args(level, name, kwin, **kw):
        kw = kw.copy()
        kw['level'] = level
        for (k, v) in kwin.items():
            if k.startswith(name + '_'):
                kw[k[len(name) + 1:]] = v
        return kw

    #--------------------------------------------------------------
    # Clusters
    #--------------------------------------------------------------

    from CaloD3PDMaker.ClusterD3PDObject import ClusterD3PDObject

    if minbiasD3PDflags.doClusterHad():
        # define clusters
        from CaloD3PDMaker import ClusterMomentFillerTool as CMFT
        myMoments = [
            CMFT.CENTER_LAMBDA, 'center_lambda', CMFT.LATERAL, 'lateral',
            CMFT.LONGITUDINAL, 'longitudinal', CMFT.ISOLATION, 'isolation',
            CMFT.SIGNIFICANCE, 'significance', CMFT.CELL_SIGNIFICANCE,
            'cellSignificance', CMFT.CELL_SIG_SAMPLING, 'cellSigSampling'
        ]

        d3pdalg += ClusterD3PDObject(**_args(0,
                                             'CaloCalTopoCluster',
                                             kw,
                                             prefix='cl_had_',
                                             include='Moments',
                                             Kinematics_WriteE=True,
                                             Moments_Moments=myMoments))

    if minbiasD3PDflags.doClusterEM():
        d3pdalg += ClusterD3PDObject(**_args(0,
                                             'CaloCalTopoCluster',
                                             kw,
                                             prefix='cl_em_',
                                             Kinematics_WriteE=True,
                                             Kinematics_SignalState=0))

    #--------------------------------------------------------------
    # Alfa
    #--------------------------------------------------------------

    if globalflags.DataSource == "data":
        IOVDbSvc = Service("IOVDbSvc")

        from IOVDbSvc.CondDB import conddb
        ####for other possible servers see dbreplica.config in Athena
        #     #installation
        #   IOVDbSvc.dbConnection="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_DCS;dbname=COMP200"
        if not conddb.folderRequested('/RPO/DCS/BLM'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/BLM")
        if not conddb.folderRequested('/RPO/DCS/FECONFIGURATION'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/FECONFIGURATION")
        if not conddb.folderRequested('/RPO/DCS/HVCHANNEL'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/HVCHANNEL")
        if not conddb.folderRequested('/RPO/DCS/LOCALMONITORING'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/LOCALMONITORING")
        if not conddb.folderRequested('/RPO/DCS/MOVEMENT'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/MOVEMENT")
        if not conddb.folderRequested('/RPO/DCS/RADMON'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/RADMON")
        if not conddb.folderRequested('/RPO/DCS/TRIGGERRATES'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/TRIGGERRATES")
        if not conddb.folderRequested('/RPO/DCS/TRIGGERSETTINGS'):
            conddb.addFolder("DCS_OFL", "/RPO/DCS/TRIGGERSETTINGS")

    if jobproperties.Rec.doAlfa:
        from ForwardDetectorsD3PDMaker.AlfaD3PDObject import AlfaD3PDObject
        # d3pdalg += EventInfoD3PDObject(10)
        d3pdalg += AlfaD3PDObject(0)
        from ForwardDetectorsD3PDMaker import AlfaEventHeaderFillerTool
        if globalflags.DataSource == "data":
            AlfaEventHeaderFillerTool.DataType = 1
            from ForwardDetectorsD3PDMaker.AlfaDCSMetadata import addAlfaDcsMetadata
            addAlfaDcsMetadata(d3pdalg)
        elif globalflags.DataSource == "geant4":
            AlfaEventHeaderFillerTool.DataType = 0
예제 #4
0
def TrigBJetD3PDObjects(alg,
                        level=10,
                        doAddL2ID=False,
                        doAddEFID=False,
                        addNaviInfo=True,
                        addConfigInfo=True,
                        addL1Jet=True,
                        addOffTrack=False):

    # Run FlatHltNaviMaker algorithm prior to do anything on D3PDs
    if (addNaviInfo):
        alg += InitTrigD3PDObject(level)

    # Trigger navigation info
    if (addNaviInfo):
        from TriggerD3PDMaker.TrigNaviD3PDObject import ChainEntryD3PDObject, \
                                                        CombLinksD3PDObjects
        if not hasattr(alg, "trig_Nav_Filler"):
            alg += ChainEntryD3PDObject(level)  # prefix = "trig_Nav_"
        # prefix = "trig_RoI_"
        for roi in ['L2_b', 'EF_b', 'L2_j', 'EF_j']:
            if not hasattr(alg, 'trig_RoI_%s_Filler' % roi):
                alg += CombLinksD3PDObjects[roi](level)

    # LVL1 Jet RoI
    if (addL1Jet):
        from TriggerD3PDMaker.JetROID3PDObject import JetROID3PDObject
        if not hasattr(alg, 'trig_L1_jet_Filler'):
            alg += JetROID3PDObject(10)

    # Add the LVL2 jet information:
    if (addL1Jet):
        from TrigJetD3PDMaker.TrigJetD3PDObject import TrigJetD3PDObject
        if not hasattr(alg, 'trig_L2_jet_Filler'):
            alg += TrigJetD3PDObject(level)

    # Add the EF jet information:
    if (addL1Jet):
        from TrigJetD3PDMaker.EFJetD3PDObject import EFJetD3PDObject
        if not hasattr(alg, 'trig_EF_jet_Filler'):
            alg += EFJetD3PDObject(level)

    # Add the trigger configuration metadata:
    if (addConfigInfo):
        from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata
        addTrigConfMetadata(alg)

    # Add the full trigger decision information:
    from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
    if not hasattr(alg, 'TrigDecisionFiller'):
        alg += TrigDecisionD3PDObject(level)

    # Add information about the LVL2 tracks
    if doAddL2ID:
        #from RecExConfig.RecFlags import rec
        #if rec.readAOD():
        #    print "WARNING: TrigBJetD3PDMaker will not dump L2 tracks when reading from AOD. The L2 tracks are not stored in the AOD."
        #else:
        from TrigInDetD3PDMaker.TrigInDetTrackD3PDObject import TrigInDetTrackD3PDObject
        alg += TrigInDetTrackD3PDObject(level,
                                        sgkey='HLT_TrigSiTrack_Jet',
                                        prefix="trig_L2_sitrk_jet_",
                                        allowMissing=True)
        alg += TrigInDetTrackD3PDObject(level,
                                        sgkey='HLT_TrigIDSCAN_Jet',
                                        prefix="trig_L2_idtrk_jet_",
                                        allowMissing=True)
        alg += TrigInDetTrackD3PDObject(level,
                                        sgkey='HLT_TrigL2SiTrackFinder_Jet',
                                        prefix="trig_L2_star_sitrk_jet_",
                                        allowMissing=True)

    # Add information about the EF tracks:
    if doAddEFID:
        ## should not modify TrackD3PDFlags global flags!!!
        #from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags
        #EFTrackD3PDFlags = TrackD3PDFlags # We should probably make our own version of that! TODO
        #EFTrackD3PDFlags.storeTrackSummary = True
        #EFTrackD3PDFlags.storeTrackFitQuality = True
        #EFTrackD3PDFlags.storeTrackMomentum = True
        #EFTrackD3PDFlags.storeTrackInfo = True
        # Add A LOT of details!
        #EFTrackD3PDFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 3
        #EFTrackD3PDFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3
        #EFTrackD3PDFlags.trackParametersAtBeamSpotLevelOfDetails = 3
        #EFTrackD3PDFlags.storeDiagonalCovarianceAsErrors = True

        from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject
        EFTrackD3PDObject = TrackD3PDObject(
            _label="trig_EF_bjetid_",
            _prefix="trig_EF_bjetid_",
            _sgkey="HLT_InDetTrigParticleCreation_Bjet_EFID",
            typeName="Rec::TrackParticleContainer",
            #truthMapKey = 'TrackParticleTruthCollection',
            doTruth=True,
            #TruthParticleTarget='mc_',
            truthTarget='mc_',
            storeHitTruthMatching=True,
            storeTrackSummary=True,
            storeTrackFitQuality=True,
            storeTrackMomentum=True,
            storeTrackInfo=True,
            trackParametersAtGlobalPerigeeLevelOfDetails=3,
            trackParametersAtPrimaryVertexLevelOfDetails=3,
            trackParametersAtBeamSpotLevelOfDetails=3,
            storeDiagonalCovarianceAsErrors=True)
        #flags = EFTrackD3PDFlags )

        from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
        import TrackD3PDMaker
        BJetEFTrackVertAssoc = SimpleAssociation \
                            ( EFTrackD3PDObject,
                              TrackD3PDMaker.TrackParticleVertexAssociationTool,
                              prefix = 'vert',
                              blockname = "trigEFIDAssoc" )
        BJetEFTrackVertAssoc.defineBlock(
            2, 'Vertex', TrackD3PDMaker.VertexPositionFillerTool)

        alg += EFTrackD3PDObject(level)

    if addOffTrack:
        # Add offline track information
        from TrackD3PDMaker.TrackD3PDObject import TrackParticleD3PDObject
        alg += TrackParticleD3PDObject(level)

    #from TrackD3PDMaker.TrackD3PDObject import PixelTrackD3PDObject
    #from TrackD3PDMaker.TrackD3PDObject import SCTTrackD3PDObject
    #from TrackD3PDMaker.TrackD3PDObject import TRTTrackD3PDObject
    #alg += PixelTrackD3PDObject(level)
    #alg += SCTTrackD3PDObject(level)
    #alg += TRTTrackD3PDObject(level)

    #
    # Add the b-jet information:
    #
    from TrigBJetD3PDMaker.TrigL2BjetD3PDObject import TrigL2BjetD3PDObject
    from TrigBJetD3PDMaker.TrigEFBjetD3PDObject import TrigEFBjetD3PDObject
    alg += TrigL2BjetD3PDObject(level)
    alg += TrigEFBjetD3PDObject(level)

    # Add EF VxCandidates information
    from TrigBJetD3PDMaker.EFPVD3PDObject import EFPVD3PDObject
    alg += EFPVD3PDObject(level)

    # Add TrigVertex information for L2/EF PV information
    #from TrigInDetD3PDMaker.TrigVertexD3PDObject import TrigVertexD3PDObject
    from TrigBJetD3PDMaker.TrigVertexBjetD3PDObject import TrigVertexBjetD3PDObject
    trigVertexBjetD3PDObject = TrigVertexBjetD3PDObject(level)
    #    trigVertexBjetD3PDObject.OutputLevel = 1
    alg += trigVertexBjetD3PDObject

    from TrigBJetD3PDMaker.TrigVertexEFBjetD3PDObject import TrigVertexEFBjetD3PDObject
    trigVertexEFBjetD3PDObject = TrigVertexEFBjetD3PDObject(level)
    #    trigVertexEFBjetD3PDObject.OutputLevel = 1
    alg += trigVertexEFBjetD3PDObject
예제 #5
0
if TrackD3PDPixelFlags.storePixelClusters:    
    alg += PixelClusterD3PDObject(8)
    #alg_2 += PixelClusterD3PDObject(8)

if TrackD3PDPixelFlags.storeBCMrdo:
    alg += BcmRdoD3PDObject(8)

if TrackD3PDPixelFlags.storeTriggerInfo:
    ## Configure Trigger reading
    DoTrigger = True
    if DoTrigger and False:
        from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
        cfg = TriggerConfigGetter("ReadPool")

    #alg += CtpDecisionD3PDObject(10)
    #if TrackD3PDPixelFlags.doPixelNtupleExtended:
    #    alg += CtpRdoD3PDObject(10)
    alg += TrigDecisionD3PDObject(3)
    addTrigConfMetadata(alg)
    
###################################################################################################################

if globalflags.InputFormat() == 'bytestream':
    from AnalysisTools.AnalysisToolsConf import AANTupleStream
    AANTupleStream('D3PD').ExistDataHeader = False



#theApp.CreateSvc += ["FPEControlSvc"]
예제 #6
0
def MCPphysicsD3PD(file,
                   tuplename='physics',
                   seq=topSequence,
                   D3PDSvc='D3PD::RootD3PDSvc',
                   streamNameRoot=None,
                   **kw):

    # define track and cluster filters

    filter1 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='GoodTracks',
                                 ptCut=0.,
                                 nSCTPix=4)

    filter2 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='HighPtTracks',
                                 ptCut=5000.,
                                 nSCTPix=4)

    filter3 = makeClusterFilter(InputName=D3PDMakerFlags.ClusterSGKey(),
                                OutputName='HighPtClusters',
                                ptCut=10000.)

    # FIXME (Maarten) : I need to give the container name explicitly apparently
    filter4 = makeClusterFilter(InputName='EMTopoCluster430',
                                OutputName='HighPtEMClusters',
                                ptCut=10000.)

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    preseq += filter1
    preseq += filter2
    preseq += filter3
    preseq += filter4

    # now configure the D3PD

    alg = MSMgr.NewRootStream(StreamName=streamNameRoot,
                              FileName=file,
                              TreeName=tuplename)

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

    # 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,
#                                                exclude = ['EMTrackFitDetails','EgammaJetSignedIPAndPTRelKin']))

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

    # Muon blocks

    alg += MuonD3PDObject(**_args(
        10,
        'Muons',
        kw,
        sgkey='Muons',
        prefix='mu_',
        include=[
            "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex", "L2CBInfoIndex",
            "L1InfoIndex"
        ],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))
    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))
    alg += MuonD3PDObject(**_args(
        0, 'CaloMuon', kw, sgkey='CaloMuonCollection', prefix='mu_calo_'))

    # Tau block

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

    # Jet blocks

    alg += JetD3PDObject(
        **_args(3,
                'AK4TopoEMJet',
                kw,
                sgkey='AntiKt4TopoEMJets',
                prefix='jet_akt4topoem_',
                include=['BTag', 'TrueFlavorComponents', 'BTagComponents'],
                allowMissing=True))
    alg += JetD3PDObject(
        **_args(3,
                'AK6TopoEMJet',
                kw,
                sgkey='AntiKt6TopoEMJets',
                prefix='jet_akt6topoem_',
                include=['BTag', 'TrueFlavorComponents', 'BTagComponents'],
                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

    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_Composition'
        ],
        allowMissing=True))

    # HadronicRecoil blocks

    #    alg += ElectronD3PDObject(0,  sgkey = "HR_selectedElectrons", prefix = "hr_el_")
    #    alg += MuonD3PDObject( 0,     sgkey = "HR_selectedMuons",     prefix = "hr_mu_" )
    #    alg += MissingETD3PDObject(0, sgkey = "RoughRecoil",          prefix = "hr_roughRecoil")
    #    alg += MissingETD3PDObject(0, sgkey = "ueCorrection",         prefix = "hr_ueCorrection")

    # 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_'))

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

    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.trackParametersAtBeamSpotLevelOfDetails = 0
    highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
    highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3

    from TrackD3PDMaker.TrackD3PDObject import TrackD3PDObject

    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_'))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJet',
                                     kw,
                                     sgkey='AntiKt6TruthJets',
                                     prefix='jet_antikt6truth_'))
        alg += JetD3PDObject(**_args(1,
                                     'AK4TruthJetALL',
                                     kw,
                                     sgkey='AntiKt4TruthJets_ALL',
                                     prefix='jet_antikt4truthALL_'))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJetALL',
                                     kw,
                                     sgkey='AntiKt6TruthJets_ALL',
                                     prefix='jet_antikt6truthALL_'))
        alg += JetD3PDObject(**_args(1,
                                     'AK4TruthJetWZ',
                                     kw,
                                     sgkey='AntiKt4TruthJets_WZ',
                                     prefix='jet_antikt4truthWZ_'))
        alg += JetD3PDObject(**_args(1,
                                     'AK6TruthJetWZ',
                                     kw,
                                     sgkey='AntiKt6TruthJets_WZ',
                                     prefix='jet_antikt6truthWZ_'))

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

    # Trigger

    if D3PDMakerFlags.DoTrigger():

        # 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, 0)
        #        TrigMuonD3PDObjects( alg, 0)

        # 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()]

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

    return alg
예제 #7
0
from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject
d3pdalg += EventInfoD3PDObject(2)
#trigalg += EventInfoD3PDObject( 0, exclude = [ "eventMu", "eventType" ] )
if triggerAvailable:
    from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
    d3pdalg += BGCodeD3PDObject(0)
    pass

##
## Add the encoded trigger decision. It has to be done at the beginning,
## because some of the following functions would add it with a lower
## detail level.
##
if triggerAvailable:
    from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
    d3pdalg += TrigDecisionD3PDObject(10)
    pass

##
## Offline e/gamma information:
##
oflEgammaIncludes = ['ClusterKin']
from egammaD3PDMaker.ElectronD3PDObject import ElectronD3PDObject
added = False
for sgkey in D3PDMakerFlags.ElectronSGKey().split(","):
    if cfgKeyStore.isInInput("ElectronContainer", sgkey):
        d3pdalg += ElectronD3PDObject(1, include=oflEgammaIncludes)
        added = True
        break
    pass
if not added:
예제 #8
0
def backgroundD3PD(alg=None,
                   level=10,
                   file='background.root',
                   tuplename='background',
                   flags=BackgroundD3PDMakerFlags,
                   **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    if (not hasattr(topSequence, 'BeamBackgroundFiller')
            and not hasattr(preseq, 'BeamBackgroundFiller')):
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            from RecBackgroundAlgs import RecBackgroundAlgsConf
            preseq += RecBackgroundAlgsConf.BeamBackgroundFiller()

    if (not hasattr(topSequence, 'BeamBackgroundFillerMoore')
            and not hasattr(preseq, 'BeamBackgroundFillerMoore')):
        if cfgKeyStore.isInInput("Trk::SegmentCollection", "MooreSegments"):
            from RecBackgroundAlgs.RecBackgroundAlgsConf import BeamBackgroundFiller
            BeamBackgroundFillerMoore = BeamBackgroundFiller(
                'BeamBackgroundFillerMoore',
                muonSegmentContainerKey='MooreSegments',
                BeamBackgroundKey='BeamBackgroundDataMoore')
            preseq += BeamBackgroundFillerMoore

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

    #Event level info
    alg += EventInfoD3PDObject(**_args(1, 'EventInfo', kw))
    if globalflags.DataSource == "data":
        alg += LBLengthD3PDObject(**_args(0, 'LBLength', kw))

    if rec.doTruth():
        from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
        alg += GenEventD3PDObject(**_args(0, 'GenEvent', kw))

    if rec.doTrigger():
        alg += TrigDecisionD3PDObject(**_args(2, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        bcToolType = ""
        if globalflags.DataSource == "data":
            bcToolType = "LHC"
        addBunchStructureMetadata(alg, bcToolType)

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

        if flags.AddTriggerBits():
            alg += getBkgdTriggerBitsD3PDObject([])

    alg += BackgroundWordD3PDObject(**_args(0, 'BkgWord', kw))
    if flags.doLUCID():
        alg += Lucid_RawDataD3PDObject(**_args(0, 'Lucid', kw))
    alg += RawInfoSummaryForTagD3PDObject(**_args(0, 'SumForTag', kw))

    alg += MBTSD3PDObject(**_args(0, 'MBTS', kw))
    alg += LArCollisionTimeD3PDObject(**_args(0, 'LArTimeDiff', kw))

    if flags.doMet():
        alg += MissingETD3PDObject(**_args(1,
                                           'MET_RefFinal',
                                           kw,
                                           sgkey='MET_RefFinal',
                                           prefix='MET_RefFinal',
                                           allowMissing=True))

    alg += MuonD3PDObject(
        **_args(0,
                'Muon',
                kw,
                sgkey='MuonCollection',
                prefix='mu_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    alg += MuonD3PDObject(
        **_args(0,
                'MuidMuon',
                kw,
                sgkey='MuidMuonCollection',
                prefix='mu_muid_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    alg += MuonD3PDObject(
        **_args(0,
                'StacoMuon',
                kw,
                sgkey='StacoMuonCollection',
                prefix='mu_staco_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    if flags.doCaloMuon():
        alg += MuonD3PDObject(
            **_args(0,
                    'CaloMuon',
                    kw,
                    sgkey='CaloMuonCollection',
                    prefix='mu_calo_',
                    include=[
                        "Isolation", "Quality", "MuonTimingFillerTool",
                        "MuonTileTimeTool", "ChamberT0"
                    ],
                    allowMissing=True))

    alg += MuonSegmentD3PDObject(**_args(
        1,
        'MuonSeg',
        kw,
        sgkey='MuonSegments',
        prefix='museg_',
        # MooreSegmentT0 takes the default time
        # MuonboySegmentT0 recalculates time (see MuonSegmentD3PDObject.py and MuonSegmentT0FillerTool.cxx)
        include=['MooreSegmentT0'],
        exclude=['MuonboySegmentT0'],
        allowMissing=True))
    alg += MuonSegmentD3PDObject(**_args(1,
                                         'MooreSeg',
                                         kw,
                                         sgkey='MooreSegments',
                                         prefix='mooreseg_',
                                         include=['MooreSegmentT0'],
                                         exclude=['MuonboySegmentT0'],
                                         allowMissing=True))
    alg += MuonSegmentD3PDObject(**_args(1,
                                         'MboySeg',
                                         kw,
                                         sgkey='ConvertedMBoySegments',
                                         prefix='mboyseg_',
                                         include=['MuonboySegmentT0'],
                                         exclude=['MooreSegmentT0'],
                                         allowMissing=True))
    if flags.doMuGirlSeg():
        alg += MuonSegmentD3PDObject(**_args(1,
                                             'MuGirlSeg',
                                             kw,
                                             sgkey='MuGirlSegments',
                                             prefix='mgseg_',
                                             include=['MooreSegmentT0'],
                                             exclude=['MuonboySegmentT0'],
                                             allowMissing=True))

    if flags.doTrk():
        alg += xAODTrackParticleD3PDObject(
            **_args(0, 'TrackParticle', kw, prefix='trk_'))

    if flags.doMuonHits():
        alg += MdtPrepDataD3PDObject(0)
        alg += RpcPrepDataD3PDObject(0)
        alg += CscPrepDataD3PDObject(0)
        alg += TgcPrepDataD3PDObject(0)

        alg += TgcPrepDataD3PDObject(**_args(0,
                                             'TGC_MeasurementsPriorBC',
                                             kw,
                                             sgkey='TGC_MeasurementsPriorBC',
                                             prefix='tgcPriorBC_',
                                             label='TgcPrepDataPriorBC'))
        alg += TgcPrepDataD3PDObject(**_args(0,
                                             'TGC_MeasurementsNextBC',
                                             kw,
                                             sgkey='TGC_MeasurementsNextBC',
                                             prefix='tgcNextBC_',
                                             label='TgcPrepDataNextBC'))

    if flags.doCaloJet():
        #alg += JetD3PDObject (**_args(4,'AntiKt4TopoEMJets', kw,  sgkey='AntiKt4TopoEMJets',   prefix='AntiKt4TopoEM_', include='BeamBackground' ))
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            alg += JetD3PDObject(
                **_args(4,
                        'AntiKt4TopoEMJets',
                        kw,
                        sgkey='AntiKt4TopoEMJets',
                        prefix='AntiKt4TopoEM_',
                        include=['BeamBackground'],
                        exclude=[
                            'JetVertexFraction', 'JVtx', 'ActiveArea',
                            'TruthMF', 'TracksMoments'
                        ],
                        BeamBackground_BeamBackgroundKey='BeamBackgroundData'))
        else:
            alg += JetD3PDObject(
                **_args(4,
                        'AntiKt4TopoEMJets',
                        kw,
                        sgkey='AntiKt4TopoEMJets',
                        prefix='AntiKt4TopoEM_',
                        exclude=[
                            'JetVertexFraction', 'JVtx', 'ActiveArea',
                            'TruthMF', 'TracksMoments'
                        ]))
    else:
        alg += JetD3PDObject(
            **_args(4,
                    'AntiKt4TrackJets',
                    kw,
                    sgkey='AntiKt4TrackJets',
                    prefix='AntiKt4Track_',
                    exclude=[
                        'JetVertexFraction', 'JVtx', 'ActiveArea', 'TruthMF',
                        'TracksMoments'
                    ]))

    alg += PrimaryxAODVertexD3PDObject(0)

    if flags.doBeamBkgd():
        #alg += BeamBackgroundD3PDObject(1)
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            alg += BeamBackgroundD3PDObject(
                **_args(1,
                        'BeamBackgroundData',
                        kw,
                        sgkey='BeamBackgroundData',
                        prefix='bb_',
                        bbJetIndex_Target='AntiKt4TopoEM_',
                        bbClusterIndex_Target='cl_'))
        if cfgKeyStore.isInInput("Trk::SegmentCollection", "MooreSegments"):
            alg += BeamBackgroundD3PDObject(
                **_args(1,
                        'BeamBackgroundData',
                        kw,
                        sgkey='BeamBackgroundDataMoore',
                        prefix='bbMoore_',
                        bbJetIndex_Target='AntiKt4TopoEM_',
                        bbClusterIndex_Target='cl_'))

    if flags.doBCM():
        alg += BcmRdoFlatD3PDObject(**_args(0, 'BCMRdo', kw))

    if flags.doZDC():
        if globalflags.DataSource == "data": alg += ZdcD3PDObject(10)

    if flags.doPixelClus():
        from InDetD3PDMaker.PixelClusterD3PDObject import PixelClusterD3PDObject
        alg += PixelClusterD3PDObject(0)

    if flags.doCaloClus():
        from CaloSysD3PDMaker.ClusterD3PDObject import ClusterD3PDObject
        alg += ClusterD3PDObject(1)

    return alg
예제 #9
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
예제 #10
0
def ZPrimeEED3PD(alg=None,
                 file='smwz.root',
                 tuplename='physics',
                 streamname='d3pdstream',
                 doSoftQCD=False,
                 **kw):

    # 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))

    # Electron/Photon blocks
    elInclude = [
        'HadLeakage',
        'Layer1Shape',
        'Layer1ShapeExtra',
        'Layer2Shape',
        'Layer3Shape',
        'Iso',
        'IsoPtCorrected',
        'ConvFlags',
        'Conversion',
        'TrkMatch',
        'Retaphi',
        'Rings',
        'ElecDiscrim',
        'Pointing',
        'Samplings',
        'ClusterKin',
        'FwdEVars',
        'D3PD__egammaRawClusterAssociationTool',
        'RawSamplings',
        'RawClusterKin',
        'TrkInfo',
        'Trk',
        'TrkFitQuality',
        'IDHits',
        'TrackSummaryPID',
        'Vertex',
        'trackImpactbeam',
        'trackImpactSigbeam',
        'trackImpactpv',
        'trackImpactSigpv',
        'trackOldImpactpvunbiased',
        'trackImpactpvunbiased',
        'UDLayer1Shape',
        'UDShowerDepth',
        'IsIso',
        'MVAIso',
        'JetMatch',
        'JetKinematics',
        'PAU',
        'PAUVariables',
        'EFIndex',
        'L2Index',
        'L1Index',
    ]
    elExclude = []
    alg += ElectronD3PDObject(
        **_args(0,
                'Electron',
                kw,
                sgkey=kw.get('electronContainer', 'ElectronAODCollection'),
                include=elInclude,
                exclude=elExclude))

    phInclude = [
        'HadLeakage', 'Layer1Shape', 'Layer1ShapeExtra', 'Layer2Shape', 'Iso',
        'IsoPtCorrected', 'Conversion', 'Retaphi', 'TopoClusterIsolationCones',
        'Pointing', 'ClusterKin', 'Samplings', 'UDTopoCones', 'CorrIso',
        'ConvIP', 'TopoMatch', 'TopoKinematics', 'TopoEMMatch',
        'TopoEMKinematics'
    ]
    phExclude = []
    alg += PhotonD3PDObject(
        **_args(0,
                'Photon',
                kw,
                sgkey=kw.get('photonContainer', 'PhotonAODCollection'),
                include=phInclude,
                exclude=phExclude))

    # Muon blocks
    muInclude = ['AcceptMethods']
    muExclude = [
        'TrkInfo', 'EFCBInfoIndex', 'EFCBInfo', 'EFMGInfo', 'EFMEInfo',
        'L2CBInfoIndex', 'L2CBInfo', 'L1InfoIndex', 'L1Info', 'AllAuthor',
        'SelectionFlagging', 'CBTrackDetails', 'MGTrackDetails'
    ]

    #Muid
    if cfgKeyStore.isInInput("Analysis::MuonContainer", "MuidMuonCollection"):
        alg += MuonD3PDObject(**_args(0,
                                      'MuidMuon',
                                      kw,
                                      sgkey='MuidMuonCollection',
                                      prefix='mu_muid_',
                                      include=muInclude,
                                      exclude=muExclude,
                                      allowMissing=True))

    #Staco
    if cfgKeyStore.isInInput("Analysis::MuonContainer", "StacoMuonCollection"):
        alg += MuonD3PDObject(**_args(0,
                                      'StacoMuon',
                                      kw,
                                      sgkey='StacoMuonCollection',
                                      prefix='mu_staco_',
                                      include=muInclude,
                                      exclude=muExclude,
                                      allowMissing=True))

    #Third chain
    if cfgKeyStore.isInInput("Analysis::MuonContainer", "Muons"):
        alg += MuonD3PDObject(**_args(0,
                                      'Muons',
                                      kw,
                                      sgkey='Muons',
                                      prefix='mu_',
                                      include=muInclude,
                                      exclude=muExclude,
                                      allowMissing=True))

    # Jet blocks
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags

    alg += JetD3PDObject(**_args(1,
                                 'AK4TopoEMJet',
                                 kw,
                                 sgkey='AntiKt4TopoEMJets',
                                 prefix='jet_AntiKt4TopoEM_',
                                 include=[],
                                 exclude=[
                                     'JESMoments', 'JVtx', 'El02Match',
                                     'Mu02Match', 'L1Info', 'L2Info', 'EFInfo'
                                 ],
                                 allowMissing=True))

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

    #MET
    metKeys = [
        'MET_LocHadTopo', 'MET_RefFinal', 'MET_RefEle', 'MET_RefMuon',
        'MET_RefMuon_Staco', 'MET_RefMuon_Muid', 'MET_CorrTopo',
        'MET_RefFinal_em', 'MET_Topo', 'MET_Calib', 'MET_CellOut_Eflow_Muons',
        'MET_CellOut_Eflow', 'MET_CellOut_Eflow_Muid', 'MET_MuonBoy',
        'MET_Muons', 'MET_Muid', 'MET_RefMuons', 'MET_RefFinal_STVF',
        'MET_RefJet_JVF', 'MET_RefJet_JVFCut', 'MET_CellOut_Eflow_STVF',
        'MET_CellOut_Eflow_JetArea'
    ]

    for key in metKeys:
        alg += MissingETD3PDObject(
            **_args(-1,
                    key,
                    kw,
                    prefix=key,
                    sgkey=key,
                    include=['MET_Phi', 'MET_Et', 'MET_SumEt'],
                    exclude=[],
                    allowMissing=True))
    #EMFrac for MET_LocHadTopo
    alg += TopoMETD3PDObject(
        **_args(-1,
                'MET_LocHadTopo_SUMET_EMFrac',
                kw,
                prefix='MET_LocHadTopo_',
                name_prefix='MET_LocHadTopo_SUMET_EMFrac_',
                sgkey='MET_LocHadTopo',
                include=['MET_Calo_EMFracSET'],
                exclude=[],
                allowMissing=True))

    # Primary vertex block - May be missing in single-beam data.
    alg += PrimaryVertexD3PDObject(**_args(1,
                                           'PrimaryVertex',
                                           kw,
                                           allowMissing=True,
                                           sgkey=D3PDMakerFlags.VertexSGKey(),
                                           prefix='vxp_'))
    # 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))
    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)

    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += ZPrimeEETriggerBitsD3PDObject(
            **_args(10, 'ZPrimeEETriggerBits', kw))

        # Trigger Decision + metadata

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

        # Egamma
        alg += InitTrigD3PDObject(1)
        alg += EmTauROID3PDObject(1,
                                  prefix="trig_L1_emtau_",
                                  exclude=['ThrInfo'])
        alg += TrigElectronD3PDObject(
            1,
            name='trig_L2_el_',
            prefix='trig_L2_el_',
            sgkey='HLT_L2ElectronFex,HLT_L2IDCaloFex',
            allowMissing=True)
        alg += TrigPhotonD3PDObject(1,
                                    name='trig_L2_ph_',
                                    prefix='trig_L2_ph_')
        alg += EFElectronD3PDObject(1,
                                    name='trig_EF_el_',
                                    sgkey='HLT_egamma_Electrons,HLT_egamma',
                                    prefix='trig_EF_el_',
                                    allowMissing=True)
        alg += EFPhotonD3PDObject(1,
                                  name='trig_EF_ph_',
                                  sgkey='HLT_egamma_Photons,HLT_egamma',
                                  prefix='trig_EF_ph_',
                                  allowMissing=True)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #11
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
예제 #12
0
def WPrimeMND3PD (alg = None,
              file = 'smwz.root',
              tuplename = 'physics',
              streamname = 'd3pdstream',
              doSoftQCD = False,
              doThirdMuonChain = True,
              **kw):
			  
    # 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))
    
    # Muon blocks

### 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"],
                                                        exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info","SelectionFlagging",
	    													  "Likelihood","TrkMatchQuality","Quality","MuonTimingFillerTool","TrkParameters",
	    													  "TrkCovDiag","TrkCovOffDiag","TrkFitQuality","TrkInfoInDet","L2CBInfoIndex", "L1InfoIndex"],
                                                        allowMissing = True ))
### Third muon chain variables!        



    if cfgKeyStore.isInInput( "Analysis::MuonContainer", "StacoMuonCollection" ):
        alg += MuonD3PDObject             (**_args (10, 'StacoMuon', kw,
                                                    sgkey='StacoMuonCollection', prefix='mu_staco_',
                                                    include = ["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex"],
                                                    exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info","SelectionFlagging",
						    								  "Likelihood","TrkMatchQuality","Quality","MuonTimingFillerTool","TrkParameters",
						    								  "TrkCovDiag","TrkCovOffDiag","TrkFitQuality","TrkInfoInDet","L2CBInfoIndex", "L1InfoIndex"],
                                                    allowMissing = True ))

    # Jet blocks
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags

    alg += JetD3PDObject              (**_args ( 1, 'AK4TopoEMJet', kw,
                                                 sgkey='AntiKt4TopoEMJets', prefix='jet_AntiKt4TopoEM_',
                                                 include = [],
                                                 exclude = ['JESMoments','JVtx','OriginCorrection',
                                                            'El02Match','Mu02Match','L1Info','L2Info','EFInfo'],
                                                 allowMissing = True))
    

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

    

    alg += MissingETD3PDObject        (**_args (0, 'MissingET', kw,
                                                include=['MET_RefFinal_Comps','MET_CellOut_Comps','MET_REfFinal','MET_CellOut','MET_CellOut_Eflow',
                                                         'MET_LocHadTopo_Comps','MET_LocHadTopo',
                                                         'MET_LocHadTopoObj_Comps','MET_LocHadTopoObj',
                                                         'MET_MuonBoy_Comps','MET_MuonBoy',
                                                         'MET_MuonBoy_Track_Comps','MET_MuonBoy_Track',
                                                         'MET_RefMuon_Comps','MET_RefMuon','MET_RefMuon_em',
                                                         'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_Comps','MET_RefMuon_Track',
                                                         'MET_RefMuon_em_Comps','MET_SoftJets_Comps','MET_SoftJets','MET_RefMuon_em'
                                                         'MET_SoftJets_em_Comps','MET_Topo_Comps',
                                                         'MET_TopoObj_Comps','MET_Track_Comps','MET_Comps',
                                                         'MET_RefFinal_STVF','MET_RefJet_JVF', 'MET_RefJet_JVFCut',
                                                         'MET_CellOut_Eflow_STVF','MET_CellOut_Eflow_JetArea',
                                                         'MET_Truth_NonInt','MET_Truth_NonInt_Phi','MET_Truth_NonInt_Et','MET_Truth_NonInt_SumEt',
                                                         'MET_CellOut_Eflow_JetAreaRhoEta5JVF',
                                                         ],
                                                allowMissing=True))


    alg+=MissingETCompositionD3PDObject(**_args(4,"MissingETComposition",kw))
    

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

    alg += PrimaryVertexD3PDObject (**_args (1, 'PrimaryVertex', kw,
                                             allowMissing = True,
                                             sgkey = D3PDMakerFlags.VertexSGKey(),
                                             exclude = ["Error","DiagCovariance","Covariance","Purity","TrackAtVertex"],
                                             prefix = 'vxp_'))
        
    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += WPrimeMNTriggerBitsD3PDObject      (**_args (10, 'WPrimeMNTriggerBits', kw))
        
        # Trigger Decision + metadata

        alg += TrigDecisionD3PDObject  (**_args(0, 'TrigDecision', kw))
        addTrigConfMetadata(alg)
		
        
        from TrigMuonD3PDMaker.TrigMuonEFInfoD3PDObject import TrigMuonEFInfoD3PDObject
        alg += TrigMuonEFInfoD3PDObject( **_args( -1, "TrigMuonEF", kw, include=["Decision"] ) )
        #Mu
       # TrigMuonD3PDObjects( alg, 1)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #13
0
# >>>>>Backward compatibility for Staco/Miud<<<<<
if not MuonD3PDFlags.doNewChainOnly:
    StacoD3PDObject = MuonD3PDObject.copy()
    MuidD3PDObject = MuonD3PDObject.copy()
# >>>>>----------------end------------------<<<<<

# Trigger Decision
if D3PDMakerFlags.DoTrigger():
    from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
    from TriggerD3PDMaker.TrigConfMetadata import addTrigConfMetadata
    from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata(MuonD3PDStream)
    # Trigger Decision + metadata
    MuonD3PDStream += TrigDecisionD3PDObject(10)
    addTrigConfMetadata(MuonD3PDStream)
    # Bunch group info
    MuonD3PDStream += BGCodeD3PDObject(2)

# Muon Trigger Info
from TrigMuonD3PDMaker.TrigMuonEFInfoD3PDObject import TrigMuonEFInfoD3PDObject

MuonD3PDStream += TrigMuonEFInfoD3PDObject(0,
                                           include=['Decision'],
                                           exclude=[
                                               'TrackDetails',
                                               'SpectrometerTrackBasics',
                                               'ExtrapolatedTrackBasics'
                                           ],
                                           allowMissing=True)
from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject
InDetTrackD3PDMaker += EventInfoD3PDObject(0, prefix='ei_')
levelOfDetail = 8
if InDetFlags.doTruth():
   levelOfDetail = 10
   from TrackD3PDMaker.TruthTrackD3PDObject import TruthTrackD3PDObject
   InDetTrackD3PDMaker += TruthTrackD3PDObject(levelOfDetail)
   from TrackD3PDMaker.TruthVertexD3PDObject import TruthVertexD3PDObject
   InDetTrackD3PDMaker += TruthVertexD3PDObject(levelOfDetail)
if InDetFlags.doTriggerD3PD():
   from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
   cfg = TriggerConfigGetter("ReadPool")
   from TriggerD3PDMaker.defineTriggerBits import defineTriggerBits
   from TriggerD3PDMaker.TrigConfMetadata  import addTrigConfMetadata
   from TriggerD3PDMaker.TrigDecisionD3PDObject import TrigDecisionD3PDObject
   InDetTrackD3PDMaker += TrigDecisionD3PDObject(0)
   addTrigConfMetadata(InDetTrackD3PDMaker)
if InDetFlags.doTrkD3PD():
   from TrackD3PDMaker.TrackD3PDObject import TrackParticleD3PDObject
   InDetTrackD3PDMaker += TrackParticleD3PDObject(levelOfDetail)
if InDetFlags.doVtxD3PD():
   from TrackD3PDMaker.VertexD3PDObject import PrimaryVertexD3PDObject
   InDetTrackD3PDMaker += PrimaryVertexD3PDObject(levelOfDetail)
if InDetFlags.doV0VtxD3PD():
   from TrackD3PDMaker.V0D3PDObject import V0D3PDObject
   InDetTrackD3PDMaker += V0D3PDObject(10)
if InDetFlags.doPixelTrkD3PD():
   from TrackD3PDMaker.TrackD3PDObject import PixelTrackD3PDObject
   InDetTrackD3PDMaker += PixelTrackD3PDObject(levelOfDetail)
if InDetFlags.doSctTrkD3PD():
   from TrackD3PDMaker.TrackD3PDObject import SCTTrackD3PDObject
예제 #15
0
def WPrimeEND3PD(alg=None,
                 file='smwz.root',
                 tuplename='physics',
                 streamname='d3pdstream',
                 doSoftQCD=False,
                 **kw):

    # now configure the D3PD
    if not alg:
        alg = MSMgr.NewRootStream(StreamName=streamname,
                                  FileName=file,
                                  TreeName=tuplename)

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

    # Electron/Photon blocks
    elInclude = [
        'Kinematics', 'Charge', 'Author', 'isEM', 'OQ', 'HadLeakage',
        'Layer1Shape', 'Layer1ShapeExtra', 'Layer2Shape', 'Layer3Shape', 'Iso',
        'IsoPtCorrected', 'ConvFlags', 'TrkMatch', 'Retaphi', 'Pointing',
        'Samplings', 'ClusterKin', 'D3PD__egammaRawClusterAssociationTool',
        'TrkInfo', 'Truth', 'Trk', 'TrkFitQuality', 'IDHits',
        'TrackSummaryPID', 'Vertex', 'trackOldImpactpvunbiased',
        'trackImpactpvunbiased', 'IsIso', 'MVAIso', 'PAU', 'PAUVariables',
        'EFIndex', 'L1Index', 'trackImpactpv', 'trackPVPerigeeAssoc'
    ]
    alg += ElectronD3PDObject(
        **_args(0,
                'Electron',
                kw,
                sgkey=kw.get('electronContainer', 'ElectronAODCollection'),
                include=elInclude))

    alg += PhotonD3PDObject(**_args(0,
                                    'Photon',
                                    kw,
                                    include=['ClusterKin'],
                                    exclude=['IsEMCuts', 'IsGoodOQCuts']))

    # Jet blocks
    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags

    alg += JetD3PDObject(
        **_args(1,
                'AK4TopoEMJet',
                kw,
                sgkey='AntiKt4TopoEMJets',
                prefix='jet_AntiKt4TopoEM_',
                include=[],
                exclude=[
                    'JESMoments', 'JVtx', 'OriginCorrection', 'El02Match',
                    'Mu02Match', 'L1Info', 'L2Info', 'EFInfo'
                ],
                allowMissing=True))

    alg += JetD3PDObject(
        **_args(1,
                'AK4LCTopoJet',
                kw,
                sgkey='AntiKt4LCTopoJets',
                prefix='jet_AntiKt4LCTopo_',
                include=[],
                exclude=[
                    'JESMoments', 'JVtx', 'OriginCorrection', 'El02Match',
                    'Mu02Match', 'L1Info', 'L2Info', 'EFInfo'
                ],
                allowMissing=True))

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

    #MET
    metKeys = [
        'MET_LocHadTopo', 'MET_RefFinal', 'MET_RefEle', 'MET_RefFinal_em',
        'MET_CellOut_Eflow', 'MET_MuonBoy', 'MET_RefMuons', 'MET_RefMuon',
        'MET_Truth_NonInt', 'MET_RefJet', 'MET_SoftJets', 'MET_RefGamma',
        'MET_RefTau', 'MET_CellOut', 'MET_RefFinal_STVF', 'MET_RefJet_JVF',
        'MET_RefJet_JVFCut', 'MET_CellOut_Eflow_STVF',
        'MET_CellOut_Eflow_JetArea', 'MET_CellOut_Eflow_JetAreaRhoEta5JVF'
    ]

    for key in metKeys:
        alg += MissingETD3PDObject(**_args(
            4,
            key,
            kw,
            prefix=key,
            sgkey=key,
            #include=['MET_Phi','MET_Et','MET_SumEt','MET_etx','MET_ety','MissingETComposition'],
            exclude=[
                'MET_Calo', 'MET_Calo_Phi', 'MET_Calo_Et', 'MET_Calo_SumEt',
                'MET_Calo_EMFracSET', 'MET_Calo_Samplings', 'MET_Calo_Regions'
            ],
            allowMissing=True))
    #EMFrac for MET_LocHadTopo
    alg += TopoMETD3PDObject(
        **_args(-1,
                'MET_LocHadTopo_SUMET_EMFrac',
                kw,
                prefix='MET_LocHadTopo_',
                name_prefix='MET_LocHadTopo_SUMET_EMFrac_',
                sgkey='MET_LocHadTopo',
                include=['MET_Calo_EMFracSET'],
                exclude=[],
                allowMissing=True))

    alg += MissingETCompositionD3PDObject(
        **_args(4, "MissingETComposition", kw))

    # Primary vertex block - May be missing in single-beam data.
    alg += PrimaryVertexD3PDObject(**_args(1,
                                           'PrimaryVertex',
                                           kw,
                                           allowMissing=True,
                                           sgkey=D3PDMakerFlags.VertexSGKey(),
                                           prefix='vxp_'))

    # Trigger

    if D3PDMakerFlags.DoTrigger():

        alg += WPrimeENTriggerBitsD3PDObject(
            **_args(10, 'WPrimeENTriggerBits', kw))

        # Trigger Decision + metadata

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

        # Egamma
        alg += InitTrigD3PDObject(1)

        alg += EFElectronD3PDObject(1,
                                    name='trig_EF_el_',
                                    sgkey='HLT_egamma_Electrons,HLT_egamma',
                                    prefix='trig_EF_el_',
                                    allowMissing=True)
        alg += EFPhotonD3PDObject(1,
                                  name='trig_EF_ph_',
                                  sgkey='HLT_egamma_Photons,HLT_egamma',
                                  prefix='trig_EF_ph_',
                                  allowMissing=True)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #16
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
예제 #17
0
def SMTrilepD3PD(
        alg=None,
        #fileName              = 'smtrilep.root',
        tuplename='physics',
        #streamname           = 'NTUP_SMTRILEP',
        stdElectronContainer='None',
        gsfElectronContainer='None',
        stacoMuonContainer='None',
        muidMuonContainer='None',
        caloMuonContainer='None',
        thirdMuonContainer='None',
        photonContainer='None',
        jetContainer='None',
        jetLC4Container='None',
        clusterContainer='None',
        tauContainer='None',
        trackContainer='None',
        addHadronicRecoil=False,
        **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())

    # perform recoil calculation
    if addHadronicRecoil:
        import HadronicRecoil.Configurables as hrc
        preseq = hrc.add_hadronic_recoil_filters(preseq)

    # configure the D3PD
    if not alg:
        from AthenaCommon.JobProperties import jobproperties
        prodFlags = jobproperties.D3PDProdFlags
        from PrimaryDPDMaker.PrimaryDPDHelpers import buildFileName
        fileName = buildFileName(prodFlags.WriteSMTRILEPD3PD)
        streamName = prodFlags.WriteSMTRILEPD3PD.StreamName

        alg = MSMgr.NewRootStream(StreamName=streamname,
                                  FileName=fileName,
                                  TreeName=tuplename)

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

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    # Electron/Photon blocks
    electron_excludes = [
        #'EMTrackFit',
        #'EMTrackFitDetailsBrem',
        #'EMTrackFitDetailsRefit',
        'EMTrackFitDetailsRefitCov',
        #'TopoClusterIsolationCones',
        'UDTopoCones',
        'Rings',
        'TrackIsoIP',
        'ElecDiscrim',
        'TraversedMaterial',
        'TrkCovDiag',
        'TrkCovOffDiag',
        'TrackSummaryPID',
        'UnrefitTrk',
        'ElectronPointingVariables',
        'MVAIso',
        'IsIso',
        'ElectronClusterQuantities'
    ]

    if stdElectronContainer != 'None':
        alg += ElectronD3PDObject(**_args(10,
                                          'Electron',
                                          kw,
                                          sgkey=stdElectronContainer,
                                          prefix='el_',
                                          exclude=electron_excludes,
                                          allowMissing=True))

    if (gsfElectronContainer != 'None') and testSGKey('ElectronContainer',
                                                      gsfElectronContainer):
        alg += GSFElectronD3PDObject(**_args(1,
                                             'GSFElectron',
                                             kw,
                                             sgkey=gsfElectronContainer,
                                             prefix='el_gsf_',
                                             exclude=electron_excludes,
                                             allowMissing=True))

    D3PDMakerFlags.DoPAU = False
    if photonContainer != 'None':
        alg += PhotonD3PDObject(**_args(0,
                                        '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)

    std_muon_excludes = [
        'EFCBInfo', 'EFMGInfo', 'EFMEInfo', 'L2CBInfo', 'L1Info',
        'MuonTimingFillerTool', 'Likelihood', 'MuonTimingFillerTool',
        'PrimaryTrackDiagonalCovarianceAtPV',
        'PrimaryTrackOffDiagonalCovarianceAtPV',
        'IDTrackDiagonalCovarianceAtPV', 'IDTrackOffDiagonalCovarianceAtPV',
        'METrackDiagonalCovarianceAtPV', 'METrackOffDiagonalCovarianceAtPV',
        'TrkCovDiag', 'TrkCovOffDiag'
    ]
    calo_muon_excludes = [
        'EFCBInfo', 'EFMGInfo', 'EFMEInfo', 'L2CBInfo', 'L1Info',
        'MuonTimingFillerTool', 'Likelihood', 'MuonTimingFillerTool',
        'PrimaryTrackDiagonalCovarianceAtPV',
        'PrimaryTrackOffDiagonalCovarianceAtPV',
        'IDTrackDiagonalCovarianceAtPV', 'IDTrackOffDiagonalCovarianceAtPV',
        'METrackDiagonalCovarianceAtPV', 'METrackOffDiagonalCovarianceAtPV',
        'TrkCovDiag', 'TrkCovOffDiag', 'MGTrackDetails', 'MuGirlTrackBasics',
        'CBTrackDetails', 'CombinedTrackBasics', 'MuonSpectrometerHitSummary'
    ]

    if stacoMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(
            10,
            'StacoMuon',
            kw,
            sgkey=stacoMuonContainer,
            prefix='mu_staco_',
            #include = ['EFCBInfoIndex', 'EFMGInfoIndex', 'EFMEInfoIndex',
            #'MuonScatteringAngleSignificance'],
            exclude=std_muon_excludes,
            allowMissing=True))

    if muidMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'MuidMuon',
                                      kw,
                                      sgkey=muidMuonContainer,
                                      prefix='mu_muid_',
                                      exclude=std_muon_excludes,
                                      allowMissing=True))

    if thirdMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'ThirdMuon',
                                      kw,
                                      sgkey=thirdMuonContainer,
                                      prefix='mu_',
                                      exclude=std_muon_excludes,
                                      allowMissing=True))

    if caloMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'CaloMuon',
                                      kw,
                                      sgkey=caloMuonContainer,
                                      prefix='mu_calo_',
                                      exclude=calo_muon_excludes,
                                      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()
                                     ]))

    if jetLC4Container != 'None':
        alg += JetD3PDObject(**_args(3,
                                     'AK4LCJet',
                                     kw,
                                     sgkey=jetContainer,
                                     allowMissing=True,
                                     prefix='jet_AntiKt4LCTopo_',
                                     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

    if addHadronicRecoil:

        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 += SMTrilepTriggerBitsD3PDObject      (**_args (10, 'SMTrilepTriggerBits', kw))

        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)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #18
0
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
예제 #19
0
def egammaD3PD(alg=None,
               trigalg=None,
               level=10,
               file='egamma.root',
               tuplename='egamma',
               **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    createxAOD(preseq)

    if not cfgKeyStore.isInInput('xAOD::ElectronContainer', 'AllElectrons'):
        preseq += MergeElectrons()

    # Core algorithm
    # By default the user of this function should have created an algorithm already.
    # But for backwards compatibility let the function create its own algorithm if
    # needed...
    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file)

    alg += EventInfoD3PDObject(**_args(level, 'EventInfo', kw))

    # Segregate trigger decision flags in a separate tree.
    if not trigalg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        trigalg = MSMgr.NewRootStream(tuplename + ':' + tuplename + 'TrigDec',
                                      FileName=file,
                                      TreeName=tuplename + 'TrigDec')

    trigalg += EventInfoD3PDObject(0)
    alg.Stream.trigDecisionTree = trigalg

    # Add bunch structure metadata.
    from TriggerD3PDMaker.BunchStructureMetadata \
         import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    alg += LArCollisionTimeD3PDObject(**_args(level, 'LArCollisionTime', kw))
    alg += ElectronD3PDObject(**_args(
        level, 'Electron', kw, EgammaJetSignedIPAndPTRel_target='jet_'))
    alg += PhotonD3PDObject(**_args(level, 'Photon', kw))

    # # Additional muon variables for Zg skims.
    # 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,
        'Muons',
        kw,
        sgkey='StacoMuonCollection,Muons',
        prefix='mu_',
        include=[
            "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex", "L2CBInfoIndex",
            "L1InfoIndex", "MuonScatteringAngleSignificance"
        ],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))

    alg += JetD3PDObject(
        **_args(0, 'Jet', kw, include=['JetQual', 'DQMoments']))
    alg += MBTSD3PDObject(**_args(level, 'MBTS', kw))
    alg += MBTSTimeD3PDObject(**_args(level, 'MBTSTime', kw))
    # alg += MBTSTriggerBitsD3PDObject  (**_args (level, 'MBTSTriggerBits', kw))
    # alg += ZDCTriggerBitsD3PDObject   (**_args (level, 'ZDCTriggerBits', kw))
    alg += CollisionDecisionD3PDObject(**_args(level, 'CollisionDecision', kw))
    alg += MissingETD3PDObject(**_args(level,
                                       'MissingET',
                                       kw,
                                       sgkey='MET_Core_AntiKt4EMTopo',
                                       prefix='MET_RefFinal_'))
    if D3PDMakerFlags.DoTrigger():
        from TriggerD3PDMaker.TrigDecisionD3PDObject \
             import TrigDecisionD3PDObject
        alg += TrigDecisionD3PDObject(**_args(2, 'TrigDecision', kw))
        #TrigEgammaD3PDObjects (alg, **_args (1, 'TrigEgamma', kw,
        #                                     TrigEMCluster_level = 2))

    #     from TriggerD3PDMaker.EnergySumROID3PDObject import EnergySumROID3PDObject
    #     from TrigMissingETD3PDMaker.TrigMETD3PDObject import TrigMETD3PDObject

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

    #     # The LVL2 information:
    #     alg += TrigMETD3PDObject(**_args( level, 'TrigMETL2', kw,
    #                                       prefix = "trig_L2_met_",
    #                                       sgkey = "HLT_T2MissingET" ))
    #     if cfgKeyStore.isInInputFile( "TrigMissingETContainer", "HLT_L2MissingET_FEB" ):
    #         alg += TrigMETD3PDObject(**_args( level, 'TrigMETL2_FEB', kw,
    #                                           prefix = "trig_L2_feb_met_",
    #                                           sgkey = "HLT_L2MissingET_FEB" ))

    #     # The EF information:
    #     alg += TrigMETD3PDObject(**_args ( level, 'TrigMETEF', kw,
    #                                        prefix = "trig_EF_met_",
    #                                        sgkey = "HLT_TrigEFMissingET" ))

    #     from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
    #     alg += BGCodeD3PDObject (**_args (2, 'BGCode', kw))

    # May be missing in single-beam data.
    alg += PrimaryxAODVertexD3PDObject(**_args(
        1,
        'PrimaryVertex',
        kw,
        #allowMissing = True,
        sgkey=D3PDMakerFlags.VertexSGKey(),
        prefix='vxp_',
        storeVertexTrackIndexAssociation=False,
        storeVertexTrackAssociation=True,
        storeDiagonalCovarianceAsErrors=True))

    if rec.doTruth():
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject(**_args(level, 'TruthMuon', kw))
        alg += TruthEventD3PDObject(**_args(1, 'TruthEvent', kw))
        alg += TruthParticleD3PDObject(**_args(level, 'TruthParticle', kw))

    # alg.MetadataTools += [LBMetadataConfig()]

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

    return alg
예제 #20
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
예제 #21
0
def HSG2physicsD3PD(name, file, tuplename='physics', **kw):

    from AthenaCommon.AlgSequence import AlgSequence  # needed for attila's code
    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags  # needed for attila's code

    # define track and cluster filters
    filter1 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='GoodTracks' + name,
                                 ptCut=0.,
                                 nSCTPix=4)

    filter2 = makeTrackFilterAlg(TracksName=D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='HighPtTracks' + name,
                                 ptCut=5000.,
                                 nSCTPix=4)

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    preseq += filter1
    preseq += filter2

    # now configure the D3PD
    from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
    alg = MSMgr.NewRootStream(name, file, TreeName=tuplename)

    #alg = D3PDMakerCoreComps.MakerAlg(tuplename, seq,
    #                                  file = file,
    #                                  D3PDSvc = D3PDSvc,
    #                                  streamNameRoot = streamNameRoot)

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

    from D3PDMakerCoreComps.D3PDObject import make_SG_D3PDObject

    import EventCommonD3PDMaker

    # Electron/Photon block
    alg += ElectronD3PDObject(
        **_args(10,
                'Electron',
                kw,
                exclude=[
                    'L1Index', 'L2Index', 'EMTrackFitDetails',
                    'EgammaJetSignedIPAndPTRelKin'
                ]))
    # Photon block
    alg += PhotonD3PDObject(**_args(10, 'Photon', kw))

    # Muon blocks
    alg += MuonD3PDObject(**_args(
        10,
        'MuidMuon',
        kw,
        sgkey='MuidMuonCollection',
        prefix='mu_muid_',
        include=["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex"],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))
    alg += MuonD3PDObject(**_args(
        10,
        'StacoMuon',
        kw,
        sgkey='StacoMuonCollection',
        prefix='mu_staco_',
        include=["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex"],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))
    alg += MuonD3PDObject(**_args(
        10,
        'CaloMuon',
        kw,
        sgkey='CaloMuonCollection',
        prefix='mu_calo_',
        include=["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex"],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))

    alg += MuonD3PDObject(**_args(
        10,
        'Muons',
        kw,
        sgkey='Muons',
        prefix='mu_muon_',
        include=["EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex"],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))
    # Quadruplet vertex block
    from AthenaCommon.AlgSequence import AlgSequence
    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
    from HSG2VertexCreation.HSG2VertexReconstruction import HSG2VertexReconstruction
    HSG2VertexReconstruction("HSG2VertexReconstruction",
                             AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()))

    from HiggsD3PDMaker.HSG2VertexReconstruction import addHSG2VertexReconstruction
    addHSG2VertexReconstruction(alg,
                                electron_target="el_",
                                muid_target="mu_muid_",
                                staco_target="mu_staco_",
                                calo_target="mu_calo_",
                                muon_target="mu_muon_")

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

    # Jet blocks
    alg += JetD3PDObject(**_args(
        3,
        'AK4TopoEMJet',
        kw,
        sgkey='AntiKt4TopoEMJets' + JetTagD3PD_CollectionPostfix,
        prefix='jet_akt4topoem_',
        #include = ['BTag','TrueFlavorComponents','BTagComponents'],
        include=[
            JetTagD3PDKeys.BTagWeightsBlockName(),
            JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
            JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(),
            JetTagD3PDKeys.TruthInfoBlockName(),
            "Constituents",
            'TracksMoments',
            'Samplings',  # For GSC corrections
        ],
        allowMissing=True))
    # For VBF and ZH(->inv) analyses
    alg += JetD3PDObject(**_args(
        3,
        'AK4LCTopoJet',
        kw,
        sgkey='AntiKt4LCTopoJets' + JetTagD3PD_CollectionPostfix,
        prefix='jet_AntiKt4LCTopo_',
        include=[
            JetTagD3PDKeys.BTagWeightsBlockName(),
            JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
            JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(),
            JetTagD3PDKeys.TruthInfoBlockName(),
            "Constituents",
            "ConstituentScale",  # For ZH(->inv) analysis
            'TracksMoments',
            'Samplings',  # For GSC corrections
        ],
        allowMissing=True))

    # 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'
        ],
        allowMissing=True))

    # Pileup-subtracted MET RefFinal for ZH(->inv) analysis
    alg += MissingETCompositionD3PDObject(level=4,
                                          sgkey='MET_RefComposition_STVF',
                                          suffix='STVF_',
                                          allowMissing=True,
                                          jetSGKey='AntiKt4LCTopoJets',
                                          jetPrefix='jet_AntiKt4LCTopo_MET_')

    # ... good tracks only (nSCT>3; no pt cut)
    alg += TrackParticleD3PDObject(**_args(3,
                                           'Tracks1',
                                           kw,
                                           sgkey='GoodTracks' + name,
                                           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.trackParametersAtBeamSpotLevelOfDetails = 0
    highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
    highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3

    alg += TrackParticleD3PDObject(**_args(3,
                                           'Tracks2',
                                           kw,
                                           sgkey='HighPtTracks' + name,
                                           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_'))

    # Truth
    if rec.doTruth():

        from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
        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))

        # add Heavy flavour overlap
        from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
        alg += HforD3PDObject(**_args(0, 'HforD3PD', kw))

        # add mcVx information
        from TrackD3PDMaker.TruthVertexD3PDObject import TruthVertexD3PDObject
        alg += TruthVertexD3PDObject(**_args(0, 'TruthVertex', kw))

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

    if D3PDMakerFlags.DoTrigger():

        # Trigger Decision + metadata
        alg += TrigDecisionD3PDObject(**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        from TrigMissingETD3PDMaker.TrigMETD3PD import TrigMETD3PDObjects
        TrigMETD3PDObjects(alg)

        from TrigEgammaD3PDMaker.TrigEgammaD3PD import TrigEgammaD3PDObjects
        TrigMuonD3PDObjects(alg, 1)
        TrigEgammaD3PDObjects(alg, level=10)

    # Event metadata
    alg.MetadataTools += [LBMetadataConfig()]

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

    # Bunch train information
    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    ## Silence the trigger navigation warnings about missing containers:
    from AthenaCommon.AppMgr import ToolSvc
    if not hasattr(ToolSvc, "TrigDecisionTool"):
        from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
        ToolSvc += Trig__TrigDecisionTool("TrigDecisionTool")
        pass
    ToolSvc.TrigDecisionTool.Navigation.OutputLevel = 5

    # EventShape variables
    # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/D3PDVariablesForPileup#EventShape_variables
    from QcdD3PDMaker.QcdEventShapeD3PDObject import EventShapeD3PDObject
    alg += EventShapeD3PDObject(**_args(0, 'rho', kw))

    return alg