Пример #1
0
def AddTrackD3PDComponents(alg, level=1, **kw):

    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.VertexD3PDObject import PrimaryVertexD3PDObject
    from TrackD3PDMaker.V0D3PDObject import DefaultV0D3PDObject as V0D3PDObject
    from TrackD3PDMaker.PixelClusterD3PDObject import PixelClusterD3PDObject

    alg += V0D3PDObject(level)
    alg += PixelClusterD3PDObject(**_args(level, 'PixelCluster', kw))
    alg += TruthTrackD3PDObject(**_args(level, 'TruthTrack', kw))
    alg += TruthVertexD3PDObject(**_args(level, 'TruthVertex', kw))
    alg += TrackParticleD3PDObject(**_args(level, 'Track', kw))
    alg += PrimaryVertexD3PDObject(**_args(level, 'PrimaryVertex', kw))
## D3PD Maker alg
InDetTrackD3PDMaker = D3PDMakerCoreComps.MakerAlg('InDetTrackTree',
                                                   topSequence,
                                                   InDetKeys.trkD3PDFileName())

## Add blocks to the tree
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():
Пример #3
0
from TrackD3PDMaker.VertexD3PDObject import PrimaryVertexD3PDObject
from TrackD3PDMaker.V0D3PDObject import V0D3PDObject
## CTP RDO
from TrigMbD3PDMaker.CtpRdoD3PDObject import CtpRdoD3PDObject

## D3PD Maker alg
alg = D3PDMakerCoreComps.MakerAlg('MinBiasTree', topSequence, outFileName)

## Add blocks to the tree
alg += EventInfoD3PDObject(0)
alg += V0D3PDObject(10)
if DoTrigger:
    alg += CtpRdoD3PDObject(10)
if DoTruth:
    alg += TruthTrackD3PDObject(10)
    alg += TruthVertexD3PDObject(10)
    alg += TrackParticleD3PDObject(10)
    alg += PrimaryVertexD3PDObject(10)
    if DoTracklets:
        alg += PixelTrackD3PDObject(10)
        alg += SCTTrackD3PDObject(10)
        alg += TRTTrackD3PDObject(10)
else:
    alg += TrackParticleD3PDObject(8)
    alg += PrimaryVertexD3PDObject(8)
    if DoTracklets:
        alg += PixelTrackD3PDObject(8)
        alg += SCTTrackD3PDObject(8)
        alg += TRTTrackD3PDObject(8)

## Configure input
Пример #4
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
Пример #5
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