Exemplo n.º 1
0
def SctHitOnTrackAssociation(parent,
                             associator,
                             _prefix='',
                             _blocknameprefix='',
                             _level=0):
    assoc = ContainedVectorMultiAssociation\
            (parent, associator,
             prefix = _prefix, level = _level,
             blockname = _blocknameprefix+'clAssoc')
    assoc.defineBlock(0, _blocknameprefix + 'clAssoc', ClusterAssocFillerTool)

    return assoc
Exemplo n.º 2
0
def AddConstitIndex(object, typename='CaloCluster', target='cl_', level=0):
 
   import EventCommonD3PDMaker
   import D3PDMakerCoreComps
   ConstitAssoc = ContainedVectorMultiAssociation \
             (object,
             EventCommonD3PDMaker.NavigableConstituentAssociationTool,
             'constit_',
             blockname=typename+'NavigableConstituentAssociationTool',
             TypeName = typename, WriteWeight = True,
             level = level)

   ConstitAssoc.defineBlock (0, 'ConstitIndex'+typename, D3PDMakerCoreComps.IndexFillerTool, Target = target)
Exemplo n.º 3
0
def AddAssocConstitIndex(object,
                         typename='Analysis::Electron',
                         target='el_',
                         level=0):

    import EventCommonD3PDMaker
    import D3PDMakerCoreComps
    ConstitAssoc = ContainedVectorMultiAssociation \
              (object,
              EventCommonD3PDMaker.NavigableConstituentAssociationTool,
              'constit_'+target,
              blockname=typename+'NavigableConstituentAssociationTool',
              TypeName = typename, WriteWeight = True,
              level = level)

    ConstitAssoc.defineBlock(0,
                             'ConstitIndex' + typename,
                             D3PDMakerCoreComps.IndexFillerTool,
                             Target=target)  #, ContainerIndexName = 'contidx')
Exemplo n.º 4
0
ClusterD3PDObject.defineBlock(
    3,
    'SamplingEtaPhi',
    CaloD3PDMaker.ClusterSamplingFillerTool,
    EmHadEnergies=False,  # don't duplicate this one!
    SamplingEnergies=False,  # don't duplicate this one!
    SamplingEtaPhi=True,
    WriteRecoStatus=False)  # don't duplicate this one!

CaloCellInCluster = ContainedVectorMultiAssociation(
    ClusterD3PDObject, CaloD3PDMaker.CaloClusterCellAssociationTool, "cell_",
    4)

CaloCellInCluster.defineBlock(4,
                              'CellKinematics',
                              EventCommonD3PDMaker.FourMomFillerTool,
                              WriteE=True,
                              WriteM=False)

CaloCellInCluster.defineBlock(
    5,
    'Detail1',
    CaloD3PDMaker.CaloCellDetailsFillerTool,
    SaveCellQuality=True,
    SaveTimeInfo=True,
    SaveDetInfo=True,
    SaveCellGain=True,
    SaveBadCellStatus=False,
    SaveId=False,
    SavePositionInfo=False,
)
BeamBackgroundD3PDObject = \
    make_SG_D3PDObject ('BeamBackgroundData',
        'BeamBackgroundData',
        'bb_', 'BeamBackgroundD3PDObject')

BeamBackgroundD3PDObject.defineBlock(
    0, 'decision', BackgroundD3PDMaker.BeamBackgroundDecisionFillerTool)

ClusterAssoc = ContainedVectorMultiAssociation(
    BeamBackgroundD3PDObject,
    BackgroundD3PDMaker.BeamBackgroundClusterAssociationTool,
    blockname="bbClusterInfo",
    prefix="cl_")

ClusterAssoc.defineBlock(1,
                         "clus",
                         BackgroundD3PDMaker.BeamBackgroundClusterFillerTool,
                         BeamBackgroundKey=DeferArg('sgkey'))

ClusterAssoc.defineBlock(1,
                         'bbClusterKinematics',
                         EventCommonD3PDMaker.FourMomFillerTool,
                         WriteE=False,
                         WriteM=False)
ClusterAssoc.defineBlock(1, 'bbClusterSamplingBasics',
                         CaloD3PDMaker.ClusterSamplingFillerTool)
from CaloD3PDMaker import ClusterMomentFillerTool as CMFT
ClusterAssoc.defineBlock(
    1,
    'bbClusterMoments',
    CMFT,
    Moments=[
def TrackStateOnSurfaceAssociation(parent,
                                   associator,
                                   _prefix='',
                                   _blocknameprefix='',
                                   _level=0,
                                   getBLayerMeasurements=False,
                                   getPixelMeasurements=False,
                                   getSCTMeasurements=False,
                                   getTRTMeasurements=False,
                                   getMDTMeasurements=False,
                                   getCSCMeasurements=False,
                                   getRPCMeasurements=False,
                                   getTGCMeasurements=False,
                                   getBLayerOutliers=False,
                                   getPixelOutliers=False,
                                   getSCTOutliers=False,
                                   getTRTOutliers=False,
                                   getMDTOutliers=False,
                                   getCSCOutliers=False,
                                   getRPCOutliers=False,
                                   getTGCOutliers=False,
                                   getBLayerHoles=False,
                                   getPixelHoles=False,
                                   getSCTHoles=False,
                                   getTRTHoles=False,
                                   getMDTHoles=False,
                                   getCSCHoles=False,
                                   getRPCHoles=False,
                                   getTGCHoles=False,
                                   fillPullsName='False',
                                   flags=TrackD3PDFlags):

    assoc = ContainedVectorMultiAssociation\
            (parent, associator,
             prefix = _prefix, level = _level,
             blockname = _blocknameprefix+'HitsOnTrackAssoc',
             GetBLayerMeasurements = getBLayerMeasurements,
             GetPixelMeasurements = getPixelMeasurements,
             GetSCTMeasurements = getSCTMeasurements,
             GetTRTMeasurements = getTRTMeasurements,
             GetMDTMeasurements = getMDTMeasurements,
             GetCSCMeasurements = getCSCMeasurements,
             GetRPCMeasurements = getRPCMeasurements,
             GetTGCMeasurements = getTGCMeasurements,
             GetBLayerOutliers = getBLayerOutliers,
             GetPixelOutliers = getPixelOutliers,
             GetSCTOutliers = getSCTOutliers,
             GetTRTOutliers = getTRTOutliers,
             GetMDTOutliers = getMDTOutliers,
             GetCSCOutliers = getCSCOutliers,
             GetRPCOutliers = getRPCOutliers,
             GetTGCOutliers = getTGCOutliers,
             GetBLayerHoles = getBLayerHoles,
             GetPixelHoles = getPixelHoles,
             GetSCTHoles = getSCTHoles,
             GetTRTHoles = getTRTHoles,
             GetMDTHoles = getMDTHoles,
             GetCSCHoles = getCSCHoles,
             GetRPCHoles = getRPCHoles,
             GetTGCHoles = getTGCHoles)

    assoc.defineBlock(0,
                      _blocknameprefix + 'HitsOnTrack',
                      TrackD3PDMaker.TrackStateOnSurfaceFillerTool,
                      FillPixelHits=getPixelMeasurements or getPixelOutliers
                      or getBLayerMeasurements or getBLayerOutliers,
                      FillSCTHits=getSCTMeasurements or getSCTOutliers,
                      FillTRTHits=getTRTMeasurements or getTRTOutliers,
                      FillMDTHits=getMDTMeasurements or getMDTOutliers,
                      FillCSCHits=getCSCMeasurements or getCSCOutliers,
                      FillRPCHits=getRPCMeasurements or getRPCOutliers,
                      FillTGCHits=getTGCMeasurements or getTGCOutliers,
                      FillPixelHoles=getPixelHoles or getBLayerHoles,
                      FillSCTHoles=getSCTHoles,
                      FillTRTHoles=getTRTHoles,
                      FillMDTHoles=getMDTHoles,
                      FillCSCHoles=getCSCHoles,
                      FillRPCHoles=getRPCHoles,
                      FillTGCHoles=getTGCHoles,
                      FillPulls=deferFlag(fillPullsName, flags),
                      ResidualPullCalculator=deferFlag(
                          '_get_res() if %s else None' % fillPullsName, flags,
                          {'_get_res': _get_res}))

    ## TODO - add Muon holes
    if not (getPixelHoles or getBLayerHoles or getSCTHoles or getTRTHoles):
        fqassoc = SimpleAssociation\
                  (assoc,
                   TrackD3PDMaker.TSOFitQualityAssociationTool,
                   prefix = '', level = 0, blockname = _blocknameprefix+'HitsOnTrack_FitQualityAssoc')

        fqassoc.defineBlock(0, _blocknameprefix + 'HitsOnTrack_FitQuality',
                            TrackD3PDMaker.TrackFitQualityFillerTool)

    return assoc
Exemplo n.º 7
0
def egammaCluster(egamma, allSamplings=False, fwdEVars=False):
    ClusterAssoc = SimpleAssociation \
      (egamma,
       egammaD3PDMaker.egammaClusterAssociationTool)
    ClusterAssoc.defineBlock \
      (2, 'ClusterKin', EventCommonD3PDMaker.FourMomFillerTool,
       prefix = 'cl_',
       WriteE = True,
       WriteM = False)
    ClusterAssoc.defineBlock(2,
                             'ClusterTime',
                             D3PDMakerCoreComps.AuxDataFillerTool,
                             Vars=['time'],
                             prefix='cl_')

    ClusterAssoc.defineBlock \
      (2, 'PositionInCalo', CaloD3PDMaker.ClusterPositionInCaloFillerTool,
       prefix = 'cl_')
    ClusterAssoc.defineBlock \
      (2, 'Position0InCalo', CaloD3PDMaker.ClusterPositionInCaloFillerTool,
       prefix = 'cl_',
       FillSeedCoordinates=True)
    ClusterAssoc.defineBlock \
      (2, 'Samplings', CaloD3PDMaker.ClusterEMSamplingFillerTool)

    if allSamplings:
        ClusterAssoc.defineBlock \
          (2, 'AllSamplings', CaloD3PDMaker.ClusterSamplingFillerTool,
           EmHadEnergies = False,
           SamplingEnergies = True)
    if fwdEVars:
        ClusterAssoc.defineBlock(1,
                                 'FwdEVars',
                                 D3PDMakerCoreComps.AuxDataFillerTool,
                                 Vars=[
                                     'firstEdens = FIRST_ENG_DENS < float: 0',
                                     'cellmaxfrac = ENG_FRAC_MAX < float: 0',
                                     'longitudinal = LONGITUDINAL < float: 0',
                                     'secondlambda = SECOND_LAMBDA < float: 0',
                                     'lateral = LATERAL < float: 0',
                                     'secondR = SECOND_R < float: 0',
                                     'centerlambda = CENTER_LAMBDA < float: 0',
                                 ])

    # Allow writing cluster cells.
    # Off by default.
    Cells = ContainedVectorMultiAssociation(
        ClusterAssoc,
        CaloD3PDMaker.CaloClusterCellAssociationTool,
        "cell_",
        99,
        blockname='ClusterCells')
    Cells.defineBlock(4,
                      'CellKinematics',
                      EventCommonD3PDMaker.FourMomFillerTool,
                      WriteE=True,
                      WriteM=False)
    Cells.defineBlock(4, 'CellRawPosition',
                      CaloD3PDMaker.CaloCellRawFillerTool)
    Cells.defineBlock(
        5,
        'CellDetail1',
        CaloD3PDMaker.CaloCellDetailsFillerTool,
        SaveCellQuality=True,
        SaveTimeInfo=True,
        SaveDetInfo=True,
        SaveCellGain=True,
        SaveBadCellStatus=False,
        SaveId=False,
        SavePositionInfo=False,
    )
    Cells.defineBlock(
        6,
        'CellDetail2',
        CaloD3PDMaker.CaloCellDetailsFillerTool,
        SaveCellQuality=False,
        SaveTimeInfo=False,
        SaveDetInfo=False,
        SaveCellGain=False,
        SaveBadCellStatus=True,
        SaveId=True,
        SavePositionInfo=True,
    )

    return ClusterAssoc
Exemplo n.º 8
0
                                                SaveMetadata = \
                                                D3PDMakerFlags.SaveObjectMetadata())



TileCosmicMuonD3PDObject=D3PDObject(makeTileCosmicMuonD3PDObject,'TileTracks_','TileCosmicMuonD3PDObject')
    
TileCosmicMuonD3PDObject.defineBlock (0, 'TileCosmicMuons',
                                      CaloSysD3PDMaker.TileCosmicMuonFillerTool)

TileCosmicMuonTileCells=ContainedVectorMultiAssociation(TileCosmicMuonD3PDObject,
                                                        CaloSysD3PDMaker.TileCosmicMuonTileCellAssociationTool,
                                                        "cell",1)

TileCosmicMuonTileCells.defineBlock (1, 'TileDetail0',
                                CaloSysD3PDMaker.TileCellDetailsFillerTool,
                                SaveCellDetails=True,
                                SavePositionInfo=False,
                                )
    
TileCosmicMuonTileCells.defineBlock (2, 'TileDetail1',
                                CaloSysD3PDMaker.TileCellDetailsFillerTool,
                                SaveCellDetails=False,
                                SavePositionInfo=True,
                                )





Exemplo n.º 9
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))
Exemplo n.º 10
0
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration

import TruthD3PDMaker
import D3PDMakerCoreComps
from D3PDMakerCoreComps.D3PDObject import *
from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
from TruthD3PDMaker.TruthD3PDMakerConf import *
from D3PDMakerCoreComps.ContainedVectorMultiAssociation import ContainedVectorMultiAssociation

PileUpInfoD3PDObject = make_SG_D3PDObject("PileUpEventInfo", "OverlayEvent",
                                          "pevt_", "PileUpInfoD3PDObject")

PileUpObject = ContainedVectorMultiAssociation(
    PileUpInfoD3PDObject, TruthD3PDMaker.PileUpInfoAssociatorTool, "")

PileUpObject.defineBlock(0, 'PileUpInfo', TruthD3PDMaker.PileUpInfoFillerTool)
Exemplo n.º 11
0
                             ])

#----------------------------------------------
# This part gets all conversion vertices
# associated with the photon.  So it makes vector<vector<vector<T>>>'s, again with the
# index pointing towards the trk_ block.
#

# Associate the photon with secondary vertices
ConversionVertexAssociation = ContainedVectorMultiAssociation(
    PhotonD3PDObject,
    egammaD3PDMaker.ConversionVertexAssociationTool,
    prefix='vx_')
ConversionVertexAssociation.defineBlock(
    10,
    'ConversionVertexPosition',
    D3PDMakerCoreComps.AuxDataFillerTool,
    Vars=['x < float:0 ', 'y < float:0', 'z < float:0'])
ConversionVertexAssociation.defineBlock(10, 'ConversionVertexKinematics',
                                        TrackD3PDMaker.VertexKineFillerTool)


ConversionVertexTrackParticleAssociation = \
   ContainedVectorMultiAssociation (ConversionVertexAssociation,
                                    TrackD3PDMaker.VertexTrackParticleAssociationTool,
                                    prefix = 'convTrk_')


# `target' arg needs to be passed in from the caller;
# otherwise, we don't make this block.
def _cvAssocLevel(reqlev, args):
Exemplo n.º 12
0
Obj1D3PDObject.defineBlock(0, 'Obj1', D3PDMakerTest.Obj1FillerTool)
Obj1D3PDObject.defineBlock(0, 'Obj1a', D3PDMakerTest.Obj12FillerTool)
Obj1D3PDObject.defineBlock(0, 'Def2', D3PDMakerTest.DefaultFillerTool2)

#####################

Obj2aAssoc = SimpleAssociation(Obj1D3PDObject,
                               D3PDMakerTest.Obj1Obj2AssociationTool,
                               prefix='o2a_')
Obj2aAssoc.defineBlock(0, 'Obj2Assoc', D3PDMakerTest.Obj2FillerTool)

Obj2bAssoc = ContainedVectorMultiAssociation \
             (Obj1D3PDObject,
              D3PDMakerTest.Obj1Obj2MultiAssociationTool,
              prefix = 'o2b_')
Obj2bAssoc.defineBlock(0, 'Obj2', D3PDMakerTest.Obj2FillerTool)
Obj2bAssoc.defineBlock(0, 'Obja2', D3PDMakerTest.Obj12FillerTool)

Obj2cAssoc = SimpleAssociation(Obj1D3PDObject,
                               D3PDMakerTest.ToObj2AssociationTool,
                               prefix='o2c_')
Obj2cAssoc.defineBlock(0, 'Obj2Assoc_c', D3PDMakerTest.Obj2FillerTool)

Obj2dAssoc = SimpleAssociation(Obj2cAssoc,
                               D3PDMakerTest.ToObj2AssociationTool,
                               prefix='o2d_',
                               blockname='Assoc_d')
Obj2dAssoc.defineBlock(0, 'Obj2Assoc_d', D3PDMakerTest.Obj2FillerTool)

Obj2eAssoc = ContainedMultiAssociation(
    Obj2cAssoc,
def DefinexAODVertexD3PDObject(object,
                               trackTarget='trk',
                               trackPrefix='trk_',
                               flags=TrackD3PDFlags):

    # Position
    object.defineBlock(flagTestLOD('vertexPositionLevelOfDetails>=1', flags),
                       'Position',
                       D3PDMakerCoreComps.AuxDataFillerTool,
                       Vars=['x', 'y', 'z'])

    # 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',
                       D3PDMakerCoreComps.AuxDataFillerTool,
                       Vars=['type = vertexType'])

    # Fit Quality
    object.defineBlock(flagTestLOD('storeVertexFitQuality', flags),
                       'FitQuality',
                       D3PDMakerCoreComps.AuxDataFillerTool,
                       Vars=['chi2 = chiSquared', 'ndof = numberDoF'])

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

    # Track Association
    TrackAssoc = ContainedVectorMultiAssociation \
                 (object,
                  TrackD3PDMaker.VertexTrackParticleAssociationTool,
                  trackPrefix,
                  level = flagTestLOD ('storeVertexTrackAssociation or storeVertexTrackIndexAssociation',
                                       flags))

    TrackAssoc.defineBlock(flagTestLOD(
        'storeVertexTrackAssociation or storeVertexTrackIndexAssociation',
        flags),
                           'TrkFitQuality',
                           D3PDMakerCoreComps.AuxDataFillerTool,
                           Vars=['chi2 = chiSquared'])

    PerigeeAssoc = SimpleAssociation \
                   (TrackAssoc,
                    TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool)
    PerigeeAssoc.defineBlock(
        flagTestLOD(
            'storeVertexTrackAssociation or storeVertexTrackIndexAssociation',
            flags), 'Trk', TrackD3PDMaker.PerigeeFillerTool)

    TrackAssoc.defineBlock(flagTestLOD('storeVertexTrackIndexAssociation',
                                       flags),
                           'TrackAssocIndex',
                           D3PDMakerCoreComps.IndexFillerTool,
                           Target=trackTarget)
Exemplo 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
Exemplo 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")