Ejemplo n.º 1
0
def AddLeptonicInfo(obj, level=0):
    ############ Electron #####
    IndJetElectronAssoc = IndexMultiAssociation(
        obj,
        JetSubstructureD3PDMaker.
        JetSubstructureTagJetINavigable4MomentumAssociationTool,
        'el_',
        level=level,
        prefix='Electron_',
        blockname='elecblockindex',
        AssociationName='jetsubstructure_electrons',
        IndexedMoments=['contained'],
        IndexedMomentsSuffix="_E")
    # IndexedMoments=['X', 'Y', 'Z','MINIISO', 'MINIISO10','DR','X_Prime', 'Y_Prime','Z_Prime', 'DR_Prime', 'contained']
    ############# Muon #########
    IndJetMuonAssoc = IndexMultiAssociation(
        obj,
        JetSubstructureD3PDMaker.
        JetSubstructureTagJetINavigable4MomentumAssociationTool,
        'mu_',
        level=level,
        prefix='Muon_',
        blockname='muonblockindex',
        AssociationName='jetsubstructure_muons',
        IndexedMoments=['contained'],
        IndexedMomentsSuffix="_U")
Ejemplo n.º 2
0
def AddAssocJetsIndex(obj, jetassocname, jettarget, intermediate_names = [], level=0):
   
   JetAssocTrack = IndexMultiAssociation(obj, 
                                         JetSubstructureD3PDMaker.JetSubstructureTagJetINavigable4MomentumAssociationTool,
                                         jettarget,level = level,
                                         prefix=jetassocname+'_',
                                         blockname=jetassocname+'blockindex', 
                                         AssociationName = jetassocname , 
                                         IntermediateAssociationNames=intermediate_names, 
                                         OutputLevel=3 )
Ejemplo n.º 3
0
def AddTrackAssocIndex(obj, level=99):
    import JetTagD3PDMaker
    JetTrackAssoc = IndexMultiAssociation(
        obj,
        JetTagD3PDMaker.JetTagJetTrackAssociationTool,
        'trk',
        prefix='TrackAssoc_',
        TrackAssocName="TrackAssoc",
        blockname='TrackAssocblockindex',
        level=level,
        FillVariables=False)
Ejemplo n.º 4
0
def TileCellDigitAssoc(parent,
                       prefix='',
                       target='',
                       level=0,
                       blockname=None,
                       *args,
                       **kw):
    if blockname == None:
        blockname = prefix + 'TileCellDigitAssociation'

    return IndexMultiAssociation(parent,
                                 CaloSysD3PDMaker.TileCellDigitAssociationTool,
                                 target,
                                 prefix,
                                 level,
                                 blockname,
                                 nrowName='')
Ejemplo n.º 5
0
def TruthTauDecayAssociation(parent,
                             prefix='',
                             target='',
                             level=0,
                             blockname=None,
                             *args,
                             **kw):
    """Helper for setting up an association to tau decay products in the truth record"""

    if blockname == None:
        blockname = prefix + 'TauDecayMultiAssoc'

    return IndexMultiAssociation(parent,
                                 TruthD3PDMaker.TruthTauDecayAssociationTool,
                                 target,
                                 prefix,
                                 level,
                                 blockname,
                                 nrowName='')
def TruthLeptonParentAssociation(parent,
                                 prefix='',
                                 target='',
                                 level=0,
                                 blockname=None,
                                 *args,
                                 **kw):
    """Helper for setting up an association to lepton parents in the truth record"""

    if blockname == None:
        blockname = prefix + 'LeptonParentMultiAssoc'

    return IndexMultiAssociation(
        parent,
        TruthD3PDMaker.TruthLeptonParentAssociationTool,
        target,
        prefix,
        level,
        blockname,
        nrowName='')
Ejemplo n.º 7
0
def TruthParticleChildAssociation(parent,
                                  prefix='',
                                  target='',
                                  level=0,
                                  blockname=None,
                                  *args,
                                  **kw):
    """Helper for setting up an association for truth particle
children by index.
"""
    if blockname == None:
        blockname = prefix + 'TruthParticleChildAssociation'

    return IndexMultiAssociation(
        parent,
        TruthD3PDMaker.TruthParticleChildAssociationTool,
        target,
        prefix,
        level,
        blockname,
        nrowName='')
Ejemplo n.º 8
0
GenVertexD3PDObject = make_GenVertex_D3PDObject(
    TruthD3PDKeys.GenVertexPrefix(), D3PDMakerFlags.TruthSGKey(),
    "GenVertexD3PDObject")

GenVertexD3PDObject.defineBlock(0,
                                'GenVertex',
                                TruthD3PDMaker.GenVertexFillerTool,
                                WriteID=TruthD3PDFlags.WriteTruthVertexIDs())

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(
Ejemplo n.º 9
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.º 10
0
    
alg = D3PDMakerCoreComps.MakerAlg('InDetTrackTree',
                                  topSequence,
                                  name)

#alg_2 = D3PDMakerCoreComps.MakerAlg('InDetAllTree',
#                                     topSequence,
#                                     name)

#print "4 ", name

##########################################################################################################
## Track to cluster association for full/extended version 
if TrackD3PDPixelFlags.doTrackToClusterAssociation:
    PixelClusterAssoc = IndexMultiAssociation(TrackParticleD3PDObject,
                                            TrackD3PDMaker.TrackParticleToPixelClusterAssociationTool,
                                            'PixelClus','clAssoc_',level = 1)

##########################################################################################################
## Cluster on Tracks for light version 
if TrackD3PDPixelFlags.storeHitsOnTracks:
    LightAssociationTool = TrackD3PDMaker.TrackParticleToPixelClusterAssociationToolLight
    Pixel_clAssocLight     = PixelHitOnTrackAssociation\
                           (TrackParticleD3PDObject,
                            LightAssociationTool,
                            'clAssoc_', 'clAssoc_', 0) 
## Pixel CLusters ##########################################################################################
## Set up associaations for full/extended version 
if TrackD3PDPixelFlags.doClusterToRdoAssociation:
    PixelRDOAssoc = IndexMultiAssociation(PixelClusterD3PDObject,
                                        TrackD3PDMaker.PixelClusterPixelRDOAssociationTool,
Ejemplo n.º 11
0
    'JetTagMSVVtxInfoInJetD3PDObject')

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


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


MSVVtxInfoAssoc = IndexMultiAssociation(
    JetTagMSVVtxInfoInJetD3PDObject,
    JetTagD3PDMaker.JetTagMSVVtxInfoTrackAssociationTool,
    '',
    level=_jetTagMultiSVAssocLevel,
    prefix=JetTagD3PDKeys.MSVVtxInfoTrackAssocPrefix(),
    blockname="JetTag_JetMultiSVVtxAssoc")

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


def _updateDict(name, value, kwin):
    kw = kwin.copy()
    if not kw.has_key(name + '_target'):
        kw[name + '_target'] = value
Ejemplo n.º 12
0

VxOnJetAxisD3PDObject = D3PDObject(make_VxOnJetAxis_D3PDObject,
                                   JetTagD3PDKeys.JFVxOnJetAxisPrefix(),
                                   'VxOnJetAxisD3PDObject')

VxOnJetAxisD3PDObject.defineHook(_jetTagVxOnJetAxisAlgHook)

VxOnJetAxisD3PDObject.defineBlock(0, '',
                                  JetTagD3PDMaker.JetTagVxOnJetAxisFillerTool)

if JetTagD3PDFlags.TrackAssocLabel() != "":

    VxOnJetAxisTrackAssoc = IndexMultiAssociation(
        VxOnJetAxisD3PDObject,
        JetTagD3PDMaker.JetTagVxOnJetAxisTrackAssociationTool,
        JetTagD3PDFlags.TrackAssocLabel(),
        level=0,
        prefix=JetTagD3PDKeys.VxOnJetAxisTrackAssocPrefix())

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


def getJetTagVxOnJetAxisD3PDObject(
        level, jetCollections, sgkey=JetTagD3PDKeys.JFVxOnJetAxisDataSGKey(),
        **kw):

    return VxOnJetAxisD3PDObject(level=level,
                                 jetCollections=jetCollections,
Ejemplo n.º 13
0
#    name = 'Light_'+InDetD3PDSCTFlags.outputFile()
#    print "2 ", name
#elif InDetD3PDSCTFlags.doSCTNtupleExtended and True:
#    name = 'Extended_'+InDetD3PDSCTFlags.outputFile()
#    print "3 ", name

alg = D3PDMakerCoreComps.MakerAlg('InDetTrackTree', topSequence, name)

#print "4 ", name

##########################################################################################################
## Track to cluster association for full/extended version
if InDetD3PDSCTFlags.doTrackToClusterAssociation:
    SCTClusterAssoc = IndexMultiAssociation(
        TrackParticleD3PDObject,
        InDetD3PDMaker.TrackParticleToSCTClusterAssociationTool,
        'SCTClus',
        'clAssoc_',
        level=1)

##########################################################################################################
## Cluster on Tracks for light version
if InDetD3PDSCTFlags.storeHitsOnTracks:
    LightAssociationTool = InDetD3PDMaker.TrackParticleToSCTClusterAssociationToolLight
    SCT_clAssocLight     = SctHitOnTrackAssociation\
                           (TrackParticleD3PDObject,
                            LightAssociationTool,
                            'clAssoc_', 'clAssoc_', 0)
## SCT CLusters ##########################################################################################
## Set up associaations for full/extended version
if InDetD3PDSCTFlags.doClusterToRdoAssociation:
    SCTRDOAssoc = IndexMultiAssociation(
Ejemplo n.º 14
0
def getJetTileD3PDObject(objectname='JetTileD3PDObject',
                         prefix='jet_',
                         btagleveloffset=7):

    object = make_SGDataVector_D3PDObject('JetCollection',
                                          D3PDMakerFlags.JetSGKey(), prefix,
                                          objectname)

    object.defineHook(_fixJetTiming)

    object.defineBlock(0,
                       'Kinematics',
                       EventCommonD3PDMaker.FourMomFillerTool,
                       WriteE=True)

    object.defineBlock(1,
                       'OriginCorrection',
                       JetD3PDMaker.JetMomentFillerTool,
                       Moments=['EtaOrigin', 'PhiOrigin', 'MOrigin'])

    object.defineBlock(
        1,
        'DQMoments',
        JetD3PDMaker.JetMomentFillerTool,
        Moments=[
            'WIDTH', 'n90', 'Timing', 'LArQuality', 'nTrk', 'sumPtTrk',
            'OriginIndex', 'HECQuality', 'NegativeE', 'AverageLArQF',
            'BCH_CORR_CELL', 'BCH_CORR_DOTX', 'BCH_CORR_JET',
            'BCH_CORR_JET_FORCELL', 'ENG_BAD_CELLS', 'N_BAD_CELLS',
            'N_BAD_CELLS_CORR', 'BAD_CELLS_CORR_E', 'NumTowers',
            'ootFracCells5', 'ootFracCells10', 'ootFracClusters5',
            'ootFracClusters10'
        ])

    object.defineBlock(1, 'JetSamplingsFrac',
                       JetD3PDMaker.JetSamplingsFracFillerTool)
    object.defineBlock(1, 'JetQual', JetD3PDMaker.JetCaloUtilsFillerTool)
    object.defineBlock(1, 'EMFraction', JetD3PDMaker.JetEMFractionFillerTool)

    object.defineBlock(
        1,
        'JES',
        JetD3PDMaker.JetMomentFillerTool,
        Moments=['Offset', 'EMJES', 'EMJES_EtaCorr', 'EMJESnooffset'])

    object.defineBlock(1,
                       'EMScale',
                       JetD3PDMaker.JetSignalStateFillerTool,
                       WriteE=True,
                       SignalStateNumber=0,
                       SignalStatePrefix='emscale')

    object.defineBlock(2, 'JetTileFiller', JetD3PDMaker.JetTileCellFillerTool)

    #    object.defineBlock(3, 'JVtx',
    #                              JetD3PDMaker.JetVtxFillerTool,
    #                              JetVertexAssociationTool=_getJvfTool())

    object.defineBlock(3,
                       'Layer',
                       JetD3PDMaker.JetMomentFillerTool,
                       Moments=['GSCFactorF', 'WidthFraction'])

    object.defineBlock(4, 'Samplings', JetD3PDMaker.JetSamplingsFillerTool)

    object.defineBlock(5,
                       'JESMoments',
                       JetD3PDMaker.JetMomentFillerTool,
                       Moments=['LCJES'])
    #                              Moments=['GCWJES', 'GCWJES_EtaCorr','CB'])

    object.defineBlock(5, 'JetShape', JetD3PDMaker.JetShapeFillerTool)

    object.defineBlock(5,
                       'Constituents',
                       JetD3PDMaker.JetConstituentFillerTool,
                       SignalStateNumber=0,
                       SignalStatePrefix='emscale')

    object.defineBlock(5,
                       'ConstituentScale',
                       JetD3PDMaker.JetSignalStateFillerTool,
                       WriteE=True,
                       SignalStateNumber=2,
                       SignalStatePrefix='constscale')

    object.defineBlock(6,
                       'JetLArHVMoment',
                       JetD3PDMaker.JetMomentFillerTool,
                       Moments=['LArBadHVEnergy', 'LArBadHVRatio'])

    addBTagInfoToJetObject(object, btagleveloffset)

    # Track association cannot be done unless there are tracks.
    # As often this is not the case track association will be done only
    # if this is explicitly asked for. by defining it in the include list.
    #
    # You can also enable it by passing an argument to JetD3PDObject
    # like:
    #   AssocTrackCont_target='mytarget_'
    def _jetAssocLevel(reqlev, args):
        return args.has_key('target') or (reqlev >= 999)

    IndexMultiAssociation(object,
                          JetD3PDMaker.FlavorAssociationTool,
                          'trk',
                          prefix='flavor_assoctrk_',
                          level=_jetAssocLevel,
                          blockname='AssocTrackCont')

    object.defineBlock(10, 'JetRoIword', JetD3PDMaker.JetROIWordFillerTool)

    JetElAssoc = DRAssociation(object,
                               "ElectronContainer",
                               D3PDMakerFlags.ElectronSGKey(),
                               0.2,
                               prefix='el_',
                               matched="matched",
                               blockname="El02Match")

    JetMuAssoc = DRAssociation(object,
                               "Analysis::MuonContainer",
                               D3PDMakerFlags.MuonSGKey(),
                               0.2,
                               prefix='mu_',
                               matched="matched",
                               blockname="Mu02Match")

    #JetTrkAssoc = DRAssociation(object,"Rec::TrackParticleContainer",D3PDMakerFlags.TrackSGKey(),0.4,prefix='trk_',matched="matched",blockname="Trk04Match")

    #---------------- Trigger Object ----------------------------

    JetL1Assoc = SimpleAssociation(
        object,
        JetD3PDMaker.JetL1TriggerObjectAssociationTool,
        matched='matched',
        blockname='L1Info',
        prefix='L1_',
        MaxDR=0.6,
        ChainPattern='L1_J.*')

    JetL1Assoc.defineBlock(99,
                           'L1Kinematics',
                           EventCommonD3PDMaker.FourMomFillerTool,
                           WriteE=True,
                           WriteEt=False,
                           WriteM=False)

    JetL2Assoc = SimpleAssociation(
        object,
        JetD3PDMaker.JetL2TriggerObjectAssociationTool,
        matched='matched',
        blockname='L2Info',
        prefix='L2_',
        MaxDR=0.25,
        ChainPattern='L2_j.*')

    JetL2Assoc.defineBlock(99,
                           'L2Kinematics',
                           EventCommonD3PDMaker.FourMomFillerTool,
                           WriteE=True,
                           WriteEt=False,
                           WriteM=False)

    JetEFAssoc = SimpleAssociation(
        object,
        JetD3PDMaker.JetEFTriggerObjectAssociationTool,
        matched='matched',
        blockname='EFInfo',
        prefix='EF_',
        MaxDR=0.25,
        ChainPattern='EF_j.*')

    JetEFAssoc.defineBlock(99,
                           'EFKinematics',
                           EventCommonD3PDMaker.FourMomFillerTool,
                           WriteE=True,
                           WriteEt=False,
                           WriteM=False)


    ConstitAssoc = ContainedVectorMultiAssociation \
        (object,
         #JetD3PDMaker.JetConstituentAssociationTool,
         EventCommonD3PDMaker.NavigableConstituentAssociationTool,
         'constit_',
         TypeName = 'CaloCluster',
         nrowName = '',
         level = 1)

    ConstitAssoc.defineBlock(_constitAssocLevel,
                             'ConstitIndex',
                             D3PDMakerCoreComps.IndexFillerTool,
                             Target='')

    return object
Ejemplo n.º 15
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.º 16
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.º 17
0
JetTagTwoTrackVertexD3PDObject = D3PDObject(
    make_TwoTrackVertex_D3PDObject, JetTagD3PDKeys.JFTwoTrackVertexPrefix(),
    'JetTagTwoTrackVertexD3PDObject')

JetTagTwoTrackVertexD3PDObject.defineHook(_jetTwoTrackVertexTagAlgHook)

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

if JetTagD3PDFlags.TrackAssocLabel() != "":


    JetTagTwoTrackVertexTrackAssoc = IndexMultiAssociation(\
        JetTagTwoTrackVertexD3PDObject,
        JetTagD3PDMaker.JetTagTwoTrackVertexTrackAssociationTool,
        JetTagD3PDFlags.TrackAssocLabel(),
        level=0,
        prefix=JetTagD3PDKeys.TwoTrackVertexTrackAssocPrefix())

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


def getJetTagTwoTrackVertexD3PDObject(
        level,
        jetCollections,
        sgkey=JetTagD3PDKeys.JFTwoTrackVertexDataSGKey(),
        **kw):
# 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:
ElAssoc = IndexMultiAssociation(
    CombAssoc,
    EventCommonD3PDMaker.CompositeParticleAssociationTool,
    target="el_",
    blockname="ElectronIndex",
    prefix="el_",
    level=2)

# Save the indices of all the MuID muons that took part in the combination:
MuidAssoc = IndexMultiAssociation(
    CombAssoc,
    EventCommonD3PDMaker.CompositeParticleAssociationTool,
    target="mu_muid_",
    blockname="MuonMuidIndex",
    prefix="mu_muid_",
    level=2)

# Save the indices of all the Staco muons that took part in the combination:
StacoAssoc = IndexMultiAssociation(