Exemplo n.º 1
0
def getInDetxAODParticleCreatorTool(prd_to_track_map=None, suffix=""):
    from AthenaCommon.AppMgr import ToolSvc
    if hasattr(ToolSvc, 'InDetxAODParticleCreatorTool' + suffix):
        return getattr(ToolSvc, 'InDetxAODParticleCreatorTool')

    _perigee_expression = InDetFlags.perigeeExpression()
    # need to treat Vertex specifically because at the time of
    # the track particle creation the primary vertex does not yet exist.
    # The problem is solved by first creating track particles wrt. the beam line
    # and correcting the parameters after the vertex finding.
    if _perigee_expression == 'Vertex':
        _perigee_expression = 'BeamLine'

    from InDetRecExample import TrackingCommon as TrackingCommon
    from InDetRecExample.TrackingCommon import setDefaults
    if prd_to_track_map is None:
        track_summary_tool = TrackingCommon.getInDetTrackSummaryToolSharedHits(
        )
    else:
        prop_args = setDefaults({}, nameSuffix=suffix)
        asso_tool = TrackingCommon.getConstPRD_AssociationTool(
            **setDefaults(prop_args, PRDtoTrackMap=prd_to_track_map))
        helper_tool = TrackingCommon.getInDetSummaryHelperSharedHits(
            **setDefaults(prop_args, AssoTool=asso_tool))
        track_summary_tool = TrackingCommon.getInDetTrackSummaryToolSharedHits(
            **setDefaults(prop_args, InDetSummaryHelperTool=helper_tool))

    from TrkParticleCreator.TrkParticleCreatorConf import Trk__TrackParticleCreatorTool
    InDetxAODParticleCreatorTool = Trk__TrackParticleCreatorTool(
        name="InDetxAODParticleCreatorTool" + suffix,
        Extrapolator=InDetExtrapolator,
        TrackSummaryTool=track_summary_tool,
        BadClusterID=InDetFlags.pixelClusterBadClusterID(),
        KeepParameters=True,
        KeepFirstParameters=InDetFlags.KeepFirstParameters(),
        PerigeeExpression=_perigee_expression)

    ToolSvc += InDetxAODParticleCreatorTool
    if InDetFlags.doPrintConfigurables():
        printfunc(InDetxAODParticleCreatorTool)
    return InDetxAODParticleCreatorTool
Exemplo n.º 2
0
     def __init__(self, InputTrackCollection = None, InputTrackTruthCollection = None, OutputTrackParticleContainer = None):


         from InDetRecExample.InDetJobProperties import InDetFlags
         from InDetRecExample.InDetKeys import InDetKeys
         #
         # --- get ToolSvc and topSequence
         #
         from AthenaCommon.AppMgr                import ToolSvc
         from AthenaCommon.AlgSequence           import AlgSequence
         topSequence = AlgSequence()

         _perigee_expression=InDetFlags.perigeeExpression()
         # need to treat Vertex specifically because at the time of
         # the track particle creation the primary vertex does not yet exist.
         # The problem is solved by first creating track particles wrt. the beam line
         # and correcting the parameters after the vertex finding.
         if _perigee_expression == 'Vertex' :
              _perigee_expression = 'BeamLine'

         #Always the same (so far) so can in principle go in InDetRecLoadTools
         from TrkParticleCreator.TrkParticleCreatorConf import Trk__TrackParticleCreatorTool
         InDetxAODParticleCreatorTool = Trk__TrackParticleCreatorTool(name = "InDetxAODParticleCreatorTool"+InputTrackCollection, 
                                                                      Extrapolator            = InDetExtrapolator,
                                                                      TrackSummaryTool        = InDetTrackSummaryToolSharedHits,
                                                                      BadClusterID            = InDetFlags.pixelClusterBadClusterID(),
                                                                      KeepParameters          = True,
                                                                      KeepFirstParameters     = InDetFlags.KeepFirstParameters(),
                                                                      PerigeeExpression       = _perigee_expression)

         ToolSvc += InDetxAODParticleCreatorTool
         if (InDetFlags.doPrintConfigurables()):
            printfunc (InDetxAODParticleCreatorTool)

         from xAODTrackingCnv.xAODTrackingCnvConf import xAODMaker__TrackParticleCnvAlg
         xAODTrackParticleCnvAlg = xAODMaker__TrackParticleCnvAlg(name = "InDetxAODParticleCreatorAlg"+InputTrackCollection,
                                                                  ConvertTracks = True,
                                                                  ConvertTrackParticles = False,
                                                                  TrackContainerName = InputTrackCollection,
                                                                  xAODContainerName = OutputTrackParticleContainer,
                                                                  xAODTrackParticlesFromTracksContainerName = OutputTrackParticleContainer,
                                                                  TrackParticleCreator = InDetxAODParticleCreatorTool)

         if (InDetFlags.doTruth() and not InputTrackTruthCollection == ''):
             xAODTrackParticleCnvAlg.AddTruthLink = True
             xAODTrackParticleCnvAlg.TrackTruthContainerName = InputTrackTruthCollection

             from MCTruthClassifier.MCTruthClassifierBase import MCTruthClassifier
             xAODTrackParticleCnvAlg.MCTruthClassifier = MCTruthClassifier

         elif (InDetFlags.doTruth() and InputTrackTruthCollection == ''):
             printfunc ("WARNING: ConfiguredxAODTrackParticleCreation - doTruth = True, but no input Truth collection specified!")
         else:
            xAODTrackParticleCnvAlg.AddTruthLink = False

         topSequence += xAODTrackParticleCnvAlg
         if (InDetFlags.doPrintConfigurables()):
            printfunc (xAODTrackParticleCnvAlg)
    xAODTruthCnvPU.xAODTruthPileupEventContainerName = "TruthPileupEvents_PU"  #output
    xAODTruthCnvPU.xAODTruthParticleContainerName = "TruthParticles_PU"  #output
    xAODTruthCnvPU.xAODTruthVertexContainerName = "TruthVertices_PU"  #output
    xAODTruthCnvPU.TruthLinks = "xAODTruthLinks_PU"  #output/intermediate
    xAODTruthCnvPU.MetaObjectName = "TruthMetaData_PU"  #output
    topSequence += xAODTruthCnvPU

from TrkParticleCreator.TrkParticleCreatorConf import Trk__TrackParticleCreatorTool
InDetxAODParticleCreatorTool = Trk__TrackParticleCreatorTool(
    name="InDetxAODParticleCreatorTool",
    Extrapolator=InDetExtrapolator,
    TrackSummaryTool=InDetTrackSummaryToolSharedHits,
    BadClusterID=InDetFlags.pixelClusterBadClusterID(),
    ForceTrackSummaryUpdate=False,
    KeepParameters=True,
    KeepFirstParameters=InDetFlags.KeepFirstParameters(),
    PerigeeExpression=_perigee_expression)

ToolSvc += InDetxAODParticleCreatorTool
if InDetFlags.doPrintConfigurables():
    print InDetxAODParticleCreatorTool

if (
        doCreation or doConversion
):  # or InDetFlags.useExistingTracksAsInput()) : <---- [XXX JDC Should we included this?
    #                                                    problems appear when nothing should
    #                                                    be done but
    #                                                    useExistinTracksAsInput...
    # [XXX JDC: to deal with the MergedTracks case, the truth collections are
    #           defined in the InputTrackCollectionTruth variable. To be deprecated
    #           if finally there is no need of the special "MergedTrack" name