Ejemplo n.º 1
0
def AddConstitTruthIndex(object,
                         typename='TruthParticle',
                         target='mc_',
                         level=0):

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

    genPart = SimpleAssociation(
        ConstitAssoc,
        TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
        blockname='TruthParticleGenParticleAssociationTool_AddConstitTruthIndex'
    )
    trupart2 = IndexAssociation(
        genPart,
        TruthD3PDMaker.GenParticleTruthParticleAssociationTool,
        blockname=
        'GenParticleTruthParticleAssociationTool_AddConstitTruthIndex',
        target='mc_',
        Target='mc_')
Ejemplo n.º 2
0
def AddTruthLeptonicInfo(object,
                         typename='TruthParticle',
                         target='mc_',
                         level=0,
                         extra_list_m=[]):
    import TruthD3PDMaker
    LeptAssoc = ContainedVectorMultiAssociation \
              (object,
              JetSubstructureD3PDMaker.JetSubstructureTagJetINavigable4MomentumAssociationTool,
              'Lepton_',
              blockname=typename+'Leptonblockindex',
              level = level, AssociationName='jetsubstructure_truthleptons', IndexedMoments=['X', 'Y', 'Z','MINIISO', 'MINIISO10','DR','X_Prime', 'Y_Prime','Z_Prime', 'DR_Prime', 'contained'] + extra_list_m, IndexedMomentsSuffix = "_L")

    genPart = SimpleAssociation(
        LeptAssoc,
        TruthD3PDMaker.TruthParticleGenParticleAssociationTool,
        blockname='TruthParticleGenParticleAssociationTool_AddTruthLeptonicInfo'
    )
    trupart2 = IndexAssociation(
        genPart,
        TruthD3PDMaker.GenParticleTruthParticleAssociationTool,
        blockname=
        'GenParticleTruthParticleAssociationTool_AddTruthLeptonicInfo',
        target='mc_',
        Target='mc_')
def trackBeamlineParametersFiller (tobj,
                                   blockprefix = '',
                                   prefix = '',
                                   suffix = '_wrtBL',
                                   parametersLOD = None,
                                   errorsLOD = None,
                                   covarianceLOD = None):

    """Add blocks to TOBJ to write track parameters / errors / covariance
as evaluated at the beamline.

TOBJ may represent one of Track, TrackParameters, or TrackParticle.

BLOCKPREFIX is a prefix to add onto the block names.

PREFIX and SUFFIX are added to variable names.

If PARAMETERSLOD is None, then whether or not the parameters are written
is controlled by TrackD3PDFlags.trackParametersAtBeamLineLevelOfDetails.
Otherwise, it should be the level of detail for the block.

ERRORSLOD and COVARIANCELOD are similar for the errors and covariances.
"""

    def make_lod (lod, flagthresh):
        if lod != None:
            return lod
        return flagTestLOD ('trackParametersAtBeamLineLevelOfDetails >= %d and reqlev >= %d' % (flagthresh, flagthresh), TrackD3PDFlags)

    BLParamsAssoc = SimpleAssociation \
                    (tobj,
                     TrackD3PDMaker.TrackBeamlineParametersAssociationTool,
                     blockname = blockprefix + 'BLParamsAssoc',
                     prefix = prefix,
                     suffix = suffix)
    BLParamsAssoc.defineBlock (make_lod (parametersLOD, 1),
                               blockprefix + 'BLParams',
                               TrackD3PDMaker.TrackParametersFillerTool,
                               DefaultValue = -9999)

    BLErrorsAssoc = SimpleAssociation \
                    (BLParamsAssoc,
                     TrackD3PDMaker.TrackParametersErrorMatrixAssociationTool,
                     blockname = blockprefix + 'BLErrorsAssoc')
    BLErrorsAssoc.defineBlock (make_lod (parametersLOD, 2),
                               blockprefix + 'BLErrors',
                               TrackD3PDMaker.ErrorMatrixErrorFillerTool,
                               DefaultValue = -9999)
    BLErrorsAssoc.defineBlock (make_lod (parametersLOD, 3),
                               blockprefix + 'BLCovariance',
                               TrackD3PDMaker.ErrorMatrixCovarianceFillerTool,
                               DefaultValue = -9999)
    
    return
Ejemplo n.º 4
0
         'nbCells_s3MedGain',
         'nbCells_s3HighGain',
         ])

if rec.doTruth():
    from TruthD3PDMaker.MCTruthClassifierConfig \
         import D3PDMCTruthClassifier
    PhotonD3PDObject.defineBlock(
        1,
        'TruthClassification',
        egammaD3PDMaker.egammaTruthClassificationFillerTool,
        Classifier=D3PDMCTruthClassifier)
    PhotonTruthPartAssoc = SimpleAssociation \
        (PhotonD3PDObject,
         egammaD3PDMaker.egammaGenParticleAssociationTool,
         prefix = 'truth_',
         matched = 'matched',
         blockname = 'TruthAssoc',
         DRVar = 'deltaRRecPhoton',
         Classifier = D3PDMCTruthClassifier)
    PhotonTruthPartAssoc.defineBlock(0,
                                     'TruthKin',
                                     EventCommonD3PDMaker.FourMomFillerTool,
                                     WriteE=True,
                                     WriteM=False)
    PhotonTruthPartAssoc.defineBlock(0,
                                     'Truth',
                                     TruthD3PDMaker.TruthParticleFillerTool,
                                     PDGIDVariable='type')
    PhotonTruthPartMotherAssoc = SimpleAssociation \
      (PhotonTruthPartAssoc,
       D3PDMakerCoreComps.FirstAssociationTool,
Ejemplo n.º 5
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.º 6
0
#                                                                 blockname="ConversionVertexTrackIndex",
#                                                                 allowMissing=False)
## Associate each TrackParticle with TrackInfo
#ConversionVertexTrackTrackParticleTrackInfoAssociation = SimpleAssociation(ConversionVertexTrackTrackParticleAssociation,
#                                                                           TrackD3PDMaker.TrackParticleInfoAssociationTool)
#ConversionVertexTrackTrackParticleTrackInfoAssociation.defineBlock(1, "ConversionVertexTrackInfo", TrackD3PDMaker.TrackInfoFillerTool)

# Track parameters at conversion vertex
from D3PDMakerCoreComps.ContainedVectorMultiAssociation import ContainedVectorMultiAssociation
from egammaD3PDMaker.PhotonD3PDObject import ConversionVertexAssociation
VxTrackAtConversionVertexAssociationTool = ContainedVectorMultiAssociation(
    ConversionVertexAssociation,
    PhotonD3PDMaker.VxTrackAtVertexAssociationTool,
    prefix="paramsAtConvVtx_")
ConversionVertexTrackTrackParticlePerigeeAtVertexAssociationTool = SimpleAssociation(
    VxTrackAtConversionVertexAssociationTool,
    PhotonD3PDMaker.ConversionPerigeeAssociationTool)
ConversionVertexTrackTrackParticlePerigeeAtVertexAssociationTool.defineBlock(
    1, 'Trk', TrackD3PDMaker.PerigeeFillerTool)
TrackParticleCovarAssoc = SimpleAssociation(
    ConversionVertexTrackTrackParticlePerigeeAtVertexAssociationTool,
    TrackD3PDMaker.PerigeeCovarianceAssociationTool)
TrackParticleCovarAssoc.defineBlock(3,
                                    'TrkCovDiag',
                                    TrackD3PDMaker.CovarianceFillerTool,
                                    IsTrackPerigee=True,
                                    Error=False,
                                    DiagCovariance=True)
TrackParticleCovarAssoc.defineBlock(3,
                                    'TrkCovOffDiag',
                                    TrackD3PDMaker.CovarianceFillerTool,
Ejemplo n.º 7
0
import EventCommonD3PDMaker
import QcdD3PDMaker
from D3PDMakerCoreComps.D3PDObject import D3PDObject
from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation
from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
from TrackD3PDMaker import TrackD3PDMakerConf

## BeamSpotD3PDObject = make_SG_D3PDObject ('VxContainer','MinBiasD3PD::BeamSpotRecVertex','beamSpot_')

QcdBeamSpotD3PDObject = make_SGDataVector_D3PDObject(
    'VxContainer', 'QcdD3PD::BeamSpotRecVertex', 'beamSpot_',
    'QcdBeamSpotD3PDObject')

# Position
QcdBeamSpotD3PDObject.defineBlock(0, 'Position',
                                  TrackD3PDMaker.VertexPositionFillerTool)

# Spread
QcdCovarianceAssoc = SimpleAssociation \
                  (QcdBeamSpotD3PDObject,
                   TrackD3PDMaker.VertexCovarianceAssociationTool)

QcdCovarianceAssoc.defineBlock(1,
                               'Error',
                               TrackD3PDMaker.CovarianceFillerTool,
                               Error=True,
                               DiagCovariance=True,
                               IsPosition=True)
Ejemplo n.º 8
0
    d3pd_tests += [('scells.root', 'scells.ref')]


# Test LeadingPtAssociationTool.
from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation
from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject
import EventCommonD3PDMaker
TestJetD3PDObject = make_SGDataVector_D3PDObject ('JetCollection',
                                                  'AntiKt4TopoEMJets,' +
                                                  'AntiKt4TopoJets,' +
                                                  'AntiKt4H1TopoJets',
                                                  'testjet_', 'testjet')
TestJetD3PDObject.defineBlock (0, 'Kin', EventCommonD3PDMaker.FourMomFillerTool)
LeadingConstitAssoc = SimpleAssociation \
  (TestJetD3PDObject,
   EventCommonD3PDMaker.LeadingPtAssociationTool,
   level = 0,
   prefix = 'lconstit_',
   blockname = 'LeadingConstitAssoc',
   MultiAssocTool = EventCommonD3PDMaker.NavigableConstituentAssociationTool
     ('LeadingConstitMAssoc', TypeName = 'CaloCluster'))
LeadingConstitAssoc.defineBlock (0, 'LeadKin',
                                 EventCommonD3PDMaker.FourMomFillerTool)


from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
alg = MSMgr.GetStream('StreamNTUP_PHYSICS')
alg += TestJetD3PDObject(10)

Ejemplo n.º 9
0
                          'Kinematics',
                          EventCommonD3PDMaker.FourMomFillerTool,
                          WriteEt=True,
                          WritePt=True)
TauD3PDObject.defineBlock(0, 'Charge', EventCommonD3PDMaker.ChargeFillerTool)
TauD3PDObject.defineBlock(0, 'PID', D3PD__TauPIDFillerTool)
TauD3PDObject.defineBlock(0, 'TauJet', D3PD__TauJetFillerTool)
TauD3PDObject.defineBlock(0, 'TracksToOrigin',
                          D3PD__TauTrackToOriginFillerTool)
# Associate tau with its tracks
TauTrackAssoc = ContainedVectorMultiAssociation \
            (TauD3PDObject,
             D3PD__TauTrackAssociationTool,prefix='track_')
TrackParticlePerigeePVAssoc = SimpleAssociation \
        (TauTrackAssoc,
         TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool,
         prefix = 'atPV_',
             blockname = 'SeedCaloTrkPVAssoc')
TrackParticlePerigeePVAssoc.defineBlock(2,
                                        'TrkPV',
                                        TrackD3PDMaker.TrackPerigeeFillerTool,
                                        FillMomentum=True)
alg += TauD3PDObject(10)

#### Add the primary vertex ####
from TrackD3PDMaker.VertexD3PDObject import PrimaryVertexD3PDObject
alg += PrimaryVertexD3PDObject(0,
                               allowMissing=True,
                               sgkey=D3PDMakerFlags.VertexSGKey(),
                               prefix='vxp_')
Ejemplo n.º 10
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
Ejemplo n.º 11
0
egammaTruthD3PDObject.defineBlock(0, 'TruthInfo',
                                  TruthD3PDMaker.TruthParticleFillerTool)
egammaTruthD3PDObject.defineBlock(
    0,
    'CaloPos',
    D3PDMakerCoreComps.AuxDataFillerTool,
    AuxPrefix=D3PDMakerFlags.EgammaUserDataPrefix(),
    Vars=[
        'etaCalo #Eta position of the impact of the track in calorimeter sampling 2',
        'phiCalo #Phi position of the impact of the track in calorimeter sampling 2'
    ])
egammaTruthD3PDObject.defineBlock(
    0,
    'TruthIso',
    D3PDMakerCoreComps.AuxDataFillerTool,
    AuxPrefix=D3PDMakerFlags.EgammaUserDataPrefix(),
    Vars=['Etcone20'])


ProdVertexAssoc = SimpleAssociation \
                  (egammaTruthD3PDObject,
                   TruthD3PDMaker.TruthParticleProdVertexAssociationTool,
                   level = 1,
                   prefix = 'vx_',
                   blockname = 'ProdVert')
ProdVertexAssoc.defineBlock(1,
                            'ProdVertPos',
                            D3PDMakerCoreComps.AuxDataFillerTool,
                            Vars=['x', 'y', 'z', 'barcode'])
        ChainPattern = D3PDMakerFlags.PhotonL2TrigPattern(),
        allowMissing = True )
    
    PhotonL1IndexAssoc = IndexAssociation(
        PhotonD3PDObject,
        egammaD3PDMaker.egammaL1TriggerObjectAssociationTool,
        target = "trig_L1_emtau_", prefix = "L1_", level = 1,
        ChainPattern = D3PDMakerFlags.egammaL1TrigPattern(),
        blockname = "L1Index")

    ### Matched objects by containment.

    PhotonEFAssoc = SimpleAssociation \
        (PhotonD3PDObject,
         egammaD3PDMaker.egammaEFTriggerObjectAssociationTool,
         matched = 'matched',
         blockname = 'EFInfo',
         prefix = 'EF_',
         ChainPattern = D3PDMakerFlags.PhotonEFTrigPattern(),
         WriteDR = False)
    PhotonEFAssoc.defineBlock (1, 'EFKinematics',
                                 EventCommonD3PDMaker.FourMomFillerTool,
                                 WriteE = True,
                                 WriteEt = True,
                                 WriteM = False)
    PhotonEFAssoc.defineBlock (1, 'EFHadLeakage',
                                 egammaD3PDMaker.egammaDetailFillerTool,
                                 Details = [egammaParameters.ethad,
                                            'Ethad',
                                            egammaParameters.ethad1,
                                            'Ethad1',
                                            ])
Ejemplo n.º 13
0
def DefineVertexD3PDObject(object,
                           trackTarget='trk',
                           trackPrefix='trk_',
                           trackType='Rec::TrackParticleContainer',
                           flags=TrackD3PDFlags):

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

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

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

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

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

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

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

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

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

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

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

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

    TrackParticleAssoc = IndexAssociation(
        TrackAssoc,
        vxTrackAtVertexTrackAssociationTool,
        trackTarget,
        level=flagTestLOD('storeVertexTrackIndexAssociation', flags))
Ejemplo n.º 14
0
def trackParticleLastParametersFiller(tpobj, covarianceLOD=99):

    TPLastParameters = SimpleAssociation \
        (tpobj,
         TrackD3PDMaker.TrackParticleLastParametersAssociationTool,
         suffix = '_LM')
    TPLastParameters.defineBlock(1,
                                 'TPLastQoverP',
                                 TrackD3PDMaker.TrackParametersFillerTool,
                                 LocalType="NONE",
                                 FillPhi=False)
    TPLastParameters.defineBlock(3,
                                 'TPLastParameters',
                                 TrackD3PDMaker.TrackParametersFillerTool,
                                 LocalType="CARTESIAN",
                                 FillThetaAndQoverP=False)
    TPLastErrors = SimpleAssociation \
                   (TPLastParameters,
                    TrackD3PDMaker.TrackParametersErrorMatrixAssociationTool)
    TPLastErrors.defineBlock(2,
                             'TPLastQoverPErr',
                             TrackD3PDMaker.ErrorMatrixErrorFillerTool,
                             LocalType="NONE",
                             FillPhi=False)
    TPLastErrors.defineBlock(3,
                             'TPLastParametersErr',
                             TrackD3PDMaker.ErrorMatrixErrorFillerTool,
                             LocalType="CARTESIAN",
                             FillThetaAndQoverP=False)

    TPLastErrors.defineBlock(covarianceLOD,
                             'TPLastParametersCov',
                             TrackD3PDMaker.ErrorMatrixCovarianceFillerTool,
                             LocalType="CARTESIAN")

    return
Ejemplo n.º 15
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
def TrackParticleImpactParameters (TPD3PDObject,
                                   prefix = 'track',
                                   beam_suffix = 'beam',
                                   pv_suffix = 'pv',
                                   pvunbiased_suffix = 'pvunbiased'):
    """Add to a D3PD object blocks filling in impact parameter information.

TPD3PDObject should be a D3PD object for a TrackParticle
(could be an association).  This will add information for impact
parameters with respect to the beam spot and the primary vertex,
and the unbiased impact parameter with respect to the primary vertex.
The variable names are constructed using the prefix and *_suffix
arguments."""


    #
    # Beamspot
    #
    BSPerigeeAssoc = SimpleAssociation \
                     (TPD3PDObject,
                      TrackD3PDMaker.TrackParticlePerigeeAtBSAssociationTool,
                      blockname = prefix + 'BSPerigeeAssoc',
                      prefix = prefix)
    BSPerigeeAssoc.defineBlock (1, prefix + 'Impact' + beam_suffix,
                                TrackD3PDMaker.PerigeeFillerTool,
                                FillThetaAndQoverP = False,
                                FillPhi = False,
                                Suffix = beam_suffix,
                                DefaultValue = -9999)
    BSCovarAssoc = SimpleAssociation \
                   (BSPerigeeAssoc,
                    TrackD3PDMaker.PerigeeCovarianceAssociationTool,
                    blockname = prefix + 'BSPerigeeCovarAssoc')
    BSCovarAssoc.defineBlock (1, prefix + 'ImpactSig' + beam_suffix,
                              TrackD3PDMaker.ImpactSigmaFillerTool,
                              Suffix = beam_suffix)

    #
    # Primary vertex
    #
    PVPerigeeAssoc = SimpleAssociation \
                     (TPD3PDObject,
                      TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool,
                      blockname = prefix + 'PVPerigeeAssoc',
                      prefix = prefix)
    PVPerigeeAssoc.defineBlock (1, prefix + 'Impact' + pv_suffix,
                                TrackD3PDMaker.PerigeeFillerTool,
                                FillThetaAndQoverP = False,
                                FillPhi = False,
                                Suffix = pv_suffix,
                                DefaultValue = -9999)
    PVCovarAssoc = SimpleAssociation \
                   (PVPerigeeAssoc,
                    TrackD3PDMaker.PerigeeCovarianceAssociationTool,
                    blockname = prefix + 'PVPerigeeCovarAssoc')
    PVCovarAssoc.defineBlock (1, prefix + 'ImpactSig' + pv_suffix,
                              TrackD3PDMaker.ImpactSigmaFillerTool,
                              Suffix = pv_suffix)
Ejemplo n.º 17
0
                                       'Kinematics',
                                       EventCommonD3PDMaker.FourMomFillerTool,
                                       WriteE=True,
                                       WriteEt=True,
                                       WriteRect=True)
Atlfast1ElectronD3PDObject.defineBlock(0, 'Charge',
                                       EventCommonD3PDMaker.ChargeFillerTool)

if rec.doTruth():
    import TruthD3PDMaker.MCTruthClassifierConfig
    Atlfast1ElectronD3PDObject.defineBlock(
        1, 'TruthClassification',
        egammaD3PDMaker.egammaTruthClassificationFillerTool)
    Atlfast1ElectronGenPartAssoc = SimpleAssociation \
        (Atlfast1ElectronD3PDObject,
         egammaD3PDMaker.egammaGenParticleAssociationTool,
         prefix = 'truth_',
         matched = 'matched',
         blockname = 'Truth')
    Atlfast1ElectronGenPartAssoc.defineBlock(
        0,
        'Truth',
        EventCommonD3PDMaker.GenParticleFillerTool,
        WriteE=True,
        WriteM=False)
    Atlfast1ElectronGenPartAssoc.defineBlock(
        0, 'TruthBrem', EventCommonD3PDMaker.GenParticleBremFillerTool)

############################################################################
# Check isolation via associations
#
Atlfast1EleIsoD3PDAssoc = DRAssociation(
Ejemplo n.º 18
0
                           MuonD3PDMaker.MuonComponentTrkParameters)

MuonD3PDObject.defineBlock(2, 'MuonHitSummary',
                           MuonD3PDMaker.MuonTrkHitFillerTool)

MuonD3PDObject.defineBlock(2, 'MuonSpectrometerHitSummary',
                           MuonD3PDMaker.MuonSpectrometerTrkSummary)


MuonTPAssoc = SimpleAssociation \
    (MuonD3PDObject,
     MuonD3PDMaker.MuonTrackParticleAssociationTool,
     matched = 'hastrack',
     blockname = 'TrkInfo')
TrackParticlePerigeeAssoc = SimpleAssociation \
    (MuonTPAssoc,
     TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool,
     prefix = 'track')
TrackParticlePerigeeAssoc.defineBlock(1, 'TrkParameters',
                                      TrackD3PDMaker.TrackPerigeeFillerTool)

TrackParticleCovarAssoc = SimpleAssociation(
    TrackParticlePerigeeAssoc, TrackD3PDMaker.PerigeeCovarianceAssociationTool)
TrackParticleCovarAssoc.defineBlock(1,
                                    'TrkCovDiag',
                                    TrackD3PDMaker.CovarianceFillerTool,
                                    IsTrackPerigee=True,
                                    Error=False,
                                    DiagCovariance=True)
TrackParticleCovarAssoc.defineBlock(2,
                                    'TrkCovOffDiag',
                                    TrackD3PDMaker.CovarianceFillerTool,
Ejemplo n.º 19
0
def TrigBJetD3PDObjects(alg,
                        level=10,
                        doAddL2ID=False,
                        doAddEFID=False,
                        addNaviInfo=True,
                        addConfigInfo=True,
                        addL1Jet=True,
                        addOffTrack=False):

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

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

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

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

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

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

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

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

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

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

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

        alg += EFTrackD3PDObject(level)

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

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

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

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

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

    from TrigBJetD3PDMaker.TrigVertexEFBjetD3PDObject import TrigVertexEFBjetD3PDObject
    trigVertexEFBjetD3PDObject = TrigVertexEFBjetD3PDObject(level)
    #    trigVertexEFBjetD3PDObject.OutputLevel = 1
    alg += trigVertexEFBjetD3PDObject
Ejemplo n.º 20
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.º 21
0
                           ])

MuonD3PDObject.defineBlock(
    4,
    'MuonSpectrometerFieldIntegral',
    D3PDMakerCoreComps.AuxDataFillerTool,
    Vars=['MSFieldIntegral = spectrometerFieldIntegral < float: 0'])

############################################################################
# TrackParticle variables
############################################################################


MuonTPAssoc = SimpleAssociation \
    (MuonD3PDObject,
     MuonD3PDMaker.MuonTrackParticleAssociationTool,
     matched = 'hastrack',
     blockname = 'TrkInfo')
MuonTPAssoc.defineBlock(0, 'Charge',
                        TrackD3PDMaker.TrackParticleChargeFillerTool)
TrackParticlePerigeeAssoc = SimpleAssociation \
    (MuonTPAssoc,
     TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool,
     prefix = 'track',
     blockname = 'TrackParticlePerigeeAssoc')
TrackParticlePerigeeAssoc.defineBlock(1, 'TrkParameters',
                                      TrackD3PDMaker.PerigeeFillerTool)

TrackParticleCovarAssoc = SimpleAssociation(
    TrackParticlePerigeeAssoc,
    TrackD3PDMaker.PerigeeCovarianceAssociationTool,
         'nbCells_s3MedGain',
         'nbCells_s3HighGain',
         ])
            

if rec.doTruth():
    from TruthD3PDMaker.MCTruthClassifierConfig \
         import D3PDMCTruthClassifier
    ElectronD3PDObject.defineBlock (1, 'TruthClassification',
                                    egammaD3PDMaker.egammaTruthClassificationFillerTool,
                                    DoBkgElecOrigin = True,
                                    Classifier = D3PDMCTruthClassifier)
    ElectronTruthPartAssoc = SimpleAssociation \
        (ElectronD3PDObject,
         egammaD3PDMaker.egammaGenParticleAssociationTool,
         prefix = 'truth_',
         matched = 'matched',
         blockname = 'TruthAssoc',
         Classifier = D3PDMCTruthClassifier)
    ElectronTruthPartAssoc.defineBlock (0, 'TruthKin',
                                        EventCommonD3PDMaker.FourMomFillerTool,
                                        WriteE = True,
                                        WriteM = False)
    ElectronTruthPartAssoc.defineBlock (0, 'Truth',
                                        TruthD3PDMaker.TruthParticleFillerTool,
                                        PDGIDVariable = 'type')
    ElectronTruthPartMotherAssoc = SimpleAssociation \
      (ElectronTruthPartAssoc,
       D3PDMakerCoreComps.FirstAssociationTool,
       Associator = TruthD3PDMaker.TruthParticleParentAssociationTool
         ('ElectronTruthPartMotherAssoc2'),
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
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)
Ejemplo n.º 25
0
PixelSiHitD3PDObject = D3PDObject(makeD3PDObject, 'pixhit_',
                                  'PixelSiHitD3PDObject')

PixelSiHitD3PDObject.defineBlock(1, 'Hits', InDetD3PDMaker.SiHitFillerTool)

SctSiHitD3PDObject = D3PDObject(makeD3PDObject, 'scthit_',
                                'SctSiHitD3PDObject')

SctSiHitD3PDObject.defineBlock(1, 'Hits', InDetD3PDMaker.SiHitFillerTool)

# Truth matching
#if rec.doTruth() :
if True:
    TruthAssoc = SimpleAssociation\
                 (PixelSiHitD3PDObject,
                  InDetD3PDMaker.SiHitTruthAssociationTool, prefix="mc_")
    TruthAssoc.defineBlock(1,
                           'TruthAssocIndex',
                           D3PDMakerCoreComps.IndexFillerTool,
                           Target='mc')


    TruthAssoc = SimpleAssociation\
                 (SctSiHitD3PDObject,
                  InDetD3PDMaker.SiHitTruthAssociationTool, prefix="mc_")
    TruthAssoc.defineBlock(1,
                           'TruthAssocIndex',
                           D3PDMakerCoreComps.IndexFillerTool,
                           Target='mc')
Ejemplo n.º 26
0
if InDetD3PDSCTFlags.doClusterToTrackAssociation:
    TrackAssoc = IndexMultiAssociation(
        SCTClusterD3PDObject,
        InDetD3PDMaker.SCTClusterToTrackParticleAssociationTool,
        'trk',
        'trkAssoc_',
        level=1,
        TrackParticleContainerSGKey=D3PDMakerFlags.TrackSGKey())

## Muons ##########################################################################################
## TrackParticle to muon association
if InDetD3PDSCTFlags.doTrackToMuonAssociation:
    if InDetD3PDSCTFlags.useStacoMuonCollectionForAssociation == True:
        MuonAssoc = SimpleAssociation(
            TrackParticleD3PDObject,
            TrackD3PDMaker.SCTTrackParticleToMuonAssociationTool,
            matched='hasMuon',
            MuonContainerSGKey="StacoMuonCollection")
    else:
        MuonAssoc = SimpleAssociation(
            TrackParticleD3PDObject,
            TrackD3PDMaker.SCTTrackParticleToMuonAssociationTool,
            matched='hasMuon',
            MuonContainerSGKey="Muons")

## SCT RDOs ##############################################################################################
## Set up associations for full/extended version
if InDetD3PDSCTFlags.doRdoToClusterAssociation:
    clasterAssoc = IndexAssociation(
        SCTRDOD3PDObject,
        InDetD3PDMaker.SCTRDOClusterAssociationTool,
    ])



ElectronTPAssoc = SimpleAssociation \
    (ElectronD3PDObject,
     egammaD3PDMaker.egammaTrackParticleAssociationTool,
     matched = 'hastrack',
     blockname = 'TrkInfo')

# This generates ERROR messages.  Disabled for now.
#ElectronTPAssoc.defineBlock (1, 'TrackIso',
#                             TrackD3PDMaker.TrackIsolationFillerTool)

TrackParticlePerigeeAssoc = SimpleAssociation \
    (ElectronTPAssoc,
     TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool,
     prefix = 'track')

TrackParticlePerigeeAssoc.defineBlock(1,
                                      'Trk',
                                      TrackD3PDMaker.TrackPerigeeFillerTool,
                                      FillMomentum=True)
TrackParticleCovarAssoc = SimpleAssociation(
    TrackParticlePerigeeAssoc, TrackD3PDMaker.PerigeeCovarianceAssociationTool)
TrackParticleCovarAssoc.defineBlock(3,
                                    'TrkCovDiag',
                                    TrackD3PDMaker.CovarianceFillerTool,
                                    IsTrackPerigee=True,
                                    Error=False,
                                    DiagCovariance=True)
TrackParticleCovarAssoc.defineBlock(3,
Ejemplo n.º 28
0
###########################################################################


Obj1D3PDObject = \
           make_SGDataVector_D3PDObject ('D3PDTest::Obj1Container',
                                         'obj1container',
                                         'o1_')
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)
    'Isolation',
    MuonD3PDMaker.MuonParameterFillerTool,
    Parameters=['1', 'etcone20', '2', 'etcone30', '3', 'etcone40'])

JetTagMuonInJetD3PDObject.defineBlock(1, 'CaloEnergyLoss',
                                      MuonD3PDMaker.MuonELossFillerTool)

JetTagMuonInJetD3PDObject.defineBlock(2,
                                      'MuonHitSummary',
                                      MuonD3PDMaker.MuonTrkHitFillerTool,
                                      SaveIDMuonHitSummary=False)

MuonPrimaryTrackAssoc = SimpleAssociation(
    JetTagMuonInJetD3PDObject,
    MuonD3PDMaker.MuonTrackParticleAssociationTool,
    level=0,
    matched='hastrack',
    blockname="MuonFitQuality",
    prefix=JetTagD3PDKeys.MuonPrimaryTrackAssocPrefix(),
    Type='Primary')

MuonFitQualityAssoc = SimpleAssociation(
    MuonPrimaryTrackAssoc,
    TrackD3PDMaker.TrackParticleFitQualityAssociationTool,
    level=0)

MuonFitQualityAssoc.defineBlock(0, 'TrkFitQuality',
                                TrackD3PDMaker.TrackFitQualityFillerTool)

MuonExtrapolatedTrackAssoc = SimpleAssociation(
    JetTagMuonInJetD3PDObject,
    MuonD3PDMaker.MuonTrackParticleAssociationTool,
Ejemplo n.º 30
0
TauD3PDObject.defineBlock(2, 'TauClustersDetails',
                          TauD3PDMaker.TauClustersDetailsFillerTool)

TauD3PDObject.defineBlock(2, 'TauPi0Clusters',
                          TauD3PDMaker.TauPi0ClusterFillerTool)

TauD3PDObject.defineBlock(2, 'TauSecVtx', TauD3PDMaker.TauSecVtxFillerTool)

TauD3PDObject.defineBlock(3, 'TauCellsDetails',
                          TauD3PDMaker.TauCellsDetailsFillerTool)

###########
# Associate tau with its jet seed
TauJetAssoc = SimpleAssociation \
            (TauD3PDObject,
             TauD3PDMaker.TauJetAssociationTool)
TauJetAssoc.defineBlock \
            (2, 'TauJetAssocKine',
             EventCommonD3PDMaker.FourMomFillerTool,
             prefix='jet_',
             WriteEt = True,
             WritePt = True)

TauJetAssoc.defineBlock \
            (2, 'TauJetAssocMoments',
             JetD3PDMaker.JetMomentFillerTool,Moments=['WIDTH', 'n90',
                                   'n90constituents','fracSamplingMax', 'SamplingMax',
                            'BCH_CORR_CELL', 'BCH_CORR_JET', 'BCH_CORR_JET_FORCELL',
                            'ENG_BAD_CELLS', 'N_BAD_CELLS', 'N_BAD_CELLS_CORR',
                                   'BAD_CELLS_CORR_E'],