Ejemplo n.º 1
0
def AddTruthLeptonicInfo(object,
                         typename='TruthParticle',
                         target='mc_',
                         level=0,
                         extra_list_m=[]):
    import TruthD3PDMaker
    LeptAssoc = ContainedVectorMultiAssociation \
                (object,
                 JetSubstructureD3PDMaker.JetSubstructureTagJetINavigable4MomentumAssociationTool,
                 'Lepton_',
                 blockname=typename+'Leptonblockindex',
                 level = level, AssociationName='jetsubstructure_truthleptons', IndexedMoments=['contained'] + extra_list_m, IndexedMomentsSuffix = "_L")
    genPart = SimpleAssociation(
        LeptAssoc,
        TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
        blockname='TruthParticleGenParticleAssociationTool_AddTruthLeptonicInfo'
    )
    trupart2 = IndexAssociation(
        genPart,
        TruthD3PDMaker.GenParticleTruthParticleAssociationTool,
        blockname=
        'GenParticleTruthParticleAssociationTool_AddTruthLeptonicInfo',
        target='mc_',
        Target='mc_')
ExTrackParticlePerigeeAssoc = SimpleAssociation(
    MuonExtrapolatedTrackAssoc,
    TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool,
    level=1,
    prefix='')

ExTrackParticlePerigeeAssoc.defineBlock(1, 'ExTrkParameters',
                                        TrackD3PDMaker.PerigeeFillerTool)

if JetTagD3PDFlags.TrackAssocLabel() != "":

    MuonInDetTrackAssoc = IndexAssociation(
        JetTagMuonInJetD3PDObject,
        MuonD3PDMaker.MuonTrackParticleAssociationTool,
        JetTagD3PDFlags.TrackAssocLabel(),
        level=0,
        prefix=JetTagD3PDKeys.MuonInDetTrackAssocPrefix(),
        Type='InDet')

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


def getJetTagMuonInJetObject(level, jetCollections, **kw):

    return JetTagMuonInJetD3PDObject(level=level,
                                     jetCollections=jetCollections,
                                     **kw)
Ejemplo n.º 3
0
    smwzlepwzGenPartFilterTool.RemoveCavernBkg = True
    smwzlepwzGenPartFilterTool.RemoveEmptyEvents = True
    smwzlepwzGenPartFilterTool.RemoveDummyEvents = True
    smwzlepwzGenPartFilterTool.RemoveUnrequestedParticles = True
    smwzlepwzGenPartFilterTool.KeepLeptonicWZBosons = True
    smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonDecayChains = True
    smwzlepwzGenPartFilterTool.KeepLeptonicWZBosonsParents = True

### for NTUP_PHOTON
#associate the electron to a track
import egammaD3PDMaker
from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
ElectronTrackParticleIndexAssociation = IndexAssociation(
    ElectronD3PDObject,
    egammaD3PDMaker.egammaTrackParticleAssociationTool,
    target="trk",
    prefix="trk_",
    level=1,
    blockname="TrackIndex",
    allowMissing=False)
GSFTrackParticlesInSample = testSGKey('Rec::TrackParticleContainer',
                                      "GSFTrackParticleCandidate")
if GSFTrackParticlesInSample:
    from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
    ElectronTrackParticleIndexAssociation = IndexAssociation(
        ElectronD3PDObject,
        egammaD3PDMaker.egammaTrackParticleAssociationTool,
        target="GSF_trk",
        prefix="GSF_trk_",
        level=1,
        blockname="GSFTrackIndex",
        allowMissing=False)
    #                        ])
    #    defineTriggerBits (ElectronD3PDObject, 1,
    #                       D3PDMakerFlags.egammaL1TrigPattern())
    #    defineTriggerBits (ElectronD3PDObject, 1,
    #                       D3PDMakerFlags.ElectronL2TrigPattern())
    #    defineTriggerBits (ElectronD3PDObject, 1,
    #                       D3PDMakerFlags.ElectronEFTrigPattern())
    #

    ### Matching indices.

    ElectronEFIndexAssoc = IndexAssociation(
        ElectronD3PDObject,
        egammaD3PDMaker.egammaEFTriggerObjectAssociationTool,
        target="trig_EF_el_",
        prefix="EF_",
        level=1,
        Target="trig_EF_el_",
        blockname="EFIndex",
        ChainPattern=D3PDMakerFlags.ElectronEFTrigPattern(),
        allowMissing=True)

    ElectronL2IndexAssoc = IndexAssociation(
        ElectronD3PDObject,
        egammaD3PDMaker.ElectronL2TriggerObjectAssociationTool,
        target="trig_L2_el_",  # For IndexAssociation.
        Target="trig_L2_el_",  # Passed directly to assoc tool.
        prefix="L2_",
        level=1,
        blockname="L2Index",
        ChainPattern=D3PDMakerFlags.ElectronL2TrigPattern(),
        allowMissing=True)
Ejemplo n.º 5
0
if TruthD3PDFlags.GenParticleAssocLabel(
) != None and TruthD3PDFlags.GenParticleAssocLabel() != "":
    if TruthD3PDFlags.GenVertexInPartAssoc():
        GenVertexPartInAssoc = \
           IndexMultiAssociation( GenVertexD3PDObject,
                                  TruthD3PDMaker.GenVertexParticleAssociationTool,
                                  TruthD3PDFlags.GenParticleAssocLabel(),
                                  blockname = "GenVertexPartInAssoc",
                                  prefix = 'inpart_',
                                  InParticles = True )

    if TruthD3PDFlags.GenVertexOutPartAssoc():
        GenVertexPartOutAssoc = \
           IndexMultiAssociation( GenVertexD3PDObject,
                                  TruthD3PDMaker.GenVertexParticleAssociationTool,
                                  TruthD3PDFlags.GenParticleAssocLabel(),
                                  blockname = "GenVertexPartOutAssoc",
                                  prefix = 'outpart_',
                                  InParticles = False )

if TruthD3PDFlags.GenEventAssocLabel(
) != None and TruthD3PDFlags.GenEventAssocLabel() != "":
    GenVertexEventAssoc = IndexAssociation(
        GenVertexD3PDObject,
        TruthD3PDMaker.GenVertexEventAssociationTool,
        TruthD3PDFlags.GenEventAssocLabel(),
        level=1,
        blockname="GenVertexEventAssoc",
        prefix='mcevt_')
Ejemplo n.º 6
0
def TrackD3PDObject(_label='trkTrack',
                    _prefix='trkTrack_',
                    _sgkey='Tracks',
                    _object_name='TrackD3PDObject',
                    typeName='TrackCollection',
                    vertexTarget='vx',
                    vertexPrefix='vx_',
                    vertexSGKey='VxPrimaryCandidate',
                    truthTarget='mc',
                    truthPrefix='mc_',
                    detailedTruthPrefix='detailed_mc_',
                    truthMapKey='TrackTruthCollection',
                    SGKeyForTruth='Tracks',
                    detailedTruthMapKey='DetailedTrackTruth',
                    SGKeyForDetailedTruth='Tracks',
                    flags=TrackD3PDFlags):

    object = make_SGDataVector_D3PDObject (
        typeName,
        _sgkey,
        _prefix,
        _object_name,
        default_allowMissing = True,
        default_label = _label,
        allow_args = ['GenParticleTarget',
                      'TruthParticleTarget',
                      'storeTruthInfo',
                      'storeTrackMomentum',
                      'trackParametersAtGlobalPerigeeLevelOfDetails',
                      'trackParametersAtPrimaryVertexLevelOfDetails',
                      'trackParametersAtBeamSpotLevelOfDetails',
                      'trackParameterAtBeamLineLevelOfDetails',
                      'storeDiagonalCovarianceAsErrors',
                      'storeTrackParametersAtCalo',
                      'storeTrackParametersAtCalo2ndLayer',
                      'storeTrackFitQuality',
                      'storeTrackPredictionAtBLayer',
                      'storeTrackInfo',
                      'storeVertexAssociation',
                      'storeDetailedTruth',
                      'storeBLayerHitsOnTrack',
                      'storePixelHitsOnTrack',
                      'storeSCTHitsOnTrack',
                      'storeTRTHitsOnTrack',
                      'storeMDTHitsOnTrack',
                      'storeCSCHitsOnTrack',
                      'storeRPCHitsOnTrack',
                      'storeTGCHitsOnTrack',
                      'storeBLayerOutliersOnTrack',
                      'storePixelOutliersOnTrack',
                      'storeSCTOutliersOnTrack',
                      'storeTRTOutliersOnTrack',
                      'storeMDTOutliersOnTrack',
                      'storeCSCOutliersOnTrack',
                      'storeRPCOutliersOnTrack',
                      'storeTGCOutliersOnTrack',
                      'storeBLayerHolesOnTrack',
                      'storePixelHolesOnTrack',
                      'storeSCTHolesOnTrack',
                      'storeTRTHolesOnTrack',
                      'storeMDTHolesOnTrack',
                      'storeCSCHolesOnTrack',
                      'storeRPCHolesOnTrack',
                      'storeTGCHolesOnTrack',
                      'storePullsAndResiduals',
                      'storeTrackUnbiasedIPAtPV',
                      'storeHitTruthMatching',
                      'storeTrackSummary',
                      'doTruth',
                      ])

    if typeName=='TrackCollection':
        PerigeeAssociationTool       = TrackD3PDMaker.TrkTrackPerigeeAssociationTool
        PerigeeAtPVAssociationTool   = TrackD3PDMaker.TrkTrackPerigeeAtPVAssociationTool
        PerigeeAtBSAssociationTool   = TrackD3PDMaker.TrkTrackPerigeeAtBSAssociationTool
        FitQualityAssociationTool    = TrackD3PDMaker.TrkTrackFitQualityAssociationTool
        TrackSummaryAssociationTool  = TrackD3PDMaker.TrkTrackTrackSummaryAssociationTool
        TrackInfoAssociationTool     = TrackD3PDMaker.TrkTrackInfoAssociationTool
        HitAssociationTool           = TrackD3PDMaker.TrkTrackTSOAssociationTool
        VertexAssociationTool        = TrackD3PDMaker.TrkTrackVertexAssociationTool
        TruthAssociationTool         = TrackD3PDMaker.TrkTrackTruthAssociationTool
        DetailedTruthAssociationTool = TrackD3PDMaker.TrkTrackDetailedTruthAssociationTool
        ParametersAtBLFillerTool     = TrackD3PDMaker.TrkTrackParametersAtBLFillerTool
        
    if typeName=='Rec::TrackParticleContainer':
        PerigeeAssociationTool       = TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool
        PerigeeAtPVAssociationTool   = TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool
        PerigeeAtBSAssociationTool   = TrackD3PDMaker.TrackParticlePerigeeAtBSAssociationTool
        FitQualityAssociationTool    = TrackD3PDMaker.TrackParticleFitQualityAssociationTool
        TrackSummaryAssociationTool  = TrackD3PDMaker.TrackParticleTrackSummaryAssociationTool
        TrackInfoAssociationTool     = TrackD3PDMaker.TrackParticleInfoAssociationTool
        HitAssociationTool           = TrackD3PDMaker.TrackParticleTSOAssociationTool
        VertexAssociationTool        = TrackD3PDMaker.TrackParticleVertexAssociationTool
        TruthAssociationTool         = TrackD3PDMaker.TrackParticleTruthAssociationTool
        DetailedTruthAssociationTool = TrackD3PDMaker.TrackParticleDetailedTruthAssociationTool
        ParametersAtBLFillerTool     = TrackD3PDMaker.TrackParticleParametersAtBLFillerTool

    # This generates ERROR messages.  Disabled for now.
    #object.defineBlock(1, "Isolation", TrackD3PDMaker.TrackIsolationFillerTool)


    ## default perigee (at (0,0,0))
    PerigeeAssoc = PerigeeAssociation\
                   (object,
                    PerigeeAssociationTool, "GlobalPerigee",
                    fillMomName = 'storeTrackMomentum',
                    levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails')

    # Unbiased impact parameters at PV
    PerigeeAssoc.defineBlock (flagTestLOD('storeTrackUnbiasedIPAtPV',
                                          flags, _get_estimator),
                              _prefix+"IPEstimate",
                              TrackD3PDMaker.PerigeeUnbiasedIPAtPVFillerTool,
                              # Filled in by LOD function.
                              TrackToVertexIPEstimator=None,
                              Prefix = 'IPEstimate_',
                              Suffix = '_wrtPV')

    # perigee at Primary Vertex
    PerigeeAtPVAssoc = PerigeeAssociation\
                       (object,
                        PerigeeAtPVAssociationTool, "PerigeeAtPV",
                        suffix='_wrtPV',
                        levelName = 'trackParametersAtPrimaryVertexLevelOfDetails')

    # perigee at Beam Spot
    PerigeeAtBSAssoc = PerigeeAssociation\
                       (object,
                        PerigeeAtBSAssociationTool, "PerigeeAtBS",
                        suffix='_wrtBS', 
                        levelName = 'trackParametersAtBeamSpotLevelOfDetails')

    # perigee at Beam Line
    from TrackD3PDMaker.PerigeeAssociation import perigeeLOD
    # Not implemented in TrackToVertex.
    #object.defineBlock(perigeeLOD ('trackParametersAtBeamLineLevelOfDetails>0',
    #                               flags),
    #                   _prefix+"ParametersAtBL",
    #                   ParametersAtBLFillerTool,
    #                   levelOfDetails = deferFlag ('trackParametersAtBeamLineLevelOfDetails', flags))

    # parameters at Calo
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo', flags),
                       _prefix+"ParametersAtCalo",
                       ParametersAtCaloFillerTool)

    # parameters at Calo 2nd layer
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo2ndLayer', flags),
                       _prefix+"ParametersAtCalo2ndLayer",
                       ParametersAtCaloFillerTool,
                       Sampling = 1,
                       Suffix = '2ndLayer')

    # Fit Quality
    FitQualityAssoc = SimpleAssociation\
                      (object,
                       FitQualityAssociationTool,
                       level = flagTestLOD('storeTrackFitQuality', flags))
        
    FitQualityAssoc.defineBlock(flagTestLOD('storeTrackFitQuality', flags),
                                _prefix+'FitQuality',
                                TrackD3PDMaker.TrackFitQualityFillerTool)

    # Track Summary
    TrackSummaryAssoc = SimpleAssociation\
                        (object,
                         TrackSummaryAssociationTool,
                         level = flagTestLOD('storeTrackSummary', flags))

    TrackSummaryAssoc.defineBlock(flagTestLOD('storeTrackSummary', flags),
                                  _prefix+'TrackSummary',
                                  TrackD3PDMaker.TrackTrackSummaryFillerTool,
                                  FullInfo = flags.storeTrackSummary.FullInfo,
                                  IDHits = flags.storeTrackSummary.IDHits,
                                  IDHoles = flags.storeTrackSummary.IDHoles,
                                  IDSharedHits = flags.storeTrackSummary.IDSharedHits,
                                  IDOutliers = flags.storeTrackSummary.IDOutliers,
                                  PixelInfoPlus = flags.storeTrackSummary.PixelInfoPlus,
                                  SCTInfoPlus = flags.storeTrackSummary.SCTInfoPlus,
                                  TRTInfoPlus = flags.storeTrackSummary.TRTInfoPlus,
                                  InfoPlus = flags.storeTrackSummary.InfoPlus,
                                  MuonHits = flags.storeTrackSummary.MuonHits,
                                  MuonHoles = flags.storeTrackSummary.MuonHoles,
                                  ExpectBLayer = flags.storeTrackSummary.ExpectBLayer,
                                  HitSum = flags.storeTrackSummary.HitSum,
                                  HoleSum = flags.storeTrackSummary.HoleSum,
                                  HitPattern = flags.storeTrackSummary.HitPattern,
                                  SiHits = flags.storeTrackSummary.SiHits,
                                  TRTRatio = flags.storeTrackSummary.TRTRatio,
                                  PixeldEdx = flags.storeTrackSummary.PixeldEdx,
                                  ElectronPID = flags.storeTrackSummary.ElectronPID)
        
    # Track Info
    TrackInfoAssoc = SimpleAssociation\
                     (object,
                      TrackInfoAssociationTool,
                      level = flagTestLOD('storeTrackInfo', flags))
        
    TrackInfoAssoc.defineBlock(flagTestLOD('storeTrackInfo', flags),
                               _prefix+'TrackInfo',
                               TrackD3PDMaker.TrackInfoFillerTool)

    ## B-Layer predictions
    from AthenaCommon.AppMgr import ToolSvc
    if hasattr(ToolSvc, 'InDetRecTestBLayerTool'):
        BLayerPredictionAssoc = SimpleAssociation\
                                (object,
                                 PerigeeAssociationTool,
                                 prefix = 'blayerPrediction_',
                                 blockname = _prefix+'BLayerInfoAssoc',
                                 level = flagTestLOD('storeTrackPredictionAtBLayer', flags))

        BLayerPredictionAssoc.defineBlock (flagTestLOD('storeTrackPredictionAtBLayer', flags),
                                           _prefix+'BLayerInfo',
                                           TrackD3PDMaker.PerigeeBLPredictionFillerTool,
                                           InDetTestBLayerTool = ToolSvc.InDetRecTestBLayerTool)

    tsos_table = [
        ('storeBLayerHitsOnTrack', 'BLayer_hit_', 'getBLayerMeasurements'),
        ('storePixelHitsOnTrack',  'Pixel_hit_',  'getPixelMeasurements'),
        ('storeSCTHitsOnTrack',    'SCT_hit_',    'getSCTMeasurements'),
        ('storeTRTHitsOnTrack',    'TRT_hit_',    'getTRTMeasurements'),
        ('storeMDTHitsOnTrack',    'MDT_hit_',    'getMDTMeasurements'),
        ('storeCSCHitsOnTrack',    'CSC_hit_',    'getCSCMeasurements'),
        ('storeRPCHitsOnTrack',    'RPC_hit_',    'getRPCMeasurements'),
        ('storeTGCHitsOnTrack',    'TGC_hit_',    'getTGCMeasurements'),

        ('storeBLayerOutliersOnTrack', 'BLayer_outlier_', 'getBLayerOutliers'),
        ('storePixelOutliersOnTrack',  'Pixel_outlier_',  'getPixelOutliers'),
        ('storeSCTOutliersOnTrack',    'SCT_outlier_',    'getSCTOutliers'),
        ('storeTRTOutliersOnTrack',    'TRT_outlier_',    'getTRTOutliers'),
        ('storeMDTOutliersOnTrack',    'MDT_outlier_',    'getMDTOutliers'),
        ('storeCSCOutliersOnTrack',    'CSC_outlier_',    'getCSCOutliers'),
        ('storeRPCOutliersOnTrack',    'RPC_outlier_',    'getRPCOutliers'),
        ('storeTGCOutliersOnTrack',    'TGC_outlier_',    'getTGCOutliers'),

        ('storeBLayerHolesOnTrack',    'BLayer_hole_',    'getBLayerHoles'),
        ('storePixelHolesOnTrack',     'Pixel_hole_',     'getPixelHoles'),
        ('storeSCTHolesOnTrack',       'SCT_hole_',       'getSCTHoles'),
        ('storeTRTHolesOnTrack',       'TRT_hole_',       'getTRTHoles'),
        ('storeMDTHolesOnTrack',       'MDT_hole_',       'getMDTHoles'),
        ('storeCSCHolesOnTrack',       'CSC_hole_',       'getCSCHoles'),
        ('storeRPCHolesOnTrack',       'RPC_hole_',       'getRPCHoles'),
        ('storeTGCHolesOnTrack',       'TGC_hole_',       'getTGCHoles'),
        ]

    for flag, pref, opt in tsos_table:
        TrackStateOnSurfaceAssociation (object,
                                        HitAssociationTool,
                                        pref, _prefix + pref,
                                        flagTestLOD(flag, flags),
                                        fillPullsName = 'storePullsAndResiduals' if flag.find('Holes')<0 else 'False',
                                        **{opt : True})


    # Vertex association
    VertexAssoc = IndexAssociation  (
        object,
        VertexAssociationTool, vertexTarget,
        prefix = vertexPrefix,
        VxSGKey = vertexSGKey,
        level = flagTestLOD('storeVertexAssociation', flags))

    # Truth matching
    if rec.doTruth():
        # Simple truth matching

        # Allow associating to either GenParticles or TruthParticles.
        def _levelAssocToGP (reqlev, args, hookargs):
            if reqlev < 1: return False
            if hookargs.get ('TruthParticleTarget'): return False
            if hookargs.get ('GenParticleTarget'):
                args['Target'] = hookargs.get ('GenParticleTarget')
            return True
        def _levelAssocToTP (reqlev, args, hookargs):
            if reqlev < 1: return False
            tpt = hookargs.get ('TruthParticleTarget')
            if not tpt: return False
            args['Target'] = tpt
            return True

        TruthAssoc = SimpleAssociation\
                     (object,
                      TruthAssociationTool,
                      prefix = truthPrefix,
                      SGKey = SGKeyForTruth,
                      MapKey = truthMapKey,
                      level = flagTestLOD('doTruth and storeHitTruthMatching', flags))
        TruthAssoc.defineBlock (_levelAssocToGP,
                                'TruthAssocIndex',
                                D3PDMakerCoreComps.IndexFillerTool,
                                Target = truthTarget)

#        TruthAssocTP = SimpleAssociation\
#                       (TruthAssoc,
#                        TruthD3PDMaker.GenParticleTruthParticleAssociationTool,
#                        level = _levelAssocToTP)
#        TruthAssocTP.defineBlock (_levelAssocToTP,
#                                  'TruthAssocIndexTP',
#                                  D3PDMakerCoreComps.IndexFillerTool,
#                                  Target = truthTarget)

#        _levelTruthInfo = flagTestLOD ('doTruth and storeHitTruthMatching and reqlev>=2 and storeTruthInfo', flags)


#        TruthAssoc.defineBlock (_levelTruthInfo,
#                                'TruthPerigee',
#                                TruthD3PDMaker.GenParticlePerigeeFillerTool)
#
#        if typeName == 'Rec::TrackParticleContainer':
#            from TruthD3PDMaker.MCTruthClassifierConfig import \
#                 D3PDMCTruthClassifier
#            object.defineBlock \
#                   (_levelTruthInfo,
#                    'MCClassification',
#                    TrackD3PDMaker.TrackParticleMCClassifierFillerTool,
#                    prefix = 'mc_',
#                    Classifier = D3PDMCTruthClassifier)


        # Detailed truth matching
        DetailedTruthAssoc = IndexMultiAssociation (
            object,
            DetailedTruthAssociationTool, truthTarget,
            prefix = detailedTruthPrefix,
            level = flagTestLOD('doTruth and storeDetailedTruth and reqlev>=1', flags),
            SGKey = SGKeyForDetailedTruth,
            MapKey = detailedTruthMapKey)
    
#    if typeName == 'Rec::TrackParticleContainer':

#        from TrackD3PDMaker.trackIsolationTool import \
#             trackIsolationTool_500MeV, \
#             trackIsolationTool_1GeV, \
#             trackIsolationTool_2GeV, \
#             trackIsolationTool_3GeV, \
#             trackIsolationTool_4GeV, \
#             trackIsolationTool_5GeV, \
#             trackIsolationTool_3GeV_hitschi

#        from TrackD3PDMaker.addTrackIsolationCones import addTrackIsolationCones
#        addTrackIsolationCones (
#            object, 'Isolation', level=999,
#            sizes = [0.2, 0.3, 0.4],
#            caloIsoVar = 'cone%%_caloIso',
#            trackIsoVar = 'cone%%_trackIso',
#            nTrackIsoVar = 'cone%%_nTrackIso',
#            isolationTool = DeferArg('tool()',
#                                    tool=trackIsolationTool_500MeV))

#        iso4blocks = [[trackIsolationTool_1GeV, '1GeV', 'ptmin1gev_'],
#                      [trackIsolationTool_2GeV, '2GeV', 'ptmin2gev_'],
#                      [trackIsolationTool_3GeV, '3GeV', 'ptmin3gev_'],
#                      [trackIsolationTool_3GeV_hitschi, '3GeV_hitschi', 'ptmin3gev_hitschi_'],
#                      [trackIsolationTool_4GeV, '4GeV', 'ptmin4gev_'],
#                      [trackIsolationTool_5GeV, '5GeV', 'ptmin5gev_'],
#                      ]
#        for (tool, blksuff, varsuff) in iso4blocks:
#            object.defineBlock (999, 'Isolation_40_' + blksuff,
#                                TrackD3PDMaker.TrackIsolationFillerTool,
#                                ConeSize = 0.4,
#                                prefix = 'cone40_' + varsuff,
#                                TrackIsolationTool = DeferArg('tool()',
#                                                              tool=tool))

    return object
Ejemplo n.º 7
0
def DefineVertexD3PDObject(object,
                           trackTarget='trk',
                           trackPrefix='trk_',
                           trackType='Rec::TrackParticleContainer',
                           flags=TrackD3PDFlags):

    if trackType == 'Rec::TrackParticleContainer':
        vxTrackAtVertexTrackAssociationTool = TrackD3PDMaker.VxTrackAtVertexTrackParticleAssociationTool
    if trackType == 'TrackCollection':
        vxTrackAtVertexTrackAssociationTool = TrackD3PDMaker.VxTrackAtVertexTrkTrackAssociationTool

    # Position
    object.defineBlock(flagTestLOD('vertexPositionLevelOfDetails>=1', flags),
                       'Position', TrackD3PDMaker.VertexPositionFillerTool)

    # Covariance Matrix
    CovarianceAssoc = SimpleAssociation \
                      (object,
                       TrackD3PDMaker.VertexCovarianceAssociationTool,
                       level = flagTestLOD('vertexPositionLevelOfDetails>=2', flags))

    CovarianceAssoc.defineBlock(
        flagTestLOD('vertexPositionLevelOfDetails>=2', flags),
        'Error',
        TrackD3PDMaker.CovarianceFillerTool,
        Error=deferFlag('storeDiagonalCovarianceAsErrors', flags),
        DiagCovariance=deferFlag('not storeDiagonalCovarianceAsErrors', flags),
        OffDiagCovariance=False,
        IsPosition=True)

    CovarianceAssoc.defineBlock(flagTestLOD('vertexPositionLevelOfDetails>=3',
                                            flags),
                                'Covariance',
                                TrackD3PDMaker.CovarianceFillerTool,
                                Error=False,
                                DiagCovariance=False,
                                OffDiagCovariance=True,
                                IsPosition=True)

    # Type
    object.defineBlock(flagTestLOD('storeVertexType', flags), 'Type',
                       TrackD3PDMaker.VertexTypeFillerTool)

    # Fit Quality
    FitQualityAssoc = SimpleAssociation \
                      (object,
                       TrackD3PDMaker.VertexFitQualityAssociationTool,
                       level = flagTestLOD('storeVertexFitQuality', flags))

    FitQualityAssoc.defineBlock(flagTestLOD('storeVertexFitQuality',
                                            flags), 'FitQuality',
                                TrackD3PDMaker.TrackFitQualityFillerTool)

    # Kine
    object.defineBlock(flagTestLOD('storeVertexKinematics', flags), 'Kine',
                       TrackD3PDMaker.VertexKineFillerTool)

    # Purity
    if rec.doTruth():
        object.defineBlock(
            flagTestLOD('doTruth and storeVertexPurity', flags, _get_purity),
            'Purity', TrackD3PDMaker.VertexPurityFillerTool)

    # Track association
    TrackAssoc = ContainedVectorMultiAssociation\
                 (object,
                  TrackD3PDMaker.VertexTrackAssociationTool,
                  trackPrefix,
                  FillUnbiasedIP = deferFlag ('storeVertexTrackAssociation',
                                              flags),
                  level = flagTestLOD ('storeVertexTrackAssociation or storeVertexTrackIndexAssociation',
                                       flags))

    TrackAssoc.defineBlock(flagTestLOD('storeVertexTrackAssociation',
                                       flags), 'TrackAtVertex',
                           TrackD3PDMaker.VertexTrackAssociationFillerTool)

    TrackParticleAssoc = IndexAssociation(
        TrackAssoc,
        vxTrackAtVertexTrackAssociationTool,
        trackTarget,
        level=flagTestLOD('storeVertexTrackIndexAssociation', flags))
Ejemplo n.º 8
0
            matched='hasMuon',
            MuonContainerSGKey="StacoMuonCollection")
    else:
        MuonAssoc = SimpleAssociation(
            TrackParticleD3PDObject,
            TrackD3PDMaker.SCTTrackParticleToMuonAssociationTool,
            matched='hasMuon',
            MuonContainerSGKey="Muons")

## SCT RDOs ##############################################################################################
## Set up associations for full/extended version
if InDetD3PDSCTFlags.doRdoToClusterAssociation:
    clasterAssoc = IndexAssociation(
        SCTRDOD3PDObject,
        InDetD3PDMaker.SCTRDOClusterAssociationTool,
        'SCTClus',
        'clAssoc_',
        level=1,
        ClusterConteinerKey='SCT_Clusters')

#############################################################################################################
## SCT ByteStreaErrors
if InDetD3PDSCTFlags.storeBSerror:
    from InDetD3PDMaker import SCTByteStreamErrorFillerTool
    EventInfoD3PDObject.defineBlock(1, 'SCTErrors',
                                    SCTByteStreamErrorFillerTool)

##############################################################################################################
## Add blocks to the tree

if InDetD3PDSCTFlags.storeEventInfo:
Ejemplo n.º 9
0
## Set up associaations for full/extended version 
if TrackD3PDPixelFlags.doClusterToRdoAssociation:
    PixelRDOAssoc = IndexMultiAssociation(PixelClusterD3PDObject,
                                        TrackD3PDMaker.PixelClusterPixelRDOAssociationTool,
                                        'PixelRdo','rdoAssoc_',level = 1)

if TrackD3PDPixelFlags.doClusterToTrackAssociation:
    TrackAssoc = IndexMultiAssociation(PixelClusterD3PDObject,
                                       TrackD3PDMaker.PixelClusterToTrackParticleAssociationTool,
                                       'trk','trkAssoc_',level = 1,
                                       TrackParticleContainerSGKey = D3PDMakerFlags.TrackSGKey())

## Pixel RDOs ##############################################################################################
## Set up associations for full/extended version    
if TrackD3PDPixelFlags.doRdoToClusterAssociation:
    clasterAssoc = IndexAssociation(PixelRDOD3PDObject,TrackD3PDMaker.PixelRDOClusterAssociationTool,
                                    'PixelClus','clAssoc_',level = 1, ClusterConteinerKey = 'PixelClusters')

#############################################################################################################
## Pixel ByteStreamErrors
#if TrackD3PDPixelFlags.storeBSerror:
#    from TrackD3PDMaker.TrackD3PDMakerConf import D3PD__PixelByteStreamErrorFillerTool as PixelByteStreamFiller
#    EventInfoD3PDObject.defineBlock (1, 'PixelErrors',PixelByteStreamFiller)

##############################################################################################################
## Add blocks to the tree

if TrackD3PDPixelFlags.storeEventInfo:
    alg += EventInfoD3PDObject(10)
    if not InDetFlags.doHeavyIon():
        alg += TRTPhaseD3PDObject(10)
    
Ejemplo n.º 10
0
                                              'medium',
                                              (egammaPID.ElectronMediumIso,
                                               None),
                                              'mediumIso',
                                              (egammaPID.ElectronTight, None),
                                              'tight',
                                              (egammaPID.ElectronTightIso,
                                               None),
                                              'tightIso',
                                          ])

if JetTagD3PDFlags.TrackAssocLabel() != "":

    ElecInDetTrackAssoc = IndexAssociation(
        JetTagElectronInJetD3PDObject,
        egammaD3PDMaker.egammaTrackParticleAssociationTool,
        JetTagD3PDFlags.TrackAssocLabel(),
        level=0,
        prefix=JetTagD3PDKeys.ElectronTrackAssocPrefix())

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


def getJetTagElectronInJetD3PDObject(level, jetCollections, **kw):

    return JetTagElectronInJetD3PDObject(level=level,
                                         jetCollections=jetCollections,
                                         **kw)
Ejemplo n.º 11
0
def xAODTrackD3PDObject(_label='trkTrack',
                        _prefix='trkTrack_',
                        _sgkey='TrackParticleCandidate',
                        _object_name='TrackD3PDObject',
                        vertexTarget='vx',
                        vertexPrefix='vx_',
                        vertexSGKey='VxPrimaryCandidate',
                        flags=TrackD3PDFlags):

    object = make_SGDataVector_D3PDObject (
        'xAOD::TrackParticleContainer',
        _sgkey,
        _prefix,
        _object_name,
        default_allowMissing = True,
        default_label = _label,
        allow_args = ['storeTrackMomentum',
                      'trackParametersAtGlobalPerigeeLevelOfDetails',
                      'trackParametersAtPrimaryVertexLevelOfDetails',
                      'trackParametersAtBeamSpotLevelOfDetails',
                      'storeDiagonalCovarianceAsErrors',
                      'storeTrackFitQuality',
                      'storeTrackPredictionAtBLayer',
                      'storeTrackInfo',
                      'storeVertexAssociation',
                      'storeTrackSummary',
                      ])

    ## default perigee (at (0,0,0))
    PerigeeAssoc = PerigeeAssociation\
                   (object,
                    TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool,
                    "GlobalPerigee",
                    fillMomName = 'storeTrackMomentum',
                    levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails')

    from AthenaCommon.AppMgr import ToolSvc
    if hasattr(ToolSvc, 'InDetRecTestBLayerTool'):
        PerigeeAssoc.defineBlock (flagTestLOD('storeTrackPredictionAtBLayer', flags),
                                  _prefix+'BLayerInfo',
                                  TrackD3PDMaker.PerigeeBLPredictionFillerTool,
                                  InDetTestBLayerTool = ToolSvc.InDetRecTestBLayerTool)

    # perigee at Primary Vertex
    PerigeeAtPVAssoc = PerigeeAssociation\
                       (object,
                        TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool,
                        "PerigeeAtPV",
                        suffix='_wrtPV',
                        levelName = 'trackParametersAtPrimaryVertexLevelOfDetails')

    # perigee at Beam Spot
    PerigeeAtBSAssoc = PerigeeAssociation\
                       (object,
                        TrackD3PDMaker.TrackParticlePerigeeAtBSAssociationTool,
                        "PerigeeAtBS",
                        suffix='_wrtBS', 
                        levelName = 'trackParametersAtBeamSpotLevelOfDetails')

    object.defineBlock(flagTestLOD('storeTrackFitQuality', flags),
                       _prefix+'FitQuality',
                        D3PDMakerCoreComps.AuxDataFillerTool,
                        Vars = ['chiSquared',
                                'numberDoF'])

    # Track Summary
    class SumVars:
        HitSum         = 1 << 0
        HoleSum        = 1 << 1
        IDHits         = 1 << 2
        IDHoles        = 1 << 3
        IDSharedHits   = 1 << 4
        IDOutliers     = 1 << 5
        PixelInfoPlus  = 1 << 6
        SCTInfoPlus    = 1 << 7
        TRTInfoPlus    = 1 << 8
        InfoPlus       = 1 << 9
        ExpectBLayer   = 1 << 10
        MuonHits       = 1 << 11
        DBMHits        = 1 << 12


        varsTable = [
            # ID hits
            [IDHits,          'nBLHits',        'numberOfInnermostPixelLayerHits'],
            [IDHits + HitSum, 'nPixHits',       'numberOfPixelHits' ],
            [IDHits + HitSum, 'nSCTHits',       'numberOfSCTHits' ],
            [IDHits + HitSum, 'nTRTHits',       'numberOfTRTHits' ],
            [IDHits,          'nTRTHighTHits',  'numberOfTRTHighThresholdHits'],
            [IDHits,          'nTRTXenonHits',  'numberOfTRTXenonHits'],

            # ID holes + dead sensors - needed for appropriate cutting
            [IDHoles + HoleSum, 'nPixHoles',         'numberOfPixelHoles' ],
            [IDHoles + HoleSum, 'nSCTHoles',         'numberOfSCTHoles' ],
            [IDHoles + HoleSum, 'nTRTHoles',         'numberOfTRTHoles' ],
            [IDHoles,           'nPixelDeadSensors', 'numberOfPixelDeadSensors' ],
            [IDHoles,           'nSCTDeadSensors',   'numberOfSCTDeadSensors' ],

            # ID shared & Split hits
            [IDSharedHits,      'nBLSharedHits',     'numberOfInnermostPixelLayerSharedHits'],
            [IDSharedHits,      'nPixSharedHits',    'numberOfPixelSharedHits'],
            [IDSharedHits,      'nSCTSharedHits',    'numberOfSCTSharedHits'],
            [IDSharedHits,      'nBLayerSplitHits',  'numberOfInnermostPixelLayerSplitHits'],
            [IDSharedHits,      'nPixSplitHits',     'numberOfPixelSplitHits'],

            # ID outliers                                              
            [IDOutliers,        'nBLayerOutliers',   'numberOfInnermostPixelLayerOutliers' ],
            [IDOutliers,        'nPixelOutliers',    'numberOfPixelOutliers' ],
            [IDOutliers,        'nSCTOutliers',      'numberOfSCTOutliers' ],
            [IDOutliers,        'nTRTOutliers',      'numberOfTRTOutliers'],
            [IDOutliers,        'nTRTHighTOutliers', 'numberOfTRTHighThresholdOutliers'],

            # Pixel info plus                                          
            [PixelInfoPlus,     'nContribPixelLayers', 'numberOfContribPixelLayers' ],
            [PixelInfoPlus,     'nGangedPixels',       'numberOfGangedPixels' ],
            [PixelInfoPlus,     'nGangedFlaggedFakes', 'numberOfGangedFlaggedFakes' ],
            [PixelInfoPlus,     'nPixelSpoiltHits',    'numberOfPixelSpoiltHits' ],

            # SCT info plus                                            
            [SCTInfoPlus,       'nSCTDoubleHoles',     'numberOfSCTDoubleHoles' ],
            [SCTInfoPlus,       'nSCTSpoiltHits',      'numberOfSCTSpoiltHits' ],

            # TRT info plus                                            
            [TRTInfoPlus,       'nTRTDeadStraws',      'numberOfTRTDeadStraws' ],
            [TRTInfoPlus,       'nTRTTubeHits',        'numberOfTRTTubeHits' ],
            [TRTInfoPlus,       'nTRTSharedHits',      'numberOfTRTSharedHits' ],
            [TRTInfoPlus,       'nTRTHTHitsTotal',     'numberOfTRTHighThresholdHitsTotal' ],

            # Info plus                                                
            [InfoPlus,          'nOutliersOnTrack',           'numberOfOutliersOnTrack'],
            [InfoPlus,          'standardDeviationOfChi2OS',],

            # Expect BLayer hit                                        
            [ExpectBLayer,      'expectInnermostPixelLayerHit'],

            # Muon hits
            [MuonHits + HitSum, 'numberOfPrecisionLayers'],
            [MuonHits + HitSum, 'numberOfPrecisionHoleLayers'],
            [MuonHits + HitSum, 'numberOfPhiLayers'],
            [MuonHits + HitSum, 'numberOfPhiHoleLayers'],
            [MuonHits + HitSum, 'numberOfTriggerEtaLayers'],
            [MuonHits + HitSum, 'numberOfTriggerEtaHoleLayers'],
        ]


        @classmethod
        def varlist (cls,
                     FullInfo,
                     IDHits,
                     IDHoles,
                     IDSharedHits,
                     IDOutliers,
                     PixelInfoPlus,
                     SCTInfoPlus,
                     TRTInfoPlus,
                     InfoPlus,
                     ExpectBLayer,
                     MuonHits,
                     DBMHits,
                     HitSum,
                     HoleSum,
                     ElectronPID,
                     PixeldEdx):
            ret = []
            mask = 0
            if FullInfo: mask = ~0
            if IDHits:        mask |= cls.IDHits
            if IDHoles:       mask |= cls.IDHoles
            if IDSharedHits:  mask |= cls.IDSharedHits
            if IDOutliers:    mask |= cls.IDOutliers
            if PixelInfoPlus: mask |= cls.PixelInfoPlus
            if SCTInfoPlus:   mask |= cls.SCTInfoPlus
            if TRTInfoPlus:   mask |= cls.TRTInfoPlus
            if InfoPlus:      mask |= cls.InfoPlus
            if ExpectBLayer:  mask |= cls.ExpectBLayer
            if MuonHits:      mask |= cls.MuonHits
            if DBMHits:       mask |= cls.DBMHits
            if HitSum:        mask |= cls.HitSum
            if HoleSum:       mask |= cls.HoleSum

            for v in cls.varsTable:
                if (v[0] & mask) != 0:
                    var = v[1]
                    enum = v[2] if len(v) >= 3 else var
                    ret.append (var + ' = ' + enum)

            if ElectronPID or FullInfo:
                ret.append ('eProbabilityComb')
                ret.append ('eProbabilityHT')

            if PixeldEdx or FullInfo:
                ret.append ('pixeldEdx')
                ret.append ('numberOfUsedHitsdEdx')
                ret.append ('numberOfIBLOverflowsdEdx')
            return ret
            

    sumvarlist = SumVars.varlist (
        FullInfo = flags.storeTrackSummary.FullInfo,
        IDHits = flags.storeTrackSummary.IDHits,
        IDHoles = flags.storeTrackSummary.IDHoles,
        IDSharedHits = flags.storeTrackSummary.IDSharedHits,
        IDOutliers = flags.storeTrackSummary.IDOutliers,
        PixelInfoPlus = flags.storeTrackSummary.PixelInfoPlus,
        SCTInfoPlus = flags.storeTrackSummary.SCTInfoPlus,
        TRTInfoPlus = flags.storeTrackSummary.TRTInfoPlus,
        InfoPlus = flags.storeTrackSummary.InfoPlus,
        ExpectBLayer = flags.storeTrackSummary.ExpectBLayer,
        MuonHits = flags.storeTrackSummary.MuonHits,
        DBMHits = flags.storeTrackSummary.DBMHits,
        HitSum = flags.storeTrackSummary.HitSum,
        HoleSum = flags.storeTrackSummary.HoleSum,
        ElectronPID = flags.storeTrackSummary.ElectronPID,
        PixeldEdx = flags.storeTrackSummary.PixeldEdx,
        )

    object.defineBlock (flagTestLOD('storeTrackSummary', flags),
                        _prefix + 'TrackSummary',
                        D3PDMakerCoreComps.AuxDataFillerTool,
                        Vars = sumvarlist)


    # Track Info
    object.defineBlock (flagTestLOD('storeTrackInfo', flags),
                        _prefix + 'TrackInfo',
                        D3PDMakerCoreComps.AuxDataFillerTool,
                        Vars = ['trackFitter',
                                'particleHypothesis',
                                'trackProperties',
                                'patternRecoInfo'])

    # Vertex association
    VertexAssoc = IndexAssociation  (
        object,
        TrackD3PDMaker.TrackParticleVertexAssociationTool,
        vertexTarget,
        prefix = vertexPrefix,
        VxSGKey = vertexSGKey,
        level = flagTestLOD('storeVertexAssociation', flags))

    return object
Ejemplo n.º 12
0
def addBTagInfoToJetObject(JetD3PDObject,
                           btagLevelOffset=0,
                           LocalFlags=JetTagD3PDFlags):

    ## first check if the blocks are already added to the JetD3PDObject
    ## the weight block is always added so check for it
    from AthenaCommon.Logging import logging
    addBTagInfoLogger = logging.getLogger("addBTagInfoToJetObject")

    if JetD3PDObject.allBlocknames().has_key(
            JetTagD3PDKeys.BTagWeightsBlockName()):
        addBTagInfoLogger.warning(
            "btag blocks already added to JetD3PDObject - ignore")
        return

    addBTagInfoLogger.info("Adding btag blocks to JetD3PDObject")

    #
    ## now add the block fillers
    ## basic info weights and truth if available
    ## specify a list of taggers via LocalFlags.Taggers()
    #

    JetD3PDObject.defineBlock(btagLevelOffset + 0,
                              JetTagD3PDKeys.BTagWeightsBlockName(),
                              JetTagD3PDMaker.JetTagBTagWeightsFillerTool,
                              prefix=JetTagD3PDKeys.BTagWeightsPrefix(),
                              TaggerNames=LocalFlags.Taggers())

    if rec.doTruth:

        JetD3PDObject.defineBlock(btagLevelOffset + 0,
                                  JetTagD3PDKeys.TruthInfoBlockName(),
                                  JetTagD3PDMaker.JetTagTruthInfoFillerTool,
                                  prefix=JetTagD3PDKeys.TruthInfoPrefix(),
                                  InfoType="TruthInfo")

        if LocalFlags.QGInfo():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 0,
                JetTagD3PDKeys.QGPartonTruthInfoBlockName(),
                JetTagD3PDMaker.JetTagQGPartonTruthInfoFillerTool,
                prefix=JetTagD3PDKeys.QGPartonTruthInfoPrefix(),
                InfoType="QGPartonTruthInfo")

        if LocalFlags.PileupLabeling():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 0,
                JetTagD3PDKeys.PUTruthInfoBlockName(),
                JetTagD3PDMaker.JetTagTruthInfoFillerTool,
                prefix=JetTagD3PDKeys.PUTruthInfoPrefix(),
                InfoType="TruthInfoPU")

            if LocalFlags.QGInfo():
                JetD3PDObject.defineBlock(
                    btagLevelOffset + 0,
                    JetTagD3PDKeys.PUQGPartonTruthInfoBlockName(),
                    JetTagD3PDMaker.JetTagQGPartonTruthInfoFillerTool,
                    prefix=JetTagD3PDKeys.PUQGPartonTruthInfoPrefix(),
                    InfoType="QGPartonTruthInfoPU")
    #
    ##association to tracks, electron, muons, and photons
    ##if the getter labels are not specified no association is done
    ##can add contained information if needed
    #

    if LocalFlags.JetTrackAssoc():

        JetTrackAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetTrackAssociationTool,
            '',  ## set target when calling the JetD3PDObject
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.JetTrackAssocBlockName(),
            FillVariables=False)

        JetTagD3PDTrackToVertexIPEstimator = None
        from AthenaCommon.AppMgr import ToolSvc
        if hasattr(ToolSvc, 'BTagTrackToVertexIPEstimator'):
            JetTagD3PDTrackToVertexIPEstimator = ToolSvc.BTagTrackToVertexIPEstimator
            print("JetTagD3PD Info: found BTagTrackToVertexIPEstimator")
        elif hasattr(ToolSvc, 'JetTagD3PDTrackToVertexIPEstimator'):
            print("JetTagD3PD Info: found JetTagD3PDTrackToVertexIPEstimator")
            JetTagD3PDTrackToVertexIPEstimator = ToolSvc.JetTagD3PDTrackToVertexIPEstimator
        else:
            print("JetTagD3PD Info: configure TrackToVertexIPEstimator")
            from TrkVertexFitterUtils.TrkVertexFitterUtilsConf import Trk__FullLinearizedTrackFactory
            extrap = AtlasExtrapolator()
            ToolSvc += extrap
            JetTagD3PDLinTrkFactory = Trk__FullLinearizedTrackFactory(
                name="JetTagD3PDFullLinearizedTrackFactory",
                Extrapolator=extrap)
            ToolSvc += JetTagD3PDLinTrkFactory
            from TrkVertexFitterUtils.TrkVertexFitterUtilsConf import Trk__TrackToVertexIPEstimator
            JetTagD3PDTrackToVertexIPEstimator = Trk__TrackToVertexIPEstimator(\
                name="JetTagD3PDTrackToVertexIPEstimator",
                Extrapolator=extrap,
                LinearizedTrackFactory=JetTagD3PDLinTrkFactory)
            ToolSvc += JetTagD3PDTrackToVertexIPEstimator

        JetTrack = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetTrackAssociationTool,
            level=btagLevelOffset + 4,
            prefix=JetTagD3PDKeys.JetTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.JetTrackBlockName(),
            nrowName='',
            TrackToVertexIPEstimator=JetTagD3PDTrackToVertexIPEstimator,
            PrimaryVertexCollection=JetTagD3PDFlags.PrimaryVertexSGKey())

    if LocalFlags.JetTrackGhostAssoc():
        JetTrackAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetTrackAssociationTool,
            '',  ## set target when calling the JetD3PDObject
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetTrackGhostAssocPrefix(),
            blockname=JetTagD3PDKeys.JetTrackGhostAssocBlockName(),
            FillVariables=False,
            TrackAssocName=LocalFlags.JetTrackGhostAssocName())

    if LocalFlags.JetBHadronGhostAssoc():
        JetBHadronAssoc = ContainedVectorMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetNavigable4MomentumAssociationTool,
            JetTagD3PDKeys.JetBHadronGhostAssocPrefix(),
            level = 900,
            blockname=JetTagD3PDKeys.JetBHadronGhostAssocBlockName()+"tmp",
            Navigable4MomentumAssocName=LocalFlags.JetBHadronGhostAssocName())

        IndexAssociation(
            JetBHadronAssoc,
            TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
            '',
            level=_jetTagAssocLevel,
            blockname=JetTagD3PDKeys.JetBHadronGhostAssocBlockName(),
            prefix="")

    if LocalFlags.JetTruthGhostAssoc():
        JetTruthAssoc = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetNavigable4MomentumAssociationTool,
            JetTagD3PDKeys.JetTruthGhostAssocPrefix(),
            level=900,
            blockname=JetTagD3PDKeys.JetTruthGhostAssocBlockName() + "tmp",
            Navigable4MomentumAssocName=LocalFlags.JetTruthGhostAssocName())

        IndexAssociation(
            JetTruthAssoc,
            TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
            '',
            level=_jetTagAssocLevel,
            blockname=JetTagD3PDKeys.JetTruthGhostAssocBlockName(),
            prefix="")

    if LocalFlags.JetConstituantTruthAssoc():
        ConstitAssoc = ContainedVectorMultiAssociation \
            (JetD3PDObject,
             EventCommonD3PDMaker.NavigableConstituentAssociationTool,
             'constit_',
             nrowName = '',
             TypeName = 'TruthParticle',
             blockname= JetTagD3PDKeys.JetConstituantTruthAssocBlockName()+"tmp",
             level = 900 )

        IndexAssociation(
            ConstitAssoc,
            TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
            '',
            level=_jetTagAssocLevel,
            blockname=JetTagD3PDKeys.JetConstituantTruthAssocBlockName(),
            prefix="mcpart_")

    if LocalFlags.JetMuonAssoc():

        JetMuonAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetMuonAssociationTool,
            '',  ## set target when calling the JetD3PDObject
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetMuonAssocPrefix(),
            blockname=JetTagD3PDKeys.JetMuonAssocBlockName())

        if LocalFlags.AddSecondMuonCollection():

            JetMuon2Assoc = IndexMultiAssociation(
                JetD3PDObject,
                JetTagD3PDMaker.JetTagJetMuonAssociationTool,
                '',
                level=_jetTagAssocLevel,
                prefix=JetTagD3PDKeys.JetMuon2AssocPrefix(),
                blockname=JetTagD3PDKeys.JetMuon2AssocBlockName(),
                MuonsName="SecondMuons")

    if LocalFlags.JetElectronAssoc():

        JetElectronAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetElectronAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetElectronAssocPrefix(),
            blockname=JetTagD3PDKeys.JetElectronAssocBlockName())

    if LocalFlags.JetPhotonAssoc():

        JetPhotonAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetPhotonAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetPhotonAssocPrefix(),
            blockname=JetTagD3PDKeys.JetPhotonAssocBlockName())

    if rec.doTruth and LocalFlags.JetGenSoftLeptonAssoc():

        JetGenSoftLeptonAssoc = IndexMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetGenSoftLeptonAssociationTool,
            '',
            level = _jetTagAssocLevel,
            prefix=JetTagD3PDKeys.JetGenSoftLeptonAssocPrefix(),
            blockname=JetTagD3PDKeys.JetGenSoftLeptonAssocBlockName(),
            MCCollections = D3PDMakerFlags.TruthSGKey(),
            FillVariables=False)



        JetGenSoftLepton = ContainedVectorMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagJetGenSoftLeptonAssociationTool,
            level = btagLevelOffset+4,
            prefix=JetTagD3PDKeys.JetGenSoftLeptonAssocPrefix(),
            blockname=JetTagD3PDKeys.JetGenSoftLeptonBlockName(),
            nrowName = '',
            MCCollections = D3PDMakerFlags.TruthSGKey())

        JetGenSoftLepton.defineBlock(
            btagLevelOffset + 20,
            JetTagD3PDKeys.JetGenSoftLeptonPropBlockName(),
            EventCommonD3PDMaker.GenParticleFillerTool)

    #
    ## info base for each tagger: basicaly B/U/C probabilities
    #

    if LocalFlags.InfoBase():

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.IP2DInfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.IP2DInfoBasePrefix(),
                                  InfoType="IP2D",
                                  AddPC=True)

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.IP2DIPInfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagIPInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.IP2DInfoBasePrefix(),
                                  InfoType="IP2D")

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.IP3DInfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.IP3DInfoBasePrefix(),
                                  InfoType="IP3D",
                                  AddPC=True)

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.IP3DIPInfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagIPInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.IP3DInfoBasePrefix(),
                                  InfoType="IP3D")

        JetD3PDObject.defineBlock(
            btagLevelOffset + 1,
            JetTagD3PDKeys.JetProbInfoBaseBlockName(),
            JetTagD3PDMaker.JetTagJetProbInfoBaseFillerTool,
            prefix=JetTagD3PDKeys.JetProbInfoBasePrefix(),
            InfoType="JetProb",
            # This may be missing in 17.2 samples.
            AllowMissing=at_least_version('17.2.0'))

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.SV1InfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.SV1InfoBasePrefix(),
                                  InfoType="SV1",
                                  AddPC=True)

        JetD3PDObject.defineBlock(btagLevelOffset + 1,
                                  JetTagD3PDKeys.SV2InfoBaseBlockName(),
                                  JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                                  prefix=JetTagD3PDKeys.SV2InfoBasePrefix(),
                                  InfoType="SV2")

        JetD3PDObject.defineBlock(
            btagLevelOffset + 0,
            JetTagD3PDKeys.JetFitterInfoBaseBlockName(),
            JetTagD3PDMaker.JetTagInfoBaseFillerTool,
            prefix=JetTagD3PDKeys.JetFitterTagInfoPrefix(),
            InfoType="JetFitterTagNN,JetFitterTag",
            AddPC=True)

        JetD3PDObject.defineBlock(
            btagLevelOffset + 0,
            JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
            JetTagD3PDMaker.JetTagInfoBaseFillerTool,
            prefix=JetTagD3PDKeys.JetFitterCombInfoBasePrefix(),
            InfoType="JetFitterCOMBNN,JetFitterCOMB",
            AddPC=True)

        if LocalFlags.GbbNNInfo():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 1,
                JetTagD3PDKeys.GbbNNInfoBlockName(),
                JetTagD3PDMaker.JetTagGbbNNInfoFillerTool,
                prefix=JetTagD3PDKeys.GbbNNInfoPrefix(),
                InfoType="GbbNN")

        if LocalFlags.NewGbbNNInfo():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 1,
                JetTagD3PDKeys.NewGbbNNInfoBlockName(),
                JetTagD3PDMaker.JetTagHadFlavorTagInfoFillerTool,
                prefix=JetTagD3PDKeys.NewGbbNNInfoPrefix(),
                InfoType="NewGbbNN")

        if LocalFlags.QGInfo():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 1,
                JetTagD3PDKeys.QGInfoBlockName(),
                JetTagD3PDMaker.JetTagHadFlavorTagInfoFillerTool,
                prefix=JetTagD3PDKeys.QGInfoPrefix(),
                InfoType="QG")

        if LocalFlags.InfoBaseCalib():

            JetD3PDObject.defineBlock(
                btagLevelOffset + 3,
                JetTagD3PDKeys.JetFitterFlipInfoBaseBlockName(),
                JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                prefix=JetTagD3PDKeys.JetFitterTagFlipInfoPrefix(),
                InfoType="JetFitterTagNNFlip,JetFitterTagFlip",
                AddPC=True)

            JetD3PDObject.defineBlock(
                btagLevelOffset + 3,
                JetTagD3PDKeys.JetFitterCombIP3DPosInfoBaseBlockName(),
                JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                prefix=JetTagD3PDKeys.JetFitterCombIP3DPosInfoBasePrefix(),
                InfoType="JetFitterCOMBNNIP3DPos,JetFitterCOMBIP3DPos",
                AddPC=True)

            JetD3PDObject.defineBlock(
                btagLevelOffset + 3,
                JetTagD3PDKeys.JetFitterCombIP3DNegInfoBaseBlockName(),
                JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                prefix=JetTagD3PDKeys.JetFitterCombIP3DNegInfoBasePrefix(),
                InfoType="JetFitterCOMBNNIP3DNeg,JetFitterCOMBIP3DNeg",
                AddPC=True)

    # if LocalFlags.InfoBaseGaia():

    #     JetD3PDObject.defineBlock(
    #         btagLevelOffset+1, "JetTag_Gaia",
    #         JetTagD3PDMaker.JetTagInfoBaseFillerTool,
    #         prefix="flavor_component_gaia_",
    #         InfoType="Gaia",
    #         AddPC=True,
    #         AddPTau=False)

    #     JetD3PDObject.defineBlock(
    #         btagLevelOffset+1, "JetTag_GaiaNeg",
    #         JetTagD3PDMaker.JetTagInfoBaseFillerTool,
    #         prefix="flavor_component_gaianeg_",
    #         InfoType="GaiaNeg",
    #         AddPC=True,
    #         AddPTau=False)

    #     # TODO: this should get its own block
    #     JetD3PDObject.defineBlock(
    #         btagLevelOffset+1, "JetTag_IPFordG", # also needs a rename
    #         JetTagD3PDMaker.JetTagInfoBaseFillerTool,
    #         prefix="flavor_component_ip3dloose_",
    #         InfoType="IPFordG", # also needs to be changed in JetTagTools
    #         AddPC=True)

    ## some additional info for jet fitter
    #

    if LocalFlags.JetFitterTagInfo():

        JetD3PDObject.defineBlock(
            btagLevelOffset + 2,
            JetTagD3PDKeys.JetFitterTagInfoBlockName(),
            JetTagD3PDMaker.JetTagJetFitterTagInfoFillerTool,
            prefix=JetTagD3PDKeys.JetFitterTagInfoPrefix(),
            InfoType="JetFitterTagNN,JetFitterTag")

        if LocalFlags.JetFitterTagFlipInfo():

            JetD3PDObject.defineBlock(
                btagLevelOffset + 2,
                JetTagD3PDKeys.JetFitterTagFlipInfoBlockName(),
                JetTagD3PDMaker.JetTagJetFitterTagInfoFillerTool,
                prefix=JetTagD3PDKeys.JetFitterTagFlipInfoPrefix(),
                InfoType="JetFitterTagNNFlip,JetFitterTagFlip")

    if LocalFlags.JetFitterCharmTagInfo():

        JetD3PDObject.defineBlock(
            btagLevelOffset + 2,
            JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
            JetTagD3PDMaker.JetTagJetFitterGenericTagInfoFillerTool,
            prefix=JetTagD3PDKeys.JetFitterCharmTagInfoPrefix(),
            InfoType="JetFitterCharm")

        JetD3PDObject.defineBlock(
            btagLevelOffset + 0,
            JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(),
            JetTagD3PDMaker.JetTagInfoBaseFillerTool,
            prefix=JetTagD3PDKeys.JetFitterCharmTagInfoPrefix(),
            InfoType="JetFitterCharm",
            AddPC=True)

        if LocalFlags.InfoBaseCalib():
            JetD3PDObject.defineBlock(
                btagLevelOffset + 0,
                JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName() + "NEG",
                JetTagD3PDMaker.JetTagInfoBaseFillerTool,
                prefix="flavor_component_jfitcneg_",
                InfoType="JetFitterCharmNeg",
                AddPC=True)

    #
    ## track information used for IP taggers
    #

    if LocalFlags.IPInfoPlus():

        IPInfoPlusTrackAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagIPInfoPlusTrackAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.IPInfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.IPInfoPlusTrackAssocBlockName(),
            FillVariables=False,
            AllowMissing=True)

        IPInfoPlusTrack = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagIPInfoPlusTrackAssociationTool,
            level=btagLevelOffset + 2,
            prefix=JetTagD3PDKeys.IPInfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.IPInfoPlusTrackBlockName(),
            nrowName='',
            AllowMissing=True)

        IPInfoPlusTrack.defineBlock(btagLevelOffset + 20,
                                    JetTagD3PDKeys.IPInfoPlusTrkP4BlockName(),
                                    EventCommonD3PDMaker.FourMomFillerTool,
                                    prefix="",
                                    WriteM=False)

    #
    ## vertex information used for SV1/SV2 taggers
    #

    if LocalFlags.SVInfoPlus():
        JetD3PDObject.defineBlock(btagLevelOffset + 2,
                                  JetTagD3PDKeys.SVInfoPlusBlockName(),
                                  JetTagD3PDMaker.JetTagSVInfoPlusFillerTool,
                                  prefix=JetTagD3PDKeys.SVInfoPlusPrefix(),
                                  InfoType="SVInfoPlus",
                                  AllowMissing=True,
                                  AddNormDist=True)

        SVInfoPlusTrackAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSVInfoPlusTrackAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.SVInfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.SVInfoPlusTrackAssocBlockName(),
            AllowMissing=True)

        SVInfoPlusTrack = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSVInfoPlusTrackAssociationTool,
            level=btagLevelOffset + 20,
            prefix=JetTagD3PDKeys.SVInfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.SVInfoPlusTrackBlockName(),
            nrowName='',
            AllowMissing=True)

        SVInfoPlusTrack.defineBlock(btagLevelOffset + 20,
                                    JetTagD3PDKeys.SVInfoPlusTrkP4BlockName(),
                                    EventCommonD3PDMaker.FourMomFillerTool,
                                    prefix='',
                                    WriteM=False)

    #
    ## vertex information used for the SV0 tagger
    #

    if LocalFlags.SV0InfoPlus():

        JetD3PDObject.defineBlock(btagLevelOffset + 2,
                                  JetTagD3PDKeys.SV0InfoPlusBlockName(),
                                  JetTagD3PDMaker.JetTagSVInfoPlusFillerTool,
                                  prefix=JetTagD3PDKeys.SV0InfoPlusPrefix(),
                                  InfoType="SV0InfoPlus",
                                  AllowMissing=True)

        SV0InfoPlusTrackAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSVInfoPlusTrackAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.SV0InfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.SV0InfoPlusTrackAssocBlockName(),
            InfoType="SV0InfoPlus",
            AllowMissing=True)

        SV0InfoPlusTrack = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSVInfoPlusTrackAssociationTool,
            level=btagLevelOffset + 20,
            prefix=JetTagD3PDKeys.SV0InfoPlusTrackAssocPrefix(),
            blockname=JetTagD3PDKeys.SV0InfoPlusTrackBlockName(),
            nrowName='',
            InfoType="SV0InfoPlus",
            AllowMissing=True)

        SV0InfoPlusTrack.defineBlock(
            btagLevelOffset + 20,
            JetTagD3PDKeys.SV0InfoPlusTrkP4BlockName(),
            EventCommonD3PDMaker.FourMomFillerTool,
            prefix='',
            WriteM=False)

    #
    ## muon information used for the soft muon tagger
    #

    if LocalFlags.SoftMuonInfo():

        SoftMuonInfoMuonAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.SoftMuonInfoMuonAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftMuonInfoMuonAssocBlockName(),
            FillVariables=False,
            AllowMissing=True)

        SoftMuonInfoMuon = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
            level=btagLevelOffset + 2,
            prefix=JetTagD3PDKeys.SoftMuonInfoMuonAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftMuonInfoMuonBlockName(),
            nrowName='',
            AllowMissing=True)

        leveloffset = 20
        if LocalFlags.AddInlineSoftMuonProperties():
            leveloffset = -btagLevelOffset

        SoftMuonInfoMuon.defineBlock(btagLevelOffset + leveloffset,
                                     JetTagD3PDKeys.SoftMuonInfoP4BlockName(),
                                     EventCommonD3PDMaker.FourMomFillerTool,
                                     prefix='',
                                     WriteM=False,
                                     WriteE=True)

        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfoChargeBlockName(),
            EventCommonD3PDMaker.ChargeFillerTool)
        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfoAuthorBlockName(),
            MuonD3PDMaker.MuonAuthorFillerTool)
        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfomatchChi2BlockName(),
            MuonD3PDMaker.MuonMatchQualityFillerTool)
        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfoAcceptBlockName(),
            MuonD3PDMaker.MuonAcceptMethodFillerTool)
        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfoELossBlockName(),
            MuonD3PDMaker.MuonELossFillerTool)
        SoftMuonInfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonInfoHitsBlockName(),
            MuonD3PDMaker.MuonTrkHitFillerTool,
            SaveIDMuonHitSummary=False)

        if LocalFlags.AddSecondMuonCollection():

            SoftMuon2InfoMuon2Assoc =  IndexMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
                '',
                level = _jetTagAssocLevel,
                prefix=JetTagD3PDKeys.SoftMuon2InfoMuon2AssocPrefix(),
                blockname=JetTagD3PDKeys.SoftMuon2InfoMuon2AssocBlockName(),
                InfoType="SecondSoftMuonTag",
                FillVariables=False,
                AllowMissing = True)

            SoftMuon2InfoMuon2 =  ContainedVectorMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
                level = btagLevelOffset+3,
                prefix=JetTagD3PDKeys.SoftMuon2InfoMuon2AssocPrefix(),
                blockname=JetTagD3PDKeys.SoftMuon2InfoMuon2BlockName(),
                nrowName = '',
                InfoType="SecondSoftMuonTag",
                AllowMissing = True)

            SoftMuon2InfoMuon2.defineBlock(
                btagLevelOffset + 20,
                JetTagD3PDKeys.SoftMuon2InfoP4BlockName(),
                EventCommonD3PDMaker.FourMomFillerTool,
                prefix='',
                WriteM=False)

    #
    ## muon information used for soft muon chi2 tagger
    #

    if LocalFlags.SoftMuonChi2Info():

        SoftMuonChi2InfoMuonAssoc = IndexMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
            '',
            level=_jetTagAssocLevel,
            prefix=JetTagD3PDKeys.SoftMuonChi2InfoMuonAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftMuonChi2InfoMuonAssocBlockName(),
            InfoType="SoftMuonTagChi2",
            FillVariables=False,
            AllowMissing=True)

        SoftMuonChi2InfoMuon = ContainedVectorMultiAssociation(
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
            level=btagLevelOffset + 2,
            prefix=JetTagD3PDKeys.SoftMuonChi2InfoMuonAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftMuonChi2InfoMuonBlockName(),
            InfoType="SoftMuonTagChi2",
            nrowName='',
            AllowMissing=True)

        leveloffset = 20
        if LocalFlags.AddInlineSoftMuonChi2Properties():
            leveloffset = -btagLevelOffset

        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoP4BlockName(),
            EventCommonD3PDMaker.FourMomFillerTool,
            prefix='',
            WriteM=False,
            WriteE=True)

        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoChargeBlockName(),
            EventCommonD3PDMaker.ChargeFillerTool)
        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoAuthorBlockName(),
            MuonD3PDMaker.MuonAuthorFillerTool)
        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfomatchChi2BlockName(),
            MuonD3PDMaker.MuonMatchQualityFillerTool)
        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoAcceptBlockName(),
            MuonD3PDMaker.MuonAcceptMethodFillerTool)
        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoELossBlockName(),
            MuonD3PDMaker.MuonELossFillerTool)
        SoftMuonChi2InfoMuon.defineBlock(
            btagLevelOffset + leveloffset,
            JetTagD3PDKeys.SoftMuonChi2InfoHitsBlockName(),
            MuonD3PDMaker.MuonTrkHitFillerTool,
            SaveIDMuonHitSummary=False)

        if LocalFlags.AddSecondMuonCollection():

            SoftMuon2Chi2InfoMuon2Assoc =  IndexMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
                '',
                level = _jetTagAssocLevel,
                prefix=JetTagD3PDKeys.SoftMuon2Chi2InfoMuon2AssocPrefix(),
                blockname=JetTagD3PDKeys.SoftMuon2Chi2InfoMuon2AssocBlockName(),
                InfoType="SecondSoftMuonTagChi2",
                FillVariables=False,
                AllowMissing = True)

            SoftMuon2Chi2InfoMuon2 =  ContainedVectorMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagSoftMuonInfoMuonAssociationTool,
                level = btagLevelOffset+3,
                prefix=JetTagD3PDKeys.SoftMuon2Chi2InfoMuon2AssocPrefix(),
                blockname=JetTagD3PDKeys.SoftMuon2Chi2InfoMuon2BlockName(),
                nrowName = '',
                InfoType="SecondSoftMuonTagChi2",
                AllowMissing = True)

            SoftMuon2Chi2InfoMuon2.defineBlock(
                btagLevelOffset + 20,
                JetTagD3PDKeys.SoftMuon2Chi2InfoP4BlockName(),
                EventCommonD3PDMaker.FourMomFillerTool,
                prefix='',
                WriteM=False)

    #
    ## electron information used for the soft electron tagger
    #

    if LocalFlags.SoftElectronInfo():

        SoftElectronInfoElectronAssoc =  IndexMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftElecInfoegammaAssociationTool,
            '',
            level = _jetTagAssocLevel,
            prefix=JetTagD3PDKeys.SoftElectronInfoElectronAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftElectronInfoElectronAssocBlockName(),
            FillVariables=False,
            AllowMissing = True)


        SoftElectronInfoElectron =  ContainedVectorMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagSoftElecInfoegammaAssociationTool,
            level = btagLevelOffset+2,
            prefix=JetTagD3PDKeys.SoftElectronInfoElectronAssocPrefix(),
            blockname=JetTagD3PDKeys.SoftElectronInfoElectronBlockName(),
            nrowName = '',
            AllowMissing = True)

        SoftElectronInfoElectron.defineBlock(\
            btagLevelOffset+20, JetTagD3PDKeys.SoftElectronInfoP4BlockName(),
            EventCommonD3PDMaker.FourMomFillerTool,
            prefix='',
            WriteM=False)

    if LocalFlags.MultiSVInfoPlus():

        JetD3PDObject.defineBlock(
            btagLevelOffset + 3,
            JetTagD3PDKeys.MultiSVInfoPlusBlockName(),
            JetTagD3PDMaker.JetTagMultiSVInfoPlusFillerTool,
            prefix=JetTagD3PDKeys.MultiSVInfoPlusPrefix(),
            InfoType="MultiSVInfoPlus",
            AllowMissing=True)


        MultiSVInfoPlusTrackAssoc = IndexMultiAssociation(\
            JetD3PDObject,
            JetTagD3PDMaker.JetTagMultiSVInfoMSVVtxInfoAssociationTool,
                '',
            level = _jetTagAssocLevel,
            prefix=JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocPrefix(),
            blockname=JetTagD3PDKeys.MultiSVInfoPlusMSVVtxAssocBlockName(),
            AllowMissing = True)

#### from here keep the ifs for association labels. These are used only by btag.

#
## additional information about the VKal secondary vertex finder used for SV tagger
#

    if LocalFlags.JetVKalVxBadTrack():

        if LocalFlags.TrackAssocLabel() != "":

            JetVKalVxBadTrackAssoc = IndexMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagVKalVxInJetBadTrackAssociationTool,
                LocalFlags.TrackAssocLabel(),
                level = btagLevelOffset+5,
                prefix=JetTagD3PDKeys.JetVKalVxBadTrackAssocPrefix(),
                blockname=JetTagD3PDKeys.JetVKalVxBadTrackAssocBlockName())

            if LocalFlags.AddContainedTrackP4():
                JetVKalVxBadTrackAssoc.defineBlock(
                    btagLevelOffset + 10,
                    JetTagD3PDKeys.SV0InfoPlusTrkP4BlockName(),
                    EventCommonD3PDMaker.FourMomFillerTool,
                    prefix='',
                    WriteM=False)

        else:
            JetVKalVxBadTrackAssoc = ContainedVectorMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagVKalVxInJetBadTrackAssociationTool,
                level = btagLevelOffset+6,
                prefix=JetTagD3PDKeys.JetVKalVxBadTrackAssocPrefix(),
                blockname=JetTagD3PDKeys.JetVKalVxBadTrackAssocBlockName())

            JetVKalVxBadTrackAssoc.defineBlock(
                btagLevelOffset + 6,
                JetTagD3PDKeys.SV0InfoPlusTrkP4BlockName(),
                EventCommonD3PDMaker.FourMomFillerTool,
                prefix='',
                WriteM=False)

    #
    ## additional information about the vertex finding for JetFitter*
    ## need to be associated with three additional D3PD objects defined in:
    ## JetTagVxOnJetAxisD3PDObject.py
    ## JetTagTwoTrackVertexD3PDObject.py
    #

    if LocalFlags.JetFitterVertexFinderInfo():

        JetD3PDObject.defineBlock(
            btagLevelOffset + 5,
            JetTagD3PDKeys.JetFitterVxAssocBlockName(),
            JetTagD3PDMaker.JetTagJetFitterVxFillerTool,
            prefix=JetTagD3PDKeys.JetFitterVxAssocPrefix())

        if LocalFlags.JFVxOnJetAxisAssocLabel() != "":

            JetVxOnJetAxisAssoc = IndexMultiAssociation(
                JetD3PDObject,
                JetTagD3PDMaker.JetTagJetVxOnJetAxisAssociationTool,
                LocalFlags.JFVxOnJetAxisAssocLabel(),
                level=btagLevelOffset + 5,
                prefix=JetTagD3PDKeys.JetJFVxOnJetAxisAssocPrefix(),
                blockname=JetTagD3PDKeys.JetJFVxOnJetAxisAssocBlockName(),
                VxOnJetHolderName=LocalFlags.JetJFVxOnJetAxisAssocSGKey(),
                InfoName="NewJetFitterVxFinder")

            if LocalFlags.JetFitterFlipVxOnJetAxisAssoc():

                JFFlipJetVxOnJetAxisAssoc = IndexMultiAssociation(\
                    JetD3PDObject,
                    JetTagD3PDMaker.JetTagJetVxOnJetAxisAssociationTool,
                    LocalFlags.JFVxOnJetAxisAssocLabel(),
                    level = btagLevelOffset+6,
                    prefix=JetTagD3PDKeys.JetJFFlipVxOnJetAxisAssocPrefix(),
                    blockname=JetTagD3PDKeys.JetJFFlipVxOnJetAxisAssocBlockName(),
                    VxOnJetHolderName=LocalFlags.JetJFVxOnJetAxisAssocSGKey(),
                    InfoName="NewJetFitterVxFinderFlip")

        if LocalFlags.JFTwoTrackVertexAssocLabel() != "":

            JetJFTwoTrackVertexAssoc = IndexMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagJetJFTwoTrackVertexAssociationTool,
                LocalFlags.JFTwoTrackVertexAssocLabel(),
                level = btagLevelOffset+5,
                prefix=JetTagD3PDKeys.JetJFTwoTrackVertexAssocPrefix(),
                blockname=JetTagD3PDKeys.JetJFTwoTrackVertexAssocBlockName(),
                TwoTrackVertexName=LocalFlags.JetJFTwoTrackVertexAssocSGKey(),
                InfoName="NewJetFitterVxFinder")

            if LocalFlags.JetFitterFlipTwoTrackVertexAssoc():

                JetJFFlipTwoTrackVertexAssoc = IndexMultiAssociation(\
                JetD3PDObject,
                JetTagD3PDMaker.JetTagJetJFTwoTrackVertexAssociationTool,
                LocalFlags.JFTwoTrackVertexAssocLabel(),
                level = btagLevelOffset+6,
                prefix=JetTagD3PDKeys.JetJFFlipTwoTrackVertexAssocPrefix(),
                blockname=JetTagD3PDKeys.JetJFFlipTwoTrackVertexAssocBlockName(),
                TwoTrackVertexName=LocalFlags.JetJFTwoTrackVertexAssocSGKey(),
                InfoName="NewJetFitterVxFinderFlip")
Ejemplo n.º 13
0
def TrackD3PDObject(_label='trkTrack',
                    _prefix='trkTrack_',
                    _sgkey='Tracks',
                    _object_name='TrackD3PDObject',
                    typ=TrackParticleType,
                    vertexTarget='vx',
                    vertexPrefix='vx_',
                    vertexSGKey='VxPrimaryCandidate',
                    truthTarget='mc',
                    truthPrefix='mc_',
                    detailedTruthPrefix='detailed_mc_',
                    truthMapKey='TrackTruthCollection',
                    SGKeyForTruth='Tracks',
                    detailedTruthMapKey='DetailedTrackTruth',
                    SGKeyForDetailedTruth='Tracks',
                    flags=TrackD3PDFlags):

    object = make_SGDataVector_D3PDObject(
        typ.typeName,
        _sgkey,
        _prefix,
        _object_name,
        default_allowMissing=True,
        default_label=_label,
        allow_args=[
            'GenParticleTarget',
            'TruthParticleTarget',
            'storeTruthInfo',
            'storeTrackMomentum',
            'trackParametersAtGlobalPerigeeLevelOfDetails',
            'trackParametersAtPrimaryVertexLevelOfDetails',
            'trackParametersAtBeamSpotLevelOfDetails',
            'trackParameterAtBeamLineLevelOfDetails',
            'storeDiagonalCovarianceAsErrors',
            'storeTrackParametersAtCalo',
            'storeTrackParametersAtCalo2ndLayer',
            'storeTrackFitQuality',
            'storeTrackPredictionAtBLayer',
            'storeTrackInfo',
            'storeVertexAssociation',
            'storeDetailedTruth',
            'storeBLayerHitsOnTrack',
            'storePixelHitsOnTrack',
            'storeSCTHitsOnTrack',
            'storeTRTHitsOnTrack',
            'storeMDTHitsOnTrack',
            'storeCSCHitsOnTrack',
            'storeRPCHitsOnTrack',
            'storeTGCHitsOnTrack',
            'storeBLayerOutliersOnTrack',
            'storePixelOutliersOnTrack',
            'storeSCTOutliersOnTrack',
            'storeTRTOutliersOnTrack',
            'storeMDTOutliersOnTrack',
            'storeCSCOutliersOnTrack',
            'storeRPCOutliersOnTrack',
            'storeTGCOutliersOnTrack',
            'storeBLayerHolesOnTrack',
            'storePixelHolesOnTrack',
            'storeSCTHolesOnTrack',
            'storeTRTHolesOnTrack',
            'storeMDTHolesOnTrack',
            'storeCSCHolesOnTrack',
            'storeRPCHolesOnTrack',
            'storeTGCHolesOnTrack',
            'storePullsAndResiduals',
            'storeTrackUnbiasedIPAtPV',
            'storeHitTruthMatching',
            'storeTrackSummary',
            'doTruth',
        ])

    # This generates ERROR messages.  Disabled for now.
    #object.defineBlock(1, "Isolation", TrackD3PDMaker.TrackIsolationFillerTool)

    ## default perigee (at (0,0,0))
    PerigeeAssoc = PerigeeAssociation\
                   (object,
                    typ.PerigeeAssociationTool, "GlobalPerigee",
                    fillMomName = 'storeTrackMomentum',
                    levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails')

    # Unbiased impact parameters at PV
    PerigeeAssoc.defineBlock(
        flagTestLOD('storeTrackUnbiasedIPAtPV', flags, _get_estimator),
        _prefix + "IPEstimate",
        TrackD3PDMaker.PerigeeUnbiasedIPAtPVFillerTool,
        # Filled in by LOD function.
        TrackToVertexIPEstimator=None,
        Prefix='IPEstimate_',
        Suffix='_wrtPV')

    # perigee at Primary Vertex
    PerigeeAtPVAssoc = PerigeeAssociation\
                       (object,
                        typ.PerigeeAtPVAssociationTool, "PerigeeAtPV",
                        suffix='_wrtPV',
                        levelName = 'trackParametersAtPrimaryVertexLevelOfDetails')

    # perigee at Beam Spot
    PerigeeAtBSAssoc = PerigeeAssociation\
                       (object,
                        typ.PerigeeAtBSAssociationTool, "PerigeeAtBS",
                        suffix='_wrtBS',
                        levelName = 'trackParametersAtBeamSpotLevelOfDetails')

    # parameters at Calo
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo',
                                   flags), _prefix + "ParametersAtCalo",
                       ParametersAtCaloFillerTool)

    # parameters at Calo 2nd layer
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo2ndLayer',
                                   flags),
                       _prefix + "ParametersAtCalo2ndLayer",
                       ParametersAtCaloFillerTool,
                       Sampling=1,
                       Suffix='2ndLayer')

    # Fit Quality
    FitQualityAssoc = SimpleAssociation\
                      (object,
                       typ.FitQualityAssociationTool,
                       level = flagTestLOD('storeTrackFitQuality', flags))

    FitQualityAssoc.defineBlock(flagTestLOD('storeTrackFitQuality',
                                            flags), _prefix + 'FitQuality',
                                InDetD3PDMaker.TrackFitQualityFillerTool)

    # Track Summary
    TrackSummaryAssoc = SimpleAssociation\
                        (object,
                         typ.TrackSummaryAssociationTool,
                         level = flagTestLOD('storeTrackSummary', flags))

    TrackSummaryAssoc.defineBlock(
        flagTestLOD('storeTrackSummary', flags),
        _prefix + 'TrackSummary',
        InDetD3PDMaker.TrackTrackSummaryFillerTool,
        FullInfo=flags.storeTrackSummary.FullInfo,
        IDHits=flags.storeTrackSummary.IDHits,
        IDHoles=flags.storeTrackSummary.IDHoles,
        IDSharedHits=flags.storeTrackSummary.IDSharedHits,
        IDOutliers=flags.storeTrackSummary.IDOutliers,
        PixelInfoPlus=flags.storeTrackSummary.PixelInfoPlus,
        SCTInfoPlus=flags.storeTrackSummary.SCTInfoPlus,
        TRTInfoPlus=flags.storeTrackSummary.TRTInfoPlus,
        InfoPlus=flags.storeTrackSummary.InfoPlus,
        MuonHits=flags.storeTrackSummary.MuonHits,
        MuonHoles=flags.storeTrackSummary.MuonHoles,
        ExpectBLayer=flags.storeTrackSummary.ExpectBLayer,
        HitSum=flags.storeTrackSummary.HitSum,
        HoleSum=flags.storeTrackSummary.HoleSum,
        HitPattern=flags.storeTrackSummary.HitPattern,
        SiHits=flags.storeTrackSummary.SiHits,
        TRTRatio=flags.storeTrackSummary.TRTRatio,
        PixeldEdx=flags.storeTrackSummary.PixeldEdx,
        ElectronPID=flags.storeTrackSummary.ElectronPID)

    # Track Info
    TrackInfoAssoc = SimpleAssociation\
                     (object,
                      typ.TrackInfoAssociationTool,
                      level = flagTestLOD('storeTrackInfo', flags))

    TrackInfoAssoc.defineBlock(flagTestLOD('storeTrackInfo',
                                           flags), _prefix + 'TrackInfo',
                               InDetD3PDMaker.TrackInfoFillerTool)

    ## B-Layer predictions
    from AthenaCommon.AppMgr import ToolSvc
    if hasattr(ToolSvc, 'InDetRecTestBLayerTool'):
        BLayerPredictionAssoc = SimpleAssociation\
                                (object,
                                 typ.PerigeeAssociationTool,
                                 prefix = 'blayerPrediction_',
                                 blockname = _prefix+'BLayerInfoAssoc',
                                 level = flagTestLOD('storeTrackPredictionAtBLayer', flags))

        BLayerPredictionAssoc.defineBlock(
            flagTestLOD('storeTrackPredictionAtBLayer', flags),
            _prefix + 'BLayerInfo',
            TrackD3PDMaker.PerigeeBLPredictionFillerTool,
            InDetTestBLayerTool=ToolSvc.InDetRecTestBLayerTool)

    tsos_table = [
        ('storeBLayerHitsOnTrack', 'BLayer_hit_', 'getBLayerMeasurements'),
        ('storePixelHitsOnTrack', 'Pixel_hit_', 'getPixelMeasurements'),
        ('storeSCTHitsOnTrack', 'SCT_hit_', 'getSCTMeasurements'),
        ('storeTRTHitsOnTrack', 'TRT_hit_', 'getTRTMeasurements'),
        ('storeMDTHitsOnTrack', 'MDT_hit_', 'getMDTMeasurements'),
        ('storeCSCHitsOnTrack', 'CSC_hit_', 'getCSCMeasurements'),
        ('storeRPCHitsOnTrack', 'RPC_hit_', 'getRPCMeasurements'),
        ('storeTGCHitsOnTrack', 'TGC_hit_', 'getTGCMeasurements'),
        ('storeBLayerOutliersOnTrack', 'BLayer_outlier_', 'getBLayerOutliers'),
        ('storePixelOutliersOnTrack', 'Pixel_outlier_', 'getPixelOutliers'),
        ('storeSCTOutliersOnTrack', 'SCT_outlier_', 'getSCTOutliers'),
        ('storeTRTOutliersOnTrack', 'TRT_outlier_', 'getTRTOutliers'),
        ('storeMDTOutliersOnTrack', 'MDT_outlier_', 'getMDTOutliers'),
        ('storeCSCOutliersOnTrack', 'CSC_outlier_', 'getCSCOutliers'),
        ('storeRPCOutliersOnTrack', 'RPC_outlier_', 'getRPCOutliers'),
        ('storeTGCOutliersOnTrack', 'TGC_outlier_', 'getTGCOutliers'),
        ('storeBLayerHolesOnTrack', 'BLayer_hole_', 'getBLayerHoles'),
        ('storePixelHolesOnTrack', 'Pixel_hole_', 'getPixelHoles'),
        ('storeSCTHolesOnTrack', 'SCT_hole_', 'getSCTHoles'),
        ('storeTRTHolesOnTrack', 'TRT_hole_', 'getTRTHoles'),
        ('storeMDTHolesOnTrack', 'MDT_hole_', 'getMDTHoles'),
        ('storeCSCHolesOnTrack', 'CSC_hole_', 'getCSCHoles'),
        ('storeRPCHolesOnTrack', 'RPC_hole_', 'getRPCHoles'),
        ('storeTGCHolesOnTrack', 'TGC_hole_', 'getTGCHoles'),
    ]

    for flag, pref, opt in tsos_table:
        TrackStateOnSurfaceAssociation(object,
                                       typ.HitAssociationTool,
                                       pref,
                                       _prefix + pref,
                                       flagTestLOD(flag, flags),
                                       fillPullsName='storePullsAndResiduals'
                                       if flag.find('Holes') < 0 else 'False',
                                       **{opt: True})

    # Vertex association
    VertexAssoc = IndexAssociation(object,
                                   typ.VertexAssociationTool,
                                   vertexTarget,
                                   prefix=vertexPrefix,
                                   VxSGKey=vertexSGKey,
                                   level=flagTestLOD('storeVertexAssociation',
                                                     flags))

    # Truth matching
    if rec.doTruth():
        # Simple truth matching

        # Allow associating to either GenParticles or TruthParticles.
        def _levelAssocToGP(reqlev, args, hookargs):
            if reqlev < 1: return False
            if hookargs.get('TruthParticleTarget'): return False
            if hookargs.get('GenParticleTarget'):
                args['Target'] = hookargs.get('GenParticleTarget')
            return True

        def _levelAssocToTP(reqlev, args, hookargs):
            if reqlev < 1: return False
            tpt = hookargs.get('TruthParticleTarget')
            if not tpt: return False
            args['Target'] = tpt
            return True

        TruthAssoc = SimpleAssociation\
                     (object,
                      typ.TruthAssociationTool,
                      prefix = truthPrefix,
                      SGKey = SGKeyForTruth,
                      MapKey = truthMapKey,
                      level = flagTestLOD('doTruth and storeHitTruthMatching', flags))
        TruthAssoc.defineBlock(_levelAssocToGP,
                               'TruthAssocIndex',
                               D3PDMakerCoreComps.IndexFillerTool,
                               Target=truthTarget)

        # Detailed truth matching
        DetailedTruthAssoc = IndexMultiAssociation(
            object,
            typ.DetailedTruthAssociationTool,
            truthTarget,
            prefix=detailedTruthPrefix,
            level=flagTestLOD('doTruth and storeDetailedTruth and reqlev>=1',
                              flags),
            SGKey=SGKeyForDetailedTruth,
            MapKey=detailedTruthMapKey)

    return object
Ejemplo n.º 14
0
        typeName='Rec::TrackParticleContainer',
        truthTarget='mc',
        truthPrefix='mc_',
        detailedTruthPrefix='detailed_mc_',
        truthMapKey='MuonboyTrackTruthCollection',
        detailedTruthMapKey='DetailedTrackTruth',
        flags=TrackD3PDFlags)
    MuonD3PDStream += MboyTrackPartD3PDObject(TrackLevelOfDetail)

    import MuonD3PDMaker
    import D3PDMakerCoreComps
    from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
    IndexAssociation(StacoD3PDObject,
                     MuonD3PDMaker.MuonTrackParticleAssociationTool,
                     target="mboyTP_",
                     prefix="mboyTP_",
                     level=0,
                     blockname="StacoTrackAssocIndex",
                     Type="MuonSpectrometer")

    MooreTrackPartD3PDObject = TrackD3PDObject(
        _label='mooreTP',
        _prefix='mooreTP_',
        _sgkey='MooreTrackParticles',
        typeName='Rec::TrackParticleContainer',
        truthTarget='mc',
        truthPrefix='mc_',
        detailedTruthPrefix='detailed_mc_',
        truthMapKey='MooreTrackParticlesTruth',
        detailedTruthMapKey='MooreTracksTruth',
        flags=TrackD3PDFlags)
#                       ['EF_g20_loose',
#                        ])
#    defineTriggerBits (PhotonD3PDObject, 1,
#                       D3PDMakerFlags.egammaL1TrigPattern())
#    defineTriggerBits (PhotonD3PDObject, 1,
#                       D3PDMakerFlags.PhotonL2TrigPattern())
#    defineTriggerBits (PhotonD3PDObject, 1,
#                       D3PDMakerFlags.PhotonEFTrigPattern())


    ### Matching indices.
    
    PhotonEFIndexAssoc = IndexAssociation(
        PhotonD3PDObject,
        egammaD3PDMaker.egammaEFTriggerObjectAssociationTool,
        target = "trig_EF_ph_", prefix = "EF_", level = 1,
        blockname = "EFIndex",
        ChainPattern = D3PDMakerFlags.PhotonEFTrigPattern(),
        allowMissing = True )
    
    PhotonL2IndexAssoc = IndexAssociation(
        PhotonD3PDObject,
        egammaD3PDMaker.PhotonL2TriggerObjectAssociationTool,
        target = "trig_L2_ph_", # For IndexAssociation.
        prefix = "L2_", level = 1,
        blockname = "L2Index",
        ChainPattern = D3PDMakerFlags.PhotonL2TrigPattern(),
        allowMissing = True )
    
    PhotonL1IndexAssoc = IndexAssociation(
        PhotonD3PDObject,
# Create the D3PDObject:
HSG2QuadrupletD3PDObject = make_SGDataVector_D3PDObject(
    "QuadrupletContainer", "QuadrupletCandidates", "quad_",
    "HSG2QuadrupletD3PDObject")

# Define the vertex reconstruction hook:
HSG2QuadrupletD3PDObject.defineHook(__vertexReco)

# The basic information:
HSG2QuadrupletD3PDObject.defineBlock(0, "BaseInfo",
                                     HiggsD3PDMaker.QuadrupletFillerTool)

# Associate the reconstructed vertices:
VtxAssoc = IndexAssociation(HSG2QuadrupletD3PDObject,
                            HiggsD3PDMaker.QuadrupletVertexAssociationTool,
                            target="quad_vertex_",
                            blockname="VertexIndex",
                            prefix="vtx_",
                            level=1)

# Associate the CombinedParticles:
CombAssoc = SimpleAssociation(
    HSG2QuadrupletD3PDObject,
    HiggsD3PDMaker.QuadrupletCompositeParticleAssociationTool,
    blockname="CombPartMatch",
    prefix="cbpart_",
    level=1)

# Save the 4-momentum of the combined particles:
CombAssoc.defineBlock(1, "ComPart4Mom", EventCommonD3PDMaker.FourMomFillerTool)

# Save the indices of all the electrons that took part in the combination: