def make_lod (lod, flagthresh): if lod != None: return lod return flagTestLOD ('trackParametersAtBeamLineLevelOfDetails >= %d and reqlev >= %d' % (flagthresh, flagthresh), TrackD3PDFlags)
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))
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
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)
def xAODTrackD3PDObject(_label='trkTrack', _prefix='trkTrack_', _sgkey='TrackParticleCandidate', _object_name='TrackD3PDObject', vertexTarget='vx', vertexPrefix='vx_', vertexSGKey='VxPrimaryCandidate', flags=TrackD3PDFlags): object = make_SGDataVector_D3PDObject ( 'xAOD::TrackParticleContainer', _sgkey, _prefix, _object_name, default_allowMissing = True, default_label = _label, allow_args = ['storeTrackMomentum', 'trackParametersAtGlobalPerigeeLevelOfDetails', 'trackParametersAtPrimaryVertexLevelOfDetails', 'trackParametersAtBeamSpotLevelOfDetails', 'storeDiagonalCovarianceAsErrors', 'storeTrackFitQuality', 'storeTrackPredictionAtBLayer', 'storeTrackInfo', 'storeVertexAssociation', 'storeTrackSummary', ]) ## default perigee (at (0,0,0)) PerigeeAssoc = PerigeeAssociation\ (object, TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool, "GlobalPerigee", fillMomName = 'storeTrackMomentum', levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails') from AthenaCommon.AppMgr import ToolSvc if hasattr(ToolSvc, 'InDetRecTestBLayerTool'): PerigeeAssoc.defineBlock (flagTestLOD('storeTrackPredictionAtBLayer', flags), _prefix+'BLayerInfo', TrackD3PDMaker.PerigeeBLPredictionFillerTool, InDetTestBLayerTool = ToolSvc.InDetRecTestBLayerTool) # perigee at Primary Vertex PerigeeAtPVAssoc = PerigeeAssociation\ (object, TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool, "PerigeeAtPV", suffix='_wrtPV', levelName = 'trackParametersAtPrimaryVertexLevelOfDetails') # perigee at Beam Spot PerigeeAtBSAssoc = PerigeeAssociation\ (object, TrackD3PDMaker.TrackParticlePerigeeAtBSAssociationTool, "PerigeeAtBS", suffix='_wrtBS', levelName = 'trackParametersAtBeamSpotLevelOfDetails') object.defineBlock(flagTestLOD('storeTrackFitQuality', flags), _prefix+'FitQuality', D3PDMakerCoreComps.AuxDataFillerTool, Vars = ['chiSquared', 'numberDoF']) # Track Summary class SumVars: HitSum = 1 << 0 HoleSum = 1 << 1 IDHits = 1 << 2 IDHoles = 1 << 3 IDSharedHits = 1 << 4 IDOutliers = 1 << 5 PixelInfoPlus = 1 << 6 SCTInfoPlus = 1 << 7 TRTInfoPlus = 1 << 8 InfoPlus = 1 << 9 ExpectBLayer = 1 << 10 MuonHits = 1 << 11 DBMHits = 1 << 12 varsTable = [ # ID hits [IDHits, 'nBLHits', 'numberOfInnermostPixelLayerHits'], [IDHits + HitSum, 'nPixHits', 'numberOfPixelHits' ], [IDHits + HitSum, 'nSCTHits', 'numberOfSCTHits' ], [IDHits + HitSum, 'nTRTHits', 'numberOfTRTHits' ], [IDHits, 'nTRTHighTHits', 'numberOfTRTHighThresholdHits'], [IDHits, 'nTRTXenonHits', 'numberOfTRTXenonHits'], # ID holes + dead sensors - needed for appropriate cutting [IDHoles + HoleSum, 'nPixHoles', 'numberOfPixelHoles' ], [IDHoles + HoleSum, 'nSCTHoles', 'numberOfSCTHoles' ], [IDHoles + HoleSum, 'nTRTHoles', 'numberOfTRTHoles' ], [IDHoles, 'nPixelDeadSensors', 'numberOfPixelDeadSensors' ], [IDHoles, 'nSCTDeadSensors', 'numberOfSCTDeadSensors' ], # ID shared & Split hits [IDSharedHits, 'nBLSharedHits', 'numberOfInnermostPixelLayerSharedHits'], [IDSharedHits, 'nPixSharedHits', 'numberOfPixelSharedHits'], [IDSharedHits, 'nSCTSharedHits', 'numberOfSCTSharedHits'], [IDSharedHits, 'nBLayerSplitHits', 'numberOfInnermostPixelLayerSplitHits'], [IDSharedHits, 'nPixSplitHits', 'numberOfPixelSplitHits'], # ID outliers [IDOutliers, 'nBLayerOutliers', 'numberOfInnermostPixelLayerOutliers' ], [IDOutliers, 'nPixelOutliers', 'numberOfPixelOutliers' ], [IDOutliers, 'nSCTOutliers', 'numberOfSCTOutliers' ], [IDOutliers, 'nTRTOutliers', 'numberOfTRTOutliers'], [IDOutliers, 'nTRTHighTOutliers', 'numberOfTRTHighThresholdOutliers'], # Pixel info plus [PixelInfoPlus, 'nContribPixelLayers', 'numberOfContribPixelLayers' ], [PixelInfoPlus, 'nGangedPixels', 'numberOfGangedPixels' ], [PixelInfoPlus, 'nGangedFlaggedFakes', 'numberOfGangedFlaggedFakes' ], [PixelInfoPlus, 'nPixelSpoiltHits', 'numberOfPixelSpoiltHits' ], # SCT info plus [SCTInfoPlus, 'nSCTDoubleHoles', 'numberOfSCTDoubleHoles' ], [SCTInfoPlus, 'nSCTSpoiltHits', 'numberOfSCTSpoiltHits' ], # TRT info plus [TRTInfoPlus, 'nTRTDeadStraws', 'numberOfTRTDeadStraws' ], [TRTInfoPlus, 'nTRTTubeHits', 'numberOfTRTTubeHits' ], [TRTInfoPlus, 'nTRTSharedHits', 'numberOfTRTSharedHits' ], [TRTInfoPlus, 'nTRTHTHitsTotal', 'numberOfTRTHighThresholdHitsTotal' ], # Info plus [InfoPlus, 'nOutliersOnTrack', 'numberOfOutliersOnTrack'], [InfoPlus, 'standardDeviationOfChi2OS',], # Expect BLayer hit [ExpectBLayer, 'expectInnermostPixelLayerHit'], # Muon hits [MuonHits + HitSum, 'numberOfPrecisionLayers'], [MuonHits + HitSum, 'numberOfPrecisionHoleLayers'], [MuonHits + HitSum, 'numberOfPhiLayers'], [MuonHits + HitSum, 'numberOfPhiHoleLayers'], [MuonHits + HitSum, 'numberOfTriggerEtaLayers'], [MuonHits + HitSum, 'numberOfTriggerEtaHoleLayers'], ] @classmethod def varlist (cls, FullInfo, IDHits, IDHoles, IDSharedHits, IDOutliers, PixelInfoPlus, SCTInfoPlus, TRTInfoPlus, InfoPlus, ExpectBLayer, MuonHits, DBMHits, HitSum, HoleSum, ElectronPID, PixeldEdx): ret = [] mask = 0 if FullInfo: mask = ~0 if IDHits: mask |= cls.IDHits if IDHoles: mask |= cls.IDHoles if IDSharedHits: mask |= cls.IDSharedHits if IDOutliers: mask |= cls.IDOutliers if PixelInfoPlus: mask |= cls.PixelInfoPlus if SCTInfoPlus: mask |= cls.SCTInfoPlus if TRTInfoPlus: mask |= cls.TRTInfoPlus if InfoPlus: mask |= cls.InfoPlus if ExpectBLayer: mask |= cls.ExpectBLayer if MuonHits: mask |= cls.MuonHits if DBMHits: mask |= cls.DBMHits if HitSum: mask |= cls.HitSum if HoleSum: mask |= cls.HoleSum for v in cls.varsTable: if (v[0] & mask) != 0: var = v[1] enum = v[2] if len(v) >= 3 else var ret.append (var + ' = ' + enum) if ElectronPID or FullInfo: ret.append ('eProbabilityComb') ret.append ('eProbabilityHT') if PixeldEdx or FullInfo: ret.append ('pixeldEdx') ret.append ('numberOfUsedHitsdEdx') ret.append ('numberOfIBLOverflowsdEdx') return ret sumvarlist = SumVars.varlist ( FullInfo = flags.storeTrackSummary.FullInfo, IDHits = flags.storeTrackSummary.IDHits, IDHoles = flags.storeTrackSummary.IDHoles, IDSharedHits = flags.storeTrackSummary.IDSharedHits, IDOutliers = flags.storeTrackSummary.IDOutliers, PixelInfoPlus = flags.storeTrackSummary.PixelInfoPlus, SCTInfoPlus = flags.storeTrackSummary.SCTInfoPlus, TRTInfoPlus = flags.storeTrackSummary.TRTInfoPlus, InfoPlus = flags.storeTrackSummary.InfoPlus, ExpectBLayer = flags.storeTrackSummary.ExpectBLayer, MuonHits = flags.storeTrackSummary.MuonHits, DBMHits = flags.storeTrackSummary.DBMHits, HitSum = flags.storeTrackSummary.HitSum, HoleSum = flags.storeTrackSummary.HoleSum, ElectronPID = flags.storeTrackSummary.ElectronPID, PixeldEdx = flags.storeTrackSummary.PixeldEdx, ) object.defineBlock (flagTestLOD('storeTrackSummary', flags), _prefix + 'TrackSummary', D3PDMakerCoreComps.AuxDataFillerTool, Vars = sumvarlist) # Track Info object.defineBlock (flagTestLOD('storeTrackInfo', flags), _prefix + 'TrackInfo', D3PDMakerCoreComps.AuxDataFillerTool, Vars = ['trackFitter', 'particleHypothesis', 'trackProperties', 'patternRecoInfo']) # Vertex association VertexAssoc = IndexAssociation ( object, TrackD3PDMaker.TrackParticleVertexAssociationTool, vertexTarget, prefix = vertexPrefix, VxSGKey = vertexSGKey, level = flagTestLOD('storeVertexAssociation', flags)) return object
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