Exemple #1
0
def InDetGlobalChi2Fitter(name='InDetGlobalChi2Fitter', **kwargs):
    split_cluster_map_extension = kwargs.pop('SplitClusterMapExtension', '')

    from InDetRecExample import TrackingCommon as TrackingCommon
    if 'RotCreatorTool' not in kwargs:
        kwargs = setDefaults(
            kwargs,
            RotCreatorTool=TrackingCommon.getInDetRotCreator(
                nameSuffix=split_cluster_map_extension,
                SplitClusterMapExtension=split_cluster_map_extension))

    from InDetRecExample.InDetJobProperties import InDetFlags
    use_broad_cluster_any = InDetFlags.useBroadClusterErrors() and (
        not InDetFlags.doDBMstandalone())
    if 'BroadRotCreatorTool' not in kwargs and not InDetFlags.doRefit():
        kwargs = setDefaults(
            kwargs,
            BroadRotCreatorTool=TrackingCommon.getInDetBroadRotCreator(
                nameSuffix=split_cluster_map_extension,
                SplitClusterMapExtension=split_cluster_map_extension))

    if InDetFlags.doDBMstandalone():
        kwargs = setDefaults(kwargs,
                             StraightLine=True,
                             OutlierCut=5,
                             RecalibrateTRT=False,
                             TRTExtensionCuts=False,
                             TrackChi2PerNDFCut=20)

    if InDetFlags.doRefit() or use_broad_cluster_any is True:
        kwargs = setDefaults(kwargs, RecalibrateSilicon=False)
    if InDetFlags.doRefit():
        kwargs = setDefaults(kwargs,
                             BroadRotCreatorTool=None,
                             ReintegrateOutliers=False,
                             RecalibrateTRT=False)
    if InDetFlags.doRobustReco():
        kwargs = setDefaults(
            kwargs,
            # BroadRotCreatorTool = None
            OutlierCut=10.0,
            TrackChi2PerNDFCut=20)

    if InDetFlags.doRobustReco() or InDetFlags.doCosmics():
        kwargs = setDefaults(kwargs, MaxOutliers=99)
    if InDetFlags.doCosmics() or InDetFlags.doBeamHalo():
        kwargs = setDefaults(kwargs, Acceleration=False)

    if InDetFlags.materialInteractions() and not InDetFlags.solenoidOn():
        kwargs = setDefaults(kwargs, Momentum=1000. * Units.MeV)
    return InDetGlobalChi2FitterBase(name, **kwargs)
Exemple #2
0
def InDetGlobalChi2FitterBase(name='GlobalChi2FitterBase', **kwargs):
    from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc
    from InDetRecExample.TrackingCommon import setDefaults
    from AthenaCommon.AppMgr import ToolSvc
    from InDetRecExample.InDetJobProperties import InDetFlags
    import InDetRecExample.TrackingCommon as TrackingCommon

    kwargs = setDefaults(
        kwargs,
        ExtrapolationTool=TrackingCommon.getInDetExtrapolator(),
        NavigatorTool=TrackingCommon.getInDetNavigator(),
        PropagatorTool=TrackingCommon.getInDetPropagator(),
        MultipleScatteringTool=TrackingCommon.
        getInDetMultipleScatteringUpdator(),
        MeasurementUpdateTool=ToolSvc.InDetUpdator,
        TrackingGeometrySvc=AtlasTrackingGeometrySvc,
        MaterialUpdateTool=TrackingCommon.getInDetMaterialEffectsUpdator(),
        StraightLine=not InDetFlags.solenoidOn(),
        OutlierCut=4,
        SignedDriftRadius=True,
        ReintegrateOutliers=True,
        RecalibrateSilicon=True,
        RecalibrateTRT=True,
        TRTTubeHitCut=
        1.75,  # use tighter hit classification, old: TrackingCommon.default_ScaleHitUncertainty
        MaxIterations=40,
        Acceleration=True,
        RecalculateDerivatives=InDetFlags.doMinBias()
        or InDetFlags.doCosmics() or InDetFlags.doBeamHalo(),
        TRTExtensionCuts=True,
        TrackChi2PerNDFCut=7)
    from TrkGlobalChi2Fitter.TrkGlobalChi2FitterConf import Trk__GlobalChi2Fitter
    return Trk__GlobalChi2Fitter(name, **kwargs)
Exemple #3
0
def InDetGlobalChi2FitterTRT(name='InDetGlobalChi2FitterTRT', **kwargs):
    '''
    Global Chi2 Fitter for TRT segments with different settings
    '''
    split_cluster_map_extension = kwargs.pop('SplitClusterMapExtension', '')

    if 'RotCreatorTool' not in kwargs:
        from InDetRecExample import TrackingCommon as TrackingCommon
        kwargs = setDefaults(
            kwargs,
            RotCreatorTool=TrackingCommon.getInDetRefitRotCreator(
                nameSuffix=split_cluster_map_extension,
                SplitClusterMapExtension=split_cluster_map_extension))

    from InDetRecExample.InDetJobProperties import InDetFlags
    return InDetGlobalChi2FitterBase(
        name,
        **setDefaults(
            kwargs,
            MaterialUpdateTool='',  # default
            TrackingGeometrySvc='',  # default
            SignedDriftRadius=True,  # default,
            RecalibrateSilicon=False,  # default,
            RecalibrateTRT=False,  # default,
            TRTTubeHitCut=2.5,  # default,
            MaxIterations=10,
            Acceleration=False,  # default,
            RecalculateDerivatives=False,
            TRTExtensionCuts=True,  # default,
            TrackChi2PerNDFCut=999999,
            Momentum=1000. * Units.MeV if InDetFlags.materialInteractions()
            and not InDetFlags.solenoidOn() else 0,  # default,
            OutlierCut=5,  # default
            MaxOutliers=99 if InDetFlags.doRobustReco()
            or InDetFlags.doCosmics() else 10,  # default,
            ReintegrateOutliers=False
            if InDetFlags.doRefit() else False  # default
        ))
  def __init__(self, extension = "",InputCollections = None, NewTrackingCuts = None,
               BarrelSegments = None,
               TrackCollectionKeys=[], TrackCollectionTruthKeys=[] ):

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

    # --- Always use PRD association tool (even if only 1 collection) to remove TRT
    #     segments with significant overlaping hits 
    usePrdAssociationTool = True
    #usePrdAssociationTool = True if len(InputCollections) > 0 else False

    #
    # --- get list of already associated hits (always do this, even if no other tracking ran before)
    #
    if usePrdAssociationTool:
      from InDetTrackPRD_Association.InDetTrackPRD_AssociationConf import InDet__InDetTrackPRD_Association
      InDetTRTonly_PRD_Association = InDet__InDetTrackPRD_Association(name            = 'InDetTRTonly_PRD_Association'+extension,
                                                                      AssociationTool = InDetPrdAssociationTool,
                                                                      TracksName      = list(InputCollections)) 
      topSequence += InDetTRTonly_PRD_Association
      if (InDetFlags.doPrintConfigurables()):
        print InDetTRTonly_PRD_Association

    #
    # Cut values and output key for the TRT segments standalone TRT track finder
    #
    if extension == "_TRT":
      # TRT track segments
      pTmin                      = NewTrackingCuts.minPT()
      self.__TRTStandaloneTracks = InDetKeys.TRTTracks()
    else:
      # TRT standalone
      # pTmin                      = NewTrackingCuts.minSecondaryPt()       
      pTmin                      = NewTrackingCuts.minTRTonlyPt() # new cut parameter to make it flexible...
      self.__TRTStandaloneTracks = InDetKeys.TRTTracks_NewT()

    #
    # --- set up special Scoring Tool for standalone TRT tracks
    #
    from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetTrtTrackScoringTool
    InDetTRT_StandaloneScoringTool = InDet__InDetTrtTrackScoringTool(name                = 'InDetTRT_StandaloneScoringTool'+extension,
                                                                     SummaryTool         = InDetTrackSummaryTool,
                                                                     DriftCircleCutTool  = InDetTRTDriftCircleCut,
                                                                     useAmbigFcn         = True,
                                                                     useSigmaChi2        = False,
                                                                     PtMin               = pTmin,
                                                                     minTRTonTrk         = NewTrackingCuts.minTRTonly(),
                                                                     maxEta              = 2.1,
                                                                     UseParameterization = NewTrackingCuts.useTRTonlyParamCuts(),
                                                                     OldTransitionLogic  = NewTrackingCuts.useTRTonlyOldLogic())
    # InDetTRT_StandaloneScoringTool.OutputLevel = VERBOSE 
    ToolSvc += InDetTRT_StandaloneScoringTool
    if (InDetFlags.doPrintConfigurables()):
      print InDetTRT_StandaloneScoringTool


    #
    # set up TRT_SegmentToTrackTool
    #
    from TRT_SegmentToTrackTool.TRT_SegmentToTrackToolConf import InDet__TRT_SegmentToTrackTool
    InDetTRT_SegmentToTrackTool = InDet__TRT_SegmentToTrackTool(name = 'InDetTRT_SegmentToTrackTool'+extension,
                                                                    RefitterTool          = InDetTrackFitterTRT,
                                                                    UseAssociationTool    = usePrdAssociationTool,
                                                                    AssociationTool       = InDetPrdAssociationTool,
                                                                    ScoringTool           = InDetTRT_StandaloneScoringTool,
                                                                    Extrapolator          = InDetExtrapolator,
                                                                    FinalRefit            = True,
                                                                    MaxSharedHitsFraction = NewTrackingCuts.maxTRTonlyShared(),
                                                                    SuppressHoleSearch    = True
                                                                    )
    ToolSvc += InDetTRT_SegmentToTrackTool
    if (InDetFlags.doPrintConfigurables()):
      print InDetTRT_SegmentToTrackTool

    if not InDetFlags.doCosmics():
      #
      # --- TRT standalone tracks algorithm
      #

      from TRT_StandaloneTrackFinder.TRT_StandaloneTrackFinderConf import InDet__TRT_StandaloneTrackFinder
      InDetTRT_StandaloneTrackFinder = InDet__TRT_StandaloneTrackFinder(name                  = 'InDetTRT_StandaloneTrackFinder'+extension,
                                                                        MinNumDriftCircles    = NewTrackingCuts.minTRTonly(),
                                                                        MinPt                 = NewTrackingCuts.minTRTonlyPt(),
                                                                        InputSegmentsLocation = BarrelSegments,
                                                                        MaterialEffects       = 0,
                                                                        ResetPRD              = True if extension == "_TRT" else False,
                                                                        OldTransitionLogic    = NewTrackingCuts.useTRTonlyOldLogic(),
                                                                        OutputTracksLocation  = self.__TRTStandaloneTracks,
                                                                        TRT_SegToTrackTool    = InDetTRT_SegmentToTrackTool
                                                                        )
      #InDetTRT_StandaloneTrackFinder.OutputLevel = VERBOSE
      topSequence += InDetTRT_StandaloneTrackFinder
      if InDetFlags.doPrintConfigurables():
        print InDetTRT_StandaloneTrackFinder

      # --- Delete TRT segments for the subdetector pattern only (back-tracking has already run by this point)
      from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
      InDetSGDeletionAlg(container = "Trk::SegmentCollection#", key = BarrelSegments)
    
    else: 
      #
      # --- cosmics segment to track conversion for Barrel
      #

      from TRT_SegmentsToTrack.TRT_SegmentsToTrackConf import InDet__TRT_SegmentsToTrack
      InDetTrkSegmenttoTrk = InDet__TRT_SegmentsToTrack(name                      = "InDetTRT_SegmentsToTrack_Barrel"+extension,
                                                        InputSegmentsCollection   = BarrelSegments,
                                                        OutputTrackCollection     = self.__TRTStandaloneTracks,
                                                        TrackFitter               = InDetTrackFitter,
                                                        MinNHit                   = NewTrackingCuts.minTRTonly(),
                                                        CombineTracks             = False,
                                                        OutputCombiCollection     = "",
                                                        InputSCTCollection        = "",
                                                        OutlierRemoval            = True,
                                                        MaterialEffects           = False)
      #InDetTrkSegmenttoTrk.OutputLevel = VERBOSE
      topSequence += InDetTrkSegmenttoTrk
      if InDetFlags.doPrintConfigurables():
        print InDetTrkSegmenttoTrk


    #
    #
    # ------------ Track truth.
    #
    if ( extension == "_TRT" or not InDetFlags.doSGDeletion() ):
      if InDetFlags.doTruth():
        #
        # set up the truth info for this container
        #
        include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
        InDetTracksTruth = ConfiguredInDetTrackTruth(self.__TRTStandaloneTracks,
                                                     self.__TRTStandaloneTracks+"DetailedTruth",
                                                     self.__TRTStandaloneTracks+"TruthCollection")
        #
        # add final output for statistics
        #
        TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
        TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
      else:
        TrackCollectionKeys      += [ self.__TRTStandaloneTracks ]
Exemple #5
0
    def __init__(self,
                 extension="",
                 InputCollections=None,
                 NewTrackingCuts=None,
                 BarrelSegments=None,
                 EndcapSegments=None,
                 doPhase=False):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from InDetRecExample.InDetKeys import InDetKeys
        from AthenaCommon.DetFlags import DetFlags

        import InDetRecExample.TrackingCommon as TrackingCommon
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        #
        # --- decide if use the association tool
        #
        if len(InputCollections) > 0:
            usePrdAssociationTool = True
        else:
            usePrdAssociationTool = False
        #
        # --- get list of already associated hits (always do this, even if no other tracking ran before)
        #
        prefix = 'InDetSegment'
        suffix = extension
        if usePrdAssociationTool:
            InDetSegmentPRD_Association = TrackingCommon.getInDetTrackPRD_Association(
                namePrefix=prefix,
                nameSuffix=suffix,
                TracksName=list(InputCollections))
            topSequence += InDetSegmentPRD_Association
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSegmentPRD_Association)

        # ---------------------------------------------------------------
        #
        # --- now the main steering of the TRT segments finding
        #
        # ---------------------------------------------------------------

        if InDetFlags.doCosmics():
            #
            # --- cosmics barrel segments (use TRT track segements even for NewT)
            #

            if doPhase:
                from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_BarrelCosmics
                InDetTRT_TrackSegmentsMakerPhase = InDet__TRT_TrackSegmentsMaker_BarrelCosmics(
                    name='InDetTRTSegmentsMakerPhase' + extension,
                    TrtManagerLocation=InDetKeys.TRT_Manager(),
                    TRT_ClustersContainer=InDetKeys.
                    TRT_DriftCirclesUncalibrated(),
                    IsMagneticFieldOn=InDetFlags.solenoidOn())
                ToolSvc += InDetTRT_TrackSegmentsMakerPhase
                #InDetTRT_TrackSegmentsMakerPhase.OutputLevel = VERBOSE
                if (InDetFlags.doPrintConfigurables()):
                    printfunc(InDetTRT_TrackSegmentsMakerPhase)

            else:
                from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_BarrelCosmics
                InDetTRT_TrackSegmentsMaker = InDet__TRT_TrackSegmentsMaker_BarrelCosmics(
                    name='InDetTRTSegmentsMaker' + extension,
                    TrtManagerLocation=InDetKeys.TRT_Manager(),
                    TRT_ClustersContainer=InDetKeys.TRT_DriftCircles(),
                    IsMagneticFieldOn=InDetFlags.solenoidOn())

                ToolSvc += InDetTRT_TrackSegmentsMaker
                #InDetTRT_TrackSegmentsMaker.OutputLevel = VERBOSE
                if (InDetFlags.doPrintConfigurables()):
                    printfunc(InDetTRT_TrackSegmentsMaker)

        else:
            #
            # --- cut values
            #
            if extension == "_TRT":
                # TRT Subdetector segment finding
                MinNumberDCs = NewTrackingCuts.minTRTonly()
                pTmin = NewTrackingCuts.minPT()
                sharedFrac = NewTrackingCuts.maxTRTonlyShared()
            else:
                # TRT-only/back-tracking segment finding
                MinNumberDCs = NewTrackingCuts.minSecondaryTRTonTrk()
                pTmin = NewTrackingCuts.minSecondaryPt()
                sharedFrac = NewTrackingCuts.maxSecondaryTRTShared()
            #
            # --- offline version  of TRT segemnt making
            #
            from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_ATLxk
            InDetTRT_TrackSegmentsMaker = InDet__TRT_TrackSegmentsMaker_ATLxk(name                    = 'InDetTRT_SeedsMaker'+extension,
                                                                              TRT_ClustersContainer   = InDetKeys.TRT_DriftCircles(),
                                                                              PropagatorTool          = InDetPatternPropagator,
                                                                              TrackExtensionTool      = InDetTRTExtensionTool,
                                                                              PRDtoTrackMap           = prefix+'PRDtoTrackMap'+suffix \
                                                                                                          if usePrdAssociationTool else '',
                                                                              RemoveNoiseDriftCircles = InDetFlags.removeTRTNoise(),
                                                                              MinNumberDriftCircles   = MinNumberDCs,
                                                                              NumberMomentumChannel   = NewTrackingCuts.TRTSegFinderPtBins(),
                                                                              pTmin                   = pTmin,
                                                                              sharedFrac              = sharedFrac)
            ToolSvc += InDetTRT_TrackSegmentsMaker
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetTRT_TrackSegmentsMaker)

            # Condition algorithm for InDet__TRT_TrackSegmentsMaker_ATLxk
            from AthenaCommon.AlgSequence import AthSequencer
            condSeq = AthSequencer("AthCondSeq")
            if not hasattr(condSeq,
                           "InDet__TRT_TrackSegmentsMakerCondAlg_ATLxk"):
                from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMakerCondAlg_ATLxk
                InDetTRT_TrackSegmentsMakerCondAlg = InDet__TRT_TrackSegmentsMakerCondAlg_ATLxk(
                    name='InDetTRT_SeedsMakerCondAlg' + extension,
                    PropagatorTool=InDetPatternPropagator,
                    NumberMomentumChannel=NewTrackingCuts.TRTSegFinderPtBins(),
                    pTmin=pTmin)
                condSeq += InDetTRT_TrackSegmentsMakerCondAlg

        #
        # --- TRT track reconstruction
        #
        from TRT_TrackSegmentsFinder.TRT_TrackSegmentsFinderConf import InDet__TRT_TrackSegmentsFinder

        if doPhase:
            InDetTRT_TrackSegmentsFinderPhase = InDet__TRT_TrackSegmentsFinder(
                name='InDetTRT_TrackSegmentsFinderPhase' + extension,
                SegmentsMakerTool=InDetTRT_TrackSegmentsMakerPhase,
                SegmentsLocation=BarrelSegments)

            topSequence += InDetTRT_TrackSegmentsFinderPhase
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetTRT_TrackSegmentsFinderPhase)

        else:

            if InDetFlags.doCaloSeededTRTSegments(
            ) or NewTrackingCuts.RoISeededBackTracking():
                InDetTRT_TrackSegmentsFinder = InDet__TRT_TrackSegmentsFinder(
                    name='InDetTRT_TrackSegmentsFinder' + extension,
                    SegmentsMakerTool=InDetTRT_TrackSegmentsMaker,
                    SegmentsLocation=BarrelSegments,
                    useCaloSeeds=True,
                    CaloClusterEt=NewTrackingCuts.minRoIClusterEt(),
                    MinNumberDriftCircles=NewTrackingCuts.minSecondaryTRTonTrk(
                    ),
                    InputClusterContainerName=InDetKeys.
                    CaloClusterROIContainer())

            else:
                InDetTRT_TrackSegmentsFinder = InDet__TRT_TrackSegmentsFinder(
                    name='InDetTRT_TrackSegmentsFinder' + extension,
                    SegmentsMakerTool=InDetTRT_TrackSegmentsMaker,
                    SegmentsLocation=BarrelSegments,
                    InputClusterContainerName="")

            topSequence += InDetTRT_TrackSegmentsFinder
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetTRT_TrackSegmentsFinder)

        #
        # --- load TRT validation alg
        #
        if InDetFlags.doTruth() and not InDetFlags.doCosmics():
            from InDetSegmentDriftCircleAssValidation.InDetSegmentDriftCircleAssValidationConf import InDet__SegmentDriftCircleAssValidation
            InDetSegmentDriftCircleAssValidation = InDet__SegmentDriftCircleAssValidation(
                name="InDetSegmentDriftCircleAssValidation" + extension,
                OrigTracksLocation=BarrelSegments,
                TRT_DriftCirclesName=InDetKeys.TRT_DriftCircles(),
                pTmin=pTmin,
                Pseudorapidity=2.1,  # end of TRT
                RadiusMin=0.,
                RadiusMax=600.,
                MinNumberDCs=MinNumberDCs)
            topSequence += InDetSegmentDriftCircleAssValidation
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSegmentDriftCircleAssValidation)
        #
        # ----------- import, lock and print InDetKeys
        #
        from InDetRecExample.InDetKeys import InDetKeys
        InDetKeys.lockAllExceptAlias()
        print "Printing InDetKeys"
        InDetKeys.print_JobProperties()

        #
        # --- setup of cut values for NewTracking
        #
        if (not 'InDetNewTrackingCuts' in dir()):
            print "InDetRec_jobOptions: InDetNewTrackingCuts not set before - import them now"
            from InDetRecExample.ConfiguredNewTrackingCuts import ConfiguredNewTrackingCuts
            if InDetFlags.doCosmics():
                InDetNewTrackingCuts = ConfiguredNewTrackingCuts("Cosmics")
            elif InDetFlags.doHeavyIon():
                InDetNewTrackingCuts = ConfiguredNewTrackingCuts("HeavyIon")
            elif InDetFlags.doSLHC():
                InDetNewTrackingCuts = ConfiguredNewTrackingCuts("SLHC")
            elif InDetFlags.doMinBias():
                InDetNewTrackingCuts = ConfiguredNewTrackingCuts("MinBias")
            else:
                InDetNewTrackingCuts = ConfiguredNewTrackingCuts("Offline")
        InDetNewTrackingCuts.printInfo()
        # --- backward compatible
        InDetCutValues = InDetNewTrackingCuts

        #
        # --- setup of cut values for  Primary vertexing
  def __init__(self, extension = "",InputCollections = None, NewTrackingCuts = None, BarrelSegments = None, EndcapSegments = None, doPhase = False):

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

    #
    # --- decide if use the association tool
    #
    if len(InputCollections) > 0:
      usePrdAssociationTool = True
    else:
      usePrdAssociationTool = False
    #
    # --- get list of already associated hits (always do this, even if no other tracking ran before)
    #
    if usePrdAssociationTool:
      from InDetTrackPRD_Association.InDetTrackPRD_AssociationConf import InDet__InDetTrackPRD_Association
      InDetSegmentPRD_Association = InDet__InDetTrackPRD_Association(name            = 'InDetSegmentPRD_Association'+extension,
                                                                     AssociationTool = InDetPrdAssociationTool,
                                                                     TracksName      = list(InputCollections)) 
      topSequence += InDetSegmentPRD_Association
      if (InDetFlags.doPrintConfigurables()):
        print InDetSegmentPRD_Association

    # ---------------------------------------------------------------
    #
    # --- now the main steering of the TRT segments finding
    #
    # ---------------------------------------------------------------

    if InDetFlags.doCosmics():
      #
      # --- cosmics barrel segments (use TRT track segements even for NewT) 
      #
      
      if doPhase:
       from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_BarrelCosmics
       InDetTRT_TrackSegmentsMakerPhase = InDet__TRT_TrackSegmentsMaker_BarrelCosmics(name = 'InDetTRTSegmentsMakerPhase'+extension,
                                                                                      TrtManagerLocation      = InDetKeys.TRT_Manager(),
                                                                                      TRT_ClustersContainer   = InDetKeys.TRT_DriftCirclesUncalibrated(),
                                                                                      AssosiationTool         = InDetPrdAssociationTool,
                                                                                      UseAssosiationTool      = usePrdAssociationTool,
                                                                                      IsMagneticFieldOn       = InDetFlags.solenoidOn())
       ToolSvc += InDetTRT_TrackSegmentsMakerPhase
       #InDetTRT_TrackSegmentsMakerPhase.OutputLevel = VERBOSE 
       if (InDetFlags.doPrintConfigurables()):
         print InDetTRT_TrackSegmentsMakerPhase

      else:
       from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_BarrelCosmics
       InDetTRT_TrackSegmentsMaker = InDet__TRT_TrackSegmentsMaker_BarrelCosmics(name = 'InDetTRTSegmentsMaker'+extension,
                                                                                 TrtManagerLocation      = InDetKeys.TRT_Manager(),
                                                                                 TRT_ClustersContainer   = InDetKeys.TRT_DriftCircles(),
                                                                                 AssosiationTool         = InDetPrdAssociationTool,
                                                                                 UseAssosiationTool      = usePrdAssociationTool,
                                                                                 IsMagneticFieldOn       = InDetFlags.solenoidOn()) 

       ToolSvc += InDetTRT_TrackSegmentsMaker
       #InDetTRT_TrackSegmentsMaker.OutputLevel = VERBOSE
       if (InDetFlags.doPrintConfigurables()):
         print InDetTRT_TrackSegmentsMaker

    else:
      #
      # --- cut values
      #
      if extension == "_TRT":
        # TRT Subdetector segment finding
        MinNumberDCs   = NewTrackingCuts.minTRTonly()
        pTmin          = NewTrackingCuts.minPT()
        sharedFrac     = NewTrackingCuts.maxTRTonlyShared()
      else:
        # TRT-only/back-tracking segment finding
        MinNumberDCs   = NewTrackingCuts.minSecondaryTRTonTrk()
        pTmin          = NewTrackingCuts.minSecondaryPt()
        sharedFrac     = NewTrackingCuts.maxSecondaryTRTShared()
      #
      # --- offline version  of TRT segemnt making
      #
      from TRT_TrackSegmentsTool_xk.TRT_TrackSegmentsTool_xkConf import InDet__TRT_TrackSegmentsMaker_ATLxk
      InDetTRT_TrackSegmentsMaker = InDet__TRT_TrackSegmentsMaker_ATLxk(name                    = 'InDetTRT_SeedsMaker'+extension,
                                                                        TrtManagerLocation      = InDetKeys.TRT_Manager(),
                                                                        TRT_ClustersContainer   = InDetKeys.TRT_DriftCircles(),
                                                                        PropagatorTool          = InDetPatternPropagator,
                                                                        TrackExtensionTool      = InDetTRTExtensionTool,
                                                                        UseAssosiationTool      = usePrdAssociationTool,
                                                                        AssosiationTool         = InDetPrdAssociationTool,
                                                                        RemoveNoiseDriftCircles = InDetFlags.removeTRTNoise(),
                                                                        MinNumberDriftCircles   = MinNumberDCs,
                                                                        NumberMomentumChannel   = NewTrackingCuts.TRTSegFinderPtBins(),
                                                                        pTmin                   = pTmin,
                                                                        sharedFrac              = sharedFrac)
      ToolSvc += InDetTRT_TrackSegmentsMaker
      if (InDetFlags.doPrintConfigurables()):
        print InDetTRT_TrackSegmentsMaker

    #
    # --- TRT track reconstruction
    #
    from TRT_TrackSegmentsFinder.TRT_TrackSegmentsFinderConf import InDet__TRT_TrackSegmentsFinder
    
    if doPhase: 
      InDetTRT_TrackSegmentsFinderPhase = InDet__TRT_TrackSegmentsFinder(name              = 'InDetTRT_TrackSegmentsFinderPhase'+extension,
                                                                         SegmentsMakerTool   = InDetTRT_TrackSegmentsMakerPhase,
                                                                         SegmentsLocation    = BarrelSegments)

      topSequence += InDetTRT_TrackSegmentsFinderPhase
      if (InDetFlags.doPrintConfigurables()):
       print InDetTRT_TrackSegmentsFinderPhase

    else:

     if InDetFlags.doCaloSeededTRTSegments() or NewTrackingCuts.RoISeededBackTracking():
      InDetTRT_TrackSegmentsFinder = InDet__TRT_TrackSegmentsFinder(name              = 'InDetTRT_TrackSegmentsFinder'+extension,
                                                                    SegmentsMakerTool   = InDetTRT_TrackSegmentsMaker,
                                                                    SegmentsLocation    = BarrelSegments,
                                                                    useCaloSeeds        = True,
                                                                    InputClusterContainerName = InDetKeys.CaloClusterROIContainer())

     else:
      InDetTRT_TrackSegmentsFinder = InDet__TRT_TrackSegmentsFinder(name              = 'InDetTRT_TrackSegmentsFinder'+extension,
                                                                    SegmentsMakerTool   = InDetTRT_TrackSegmentsMaker,
                                                                    SegmentsLocation    = BarrelSegments) 


     topSequence += InDetTRT_TrackSegmentsFinder
     if (InDetFlags.doPrintConfigurables()):
      print InDetTRT_TrackSegmentsFinder
      
    #
    # --- load TRT validation alg
    #
    if InDetFlags.doTruth() and not InDetFlags.doCosmics():
      from InDetSegmentDriftCircleAssValidation.InDetSegmentDriftCircleAssValidationConf import InDet__SegmentDriftCircleAssValidation
      InDetSegmentDriftCircleAssValidation = InDet__SegmentDriftCircleAssValidation(name                 = "InDetSegmentDriftCircleAssValidation"+extension,
                                                                                    OrigTracksLocation   = BarrelSegments                  ,
                                                                                    TRT_DriftCirclesName = InDetKeys.TRT_DriftCircles()    ,
                                                                                    pTmin                = pTmin                           ,
                                                                                    Pseudorapidity       = 2.1                             , # end of TRT
                                                                                    RadiusMin            = 0.                              ,
                                                                                    RadiusMax            = 600.                            ,
                                                                                    MinNumberDCs         = MinNumberDCs)
      topSequence += InDetSegmentDriftCircleAssValidation
      if (InDetFlags.doPrintConfigurables()):
        print InDetSegmentDriftCircleAssValidation
   def __init__(self, useTimeInfo = True, usePhase = False):

      from InDetRecExample.InDetJobProperties import InDetFlags
      from AthenaCommon.DetFlags              import DetFlags
      from AthenaCommon.GlobalFlags           import globalflags
      from AthenaCommon.BeamFlags             import jobproperties
      #
      # get ToolSvc and topSequence
      #
      from AthenaCommon.AppMgr      import ToolSvc
      from AthenaCommon.AlgSequence import AlgSequence
      topSequence = AlgSequence()
      
      if InDetFlags.doPRDFormation() and DetFlags.makeRIO.TRT_on() and InDetFlags.doTRT_PRDFormation():

         #
         # --- setup naming of tools and algs
         #
         if useTimeInfo:
            prefix     = "InDetTRT_"
            collection = InDetKeys.TRT_DriftCircles()
         else:
            prefix     = "InDetTRT_noTime_"
            collection = InDetKeys.TRT_DriftCirclesUncalibrated()
         #
         # --- TRT_DriftFunctionTool
         #
         from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool
         InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool(name                = prefix+"DriftFunctionTool",
                                                            TRTCalDbTool        = InDetTRTCalDbSvc)
         # --- overwrite for uncalibrated DC production
         if (not useTimeInfo) or InDetFlags.noTRTTiming():
            InDetTRT_DriftFunctionTool.DummyMode      = True
            InDetTRT_DriftFunctionTool.UniversalError = 1.15
         # --- overwrite for calibration of MC
         if usePhase and jobproperties.Beam.beamType()=='cosmics' and globalflags.DataSource == "geant4":
            InDetTRT_DriftFunctionTool.AllowDigiVersionOverride = True
            InDetTRT_DriftFunctionTool.ForcedDigiVersion        = 9

         ToolSvc += InDetTRT_DriftFunctionTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_DriftFunctionTool
         #
         # --- TRT_DriftCircleTool
         #
         if usePhase:
            from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleToolCosmics as InDet__TRT_DriftCircleTool
         else:
            from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleTool

         #
         # set gating values for MC/DATA
         MinTrailingEdge = 11.0*ns
         MaxDriftTime    = 60.0*ns
         LowGate         = 14.0625*ns # 4.5*3.125 ns
         HighGate        = 42.1875*ns # LowGate + 9*3.125 ns
         if InDetFlags.doCosmics():
            LowGate         = 19.0*ns
            HighGate        = 44.0*ns
         if globalflags.DataSource == 'data':
            MinTrailingEdge = 11.0*ns
            MaxDriftTime    = 60.0*ns
            LowGate         = 14.0625*ns # 4.5*3.125 ns
            HighGate        = 42.1875*ns # LowGate + 9*3.125 ns
            if InDetFlags.doCosmics():
               LowGate         = 19.0*ns
               HighGate        = 44.0*ns

         InDetTRT_DriftCircleTool = InDet__TRT_DriftCircleTool(name                            = prefix+"DriftCircleTool",
                                                               TRTDriftFunctionTool            = InDetTRT_DriftFunctionTool,
                                                               TrtDescrManageLocation          = InDetKeys.TRT_Manager(),
                                                               ConditionsSummaryTool           = InDetTRTStrawStatusSummarySvc,
                                                               #used to be InDetTRTConditionsSummaryService,
                                                               UseConditionsStatus             = True,
                                                               UseConditionsHTStatus           = True,
                                                               SimpleOutOfTimePileupSupression = InDetFlags.doCosmics(),
                                                               RejectIfFirstBit                = False, # fixes 50 nsec issue 
                                                               MinTrailingEdge                 = MinTrailingEdge,
                                                               MaxDriftTime                    = MaxDriftTime,
                                                               ValidityGateSuppression         = not InDetFlags.doCosmics(),
                                                               LowGate                         = LowGate,
                                                               HighGate                        = HighGate,
                                                               MaskFirstHTBit                  = False,
                                                               MaskMiddleHTBit                 = False,
                                                               MaskLastHTBit                   = False,
                                                               SimpleOutOfTimePileupSupressionArgon = InDetFlags.doCosmics(),
                                                               RejectIfFirstBitArgon                = False, # fixes 50 nsec issue 
                                                               MinTrailingEdgeArgon                 = MinTrailingEdge,
                                                               MaxDriftTimeArgon                    = MaxDriftTime,
                                                               ValidityGateSuppressionArgon         = not InDetFlags.doCosmics(),
                                                               LowGateArgon                         = LowGate,
                                                               HighGateArgon                        = HighGate,
                                                               MaskFirstHTBitArgon                  = False,
                                                               MaskMiddleHTBitArgon                 = False,
                                                               MaskLastHTBitArgon                   = False,
                                                               useDriftTimeHTCorrection        = True,
                                                               useDriftTimeToTCorrection       = True) # reenable ToT

         from AthenaCommon.BeamFlags import jobproperties 
         if InDetFlags.InDet25nsec() and jobproperties.Beam.beamType()=="collisions": 
            InDetTRT_DriftCircleTool.ValidityGateSuppression=True  
            InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression=False  
         if jobproperties.Beam.beamType()=="cosmics": 
            InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression=False 

# --- overwrite for phase usage
         if usePhase:
            InDetTRT_DriftCircleTool.ComTimeName = "TRT_Phase"

         ToolSvc += InDetTRT_DriftCircleTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_DriftCircleTool
         
         #
         # --- TRT_RIO_Maker Algorithm
         #
         from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__TRT_RIO_Maker
         InDetTRT_RIO_Maker = InDet__TRT_RIO_Maker(name                   = prefix+"RIO_Maker",
                                                   TRT_DriftCircleTool    = InDetTRT_DriftCircleTool,
                                                   TrtDescrManageLocation = InDetKeys.TRT_Manager(),
                                                   TRTRDOLocation         = InDetKeys.TRT_RDOs(),
                                                   TRTRIOLocation         = collection)
         topSequence += InDetTRT_RIO_Maker
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_RIO_Maker

         #
         #    Include alg to save the local occupancy inside xAOD::EventInfo
         #
         if InDetFlags.doTRTGlobalOccupancy():
          from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy
          InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(  name 		= "InDet_TRT_LocalOccupancy",
								isTrigger	= False
	  )

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


          from TRT_CalibAlgs.TRT_CalibAlgsConf import TRTOccupancyInclude
          TRTOccupancyInclude = TRTOccupancyInclude( name = prefix+"TRTOccupancyInclude",
                                                   TRT_LocalOccupancyTool = InDetTRT_LocalOccupancy)
         
          topSequence += TRTOccupancyInclude
          if (InDetFlags.doPrintConfigurables()):
                  print TRTOccupancyInclude

       
         #
         # --- we need to do truth association if requested (not for uncalibrated hits in cosmics)
         #
         if InDetFlags.doTruth() and useTimeInfo:
            from InDetTruthAlgs.InDetTruthAlgsConf import InDet__PRD_MultiTruthMaker
            InDetPRD_MultiTruthMakerTRT = InDet__PRD_MultiTruthMaker (name                        = prefix+"PRD_MultiTruthMaker",
                                                                      PixelClusterContainerName   = "",
                                                                      SCTClusterContainerName     = "",
                                                                      TRTDriftCircleContainerName = InDetKeys.TRT_DriftCircles(),
                                                                      SimDataMapNamePixel         = "",
                                                                      SimDataMapNameSCT           = "",
                                                                      SimDataMapNameTRT           = InDetKeys.TRT_SDOs(),
                                                                      TruthNamePixel              = "",
                                                                      TruthNameSCT                = "",
                                                                      TruthNameTRT                = InDetKeys.TRT_DriftCirclesTruth())
            topSequence += InDetPRD_MultiTruthMakerTRT
            if (InDetFlags.doPrintConfigurables()):
               print InDetPRD_MultiTruthMakerTRT
Exemple #9
0
    def __init__(self,
                 extension="",
                 InputCollections=None,
                 NewTrackingCuts=None,
                 BarrelSegments=None,
                 TrackCollectionKeys=[],
                 TrackCollectionTruthKeys=[]):

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

        # --- Always use PRD association tool (even if only 1 collection) to remove TRT
        #     segments with significant overlaping hits
        usePrdAssociationTool = True
        #usePrdAssociationTool = True if len(InputCollections) > 0 else False

        #
        # --- get list of already associated hits (always do this, even if no other tracking ran before)
        #
        if usePrdAssociationTool:
            from InDetTrackPRD_Association.InDetTrackPRD_AssociationConf import InDet__InDetTrackPRD_Association
            InDetTRTonly_PRD_Association = InDet__InDetTrackPRD_Association(
                name='InDetTRTonly_PRD_Association' + extension,
                AssociationTool=InDetPrdAssociationTool,
                TracksName=list(InputCollections))
            topSequence += InDetTRTonly_PRD_Association
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRTonly_PRD_Association

        #
        # Cut values and output key for the TRT segments standalone TRT track finder
        #
        if extension == "_TRT":
            # TRT track segments
            pTmin = NewTrackingCuts.minPT()
            self.__TRTStandaloneTracks = InDetKeys.TRTTracks()
        else:
            # TRT standalone
            # pTmin                      = NewTrackingCuts.minSecondaryPt()
            pTmin = NewTrackingCuts.minTRTonlyPt(
            )  # new cut parameter to make it flexible...
            self.__TRTStandaloneTracks = InDetKeys.TRTTracks_NewT()

        #
        # --- set up special Scoring Tool for standalone TRT tracks
        #
        from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetTrtTrackScoringTool
        InDetTRT_StandaloneScoringTool = InDet__InDetTrtTrackScoringTool(
            name='InDetTRT_StandaloneScoringTool' + extension,
            SummaryTool=InDetTrackSummaryTool,
            DriftCircleCutTool=InDetTRTDriftCircleCut,
            useAmbigFcn=True,
            useSigmaChi2=False,
            PtMin=pTmin,
            minTRTonTrk=NewTrackingCuts.minTRTonly(),
            maxEta=2.1,
            UseParameterization=NewTrackingCuts.useTRTonlyParamCuts(),
            OldTransitionLogic=NewTrackingCuts.useTRTonlyOldLogic(),
            minTRTPrecisionFraction=NewTrackingCuts.minSecondaryTRTPrecFrac())
        # InDetTRT_StandaloneScoringTool.OutputLevel = VERBOSE
        ToolSvc += InDetTRT_StandaloneScoringTool
        if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_StandaloneScoringTool

        #
        # set up TRT_SegmentToTrackTool
        #
        from TRT_SegmentToTrackTool.TRT_SegmentToTrackToolConf import InDet__TRT_SegmentToTrackTool
        InDetTRT_SegmentToTrackTool = InDet__TRT_SegmentToTrackTool(
            name='InDetTRT_SegmentToTrackTool' + extension,
            RefitterTool=InDetTrackFitterTRT,
            UseAssociationTool=usePrdAssociationTool,
            AssociationTool=InDetPrdAssociationTool,
            ScoringTool=InDetTRT_StandaloneScoringTool,
            Extrapolator=InDetExtrapolator,
            FinalRefit=True,
            MaxSharedHitsFraction=NewTrackingCuts.maxTRTonlyShared(),
            SuppressHoleSearch=True)
        ToolSvc += InDetTRT_SegmentToTrackTool
        if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SegmentToTrackTool

        if not InDetFlags.doCosmics():
            #
            # --- TRT standalone tracks algorithm
            #

            from TRT_StandaloneTrackFinder.TRT_StandaloneTrackFinderConf import InDet__TRT_StandaloneTrackFinder
            InDetTRT_StandaloneTrackFinder = InDet__TRT_StandaloneTrackFinder(
                name='InDetTRT_StandaloneTrackFinder' + extension,
                MinNumDriftCircles=NewTrackingCuts.minTRTonly(),
                MinPt=NewTrackingCuts.minTRTonlyPt(),
                InputSegmentsLocation=BarrelSegments,
                MaterialEffects=0,
                ResetPRD=True if extension == "_TRT" else False,
                OldTransitionLogic=NewTrackingCuts.useTRTonlyOldLogic(),
                OutputTracksLocation=self.__TRTStandaloneTracks,
                TRT_SegToTrackTool=InDetTRT_SegmentToTrackTool)
            #InDetTRT_StandaloneTrackFinder.OutputLevel = VERBOSE
            topSequence += InDetTRT_StandaloneTrackFinder
            if InDetFlags.doPrintConfigurables():
                print InDetTRT_StandaloneTrackFinder

            # --- Delete TRT segments for the subdetector pattern only (back-tracking has already run by this point)
            from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
            InDetSGDeletionAlg(container="Trk::SegmentCollection#",
                               key=BarrelSegments)

        else:
            #
            # --- cosmics segment to track conversion for Barrel
            #

            from TRT_SegmentsToTrack.TRT_SegmentsToTrackConf import InDet__TRT_SegmentsToTrack
            InDetTrkSegmenttoTrk = InDet__TRT_SegmentsToTrack(
                name="InDetTRT_SegmentsToTrack_Barrel" + extension,
                InputSegmentsCollection=BarrelSegments,
                OutputTrackCollection=self.__TRTStandaloneTracks,
                TrackFitter=InDetTrackFitter,
                MinNHit=NewTrackingCuts.minTRTonly(),
                CombineTracks=False,
                OutputCombiCollection="",
                InputSCTCollection="",
                OutlierRemoval=True,
                MaterialEffects=False)
            #InDetTrkSegmenttoTrk.OutputLevel = VERBOSE
            topSequence += InDetTrkSegmenttoTrk
            if InDetFlags.doPrintConfigurables():
                print InDetTrkSegmenttoTrk

        #
        #
        # ------------ Track truth.
        #
        if (extension == "_TRT" or not InDetFlags.doSGDeletion()):
            if InDetFlags.doTruth():
                #
                # set up the truth info for this container
                #
                include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                InDetTracksTruth = ConfiguredInDetTrackTruth(
                    self.__TRTStandaloneTracks,
                    self.__TRTStandaloneTracks + "DetailedTruth",
                    self.__TRTStandaloneTracks + "TruthCollection")
                #
                # add final output for statistics
                #
                TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                TrackCollectionTruthKeys += [InDetTracksTruth.TracksTruth()]
            else:
                TrackCollectionKeys += [self.__TRTStandaloneTracks]
   def __init__(self, NewTrackingCuts = None, SiTrackCollection = None, ExtendedTrackCollection = None, ExtendedTracksMap = None, TrackCollectionKeys=[], TrackCollectionTruthKeys=[] , doPhase = True):
      
      from InDetRecExample.InDetJobProperties import InDetFlags
      from AthenaCommon.DetFlags              import DetFlags
      from InDetRecExample.InDetKeys          import InDetKeys
      #
      # get ToolSvc and topSequence
      #
      from AthenaCommon.AppMgr                import ToolSvc
      from AthenaCommon.AlgSequence           import AlgSequence
      topSequence = AlgSequence()
      
      #    
      # ---------- TRT_TrackExtension
      #
      if InDetFlags.doTRTExtension():


         #
         # Track extension to TRT algorithm
         #
         # set output extension map name
         OutputExtendedTracks = ExtendedTracksMap

         if doPhase:

           from TRT_TrackExtensionTool_xk.TRT_TrackExtensionTool_xkConf import InDet__TRT_TrackExtensionToolCosmics
           InDetTRTExtensionToolPhase = InDet__TRT_TrackExtensionToolCosmics(name                  = 'InDetTRT_ExtensionToolPhase',
                                                                             Propagator            = InDetPropagator,
                                                                             Extrapolator          = InDetExtrapolator,
                                                                             TRT_ClustersContainer = InDetKeys.TRT_DriftCirclesUncalibrated(),
                                                                             SearchNeighbour       = False, #needs debugging!!!
                                                                             RoadWidth             = 20.)

           ToolSvc += InDetTRTExtensionToolPhase
      

           from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
           InDetTRTExtensionPhase    = InDet__TRT_TrackExtensionAlg (name                   = 'InDetTRT_ExtensionPhase'+NewTrackingCuts.extension(),
                                                                     InputTracksLocation    = SiTrackCollection,
                                                                     ExtendedTracksLocation = OutputExtendedTracks,
                                                                     TrackExtensionTool     = InDetTRTExtensionToolPhase)
           
           topSequence += InDetTRTExtensionPhase
           if (InDetFlags.doPrintConfigurables()):
            print InDetTRTExtensionPhase
           
         #
         else: 
          from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
          InDetTRTExtension    = InDet__TRT_TrackExtensionAlg (name                   = 'InDetTRT_Extension'+NewTrackingCuts.extension(),
                                                              InputTracksLocation    = SiTrackCollection,
                                                              ExtendedTracksLocation = OutputExtendedTracks,
                                                              TrackExtensionTool     = InDetTRTExtensionTool)
          #InDetTRTExtension.OutputLevel = VERBOSE
          topSequence += InDetTRTExtension
          if (InDetFlags.doPrintConfigurables()):
            print InDetTRTExtension
   
      #
      # ------------ Track Extension Processor
      #
      if InDetFlags.doExtensionProcessor():
            
         if InDetFlags.trtExtensionType() is 'DAF' :
            #
            # --- DAF Fitter setup
            #
            from TrkCompetingRIOsOnTrackTool.TrkCompetingRIOsOnTrackToolConf import Trk__CompetingRIOsOnTrackTool
            InDetCompetingRotCreator =  Trk__CompetingRIOsOnTrackTool( name                        = 'InDetCompetingRotCreator'+NewTrackingCuts.extension(),
                                                                       ToolForCompPixelClusters    = None,      # default
                                                                       ToolForCompSCT_Clusters     = None,      # default
                                                                       ToolForCompTRT_DriftCircles = InDetCompetingTRT_DC_Tool )
            ToolSvc += InDetCompetingRotCreator
            if (InDetFlags.doPrintConfigurables()):
               print InDetCompetingRotCreator
            #
            from TrkDeterministicAnnealingFilter.TrkDeterministicAnnealingFilterConf import Trk__DeterministicAnnealingFilter
            InDetExtensionFitter =  Trk__DeterministicAnnealingFilter( name = 'InDetDAF'+NewTrackingCuts.extension(),
                                                                       ToolForExtrapolation           = InDetExtrapolator,
                                                                       ToolForCompetingROTsCreation   = InDetCompetingRotCreator,
                                                                       ToolForUpdating                = InDetUpdator,
                                                                       AnnealingScheme                = [200., 81., 9., 4., 1., 1., 1.],
                                                                       DropOutlierCutValue            = 1.E-7,
                                                                       OutlierCutValue                = 0.01 )
            ToolSvc += InDetExtensionFitter
            if (InDetFlags.doPrintConfigurables()):
               print InDetExtensionFitter
         else:
            InDetExtensionFitter = InDetTrackFitter
            if NewTrackingCuts.mode() == "LowPt":
               InDetExtensionFitter = InDetTrackFitterLowPt

         #
         # --- load scoring for extension
         #
         if InDetFlags.doCosmics():
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
            InDetExtenScoringTool = InDet__InDetCosmicScoringTool(name                 = 'InDetCosmicExtenScoringTool',
                                                                  nWeightedClustersMin = 0,
                                                                  minTRTHits           = NewTrackingCuts.minTRTonTrk(),
                                                                  SummaryTool          = InDetTrackSummaryTool)
            
         else:
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
            InDetExtenScoringTool = InDet__InDetAmbiScoringTool(name                    = 'InDetExtenScoringTool'+NewTrackingCuts.extension(),
                                                                Extrapolator            = InDetExtrapolator,
                                                                SummaryTool             = InDetTrackSummaryTool,
                                                                DriftCircleCutTool      = InDetTRTDriftCircleCut,
                                                                useAmbigFcn             = True,  # this is NewTracking  
                                                                useTRT_AmbigFcn         = False,
                                                                minPt                   = NewTrackingCuts.minPT(),
                                                                maxRPhiImp              = NewTrackingCuts.maxPrimaryImpact(),
                                                                maxZImp                 = NewTrackingCuts.maxZImpact(),
                                                                maxEta                  = NewTrackingCuts.maxEta(),
                                                                minSiClusters           = NewTrackingCuts.minClusters(),
                                                                minPixel                = NewTrackingCuts.minPixel(),
                                                                maxSiHoles              = NewTrackingCuts.maxHoles(),
                                                                maxPixelHoles           = NewTrackingCuts.maxPixelHoles(),
                                                                maxSCTHoles             = NewTrackingCuts.maxSCTHoles(),
                                                                maxDoubleHoles          = NewTrackingCuts.maxDoubleHoles(),
                                                                usePixel                = NewTrackingCuts.usePixel(),
                                                                useSCT                  = NewTrackingCuts.useSCT(),
                                                                minTRTonTrk             = NewTrackingCuts.minTRTonTrk(),
                                                                minTRTPrecisionFraction = NewTrackingCuts.minTRTPrecFrac())
            
            if InDetFlags.trackFitterType() in ['KalmanFitter', 'KalmanDNAFitter', 'ReferenceKalmanFitter']:
               InDetExtenScoringTool.minTRTPrecisionFraction = 0.2

         #InDetExtenScoringTool.OutputLevel = VERBOSE 
         ToolSvc += InDetExtenScoringTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetExtenScoringTool     
         
         #
         # --- output track collection
         #
         self.__ForwardTrackCollection = ExtendedTrackCollection 
         #
         # --- get configured track extension processor
         #
         if doPhase:
         
          from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor   
          InDetExtensionProcessorPhase = InDet__InDetExtensionProcessor ( name               = "InDetExtensionProcessorPhase"+NewTrackingCuts.extension(),
                                                                    TrackName          = SiTrackCollection,
                                                                    Cosmics            = True,
                                                                    ExtensionMap       = OutputExtendedTracks,
                                                                    NewTrackName       = self.__ForwardTrackCollection,
                                                                    TrackFitter        = InDetExtensionFitter,
                                                                    ScoringTool        = InDetExtenScoringTool,
                                                                    suppressHoleSearch = False,  # does not work properly
                                                                    tryBremFit         = InDetFlags.doBremRecovery(),
                                                                    caloSeededBrem     = InDetFlags.doCaloSeededBrem(),
                                                                    pTminBrem          = NewTrackingCuts.minPTBrem(),
                                                                    RefitPrds          = not (InDetFlags.refitROT() or (InDetFlags.trtExtensionType() is 'DAF')))
         #InDetExtensionProcessor.OutputLevel = VERBOSE
          if InDetFlags.materialInteractions():
             InDetExtensionProcessorPhase.matEffects = InDetFlags.materialInteractionsType()
          else:
             InDetExtensionProcessorPhase.matEffects = 0
   
          topSequence += InDetExtensionProcessorPhase
          if (InDetFlags.doPrintConfigurables()):
              print InDetExtensionProcessorPhase

         else:

          from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor   
          InDetExtensionProcessor = InDet__InDetExtensionProcessor ( name               = "InDetExtensionProcessor"+NewTrackingCuts.extension(),
                                                                    TrackName          = SiTrackCollection,
                                                                    Cosmics            = InDetFlags.doCosmics(),
                                                                    ExtensionMap       = OutputExtendedTracks,
                                                                    NewTrackName       = self.__ForwardTrackCollection,
                                                                    TrackFitter        = InDetExtensionFitter,
                                                                    ScoringTool        = InDetExtenScoringTool,
                                                                    suppressHoleSearch = False,  # does not work properly
                                                                    tryBremFit         = InDetFlags.doBremRecovery(),
                                                                    caloSeededBrem     = InDetFlags.doCaloSeededBrem(),
                                                                    pTminBrem          = NewTrackingCuts.minPTBrem(),
                                                                    RefitPrds          = not (InDetFlags.refitROT() or (InDetFlags.trtExtensionType() is 'DAF')))
          #InDetExtensionProcessor.OutputLevel = VERBOSE
          if InDetFlags.materialInteractions():
             InDetExtensionProcessor.matEffects = InDetFlags.materialInteractionsType()
          else:
             InDetExtensionProcessor.matEffects = 0
   
          topSequence += InDetExtensionProcessor

          if (InDetFlags.doPrintConfigurables()):
             print InDetExtensionProcessor
         
         # --- Delete Resolved Si tracks and extension map
         from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg         
         InDetSGDeletionAlg(container = "TrackExtensionMap#", key = OutputExtendedTracks)
         if not InDetFlags.doMonitoringAlignment():
            InDetSGDeletionAlg(key = SiTrackCollection)
         
         #
         # ------------ Track truth.
         #
         if not InDetFlags.doSGDeletion():
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__ForwardTrackCollection,
                                                            self.__ForwardTrackCollection+"DetailedTruth",
                                                            self.__ForwardTrackCollection+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__ForwardTrackCollection ]
               
         #
      else:
         self.__ForwardTrackCollection = SiTrackCollection
Exemple #11
0
    def __init__(self,
                 Tracks=None,
                 DetailedTruth=None,
                 TracksTruth=None,
                 PixelClustersTruth=InDetKeys.PixelClustersTruth(),
                 SCT_ClustersTruth=InDetKeys.SCT_ClustersTruth(),
                 TRT_DriftCirclesTruth=InDetKeys.TRT_DriftCirclesTruth()):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from AthenaCommon.DetFlags import DetFlags
        from InDetRecExample.InDetKeys import InDetKeys
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        from RecExConfig.hideInput import hideInput
        topSequence = AlgSequence()
        #
        # --- Enable the detailed track truth
        #
        from InDetTruthAlgs.InDetTruthAlgsConf import InDet__InDetDetailedTrackTruthMaker
        hideInput('DetailedTrackTruthCollection', DetailedTruth)
        DetailedTruthMaker = InDet__InDetDetailedTrackTruthMaker(
            name=DetailedTruth + "Maker",
            TrackCollectionName=Tracks,
            DetailedTrackTruthName=DetailedTruth,
            TruthNamePixel=PixelClustersTruth,
            TruthNameSCT=SCT_ClustersTruth,
            TruthNameTRT=TRT_DriftCirclesTruth)

        # this is how the truth maker gets to know which detector is on ...
        if (not DetFlags.haveRIO.pixel_on()):
            DetailedTruthMaker.TruthNamePixel = ""
        if (not DetFlags.haveRIO.SCT_on()):
            DetailedTruthMaker.TruthNameSCT = ""
        # for cosmics, at the stage of SiPatternRecognition, the TRT truth information is not yet available
        if ((not DetFlags.haveRIO.TRT_on())
                or (InDetFlags.doCosmics() and
                    (DetailedTruth == "SiSPSeededTracksDetailedTruth"
                     or DetailedTruth == "ResolvedTracksDetailedTruth"))):
            DetailedTruthMaker.TruthNameTRT = ""

        #if Tracks == "Tracks":
        #    DetailedTruthMaker.OutputLevel = VERBOSE
        topSequence += DetailedTruthMaker
        if (InDetFlags.doPrintConfigurables()):
            printfunc(DetailedTruthMaker)
        #
        # --- Detailed to old TrackTruth
        #
        if InDetFlags.truthMatchStrategy() == 'TruthMatchRatio':
            from TrkTruthCreatorTools.TrkTruthCreatorToolsConf import Trk__TruthMatchRatio as InDetTruthMatchTool
        elif InDetFlags.truthMatchStrategy() == 'TruthMatchTanimoto':
            from TrkTruthCreatorTools.TrkTruthCreatorToolsConf import Trk__TruthMatchTanimoto as InDetTruthMatchTool
        else:
            printfunc(
                "ConfiguredInDetTrackTruth: error! InDetFlags.truthMatchStrategy must be TruthMatchRatio or TruthMatchTanimoto but is: "
                + InDetFlags.truthMatchStrategy())

        InDetTruthMatchSimilarityTool = InDetTruthMatchTool(
            name="InDetTruthMatchTool",
            WeightPixel=10.,
            WeightSCT=5.,
            WeightTRT=1.)

        # --- only add this once !!!
        if not hasattr(ToolSvc, "InDetTruthMatchTool"):
            ToolSvc += InDetTruthMatchSimilarityTool
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetTruthMatchSimilarityTool)

        from TrkTruthAlgs.TrkTruthAlgsConf import TrackTruthSimilaritySelector
        InDetTruthSimilaritySelector = TrackTruthSimilaritySelector(
            name=TracksTruth + "Selector",
            DetailedTrackTruthName=DetailedTruth,
            OutputName=TracksTruth,
            TrackTruthSimilarityTool=InDetTruthMatchSimilarityTool)
        #if Tracks == "Tracks":
        #    InDetTruthSimilaritySelector.OutputLevel = VERBOSE
        topSequence += InDetTruthSimilaritySelector
        if (InDetFlags.doPrintConfigurables()):
            printfunc(InDetTruthSimilaritySelector)

        # --- remember imput
        self.__Tracks = Tracks
        self.__TracksTruth = TracksTruth
        self.__DetailedTruth = DetailedTruth
    def __init__(self,
                 InputCollections=None,
                 ResolvedTrackCollectionKey=None,
                 SiSPSeededTrackCollectionKey=None,
                 NewTrackingCuts=None,
                 TrackCollectionKeys=[],
                 TrackCollectionTruthKeys=[]):

        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()

        #
        # --- decide if use the association tool
        #
        if (len(InputCollections) > 0) and (
                NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode()
                == "VeryLowPt" or NewTrackingCuts.mode() == "LargeD0"
                or NewTrackingCuts.mode() == "LowPtLargeD0"
                or NewTrackingCuts.mode() == "DisplacedSoftPion"
                or NewTrackingCuts.mode() == "BeamGas"
                or NewTrackingCuts.mode() == "ForwardTracks"
                or NewTrackingCuts.mode() == "ForwardSLHCTracks"
                or NewTrackingCuts.mode() == "PixelPrdAssociation"
                or NewTrackingCuts.mode() == "VeryForwardSLHCTracks"
                or NewTrackingCuts.mode() == "SLHCConversionFinding"):
            usePrdAssociationTool = True
        else:
            usePrdAssociationTool = False

        #
        # --- get list of already associated hits (always do this, even if no other tracking ran before)
        #
        if usePrdAssociationTool:
            from InDetTrackPRD_Association.InDetTrackPRD_AssociationConf import InDet__InDetTrackPRD_Association
            InDetPRD_Association = InDet__InDetTrackPRD_Association(
                name='InDetPRD_Association' + NewTrackingCuts.extension(),
                AssociationTool=InDetPrdAssociationTool,
                TracksName=list(InputCollections))
            topSequence += InDetPRD_Association
            if (InDetFlags.doPrintConfigurables()):
                print InDetPRD_Association

        # ------------------------------------------------------------
        #
        # ----------- SiSPSeededTrackFinder
        #
        # ------------------------------------------------------------

        if InDetFlags.doSiSPSeededTrackFinder():
            #
            # --- Space points seeds maker, use different ones for cosmics and collisions
            #
            if NewTrackingCuts.mode() == "DBM":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker
            elif InDetFlags.doCosmics():
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_Cosmic as SiSpacePointsSeedMaker
            elif InDetFlags.doHeavyIon():
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_HeavyIon as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_LowMomentum as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "BeamGas":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_BeamGas as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ITK as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "DisplacedSoftPion":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_TrkSeeded as SiSpacePointsSeedMaker
            else:
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker

            InDetSiSpacePointsSeedMaker = SiSpacePointsSeedMaker(
                name="InDetSpSeedsMaker" + NewTrackingCuts.extension(),
                pTmin=NewTrackingCuts.minPT(),
                maxdImpact=NewTrackingCuts.maxPrimaryImpact(),
                maxZ=NewTrackingCuts.maxZImpact(),
                minZ=-NewTrackingCuts.maxZImpact(),
                usePixel=NewTrackingCuts.usePixel(),
                SpacePointsPixelName=InDetKeys.PixelSpacePoints(),
                # useSCT                 = NewTrackingCuts.useSCT(),
                useSCT=(NewTrackingCuts.useSCT()
                        and NewTrackingCuts.useSCTSeeding()),
                SpacePointsSCTName=InDetKeys.SCT_SpacePoints(),
                # useOverlapSpCollection = NewTrackingCuts.useSCT(),
                useOverlapSpCollection=(NewTrackingCuts.useSCT()
                                        and NewTrackingCuts.useSCTSeeding()),
                SpacePointsOverlapName=InDetKeys.OverlapSpacePoints(),
                radMax=NewTrackingCuts.radMax(),
                RapidityCut=NewTrackingCuts.maxEta())

            if NewTrackingCuts.mode() == "Offline" or InDetFlags.doHeavyIon(
            ) or NewTrackingCuts.mode() == "ForwardTracks":
                InDetSiSpacePointsSeedMaker.maxdImpactPPS = NewTrackingCuts.maxdImpactPPSSeeds(
                )
                InDetSiSpacePointsSeedMaker.maxdImpactSSS = NewTrackingCuts.maxdImpactSSSSeeds(
                )
            if usePrdAssociationTool:
                # not all classes have that property !!!
                InDetSiSpacePointsSeedMaker.UseAssociationTool = True
                InDetSiSpacePointsSeedMaker.AssociationTool = InDetPrdAssociationTool
            if not InDetFlags.doCosmics():
                InDetSiSpacePointsSeedMaker.maxRadius1 = 0.75 * NewTrackingCuts.radMax(
                )
                InDetSiSpacePointsSeedMaker.maxRadius2 = NewTrackingCuts.radMax(
                )
                InDetSiSpacePointsSeedMaker.maxRadius3 = NewTrackingCuts.radMax(
                )
            if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                try:
                    InDetSiSpacePointsSeedMaker.pTmax = NewTrackingCuts.maxPT()
                except:
                    pass
                InDetSiSpacePointsSeedMaker.mindRadius = 4.0
            if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "SLHCConversionFinding":
                InDetSiSpacePointsSeedMaker.minRadius1 = 0
                InDetSiSpacePointsSeedMaker.minRadius2 = 0
                InDetSiSpacePointsSeedMaker.minRadius3 = 0
                InDetSiSpacePointsSeedMaker.maxRadius1 = 1000. * Units.mm
                InDetSiSpacePointsSeedMaker.maxRadius2 = 1000. * Units.mm
                InDetSiSpacePointsSeedMaker.maxRadius3 = 1000. * Units.mm
            if NewTrackingCuts.mode(
            ) == "ForwardTracks" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                InDetSiSpacePointsSeedMaker.checkEta = True
                InDetSiSpacePointsSeedMaker.etaMin = NewTrackingCuts.minEta()
                InDetSiSpacePointsSeedMaker.etaMax = NewTrackingCuts.maxEta()
                InDetSiSpacePointsSeedMaker.RapidityCut = NewTrackingCuts.maxEta(
                )
            if NewTrackingCuts.mode() == "DBM":
                InDetSiSpacePointsSeedMaker.etaMin = NewTrackingCuts.minEta()
                InDetSiSpacePointsSeedMaker.etaMax = NewTrackingCuts.maxEta()
                InDetSiSpacePointsSeedMaker.useDBM = True
            if NewTrackingCuts.mode() == "PixelThreeLayer":
                InDetSiSpacePointsSeedMaker.SkipIBLcut = True
            if NewTrackingCuts.mode() == "DisplacedSoftPion":
                InDetSiSpacePointsSeedMaker.maxSeedsForSpacePoint = 50
                InDetSiSpacePointsSeedMaker.DeltaThetaRoISP = 0.8
                InDetSiSpacePointsSeedMaker.DeltaPhiRoISP = 0.8
                InDetSiSpacePointsSeedMaker.RoISeedTool = RoISeedTool

            #InDetSiSpacePointsSeedMaker.OutputLevel = VERBOSE
            ToolSvc += InDetSiSpacePointsSeedMaker
            if (InDetFlags.doPrintConfigurables()):
                print InDetSiSpacePointsSeedMaker

            #
            # --- Z-coordinates primary vertices finder (only for collisions)
            #
            if InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM":
                from SiZvertexTool_xk.SiZvertexTool_xkConf import InDet__SiZvertexMaker_xk
                InDetZvertexMaker = InDet__SiZvertexMaker_xk(
                    name='InDetZvertexMaker' + NewTrackingCuts.extension(),
                    Zmax=NewTrackingCuts.maxZImpact(),
                    Zmin=-NewTrackingCuts.maxZImpact(),
                    minRatio=0.17)  # not default
                InDetZvertexMaker.SeedMakerTool = InDetSiSpacePointsSeedMaker

                if InDetFlags.doHeavyIon():
                    InDetZvertexMaker.HistSize = 2000
                    ###InDetZvertexMaker.minContent = 200
                    InDetZvertexMaker.minContent = 30

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

            else:
                InDetZvertexMaker = None

            #
            # --- SCT and Pixel detector elements road builder
            #
            from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
            InDetSiDetElementsRoadMaker = InDet__SiDetElementsRoadMaker_xk(
                name='InDetSiRoadMaker' + NewTrackingCuts.extension(),
                PropagatorTool=InDetPatternPropagator,
                usePixel=NewTrackingCuts.usePixel(),
                PixManagerLocation=InDetKeys.PixelManager(),
                useSCT=NewTrackingCuts.useSCT(),
                SCTManagerLocation=InDetKeys.SCT_Manager(),
                RoadWidth=NewTrackingCuts.RoadWidth())
            #InDetSiDetElementsRoadMaker.OutputLevel = VERBOSE
            ToolSvc += InDetSiDetElementsRoadMaker
            if (InDetFlags.doPrintConfigurables()):
                print InDetSiDetElementsRoadMaker

            #
            # --- Local track finding using sdCaloSeededSSSpace point seed
            #

            useBremMode = NewTrackingCuts.mode(
            ) == "Offline" or NewTrackingCuts.mode(
            ) == "SLHC" or NewTrackingCuts.mode() == "DBM"
            from SiTrackMakerTool_xk.SiTrackMakerTool_xkConf import InDet__SiTrackMaker_xk as SiTrackMaker
            InDetSiTrackMaker = SiTrackMaker(
                name='InDetSiTrackMaker' + NewTrackingCuts.extension(),
                useSCT=NewTrackingCuts.useSCT(),
                usePixel=NewTrackingCuts.usePixel(),
                RoadTool=InDetSiDetElementsRoadMaker,
                CombinatorialTrackFinder=InDetSiComTrackFinder,
                pTmin=NewTrackingCuts.minPT(),
                pTminBrem=NewTrackingCuts.minPTBrem(),
                pTminSSS=InDetFlags.pT_SSScut(),
                nClustersMin=NewTrackingCuts.minClusters(),
                nHolesMax=NewTrackingCuts.nHolesMax(),
                nHolesGapMax=NewTrackingCuts.nHolesGapMax(),
                SeedsFilterLevel=NewTrackingCuts.seedFilterLevel(),
                Xi2max=NewTrackingCuts.Xi2max(),
                Xi2maxNoAdd=NewTrackingCuts.Xi2maxNoAdd(),
                nWeightedClustersMin=NewTrackingCuts.nWeightedClustersMin(),
                CosmicTrack=InDetFlags.doCosmics(),
                Xi2maxMultiTracks=NewTrackingCuts.Xi2max(),  # was 3.
                useSSSseedsFilter=InDetFlags.doSSSfilter(),
                doMultiTracksProd=True,
                useBremModel=InDetFlags.doBremRecovery() and
                useBremMode,  # only for NewTracking the brem is debugged !!!
                doCaloSeededBrem=InDetFlags.doCaloSeededBrem(),
                doHadCaloSeedSSS=InDetFlags.doHadCaloSeededSSS(),
                phiWidth=NewTrackingCuts.phiWidthBrem(),
                etaWidth=NewTrackingCuts.etaWidthBrem(),
                InputClusterContainerName=InDetKeys.CaloClusterROIContainer(
                ),  # "InDetCaloClusterROIs" 
                InputHadClusterContainerName=InDetKeys.
                HadCaloClusterROIContainer(),  # "InDetCaloClusterROIs" 
                UseAssociationTool=usePrdAssociationTool)

            if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                InDetSiTrackMaker.ITKGeometry = True

            if NewTrackingCuts.mode() == "DBM":
                InDetSiTrackMaker.MagneticFieldMode = "NoField"
                InDetSiTrackMaker.useBremModel = False
                InDetSiTrackMaker.doMultiTracksProd = False
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'
                InDetSiTrackMaker.pTminSSS = -1
                InDetSiTrackMaker.CosmicTrack = False
                InDetSiTrackMaker.useSSSseedsFilter = False
                InDetSiTrackMaker.doCaloSeededBrem = False
                InDetSiTrackMaker.doHadCaloSeedSSS = False
                InDetSiTrackMaker.UseAssociationTool = False

            elif InDetFlags.doCosmics():
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_Cosmic'

            elif InDetFlags.doHeavyIon():
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_HeavyIon'

            elif NewTrackingCuts.mode() == "LowPt":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LowMomentum'

            elif NewTrackingCuts.mode() == "VeryLowPt" or (
                    NewTrackingCuts.mode() == "Pixel"
                    and InDetFlags.doMinBias()):
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryLowMomentum'

            elif NewTrackingCuts.mode() == "BeamGas":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_BeamGas'

            elif NewTrackingCuts.mode() == "ForwardTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardTracks'

            elif NewTrackingCuts.mode() == "ForwardSLHCTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardSLHCTracks'

            elif NewTrackingCuts.mode() == "VeryForwardSLHCTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryForwardSLHCTracks'

            elif NewTrackingCuts.mode() == "SLHCConversionFinding":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_SLHCConversionTracks'

            elif NewTrackingCuts.mode() == "LargeD0" or NewTrackingCuts.mode(
            ) == "LowPtLargeD0" or NewTrackingCuts.mode(
            ) == "DisplacedSoftPion":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LargeD0'

            elif NewTrackingCuts.mode() == "PixelThreeLayer":
                InDetSiTrackMaker.CombinatorialTrackFinder = InDetSiComTrackFinderThreeLayerTracking

            else:
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'

            if InDetFlags.doStoreTrackSeeds():
                InDetSiTrackMaker.SeedSegmentsWrite = True
                InDetSiTrackMaker.SeedToTrackConversion = InDet_SeedToTrackConversion
            #InDetSiTrackMaker.OutputLevel = VERBOSE
            ToolSvc += InDetSiTrackMaker
            if (InDetFlags.doPrintConfigurables()):
                print InDetSiTrackMaker
            #
            # set output track collection name
        #
            self.__SiTrackCollection = SiSPSeededTrackCollectionKey
            #
            # --- Setup Track finder using space points seeds
            #

            from SiSPSeededTrackFinder.SiSPSeededTrackFinderConf import InDet__SiSPSeededTrackFinder

            if NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "ForwardTracks":

                InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(
                    name='InDetSiSpTrackFinder' + NewTrackingCuts.extension(),
                    TrackTool=InDetSiTrackMaker,
                    TracksLocation=self.__SiTrackCollection,
                    SeedsTool=InDetSiSpacePointsSeedMaker,
                    useZvertexTool=InDetFlags.useZvertexTool(),
                    ZvertexTool=InDetZvertexMaker,
                    useNewStrategy=False,
                    useMBTSTimeDiff=InDetFlags.useMBTSTimeDiff(),
                    useZBoundFinding=False)
                if InDetFlags.doHeavyIon():
                    InDetSiSPSeededTrackFinder.FreeClustersCut = 2  #Heavy Ion optimization from Igor

            else:
                InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(
                    name='InDetSiSpTrackFinder' + NewTrackingCuts.extension(),
                    TrackTool=InDetSiTrackMaker,
                    TracksLocation=self.__SiTrackCollection,
                    SeedsTool=InDetSiSpacePointsSeedMaker,
                    useZvertexTool=InDetFlags.useZvertexTool()
                    and NewTrackingCuts.mode() != "DBM",
                    ZvertexTool=InDetZvertexMaker,
                    useNewStrategy=InDetFlags.useNewSiSPSeededTF()
                    and NewTrackingCuts.mode() != "DBM",
                    useMBTSTimeDiff=InDetFlags.useMBTSTimeDiff(),
                    useZBoundFinding=NewTrackingCuts.doZBoundary()
                    and NewTrackingCuts.mode() != "DBM")

                if InDetFlags.doHeavyIon():
                    InDetSiSPSeededTrackFinder.FreeClustersCut = 2  #Heavy Ion optimization from Igor

            #InDetSiSPSeededTrackFinder.OutputLevel =VERBOSE
            topSequence += InDetSiSPSeededTrackFinder
            if (InDetFlags.doPrintConfigurables()):
                print InDetSiSPSeededTrackFinder

            if not InDetFlags.doSGDeletion():
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__SiTrackCollection,
                        self.__SiTrackCollection + "DetailedTruth",
                        self.__SiTrackCollection + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__SiTrackCollection]

        # ------------------------------------------------------------
        #
        # ---------- Ambiguity solving
        #
        # ------------------------------------------------------------

        if InDetFlags.doAmbiSolving():
            #
            # --- load InnerDetector TrackSelectionTool
            #

            prob1 = InDetFlags.pixelClusterSplitProb1()
            prob2 = InDetFlags.pixelClusterSplitProb2()
            nhitsToAllowSplitting = 9

            if geoFlags.Run() == 1:
                prob1 = InDetFlags.pixelClusterSplitProb1_run1()
                prob2 = InDetFlags.pixelClusterSplitProb2_run1()
                nhitsToAllowSplitting = 8

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetDenseEnvAmbiTrackSelectionTool as AmbiTrackSelectionTool
            else:
                from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetAmbiTrackSelectionTool as AmbiTrackSelectionTool
            InDetAmbiTrackSelectionTool = AmbiTrackSelectionTool(
                name='InDetAmbiTrackSelectionTool' +
                NewTrackingCuts.extension(),
                AssociationTool=InDetPrdAssociationTool,
                DriftCircleCutTool=InDetTRTDriftCircleCut,
                minHits=NewTrackingCuts.minClusters(),
                minNotShared=NewTrackingCuts.minSiNotShared(),
                maxShared=NewTrackingCuts.maxShared(),
                minTRTHits=0,  # used for Si only tracking !!!
                sharedProbCut=0.10,
                UseParameterization=False,
                Cosmics=InDetFlags.doCosmics(),
                doPixelSplitting=InDetFlags.doPixelClusterSplitting()
                and NewTrackingCuts.mode != "DBM")
            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                InDetAmbiTrackSelectionTool.sharedProbCut = prob1
                InDetAmbiTrackSelectionTool.sharedProbCut2 = prob2
                InDetAmbiTrackSelectionTool.minSiHitsToAllowSplitting = nhitsToAllowSplitting
                InDetAmbiTrackSelectionTool.minUniqueSCTHits = 4
                InDetAmbiTrackSelectionTool.minTrackChi2ForSharedHits = 3
                InDetAmbiTrackSelectionTool.InputHadClusterContainerName = InDetKeys.HadCaloClusterROIContainer(
                )
                InDetAmbiTrackSelectionTool.doHadCaloSeed = False  #Only split in cluster in region of interest
                InDetAmbiTrackSelectionTool.minPtSplit = InDetFlags.pixelClusterSplitMinPt(
                )  #Only allow split clusters on track withe pt greater than this MeV
                InDetAmbiTrackSelectionTool.phiWidth = 0.2  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.etaWidth = 0.2  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.InputEmClusterContainerName = InDetKeys.CaloClusterROIContainer(
                )
                InDetAmbiTrackSelectionTool.doEmCaloSeed = False  #Only split in cluster in region of interest
                InDetAmbiTrackSelectionTool.minPtConv = 10000  #Only allow split clusters on track withe pt greater than this MeV
                InDetAmbiTrackSelectionTool.phiWidthEM = 0.05  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.etaWidthEM = 0.05  #Split cluster ROI size

            if NewTrackingCuts.mode() == "DBM":
                InDetAmbiTrackSelectionTool.Cosmics = False
                InDetAmbiTrackSelectionTool.UseParameterization = False
                InDetAmbiTrackSelectionTool.doPixelSplitting = False
                InDetAmbiTrackSelectionTool.maxShared = 1000
                InDetAmbiTrackSelectionTool.maxTracksPerSharedPRD = 2
                InDetAmbiTrackSelectionTool.minHits = 0
                InDetAmbiTrackSelectionTool.minNotShared = 0
                InDetAmbiTrackSelectionTool.minScoreShareTracks = 0.0
                InDetAmbiTrackSelectionTool.minTRTHits = 0
                InDetAmbiTrackSelectionTool.sharedProbCut = 0.1
            if InDetFlags.doTIDE_AmbiTrackMonitoring(
            ) and InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "PixelPrdAssociation"
                    or NewTrackingCuts.mode() == "DBM"
                    or NewTrackingCuts.mode() == "PixelFourLayer"
                    or NewTrackingCuts.mode() == "PixelThreeLayer"):
                InDetAmbiTrackSelectionTool.ObserverTool = TrackObserverTool  #observerTool
                InDetAmbiTrackSelectionTool.MonitorAmbiguitySolving = True

            # if NewTrackingCuts.mode() == "ForwardTracks":
            #    InDetAmbiTrackSelectionTool.OutputLevel = VERBOSE

            ToolSvc += InDetAmbiTrackSelectionTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetAmbiTrackSelectionTool
            #
            # --- set up different Scoring Tool for collisions and cosmics
            #
            if InDetFlags.doCosmics() and NewTrackingCuts.mode() != "DBM":
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
                InDetAmbiScoringTool = InDet__InDetCosmicScoringTool(
                    name='InDetCosmicsScoringTool' +
                    NewTrackingCuts.extension(),
                    nWeightedClustersMin=NewTrackingCuts.nWeightedClustersMin(
                    ),
                    minTRTHits=0,
                    SummaryTool=InDetTrackSummaryTool)
            else:
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
                InDetAmbiScoringTool = InDet__InDetAmbiScoringTool(
                    name='InDetAmbiScoringTool' + NewTrackingCuts.extension(),
                    Extrapolator=InDetExtrapolator,
                    SummaryTool=InDetTrackSummaryTool,
                    DriftCircleCutTool=InDetTRTDriftCircleCut,
                    useAmbigFcn=True,  # this is NewTracking
                    useTRT_AmbigFcn=False,
                    minPt=NewTrackingCuts.minPT(),
                    maxRPhiImp=NewTrackingCuts.maxPrimaryImpact(),
                    maxZImp=NewTrackingCuts.maxZImpact(),
                    maxEta=NewTrackingCuts.maxEta(),
                    minSiClusters=NewTrackingCuts.minClusters(),
                    minPixel=NewTrackingCuts.minPixel(),
                    maxSiHoles=NewTrackingCuts.maxHoles(),
                    maxPixelHoles=NewTrackingCuts.maxPixelHoles(),
                    maxSCTHoles=NewTrackingCuts.maxSCTHoles(),
                    maxDoubleHoles=NewTrackingCuts.maxDoubleHoles(),
                    usePixel=NewTrackingCuts.usePixel(),
                    useSCT=NewTrackingCuts.useSCT(),
                    InputEmClusterContainerName=InDetKeys.
                    CaloClusterROIContainer(),
                    doEmCaloSeed=True and InDetFlags.doCaloSeededBrem(),
                    minTRTonTrk=0,
                    minTRTPrecisionFraction=0)
                # allow for some overlap for low-pt tracking
                #if InDetFlags.doLowPt() and not NewTrackingCuts.mode() == "LowPt":
                #   InDetAmbiScoringTool.minPt = NewTrackingCuts.minPT()-100.*Units.MeV

            # if NewTrackingCuts.mode() == "ForwardTracks":
            #   InDetAmbiScoringTool.OutputLevel = VERBOSE

            ToolSvc += InDetAmbiScoringTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetAmbiScoringTool
            #
            # --- load Ambiguity Processor
            #
            useBremMode = NewTrackingCuts.mode(
            ) == "Offline" or NewTrackingCuts.mode() == "SLHC"

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__DenseEnvironmentsAmbiguityProcessorTool as ProcessorTool
                use_low_pt_fitter = True if NewTrackingCuts.mode(
                ) == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (
                    NewTrackingCuts.mode() == "Pixel"
                    and InDetFlags.doMinBias()) else False
                fitter_list = [(InDetTrackFitter if not use_low_pt_fitter else
                                InDetTrackFitterLowPt)]
                if InDetFlags.doRefitInvalidCov():
                    from AthenaCommon import CfgGetter
                    fitter_list.append(CfgGetter.getPublicTool('KalmanFitter'))
                    fitter_list.append(
                        CfgGetter.getPublicTool('ReferenceKalmanFitter'))

                InDetAmbiguityProcessor = ProcessorTool(
                    name='InDetAmbiguityProcessor' +
                    NewTrackingCuts.extension(),
                    Fitter=fitter_list,
                    ScoringTool=InDetAmbiScoringTool,
                    SelectionTool=InDetAmbiTrackSelectionTool,
                    SuppressHoleSearch=False,
                    tryBremFit=InDetFlags.doBremRecovery() and useBremMode
                    and NewTrackingCuts.mode() != "DBM",
                    caloSeededBrem=InDetFlags.doCaloSeededBrem()
                    and NewTrackingCuts.mode() != "DBM",
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=True,
                    RejectTracksWithInvalidCov=InDetFlags.doRejectInvalidCov())
            else:
                from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__SimpleAmbiguityProcessorTool as ProcessorTool
                InDetAmbiguityProcessor = ProcessorTool(
                    name='InDetAmbiguityProcessor' +
                    NewTrackingCuts.extension(),
                    Fitter=InDetTrackFitter,
                    ScoringTool=InDetAmbiScoringTool,
                    SelectionTool=InDetAmbiTrackSelectionTool,
                    SuppressHoleSearch=False,
                    tryBremFit=InDetFlags.doBremRecovery() and useBremMode
                    and NewTrackingCuts.mode() != "DBM",
                    caloSeededBrem=InDetFlags.doCaloSeededBrem()
                    and NewTrackingCuts.mode() != "DBM",
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=True)

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                InDetAmbiguityProcessor.SplitProbTool = NnPixelClusterSplitProbTool
                InDetAmbiguityProcessor.sharedProbCut = prob1
                InDetAmbiguityProcessor.sharedProbCut2 = prob2
                InDetAmbiguityProcessor.SplitClusterAmbiguityMap = InDetKeys.SplitClusterAmbiguityMap(
                )
                if InDetFlags.doTIDE_RescalePixelCovariances():
                    InDetAmbiguityProcessor.applydRcorrection = True

            if NewTrackingCuts.mode() == "Pixel" or NewTrackingCuts.mode(
            ) == "DBM":
                InDetAmbiguityProcessor.SuppressHoleSearch = True
            if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                if InDetAmbiguityProcessor.getName().find('Dense'):
                    pass
                else:
                    InDetAmbiguityProcessor.Fitter = InDetTrackFitterLowPt

            if InDetFlags.materialInteractions():
                InDetAmbiguityProcessor.MatEffects = InDetFlags.materialInteractionsType(
                )
            else:
                InDetAmbiguityProcessor.MatEffects = 0

            # if NewTrackingCuts.mode() == "ForwardTracks":
            #    InDetAmbiguityProcessor.OutputLevel = VERBOSE

            if InDetFlags.doTIDE_AmbiTrackMonitoring(
            ) and InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "PixelPrdAssociation"
                    or NewTrackingCuts.mode() == "DBM"
                    or NewTrackingCuts.mode() == "PixelFourLayer"
                    or NewTrackingCuts.mode() == "PixelThreeLayer"):
                InDetAmbiguityProcessor.ObserverTool = TrackObserverTool  #observerTool
                InDetAmbiguityProcessor.MonitorAmbiguitySolving = True

            ToolSvc += InDetAmbiguityProcessor
            if (InDetFlags.doPrintConfigurables()):
                print InDetAmbiguityProcessor
            #
            # --- set input and output collection
            #
            InputTrackCollection = self.__SiTrackCollection
            self.__SiTrackCollection = ResolvedTrackCollectionKey
            #
            # --- configure Ambiguity solver
            #
            from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguitySolver
            InDetAmbiguitySolver = Trk__TrkAmbiguitySolver(
                name='InDetAmbiguitySolver' + NewTrackingCuts.extension(),
                TrackInput=[InputTrackCollection],
                TrackOutput=self.__SiTrackCollection,
                AmbiguityProcessor=InDetAmbiguityProcessor)
            topSequence += InDetAmbiguitySolver
            if (InDetFlags.doPrintConfigurables()):
                print InDetAmbiguitySolver

            #
            # --- Delete Silicon Sp-Seeded tracks
            #
            from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
            InDetSGDeletionAlg(key=SiSPSeededTrackCollectionKey)

            if ((NewTrackingCuts.mode() in ["Pixel", "SCT"])
                    or not InDetFlags.doSGDeletion()):
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__SiTrackCollection,
                        self.__SiTrackCollection + "DetailedTruth",
                        self.__SiTrackCollection + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__SiTrackCollection]
Exemple #13
0
def makeInDetPatternRecognition(whichSignature,
                                rois='EMViewRoIs',
                                InputCollections=None,
                                NewTrackingCuts=None):
    from InDetRecExample.InDetJobProperties import InDetFlags
    #Global keys/names for collections
    from InDetRecExample.InDetKeys import InDetKeys  #FIXME: to be replaced with Trig keys?
    from .InDetTrigCollectionKeys import TrigPixelKeys, TrigSCTKeys

    from AthenaCommon.DetFlags import DetFlags

    from AthenaCommon.AppMgr import ToolSvc

    prefix = 'InDetTrigMT'
    suffix = '_%s' % whichSignature if whichSignature else ''
    #Final output track collection
    #SiSPSeededTrackCollectionKey = "SiSPSeededTracks_%s"%whichSignature
    outEFIDTracks = "HLT_IDTrkTrack_%s_%s" % (whichSignature, 'EFID')
    outEFIDTrackParticles = "HLT_IDTrack_%s_%s" % (whichSignature, 'EFID')

    viewAlgs = []  #list of all algs running in this module
    #
    # --- decide if use the association tool
    #
    #FIXME: Make the same decision as offline (based on the tracking cuts)?
    #if (len(InputCollections) > 0) and (NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or NewTrackingCuts.mode() == "LargeD0" or NewTrackingCuts.mode() == "LowPtLargeD0" or NewTrackingCuts.mode() == "BeamGas" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "ForwardSLHCTracks"  or NewTrackingCuts.mode() == "Disappearing" or NewTrackingCuts.mode() == "VeryForwardSLHCTracks" or NewTrackingCuts.mode() == "SLHCConversionFinding"):

    #Why not use association tool? what are the cases when not needed?
    #usePrdAssociationTool = True
    #else:
    usePrdAssociationTool = False

    import InDetRecExample.TrackingCommon as TrackingCommon
    if usePrdAssociationTool:
        print('Running SiSPseedTrackFinder!')
        #FIXME: switch to naming based on tracking

        #FIXME: If so:
        # 1] Get a new association tool
        #associationTool = TrackingCommon.getInDetTrigPRDtoTrackMapToolGangedPixels(),

        # 2] Use the ganged pixel from here?
        #from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigPrdAssociationTool

        # 3] Create the new one as in offline tracking:
        InDetTrigPrdAssociation = TrackingCommon.getInDetTrackPRD_Association(
            namePrefix=prefix,
            nameSuffix=suffix,
            TracksName=list(InputCollections)
        )  #This is readHandle #What input collection Thought there are no tracks at this point??!
        # 4] if so do I use normal or ganged?
        #from InDetAssociationTools.InDetAssociationToolsConf import InDet__InDetPRD_AssociationToolGangedPixels
        #InDetTrigPrdAssociationl = InDet__InDetPRD_AssociationToolGangedPixels(name = "%sPrdAssociationTool%s"%(prefix,suffix),
        #                                                                          PixelClusterAmbiguitiesMapName = TrigPixelKeys.PRDtoTrackMap )
        viewAlgs.append(InDetTrigPrdAssociation)

    #FIXME? use trigger flags?
    #if InDetFlags.doSiSPSeededTrackFinder():
    doSiSPSeededTrackFinder = True
    if doSiSPSeededTrackFinder:
        print('Running SiSPseedTrackFinder!')

        #FIXME: Need to add different options based on the
        from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker

        InDetSiSpacePointsSeedMaker = SiSpacePointsSeedMaker(
            name="%sInDetSpSeedsMaker%s" %
            (prefix, suffix),  #+NewTrackingCuts.extension(),
            pTmin=NewTrackingCuts.minPT(),
            maxdImpact=NewTrackingCuts.maxPrimaryImpact(),
            maxZ=NewTrackingCuts.maxZImpact(),
            minZ=-NewTrackingCuts.maxZImpact(),
            usePixel=NewTrackingCuts.usePixel(),
            SpacePointsPixelName=TrigPixelKeys.SpacePoints,
            # useSCT                 = NewTrackingCuts.useSCT(),
            useSCT=(NewTrackingCuts.useSCT()
                    and NewTrackingCuts.useSCTSeeding()),
            SpacePointsSCTName=TrigSCTKeys.SpacePoints,
            # useOverlapSpCollection = NewTrackingCuts.useSCT(),
            useOverlapSpCollection=(NewTrackingCuts.useSCT()
                                    and NewTrackingCuts.useSCTSeeding()),
            SpacePointsOverlapName=InDetKeys.OverlapSpacePoints(),
            radMax=NewTrackingCuts.radMax(),
            RapidityCut=NewTrackingCuts.maxEta())

        ToolSvc += InDetSiSpacePointsSeedMaker
        #FIXME consider specific settings here
        #if NewTrackingCuts.mode() == "Offline" or InDetFlags.doHeavyIon() or  NewTrackingCuts.mode() == "ForwardTracks":
        #        InDetSiSpacePointsSeedMaker.maxdImpactPPS = NewTrackingCuts.maxdImpactPPSSeeds()
        #        InDetSiSpacePointsSeedMaker.maxdImpactSSS = NewTrackingCuts.maxdImpactSSSSeeds()

        if usePrdAssociationTool:
            #   # not all classes have that property !!!
            InDetSiSpacePointsSeedMaker.PRDtoTrackMap = TrigPixelKeys.PRDtoTrackMap  #InDetTrigPrdAssociationTool

        #if not InDetFlags.doCosmics():
        #   InDetSiSpacePointsSeedMaker.maxRadius1         = 0.75*NewTrackingCuts.radMax()
        #   InDetSiSpacePointsSeedMaker.maxRadius2         = NewTrackingCuts.radMax()
        #   InDetSiSpacePointsSeedMaker.maxRadius3         = NewTrackingCuts.radMax()
        #if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()):
        #   try :
        #      InDetSiSpacePointsSeedMaker.pTmax              = NewTrackingCuts.maxPT()
        #   except:
        #      pass
        #   InDetSiSpacePointsSeedMaker.mindRadius         = 4.0
        #if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode() == "SLHCConversionFinding":
        #   InDetSiSpacePointsSeedMaker.minRadius1         = 0
        #   InDetSiSpacePointsSeedMaker.minRadius2         = 0
        #   InDetSiSpacePointsSeedMaker.minRadius3         = 0
        #   InDetSiSpacePointsSeedMaker.maxRadius1         =1000.*Units.mm
        #   InDetSiSpacePointsSeedMaker.maxRadius2         =1000.*Units.mm
        #   InDetSiSpacePointsSeedMaker.maxRadius3         =1000.*Units.mm
        #if NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "VeryForwardSLHCTracks":
        #   InDetSiSpacePointsSeedMaker.checkEta           = True
        #   InDetSiSpacePointsSeedMaker.etaMin             = NewTrackingCuts.minEta()
        #   InDetSiSpacePointsSeedMaker.etaMax             = NewTrackingCuts.maxEta()
        #   InDetSiSpacePointsSeedMaker.RapidityCut        = NewTrackingCuts.maxEta()
        #if NewTrackingCuts.mode() == "DBM":
        #   InDetSiSpacePointsSeedMaker.etaMin             = NewTrackingCuts.minEta()
        #   InDetSiSpacePointsSeedMaker.etaMax             = NewTrackingCuts.maxEta()
        #   InDetSiSpacePointsSeedMaker.useDBM = True

        #Z finder for the vtx
        #
        # --- Z-coordinates primary vertices finder (only for collisions)
        #
        if InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM":
            from SiZvertexTool_xk.SiZvertexTool_xkConf import InDet__SiZvertexMaker_xk
            InDetZvertexMaker = InDet__SiZvertexMaker_xk(
                name='%sInDetZvertexMaker%s' % (prefix, suffix),
                Zmax=NewTrackingCuts.maxZImpact(),
                Zmin=-NewTrackingCuts.maxZImpact(),
                minRatio=0.17)  # not default
            InDetZvertexMaker.SeedMakerTool = InDetSiSpacePointsSeedMaker

            if InDetFlags.doHeavyIon():
                InDetZvertexMaker.HistSize = 2000
                ###InDetZvertexMaker.minContent = 200
                InDetZvertexMaker.minContent = 30

            ToolSvc += InDetZvertexMaker
            #if (InDetFlags.doPrintConfigurables()):
            #   printfunc (InDetZvertexMaker)

        else:
            InDetZvertexMaker = None

        #
    #   # --- SCT and Pixel detector elements road builder
    #   #
    #FIXME which propagator
    # 1]
        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigPropagator

        # 2] How about offline

        from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
        InDetSiDetElementsRoadMaker = InDet__SiDetElementsRoadMaker_xk(
            name='%sInDetSiRoadMaker%s' %
            (prefix, suffix),  #+NewTrackingCuts.extension(),
            PropagatorTool=InDetTrigPropagator,  #InDetPatternPropagator,
            usePixel=NewTrackingCuts.usePixel(),
            PixManagerLocation=InDetKeys.PixelManager(),
            useSCT=NewTrackingCuts.useSCT(),
            SCTManagerLocation=InDetKeys.SCT_Manager(
            ),  #FIXME change the name?        
            RoadWidth=NewTrackingCuts.RoadWidth())

        ToolSvc += InDetSiDetElementsRoadMaker
        #if (InDetFlags.doPrintConfigurables()):
        #   printfunc (     InDetSiDetElementsRoadMaker)
        # Condition algorithm for InDet__SiDetElementsRoadMaker_xk
        if DetFlags.haveRIO.pixel_on():
            #FIXME:
            #pixelOn = True
            #if pixelOn:
            # Condition algorithm for SiCombinatorialTrackFinder_xk
            from AthenaCommon.AlgSequence import AthSequencer
            condSeq = AthSequencer("AthCondSeq")
            if not hasattr(condSeq,
                           "InDetSiDetElementBoundaryLinksPixelCondAlg"):
                from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiDetElementBoundaryLinksCondAlg_xk
                condSeq += InDet__SiDetElementBoundaryLinksCondAlg_xk(
                    name="InDetSiDetElementBoundaryLinksPixelCondAlg",
                    ReadKey="PixelDetectorElementCollection",
                    WriteKey="PixelDetElementBoundaryLinks_xk",
                    UsePixelDetectorManager=True)

        if NewTrackingCuts.useSCT():
            from AthenaCommon.AlgSequence import AthSequencer
            condSeq = AthSequencer("AthCondSeq")
            if not hasattr(condSeq, "InDet__SiDetElementsRoadCondAlg_xk"):
                from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadCondAlg_xk
                condSeq += InDet__SiDetElementsRoadCondAlg_xk(
                    name="InDet__SiDetElementsRoadCondAlg_xk")

            if not hasattr(condSeq,
                           "InDetSiDetElementBoundaryLinksSCTCondAlg"):
                from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiDetElementBoundaryLinksCondAlg_xk
                condSeq += InDet__SiDetElementBoundaryLinksCondAlg_xk(
                    name="InDetSiDetElementBoundaryLinksSCTCondAlg",
                    ReadKey="SCT_DetectorElementCollection",
                    WriteKey="SCT_DetElementBoundaryLinks_xk")

    #   #
    #   # --- Local track finding using sdCaloSeededSSSpace point seed
    #   #
    #   # @TODO ensure that PRD association map is used if usePrdAssociationTool is set
        is_dbm = InDetFlags.doDBMstandalone() or NewTrackingCuts.extension(
        ) == 'DBM'
        rot_creator_digital = TrackingCommon.getInDetRotCreatorDigital(
        ) if not is_dbm else TrackingCommon.getInDetRotCreatorDBM()

        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigSCTConditionsSummaryTool, InDetTrigPatternUpdator

        from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiCombinatorialTrackFinder_xk
        track_finder = InDet__SiCombinatorialTrackFinder_xk(
            name='%sInDetSiComTrackFinder%s' %
            (prefix, suffix),  #+NewTrackingCuts.extension(),
            PropagatorTool=InDetTrigPropagator,  #InDetPatternPropagator,
            UpdatorTool=InDetTrigPatternUpdator,  #InDetPatternUpdator,
            SctSummaryTool=InDetTrigSCTConditionsSummaryTool,
            RIOonTrackTool=rot_creator_digital,
            usePixel=DetFlags.haveRIO.pixel_on(),
            useSCT=DetFlags.haveRIO.SCT_on() if not is_dbm else False,
            PixelClusterContainer=TrigPixelKeys.
            Clusters,  #InDetKeys.PixelClusters(),
            SCT_ClusterContainer=TrigSCTKeys.Clusters
        )  #InDetKeys.SCT_Clusters())

        ToolSvc += track_finder
        if is_dbm:
            track_finder.MagneticFieldMode = "NoField"
            track_finder.TrackQualityCut = 9.3

        #track_finder.SctSummaryTool = InDetTrigSCTConditionsSummaryTool
        #if (DetFlags.haveRIO.SCT_on()):
        #   track_finder.SctSummaryTool = InDetSCT_ConditionsSummaryTool
        #else:
        #   track_finder.SctSummaryTool = None

    #   ToolSvc += track_finder

        useBremMode = NewTrackingCuts.mode(
        ) == "Offline" or NewTrackingCuts.mode(
        ) == "SLHC" or NewTrackingCuts.mode() == "DBM"
        from SiTrackMakerTool_xk.SiTrackMakerTool_xkConf import InDet__SiTrackMaker_xk as SiTrackMaker
        InDetSiTrackMaker = SiTrackMaker(
            name='%sInDetSiTrackMaker%s' %
            (prefix, suffix),  #+NewTrackingCuts.extension(),
            useSCT=NewTrackingCuts.useSCT(),
            usePixel=NewTrackingCuts.usePixel(),
            RoadTool=InDetSiDetElementsRoadMaker,
            CombinatorialTrackFinder=track_finder,
            pTmin=NewTrackingCuts.minPT(),
            pTminBrem=NewTrackingCuts.minPTBrem(),
            pTminSSS=InDetFlags.pT_SSScut(),
            nClustersMin=NewTrackingCuts.minClusters(),
            nHolesMax=NewTrackingCuts.nHolesMax(),
            nHolesGapMax=NewTrackingCuts.nHolesGapMax(),
            SeedsFilterLevel=NewTrackingCuts.seedFilterLevel(),
            Xi2max=NewTrackingCuts.Xi2max(),
            Xi2maxNoAdd=NewTrackingCuts.Xi2maxNoAdd(),
            nWeightedClustersMin=NewTrackingCuts.nWeightedClustersMin(),
            CosmicTrack=InDetFlags.doCosmics(),
            Xi2maxMultiTracks=NewTrackingCuts.Xi2max(),  # was 3.
            useSSSseedsFilter=InDetFlags.doSSSfilter(),
            doMultiTracksProd=True,
            useBremModel=InDetFlags.doBremRecovery()
            and useBremMode,  # only for NewTracking the brem is debugged !!!
            doCaloSeededBrem=InDetFlags.doCaloSeededBrem(),
            doHadCaloSeedSSS=InDetFlags.doHadCaloSeededSSS(),
            phiWidth=NewTrackingCuts.phiWidthBrem(),
            etaWidth=NewTrackingCuts.etaWidthBrem(),
            InputClusterContainerName=InDetKeys.CaloClusterROIContainer(
            ),  # "InDetCaloClusterROIs" 
            InputHadClusterContainerName=InDetKeys.HadCaloClusterROIContainer(
            ),  # "InDetCaloClusterROIs" 
            UseAssociationTool=usePrdAssociationTool)

        ToolSvc += InDetSiTrackMaker

        #FIXME: do only cosmics for now, but change later
        #   if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "VeryForwardSLHCTracks" :
        #      InDetSiTrackMaker.ITKGeometry = True

        #   if NewTrackingCuts.mode() == "DBM":
        #      InDetSiTrackMaker.MagneticFieldMode = "NoField"
        #      InDetSiTrackMaker.useBremModel = False
        #      InDetSiTrackMaker.doMultiTracksProd = False
        #      InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'
        #      InDetSiTrackMaker.pTminSSS = -1
        #      InDetSiTrackMaker.CosmicTrack = False
        #      InDetSiTrackMaker.useSSSseedsFilter = False
        #      InDetSiTrackMaker.doCaloSeededBrem = False
        #      InDetSiTrackMaker.doHadCaloSeedSSS = False

        #elif InDetFlags.doCosmics():
        #  InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_Cosmic'
        InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_Cosmic'
        #
        #   elif InDetFlags.doHeavyIon():
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_HeavyIon'
        #
        #   elif NewTrackingCuts.mode() == "LowPt":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LowMomentum'

        #   elif NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()):
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryLowMomentum'

        #   elif NewTrackingCuts.mode() == "BeamGas":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_BeamGas'

        #   elif NewTrackingCuts.mode() == "ForwardTracks":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardTracks'

        #   elif NewTrackingCuts.mode() == "ForwardSLHCTracks":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardSLHCTracks'

        #   elif NewTrackingCuts.mode() == "VeryForwardSLHCTracks":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryForwardSLHCTracks'

        #   elif NewTrackingCuts.mode() == "SLHCConversionFinding":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_SLHCConversionTracks'

        #   elif NewTrackingCuts.mode() == "LargeD0" or NewTrackingCuts.mode() == "LowPtLargeD0":
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LargeD0'
        #
        #   else:
        #     InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'
        #
        if InDetFlags.doStoreTrackSeeds():
            from SeedToTrackConversionTool.SeedToTrackConversionToolConf import InDet__SeedToTrackConversionTool
            InDet_SeedToTrackConversion = InDet__SeedToTrackConversionTool(
                name="%sInDet_SeedToTrackConversion%s" % (prefix, suffix),
                OutputName=InDetKeys.SiSPSeedSegments() +
                NewTrackingCuts.extension())
            InDetSiTrackMaker.SeedToTrackConversion = InDet_SeedToTrackConversion
            InDetSiTrackMaker.SeedSegmentsWrite = True

    #   #InDetSiTrackMaker.OutputLevel = VERBOSE
    #   ToolSvc += InDetSiTrackMaker
    #   if (InDetFlags.doPrintConfigurables()):
    #      printfunc (InDetSiTrackMaker)
    #   #
    #   # set output track collection name
    #  #
    #   self.__SiTrackCollection = SiSPSeededTrackCollectionKey
    #   #
    #   # --- Setup Track finder using space points seeds
    #   #

    #FIXME: which summary tool to use??
    # trackSummaryTool = TrackingCommon.getInDetTrackSummaryToolNoHoleSearch()
    #ToolSvc += trackSummaryTool
        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigTrackSummaryTool

        from SiSPSeededTrackFinder.SiSPSeededTrackFinderConf import InDet__SiSPSeededTrackFinder
        InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(
            name='%sInDetSiSpTrackFinder%s' %
            (prefix, suffix),  # +NewTrackingCuts.extension(),
            TrackTool=InDetSiTrackMaker,
            PRDtoTrackMap=TrigPixelKeys.PRDtoTrackMap
            if usePrdAssociationTool else '',
            SpacePointsPixelName=TrigPixelKeys.SpacePoints,
            SpacePointsSCTName=TrigSCTKeys.SpacePoints,
            TrackSummaryTool=InDetTrigTrackSummaryTool,
            TracksLocation=outEFIDTracks,
            SeedsTool=InDetSiSpacePointsSeedMaker,
            useZvertexTool=InDetFlags.useZvertexTool(),
            ZvertexTool=InDetZvertexMaker)

        if NewTrackingCuts.mode(
        ) == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks":
            InDetSiSPSeededTrackFinder.useNewStrategy = False
            InDetSiSPSeededTrackFinder.useMBTSTimeDiff = InDetFlags.useMBTSTimeDiff(
            )
            InDetSiSPSeededTrackFinder.useZBoundFinding = False
    #    if InDetFlags.doHeavyIon() :
    #     InDetSiSPSeededTrackFinder.FreeClustersCut = 2 #Heavy Ion optimization from Igor
        else:
            InDetSiSPSeededTrackFinder.useZvertexTool = InDetFlags.useZvertexTool(
            ) and NewTrackingCuts.mode() != "DBM"
            InDetSiSPSeededTrackFinder.useNewStrategy = InDetFlags.useNewSiSPSeededTF(
            ) and NewTrackingCuts.mode() != "DBM"
            InDetSiSPSeededTrackFinder.useMBTSTimeDiff = InDetFlags.useMBTSTimeDiff(
            )
            InDetSiSPSeededTrackFinder.useZBoundFinding = NewTrackingCuts.doZBoundary(
            ) and NewTrackingCuts.mode() != "DBM"

        viewAlgs.append(InDetSiSPSeededTrackFinder)

        #for alg in viewAlgs:
        #   print alg

    #    if InDetFlags.doHeavyIon() :
    #     InDetSiSPSeededTrackFinder.FreeClustersCut = 2 #Heavy Ion optimization from Igor

    #   #InDetSiSPSeededTrackFinder.OutputLevel =VERBOSE
    #   topSequence += InDetSiSPSeededTrackFinder
    #   if (InDetFlags.doPrintConfigurables()):
    #      printfunc (InDetSiSPSeededTrackFinder)

    #   if not InDetFlags.doSGDeletion():
    #      if InDetFlags.doTruth():
    #         #
    #         # set up the truth info for this container
    #         #
    #         include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
    #         InDetTracksTruth = ConfiguredInDetTrackTruth(self.__SiTrackCollection,
    #                                                      self.__SiTrackCollection+"DetailedTruth",
    #                                                      self.__SiTrackCollection+"TruthCollection")
    #         #
    #         # add final output for statistics
    #         #
    #         TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
    #         TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
    #      else:
    #         TrackCollectionKeys      += [ self.__SiTrackCollection ]
    #

    #Convert final track collection to xAOD track particles
    from .InDetTrigCommon import getTrackParticleCnv
    viewAlgs.append(
        getTrackParticleCnv(prefix, suffix + "_EFID", outEFIDTracks,
                            outEFIDTrackParticles))

    #print viewAlgs
    #print 'VIEWS!', len(viewAlgs)
    #print(len(viewAlgs))

    return viewAlgs
    def __init__(self, Tracks = None, DetailedTruth = None, TracksTruth = None):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from AthenaCommon.DetFlags              import DetFlags
        from InDetRecExample.InDetKeys          import InDetKeys
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr                import ToolSvc
        from AthenaCommon.AlgSequence           import AlgSequence
        topSequence = AlgSequence()
        #
        # --- Enable the detailed track truth
        #
        from InDetTruthAlgs.InDetTruthAlgsConf import InDet__InDetDetailedTrackTruthMaker
        DetailedTruthMaker = InDet__InDetDetailedTrackTruthMaker(name                   = DetailedTruth+"Maker",
                                                                 TrackCollectionName    = Tracks,
                                                                 DetailedTrackTruthName = DetailedTruth,
                                                                 TruthNamePixel         = InDetKeys.PixelClustersTruth(),
                                                                 TruthNameSCT           = InDetKeys.SCT_ClustersTruth(),
                                                                 TruthNameTRT           = InDetKeys.TRT_DriftCirclesTruth())
        # this is how the truth maker gets to know which detector is on ...
        if (not DetFlags.haveRIO.pixel_on()):
            DetailedTruthMaker.TruthNamePixel = ""
        if (not DetFlags.haveRIO.SCT_on()):
            DetailedTruthMaker.TruthNameSCT = ""
        # for cosmics, at the stage of SiPatternRecognition, the TRT truth information is not yet available
        if ((not DetFlags.haveRIO.TRT_on()) or
            (InDetFlags.doCosmics() and (DetailedTruth == "SiSPSeededTracksDetailedTruth" or DetailedTruth == "ResolvedTracksDetailedTruth"))):
            DetailedTruthMaker.TruthNameTRT = ""

        #if Tracks == "Tracks":
        #    DetailedTruthMaker.OutputLevel = VERBOSE    
        topSequence += DetailedTruthMaker
        if (InDetFlags.doPrintConfigurables()):
            print DetailedTruthMaker        
        #
        # --- Detailed to old TrackTruth
        #
        if InDetFlags.truthMatchStrategy() == 'TruthMatchRatio':
            from TrkTruthCreatorTools.TrkTruthCreatorToolsConf import Trk__TruthMatchRatio as InDetTruthMatchTool
        elif InDetFlags.truthMatchStrategy() == 'TruthMatchTanimoto':
            from TrkTruthCreatorTools.TrkTruthCreatorToolsConf import Trk__TruthMatchTanimoto as InDetTruthMatchTool
        else:
            print "ConfiguredInDetTrackTruth: error! InDetFlags.truthMatchStrategy must be TruthMatchRatio or TruthMatchTanimoto but is: "+InDetFlags.truthMatchStrategy()

        InDetTruthMatchSimilarityTool = InDetTruthMatchTool(name        = "InDetTruthMatchTool",
                                                            WeightPixel =  10.,
                                                            WeightSCT   =   5.,
                                                            WeightTRT   =   1.)
        
        # --- only add this once !!!
        if not hasattr(ToolSvc, "InDetTruthMatchTool"):
            ToolSvc += InDetTruthMatchSimilarityTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetTruthMatchSimilarityTool

        from TrkTruthAlgs.TrkTruthAlgsConf import TrackTruthSimilaritySelector
        InDetTruthSimilaritySelector = TrackTruthSimilaritySelector(name                     = TracksTruth+"Selector",
                                                                    DetailedTrackTruthName   = DetailedTruth,
                                                                    OutputName               = TracksTruth,
                                                                    TrackTruthSimilarityTool = InDetTruthMatchSimilarityTool)
        #if Tracks == "Tracks":
        #    InDetTruthSimilaritySelector.OutputLevel = VERBOSE    
        topSequence += InDetTruthSimilaritySelector
        if (InDetFlags.doPrintConfigurables()):
            print InDetTruthSimilaritySelector

        # --- remember imput
        self.__Tracks        = Tracks
        self.__TracksTruth   = TracksTruth
        self.__DetailedTruth = DetailedTruth
Exemple #15
0
include("InDetRecExample/InDetRecConditionsAccess.py")

# ------------------------------------------------------------
#
# ----------- Loading the Tracking Tools and Services
#
# ------------------------------------------------------------

include("InDetRecExample/InDetRecLoadTools.py")

# ------------------------------------------------------------
#
# ----------- Data-Preparation stage
#
# ------------------------------------------------------------

#include ("InDetRecExample/InDetRecPreProcessing.py")

include("InDetRecExample/InDetRecPreProcessingSilicon.py")

#include ("InDetRecExample/InDetRecPreProcessingTRT.py")
include("InDetRecExample/ConfiguredInDetPreProcessingTRT.py")
# --- TRT, no drift information if cosmics, do not use extrenal phase in any case
InDetPreProcessingTRT = ConfiguredInDetPreProcessingTRT(
    not InDetFlags.doCosmics(), False)

#==============================================================
# End of InnerDetector (iPatRec requirements) jobOptions fragment
#
###############################################################
Exemple #16
0
  def __init__ (self, nameExt = "",
                doStat = True, doClusVal = True,
                NewTrackingCuts = None,
                TrackCollectionKeys=[] , TrackCollectionTruthKeys=[],
                rmin = 0., rmax = 20.,
                McEventCollectionKey = "TruthEvent"):
    
    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()
    
    # ------------------------------------------------------------
    #
    # ------------- Do we do statistics for tracks ?
    #
    # ------------------------------------------------------------
    #
    if doStat:
      #
      # --- load statistics alg
      #
      from InDetRecExample.TrackingCommon            import getInDetPRDtoTrackMapToolGangedPixels
      from InDetRecStatistics.InDetRecStatisticsConf import InDet__InDetRecStatisticsAlg
      do_shared_hits=True
      InDetRecStatistics = InDet__InDetRecStatisticsAlg (name                     = "InDetRecStatistics"+nameExt,
                                                         TrackCollectionKeys      = TrackCollectionKeys,
                                                         TrackTruthCollectionKeys = TrackCollectionTruthKeys if InDetFlags.doTruth() else [],
                                                         McTrackCollectionKey     = McEventCollectionKey     if InDetFlags.doTruth() else "",
                                                         PrintSecondary           = True,
                                                         TruthToTrackTool         = (InDetTruthToTrack       if InDetFlags.doTruth() else None),
                                                         UseTrackSummary          = True,
                                                         AssociationTool          = getInDetPRDtoTrackMapToolGangedPixels() \
                                                                                       if do_shared_hits else "",
                                                         DoSharedHits             = do_shared_hits,
                                                         SummaryTool              = InDetTrackSummaryToolSharedHits, # this is a bug !!!
                                                         DoTruth                  = InDetFlags.doTruth(),
                                                         # maxEta                   = NewTrackingCuts.maxEta(),
                                                         # minPt                    = 2. * NewTrackingCuts.minPT(),
                                                         fakeTrackCut             = 0.8,    # ME: adapt cuts 
                                                         fakeTrackCut2            = 0.5,    # ME: adapt cuts 
                                                         matchTrackCut            = 0.5,    # ME: adapt cuts 
                                                         # maxEta                   = 2.5,    # ME: full coverage ends here
                                                         maxEta                   = NewTrackingCuts.maxEta(),
                                                         minPt                    = 1.*GeV, # ME: let's restrict to higher pt
                                                         maxRStartPrimary         = 25.0,   # ME: allows for IBL
                                                         maxRStartSecondary       = 560.0,  # ME: exit of SCT (we have TRT only)
                                                         maxZStartPrimary         = 320.0,  # ME: is in the beam pipe anyway
                                                         maxZStartSecondary       = 1500.0, # ME: enough forward hits
                                                         minREndPrimary           = 400.0,  # ME: between SCT 2 and 3 
                                                         minREndSecondary         = 1000.0, # ME: leaves in R
                                                         minZEndPrimary           = 2300.0, # ME: 2 disks in the forward
                                                         minZEndSecondary         = 2700.0) # ME: or leaves in z 
      if InDetFlags.doDBMstandalone() or nameExt=="DBM" or nameExt=="PUDBM":
        InDetRecStatistics.minPt              = .0*GeV
        InDetRecStatistics.maxEta             = 9999.
        InDetRecStatistics.maxRStartPrimary   = 9999999.
        InDetRecStatistics.maxRStartSecondary = 9999999.
        InDetRecStatistics.maxZStartPrimary   = 9999999.
        InDetRecStatistics.maxZStartSecondary = 9999999.
        InDetRecStatistics.minREndPrimary     = 0.
        InDetRecStatistics.minREndSecondary   = 0.
        InDetRecStatistics.minZEndPrimary     = 0.
        InDetRecStatistics.minZEndSecondary   = 0.

      elif (InDetFlags.doCosmics() or InDetFlags.doBeamHalo()):
        # change cuts for cosmics
        InDetRecStatistics.minPt              = .0*GeV
        InDetRecStatistics.maxEta             = 9999.
        InDetRecStatistics.maxEtaEndcap       = 9999.
        InDetRecStatistics.maxRStartPrimary   = 9999999.
        InDetRecStatistics.maxRStartSecondary = 9999999.
        InDetRecStatistics.maxZStartPrimary   = 9999999.
        InDetRecStatistics.maxZStartSecondary = 9999999.
        InDetRecStatistics.minREndPrimary     = 0.
        InDetRecStatistics.minREndSecondary   = 0.
        InDetRecStatistics.minZEndPrimary     = 0.
        InDetRecStatistics.minZEndSecondary   = 0.

        
      topSequence += InDetRecStatistics
      if (InDetFlags.doPrintConfigurables()):
        printfunc (InDetRecStatistics)
            
    #
    # --- load cluster validation alg
    #
    if doClusVal:
      from InDetTrackClusterAssValidation.InDetTrackClusterAssValidationConf import InDet__TrackClusterAssValidation
      InDetTrackClusterAssValidation = InDet__TrackClusterAssValidation(name                   = "InDetTrackClusterAssValidation"+nameExt,
                                                                        TracksLocation         = TrackCollectionKeys             ,
                                                                        SpacePointsPixelName   = InDetKeys.PixelSpacePoints()    ,
                                                                        SpacePointsSCTName     = InDetKeys.SCT_SpacePoints()     ,
                                                                        SpacePointsOverlapName = InDetKeys.OverlapSpacePoints()  ,
                                                                        MomentumCut            = 2. * NewTrackingCuts.minPT()   ,
                                                                        RapidityCut            = NewTrackingCuts.maxEta()        ,
                                                                        RadiusMin              = rmin                            ,
                                                                        RadiusMax              = rmax                            ,
                                                                        MinNumberClusters      = NewTrackingCuts.minClusters()   ,
                                                                        MinNumberClustersTRT   = 0                               ,
                                                                        MinNumberSpacePoints   = 3                               ,
                                                                        usePixel               = DetFlags.haveRIO.pixel_on()     ,
                                                                        useSCT                 = DetFlags.haveRIO.SCT_on()       ,
                                                                        useTRT                 = DetFlags.haveRIO.TRT_on()       )

      if InDetFlags.doDBMstandalone() or  nameExt=="DBM" or nameExt=="PUDBM":
        InDetTrackClusterAssValidation.MomentumCut            = 0
        InDetTrackClusterAssValidation.RadiusMax              = 9999999.0
#        InDetTrackClusterAssValidation.RapidityCut            = 9999.9
        InDetTrackClusterAssValidation.MinNumberClustersTRT   = 0
        InDetTrackClusterAssValidation.MinNumberClusters      = 0
        InDetTrackClusterAssValidation.MinNumberSpacePoints   = 0
      
      elif InDetFlags.doCosmics() or InDetFlags.doBeamHalo():
        InDetTrackClusterAssValidation.MomentumCut            = NewTrackingCuts.minPT()
        InDetTrackClusterAssValidation.RadiusMax              = 9999999.0
        InDetTrackClusterAssValidation.RapidityCut            = 9999.9
        InDetTrackClusterAssValidation.MinNumberClustersTRT   = 0
        InDetTrackClusterAssValidation.MinNumberClusters      = 8
        #InDetTrackClusterAssValidation.MinNumberClustersTRT   = 0
        InDetTrackClusterAssValidation.MinNumberSpacePoints   = 4
        if InDetFlags.doBeamHalo():
          InDetTrackClusterAssValidation.MomentumCut            = 0
 
      topSequence += InDetTrackClusterAssValidation
      if (InDetFlags.doPrintConfigurables()):
        printfunc (InDetTrackClusterAssValidation)
Exemple #17
0
    def __init__(self,
                 InputCollections=None,
                 NewTrackingCuts=None,
                 TrackCollectionKeys=[],
                 TrackCollectionTruthKeys=[]):

        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()

        #
        # --- decide if use the association tool
        #
        if len(InputCollections) > 0:
            usePrdAssociationTool = True
        else:
            usePrdAssociationTool = False

        # --- the PRD association tool is filled by the Segment making
        #     no need to run again

        # ------------------------------------------------------------
        #
        # ---------- TRT Seeded Tracking
        #
        # ------------------------------------------------------------

        if InDetFlags.doTRTSeededTrackFinder():
            #
            # --- decide which TRT seed space point finder to use
            #
            if InDetFlags.loadTRTSeededSPFinder():
                #
                # --- defaul space point finder
                #
                from TRT_SeededSpacePointFinderTool.TRT_SeededSpacePointFinderToolConf import InDet__TRT_SeededSpacePointFinder_ATL
                InDetTRT_SeededSpacePointFinder = InDet__TRT_SeededSpacePointFinder_ATL(
                    name='InDetTRT_SeededSpFinder',
                    SpacePointsSCTName=InDetKeys.SCT_SpacePoints(),
                    SpacePointsOverlapName=InDetKeys.OverlapSpacePoints(),
                    AssociationTool=InDetPrdAssociationTool,
                    UseAssociationTool=usePrdAssociationTool,
                    NeighborSearch=True,
                    LoadFull=False,
                    DoCosmics=InDetFlags.doCosmics(),
                    pTmin=NewTrackingCuts.minSecondaryPt())
                #InDetTRT_SeededSpacePointFinder.OutputLevel = VERBOSE

            elif InDetFlags.loadSimpleTRTSeededSPFinder():
                #
                # --- alternative version using the region selector
                #
                from RegionSelector.RegSelSvcDefault import RegSelSvcDefault
                InDetRegSelSvc = RegSelSvcDefault()
                InDetRegSelSvc.enablePixel = DetFlags.pixel_on()
                InDetRegSelSvc.enableSCT = DetFlags.SCT_on()

                ServiceMgr += InDetRegSelSvc
                if (InDetFlags.doPrintConfigurables()):
                    print InDetRegSelSvc

                from TRT_SeededSpacePointFinderTool.TRT_SeededSpacePointFinderToolConf import InDet__SimpleTRT_SeededSpacePointFinder_ATL
                InDetTRT_SeededSpacePointFinder = InDet__SimpleTRT_SeededSpacePointFinder_ATL(
                    name='InDetTRT_SeededSpFinder',
                    SpacePointsSCTName=InDetKeys.SCT_SpacePoints(),
                    SpacePointsOverlapName=InDetKeys.OverlapSpacePoints(),
                    PerigeeCut=1000.,
                    DirectionPhiCut=.3,
                    DirectionEtaCut=1.,
                    MaxHoles=2,
                    AssociationTool=InDetPrdAssociationTool,
                    RestrictROI=True)
                #InDetTRT_SeededSpacePointFinder.OutputLevel = VERBOSE
                if not usePrdAssociationTool:
                    InDetTRT_SeededSpacePointFinder.AssociationTool = None

            # add either into the Tool Service
            ToolSvc += InDetTRT_SeededSpacePointFinder
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededSpacePointFinder
            #
            # Silicon det elements road maker tool
            #
            from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
            InDetTRT_SeededSiRoadMaker = InDet__SiDetElementsRoadMaker_xk(
                name='InDetTRT_SeededSiRoad',
                PropagatorTool=InDetPatternPropagator,
                usePixel=NewTrackingCuts.usePixel(),
                PixManagerLocation=InDetKeys.PixelManager(),
                useSCT=NewTrackingCuts.useSCT(),
                SCTManagerLocation=InDetKeys.SCT_Manager(),
                RoadWidth=35.,
                MaxStep=20.)  # NOT DEFAULT ?
            #InDetTRT_SeededSiRoadMaker.OutputLevel = VERBOSE
            if InDetFlags.doCosmics():
                InDetTRT_SeededSiRoadMaker.RoadWidth = 50

            ToolSvc += InDetTRT_SeededSiRoadMaker
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededSiRoadMaker
            #
            # --- TRT seeded back tracking tool
            #
            from TRT_SeededTrackFinderTool.TRT_SeededTrackFinderToolConf import InDet__TRT_SeededTrackFinder_ATL
            InDetTRT_SeededTrackTool = InDet__TRT_SeededTrackFinder_ATL(
                name='InDetTRT_SeededTrackMaker',
                PropagatorTool=InDetPatternPropagator,
                UpdatorTool=InDetPatternUpdator,
                RoadTool=InDetTRT_SeededSiRoadMaker,
                SeedTool=InDetTRT_SeededSpacePointFinder,
                CombinatorialTrackFinder=InDetSiComTrackFinder,
                pTmin=NewTrackingCuts.minSecondaryPt(),
                nHolesMax=NewTrackingCuts.SecondarynHolesMax(),
                # ME bugfix: nHolesGapMax             = 2*NewTrackingCuts.SecondarynHolesGapMax(),
                nHolesGapMax=NewTrackingCuts.SecondarynHolesGapMax(),
                Xi2max=NewTrackingCuts.SecondaryXi2max(),
                Xi2maxNoAdd=NewTrackingCuts.SecondaryXi2maxNoAdd(),
                ConsistentSeeds=True,
                #BremCorrection           = True,
                BremCorrection=False,
                UseAssociationTool=usePrdAssociationTool)
            if InDetFlags.doCosmics():
                InDetTRT_SeededTrackTool.nWClustersMin = 0

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

            #
            # --- Output key for the finder
            #
            self.__TRTSeededTracks = InDetKeys.TRTSeededTracks()
            #
            # TRT seeded back tracking algorithm
            #
            from TRT_SeededTrackFinder.TRT_SeededTrackFinderConf import InDet__TRT_SeededTrackFinder
            InDetTRT_SeededTrackFinder = InDet__TRT_SeededTrackFinder(
                name='InDetTRT_SeededTrackFinder',
                RefitterTool=InDetTrackFitter,
                TrackTool=InDetTRT_SeededTrackTool,
                TrackExtensionTool=InDetTRTExtensionTool,
                MinTRTonSegment=NewTrackingCuts.minSecondaryTRTonTrk(),
                MinTRTonly=NewTrackingCuts.minTRTonly(),
                TrtExtension=True,
                SiExtensionCuts=NewTrackingCuts.SiExtensionCuts(),
                minPt=NewTrackingCuts.minSecondaryPt(),
                maxRPhiImp=NewTrackingCuts.maxSecondaryImpact(),
                maxZImp=NewTrackingCuts.maxZImpact(),
                maxEta=NewTrackingCuts.maxEta(),
                Extrapolator=InDetExtrapolator,
                RejectShortExtension=NewTrackingCuts.rejectShortExtensions(),
                FinalRefit=False,
                FinalStatistics=False,
                OutputSegments=False,
                InputSegmentsLocation=InDetKeys.TRT_Segments(),
                OutputTracksLocation=self.__TRTSeededTracks)
            # InDetTRT_SeededTrackFinder.OutputLevel = VERBOSE
            topSequence += InDetTRT_SeededTrackFinder
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededTrackFinder

            #
            # ------------ Track truth.
            #
            if not InDetFlags.doSGDeletion():
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__TRTSeededTracks,
                        self.__TRTSeededTracks + "DetailedTruth",
                        self.__TRTSeededTracks + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__TRTSeededTracks]

            # --- output track collection
            self.__BackTrackingTracks = self.__TRTSeededTracks

        # ------------------------------------------------------------
        #
        # --- Resolve back tracking tracks ?
        #
        # ------------------------------------------------------------

        if InDetFlags.doResolveBackTracks():
            #
            # --- set up special Scoring Tool for TRT seeded tracks
            #
            if InDetFlags.doCosmics():
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
                InDetTRT_SeededScoringTool = InDet__InDetCosmicScoringTool(
                    name='InDetCosmicScoringTool_TRT',
                    nWeightedClustersMin=0,
                    minTRTHits=NewTrackingCuts.minSecondaryTRTonTrk(),
                    SummaryTool=InDetTrackSummaryTool)
            else:
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
                InDetTRT_SeededScoringTool = InDet__InDetAmbiScoringTool(
                    name='InDetTRT_SeededScoringTool',
                    Extrapolator=InDetExtrapolator,
                    DriftCircleCutTool=InDetTRTDriftCircleCut,
                    SummaryTool=InDetTrackSummaryTool,
                    useTRT_AmbigFcn=InDetFlags.doNewTracking(
                    ),  # full search => use NewT
                    useAmbigFcn=not InDetFlags.doNewTracking(
                    ),  # full search => use NewT
                    minPt=NewTrackingCuts.minSecondaryPt(),
                    maxRPhiImp=NewTrackingCuts.maxSecondaryImpact(),
                    maxZImp=NewTrackingCuts.maxZImpact(),
                    maxEta=NewTrackingCuts.maxEta(),
                    minSiClusters=NewTrackingCuts.minSecondaryClusters(),
                    maxSiHoles=NewTrackingCuts.maxSecondaryHoles(),
                    maxPixelHoles=NewTrackingCuts.maxSecondaryPixelHoles(),
                    maxSCTHoles=NewTrackingCuts.maxSecondarySCTHoles(),
                    maxDoubleHoles=NewTrackingCuts.maxSecondaryDoubleHoles(),
                    usePixel=NewTrackingCuts.usePixel(),
                    useSCT=NewTrackingCuts.useSCT(),
                    minTRTonTrk=NewTrackingCuts.minSecondaryTRTonTrk(),
                    minTRTPrecisionFraction=NewTrackingCuts.
                    minSecondaryTRTPrecFrac())
            # InDetTRT_SeededScoringTool.OutputLevel = DEBUG
            ToolSvc += InDetTRT_SeededScoringTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededScoringTool

            #
            # --- Load selection tool
            #
            from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetAmbiTrackSelectionTool
            InDetTRT_SeededAmbiTrackSelectionTool = InDet__InDetAmbiTrackSelectionTool(
                name='InDetTRT_SeededAmbiTrackSelectionTool',
                AssociationTool=InDetPrdAssociationTool,
                DriftCircleCutTool=InDetTRTDriftCircleCut,
                minScoreShareTracks=-1.,  # off !
                minHits=NewTrackingCuts.minSecondaryClusters(),
                minNotShared=NewTrackingCuts.minSecondarySiNotShared(),
                maxShared=NewTrackingCuts.maxSecondaryShared(),
                minTRTHits=NewTrackingCuts.minSecondaryTRTonTrk(),
                UseParameterization=NewTrackingCuts.useParameterizedTRTCuts(),
                Cosmics=InDetFlags.doCosmics(),
                doPixelSplitting=InDetFlags.doPixelClusterSplitting())

            # InDetTRT_SeededAmbiTrackSelectionTool.OutputLevel = DEBUG
            ToolSvc += InDetTRT_SeededAmbiTrackSelectionTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededAmbiTrackSelectionTool

            #
            # --- load Ambiguity Processor
            #
            from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__SimpleAmbiguityProcessorTool
            InDetTRT_SeededAmbiguityProcessor = Trk__SimpleAmbiguityProcessorTool(
                name='InDetTRT_SeededAmbiguityProcessor',
                Fitter=InDetTrackFitter,
                SelectionTool=InDetTRT_SeededAmbiTrackSelectionTool,
                RefitPrds=not InDetFlags.refitROT(),
                SuppressTrackFit=False,
                SuppressHoleSearch=False,
                ScoringTool=InDetTRT_SeededScoringTool)
            # InDetTRT_SeededAmbiguityProcessor.OutputLevel = DEBUG
            if InDetFlags.materialInteractions():
                InDetTRT_SeededAmbiguityProcessor.MatEffects = InDetFlags.materialInteractionsType(
                )
            else:
                InDetTRT_SeededAmbiguityProcessor.MatEffects = 0
            #
            ToolSvc += InDetTRT_SeededAmbiguityProcessor
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededAmbiguityProcessor

            #
            # --- load the algorithm
            #
            self.__ResolvedTRTSeededTracks = InDetKeys.ResolvedTRTSeededTracks(
            )
            #
            from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguitySolver
            InDetTRT_SeededAmbiguitySolver = Trk__TrkAmbiguitySolver(
                name='InDetTRT_SeededAmbiguitySolver',
                TrackInput=[self.__TRTSeededTracks],
                TrackOutput=self.__ResolvedTRTSeededTracks,
                AmbiguityProcessor=InDetTRT_SeededAmbiguityProcessor)
            topSequence += InDetTRT_SeededAmbiguitySolver
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_SeededAmbiguitySolver

            # --- Delete (non-resloved) TRT seeded tracks
            from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
            InDetSGDeletionAlg(key=InDetKeys.TRTSeededTracks())

            #
            # ------------ Track truth.
            #
            if not InDetFlags.doSGDeletion():
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__ResolvedTRTSeededTracks,
                        self.__ResolvedTRTSeededTracks + "DetailedTruth",
                        self.__ResolvedTRTSeededTracks + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__ResolvedTRTSeededTracks]

            # --- output track collection
            self.__BackTrackingTracks = self.__ResolvedTRTSeededTracks
Exemple #18
0
    def __init__(self, useTimeInfo=True, usePhase=False):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.GlobalFlags import globalflags
        from AthenaCommon.BeamFlags import jobproperties
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        if InDetFlags.doPRDFormation() and DetFlags.makeRIO.TRT_on(
        ) and InDetFlags.doTRT_PRDFormation():

            #
            # --- setup naming of tools and algs
            #
            if useTimeInfo:
                prefix = "InDetTRT_"
                collection = InDetKeys.TRT_DriftCircles()
                if InDetFlags.doSplitReco():
                    collectionPU = InDetKeys.TRT_PU_DriftCircles()
            else:
                prefix = "InDetTRT_noTime_"
                collection = InDetKeys.TRT_DriftCirclesUncalibrated()
                if InDetFlags.doSplitReco():
                    collectionPU = InDetKeys.TRT_PU_DriftCirclesUncalibrated()
            # Calibration DB Service
            from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool
            InDetTRTCalDbTool = TRT_CalDbTool(name="TRT_CalDbTool")

            #
            # --- TRT_DriftFunctionTool
            #

            from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool
            InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool(
                name=prefix + "DriftFunctionTool",
                TRTCalDbTool=InDetTRTCalDbTool)
            # --- overwrite for uncalibrated DC production
            if (not useTimeInfo) or InDetFlags.noTRTTiming():
                InDetTRT_DriftFunctionTool.DummyMode = True
                InDetTRT_DriftFunctionTool.UniversalError = 1.15

            # --- set Data/MC flag
            if (globalflags.DataSource != 'geant4'):
                InDetTRT_DriftFunctionTool.IsMC = False
            else:
                InDetTRT_DriftFunctionTool.IsMC = True

            # --- overwrite for calibration of MC
            if usePhase and jobproperties.Beam.beamType(
            ) == 'cosmics' and globalflags.DataSource == "geant4":
                InDetTRT_DriftFunctionTool.AllowDigiVersionOverride = True
                InDetTRT_DriftFunctionTool.ForcedDigiVersion = 9

            # --- set HT corrections
            InDetTRT_DriftFunctionTool.HTCorrectionBarrelXe = 1.5205
            InDetTRT_DriftFunctionTool.HTCorrectionEndcapXe = 1.2712
            InDetTRT_DriftFunctionTool.HTCorrectionBarrelAr = 1.5205
            InDetTRT_DriftFunctionTool.HTCorrectionEndcapAr = 1.2712

            # --- set ToT corrections
            InDetTRT_DriftFunctionTool.ToTCorrectionsBarrelXe = [
                0., 4.358121, 3.032195, 1.631892, 0.7408397, -0.004113,
                -0.613288, -0.73758, -0.623346, -0.561229, -0.29828, -0.21344,
                -0.322892, -0.386718, -0.534751, -0.874178, -1.231799,
                -1.503689, -1.896464, -2.385958
            ]
            InDetTRT_DriftFunctionTool.ToTCorrectionsEndcapXe = [
                0., 5.514777, 3.342712, 2.056626, 1.08293693, 0.3907979,
                -0.082819, -0.457485, -0.599706, -0.427493, -0.328962,
                -0.403399, -0.663656, -1.029428, -1.46008, -1.919092,
                -2.151582, -2.285481, -2.036822, -2.15805
            ]
            InDetTRT_DriftFunctionTool.ToTCorrectionsBarrelAr = [
                0., 4.358121, 3.032195, 1.631892, 0.7408397, -0.004113,
                -0.613288, -0.73758, -0.623346, -0.561229, -0.29828, -0.21344,
                -0.322892, -0.386718, -0.534751, -0.874178, -1.231799,
                -1.503689, -1.896464, -2.385958
            ]
            InDetTRT_DriftFunctionTool.ToTCorrectionsEndcapAr = [
                0., 5.514777, 3.342712, 2.056626, 1.08293693, 0.3907979,
                -0.082819, -0.457485, -0.599706, -0.427493, -0.328962,
                -0.403399, -0.663656, -1.029428, -1.46008, -1.919092,
                -2.151582, -2.285481, -2.036822, -2.15805
            ]
            # Second calibration DB Service in case pile-up and physics hits have different calibrations
            if DetFlags.overlay.TRT_on():
                InDetTRTCalDbTool2 = TRT_CalDbTool(name="TRT_CalDbTool2")
                InDetTRTCalDbTool2.RtFolderName = "/TRT/Calib/MC/RT"
                InDetTRTCalDbTool2.T0FolderName = "/TRT/Calib/MC/T0"
                InDetTRT_DriftFunctionTool.TRTCalDbTool2 = InDetTRTCalDbTool2
                InDetTRT_DriftFunctionTool.IsOverlay = True
                InDetTRT_DriftFunctionTool.IsMC = False

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

            # Straw status DB Tool
            from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_StrawStatusSummaryTool
            InDetTRTStrawStatusSummaryTool = TRT_StrawStatusSummaryTool(
                name="TRT_StrawStatusSummaryTool",
                isGEANT4=(globalflags.DataSource == 'geant4'))

            #
            # --- TRT_DriftCircleTool
            #
            if usePhase:
                from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleToolCosmics as InDet__TRT_DriftCircleTool
            else:
                from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleTool

            #
            # set gating values for MC/DATA
            MinTrailingEdge = 11.0 * ns
            MaxDriftTime = 60.0 * ns
            LowGate = 14.0625 * ns  # 4.5*3.125 ns
            HighGate = 42.1875 * ns  # LowGate + 9*3.125 ns
            LowGateArgon = LowGate
            HighGateArgon = HighGate

            if InDetFlags.doCosmics():
                LowGate = 19.0 * ns
                HighGate = 44.0 * ns
                LowGateArgon = 19.0 * ns
                HighGateArgon = 44.0 * ns

            if globalflags.DataSource == 'data':
                MinTrailingEdge = 11.0 * ns
                MaxDriftTime = 60.0 * ns
                LowGate = 17.1875 * ns
                HighGate = 45.3125 * ns
                LowGateArgon = 18.75 * ns
                HighGateArgon = 43.75 * ns
                if InDetFlags.doCosmics():
                    LowGate = 19.0 * ns
                    HighGate = 44.0 * ns
                    LowGateArgon = 19.0 * ns
                    HighGateArgon = 44.0 * ns

            InDetTRT_DriftCircleTool = InDet__TRT_DriftCircleTool(
                name=prefix + "DriftCircleTool",
                TRTDriftFunctionTool=InDetTRT_DriftFunctionTool,
                ConditionsSummaryTool=InDetTRTStrawStatusSummaryTool,
                UseConditionsStatus=True,
                UseConditionsHTStatus=True,
                SimpleOutOfTimePileupSupression=False,
                RejectIfFirstBit=False,  # fixes 50 nsec issue 
                MinTrailingEdge=MinTrailingEdge,
                MaxDriftTime=MaxDriftTime,
                ValidityGateSuppression=InDetFlags.InDet25nsec(),
                LowGate=LowGate,
                HighGate=HighGate,
                SimpleOutOfTimePileupSupressionArgon=False,
                RejectIfFirstBitArgon=False,  # fixes 50 nsec issue 
                MinTrailingEdgeArgon=MinTrailingEdge,
                MaxDriftTimeArgon=MaxDriftTime,
                ValidityGateSuppressionArgon=InDetFlags.InDet25nsec(),
                LowGateArgon=LowGate,
                HighGateArgon=HighGate,
                useDriftTimeHTCorrection=True,
                useDriftTimeToTCorrection=True)
            if not usePhase:
                from InDetRecExample import TrackingCommon
                InDetTRT_DriftCircleTool.LumiDataKey = TrackingCommon.getLumiCondDataKeyForTRTMuScaling(
                )

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

            #
            # --- TRT_RIO_Maker Algorithm
            #
            from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__TRT_RIO_Maker
            InDetTRT_RIO_Maker = InDet__TRT_RIO_Maker(
                name=prefix + "RIO_Maker",
                TRT_DriftCircleTool=InDetTRT_DriftCircleTool,
                TrtDescrManageLocation=InDetKeys.TRT_Manager(),
                TRTRDOLocation=InDetKeys.TRT_RDOs(),
                TRTRIOLocation=collection)
            topSequence += InDetTRT_RIO_Maker
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetTRT_RIO_Maker)
            if InDetFlags.doSplitReco():
                InDetTRT_RIO_MakerPU = InDet__TRT_RIO_Maker(
                    name=prefix + "RIO_MakerPU",
                    TRT_DriftCircleTool=InDetTRT_DriftCircleTool,
                    TrtDescrManageLocation=InDetKeys.TRT_Manager(),
                    TRTRDOLocation=InDetKeys.TRT_PU_RDOs(),
                    TRTRIOLocation=collectionPU)
                topSequence += InDetTRT_RIO_MakerPU
                if (InDetFlags.doPrintConfigurables()):
                    printfunc(InDetTRT_RIO_MakerPU)

            #
            #    Include alg to save the local occupancy inside xAOD::EventInfo
            #
            if InDetFlags.doTRTGlobalOccupancy():
                from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy
                InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(
                    name="InDet_TRT_LocalOccupancy",
                    isTrigger=False,
                    TRTCalDbTool=InDetTRTCalDbTool,
                    TRTStrawStatusSummaryTool=InDetTRTStrawStatusSummaryTool)

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

                from TRT_CalibAlgs.TRT_CalibAlgsConf import TRTOccupancyInclude
                TRTOccupancyInclude = TRTOccupancyInclude(
                    name=prefix + "TRTOccupancyInclude",
                    TRT_LocalOccupancyTool=InDetTRT_LocalOccupancy)

                topSequence += TRTOccupancyInclude
                if (InDetFlags.doPrintConfigurables()):
                    printfunc(TRTOccupancyInclude)

            #
            # --- we need to do truth association if requested (not for uncalibrated hits in cosmics)
            #
            if InDetFlags.doTruth() and useTimeInfo:
                from InDetTruthAlgs.InDetTruthAlgsConf import InDet__PRD_MultiTruthMaker
                InDetPRD_MultiTruthMakerTRT = InDet__PRD_MultiTruthMaker(
                    name=prefix + "PRD_MultiTruthMaker",
                    PixelClusterContainerName="",
                    SCTClusterContainerName="",
                    TRTDriftCircleContainerName=InDetKeys.TRT_DriftCircles(),
                    SimDataMapNamePixel="",
                    SimDataMapNameSCT="",
                    SimDataMapNameTRT=InDetKeys.TRT_SDOs(),
                    TruthNamePixel="",
                    TruthNameSCT="",
                    TruthNameTRT=InDetKeys.TRT_DriftCirclesTruth())
                topSequence += InDetPRD_MultiTruthMakerTRT
                if (InDetFlags.doPrintConfigurables()):
                    printfunc(InDetPRD_MultiTruthMakerTRT)

                if InDetFlags.doSplitReco():
                    InDetPRD_MultiTruthMakerTRTPU = InDet__PRD_MultiTruthMaker(
                        name=prefix + "PRD_MultiTruthMakerPU",
                        PixelClusterContainerName="",
                        SCTClusterContainerName="",
                        TRTDriftCircleContainerName=InDetKeys.
                        TRT_PU_DriftCircles(),
                        SimDataMapNamePixel="",
                        SimDataMapNameSCT="",
                        SimDataMapNameTRT=InDetKeys.TRT_PU_SDOs(),
                        TruthNamePixel="",
                        TruthNameSCT="",
                        TruthNameTRT=InDetKeys.TRT_PU_DriftCirclesTruth())
                    topSequence += InDetPRD_MultiTruthMakerTRTPU
                    if (InDetFlags.doPrintConfigurables()):
                        printfunc(InDetPRD_MultiTruthMakerTRTPU)
Exemple #19
0
    def __init__(self, InputTrackCollections=[], TRT_Segments_EC=None):

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

        if InDetFlags.doPRDFormation() and DetFlags.makeRIO.TRT_on():

            #
            # --- calculation of the event phase from all 3 input collections
            #

            useNewEP = True
            if globalflags.DataSource == 'data':
                if InDetFlags.doCosmics():
                    globalOffset = 8
                else:
                    globalOffset = 0
            else:
                globalOffset = -3.125
            cutWindowCenter = -8.5
            numberIterations = 5
            cutWindowSize = 7
            # CalDb tool
            from TRT_ConditionsServices.TRT_ConditionsServicesConf import TRT_CalDbTool
            InDetTRTCalDbTool = TRT_CalDbTool(name="TRT_CalDbTool")

            #
            # --- load tool
            #
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetCosmicsEventPhaseTool
            InDetCosmicsEventPhaseTool = InDet__InDetCosmicsEventPhaseTool(
                name="InDetCosmicsEventPhaseTool",
                UseNewEP=useNewEP,
                GlobalOffset=globalOffset,
                TRTCalDbTool=InDetTRTCalDbTool)

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

            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetFixedWindowTrackTimeTool
            InDetFixedWindowTrackTimeTool = InDet__InDetFixedWindowTrackTimeTool(
                name="InDetFixedWindowTrackTimeTool",
                UseNewEP=useNewEP,
                GlobalOffset=globalOffset,
                WindowCenter=cutWindowCenter,
                WindowSize=cutWindowSize,
                TRTCalDbTool=InDetTRTCalDbTool)

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

            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetSlidingWindowTrackTimeTool
            InDetSlidingWindowTrackTimeTool = InDet__InDetSlidingWindowTrackTimeTool(
                name="InDetSlidingWindowTrackTimeTool",
                UseNewEP=useNewEP,
                GlobalOffset=globalOffset,
                NumberIterations=numberIterations,
                WindowSize=cutWindowSize,
                TRTCalDbTool=InDetTRTCalDbTool)

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

            #
            # --- load algorithm
            #
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetCosmicsEventPhase
            InDetCosmicsEventPhase = InDet__InDetCosmicsEventPhase(
                name="InDetCosmicsEventPhase",
                InputTracksNames=InputTrackCollections,
                TrackSummaryTool=InDetTrackSummaryTool,
                TRTCalDbTool=InDetTRTCalDbTool,
                #EventPhaseTool    = InDetCosmicsEventPhaseTool)
                #EventPhaseTool    = InDetFixedWindowTrackTimeTool)
                EventPhaseTool=InDetSlidingWindowTrackTimeTool)
            if InDetFlags.doCosmics():
                InDetCosmicsEventPhase.EventPhaseTool = InDetCosmicsEventPhaseTool
                topSequence += InDetCosmicsEventPhase  # indented here: do not calculate the phase in collisions
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetCosmicsEventPhase)
Exemple #20
0
    def __init__(self,
                 InputCollections=None,
                 ResolvedTrackCollectionKey=None,
                 SiSPSeededTrackCollectionKey=None,
                 NewTrackingCuts=None,
                 TrackCollectionKeys=[],
                 TrackCollectionTruthKeys=[]):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from InDetRecExample.InDetKeys import InDetKeys

        import InDetRecExample.TrackingCommon as TrackingCommon
        #
        # --- get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        #
        # --- decide if use the association tool
        #
        if (len(InputCollections) > 0) and (
                NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode()
                == "VeryLowPt" or NewTrackingCuts.mode() == "LargeD0"
                or NewTrackingCuts.mode() == "R3LargeD0"
                or NewTrackingCuts.mode() == "LowPtLargeD0"
                or NewTrackingCuts.mode() == "BeamGas"
                or NewTrackingCuts.mode() == "ForwardTracks"
                or NewTrackingCuts.mode() == "ForwardSLHCTracks"
                or NewTrackingCuts.mode() == "Disappearing"
                or NewTrackingCuts.mode() == "VeryForwardSLHCTracks"
                or NewTrackingCuts.mode() == "SLHCConversionFinding"):
            usePrdAssociationTool = True
        else:
            usePrdAssociationTool = False

        #
        # --- get list of already associated hits (always do this, even if no other tracking ran before)
        #
        asso_tool = None
        if usePrdAssociationTool:
            prefix = 'InDet'
            suffix = NewTrackingCuts.extension()
            InDetPRD_Association = TrackingCommon.getInDetTrackPRD_Association(
                namePrefix=prefix,
                nameSuffix=suffix,
                TracksName=list(InputCollections))

            # asso_tool = TrackingCommon.getConstPRD_AssociationTool(namePrefix     = prefix, nameSuffix = suffix)

            topSequence += InDetPRD_Association
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetPRD_Association)

        # ------------------------------------------------------------
        #
        # ----------- SiSPSeededTrackFinder
        #
        # ------------------------------------------------------------

        if InDetFlags.doSiSPSeededTrackFinder():
            #
            # --- Space points seeds maker, use different ones for cosmics and collisions
            #
            if NewTrackingCuts.mode() == "DBM":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker
            elif InDetFlags.doCosmics():
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_Cosmic as SiSpacePointsSeedMaker
            elif InDetFlags.doHeavyIon():
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_HeavyIon as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_LowMomentum as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "BeamGas":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_BeamGas as SiSpacePointsSeedMaker
            elif NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ITK as SiSpacePointsSeedMaker
            else:
                from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker

            InDetSiSpacePointsSeedMaker = SiSpacePointsSeedMaker(
                name="InDetSpSeedsMaker" + NewTrackingCuts.extension(),
                pTmin=NewTrackingCuts.minPT(),
                maxdImpact=NewTrackingCuts.maxPrimaryImpact(),
                maxZ=NewTrackingCuts.maxZImpact(),
                minZ=-NewTrackingCuts.maxZImpact(),
                usePixel=NewTrackingCuts.usePixel(),
                SpacePointsPixelName=InDetKeys.PixelSpacePoints(),
                # useSCT                 = NewTrackingCuts.useSCT(),
                useSCT=(NewTrackingCuts.useSCT()
                        and NewTrackingCuts.useSCTSeeding()),
                SpacePointsSCTName=InDetKeys.SCT_SpacePoints(),
                # useOverlapSpCollection = NewTrackingCuts.useSCT(),
                useOverlapSpCollection=(NewTrackingCuts.useSCT()
                                        and NewTrackingCuts.useSCTSeeding()),
                SpacePointsOverlapName=InDetKeys.OverlapSpacePoints(),
                radMax=NewTrackingCuts.radMax(),
                RapidityCut=NewTrackingCuts.maxEta())

            if NewTrackingCuts.mode() == "Offline" or InDetFlags.doHeavyIon(
            ) or NewTrackingCuts.mode() == "ForwardTracks":
                InDetSiSpacePointsSeedMaker.maxdImpactPPS = NewTrackingCuts.maxdImpactPPSSeeds(
                )
                InDetSiSpacePointsSeedMaker.maxdImpactSSS = NewTrackingCuts.maxdImpactSSSSeeds(
                )
                if not InDetFlags.doHeavyIon():
                    InDetSiSpacePointsSeedMaker.maxSeedsForSpacePointStrips = NewTrackingCuts.MaxSeedsPerSP_Strips(
                    )
                    InDetSiSpacePointsSeedMaker.maxSeedsForSpacePointPixels = NewTrackingCuts.MaxSeedsPerSP_Pixels(
                    )
                    InDetSiSpacePointsSeedMaker.alwaysKeepConfirmedStripSeeds = NewTrackingCuts.KeepAllConfirmedStripSeeds(
                    )
                    InDetSiSpacePointsSeedMaker.alwaysKeepConfirmedPixelSeeds = NewTrackingCuts.KeepAllConfirmedPixelSeeds(
                    )

            if NewTrackingCuts.mode() == "R3LargeD0":
                InDetSiSpacePointsSeedMaker.optimisePhiBinning = False
                InDetSiSpacePointsSeedMaker.usePixel = False
                InDetSiSpacePointsSeedMaker.etaMax = NewTrackingCuts.maxEta()
                InDetSiSpacePointsSeedMaker.maxSeedsForSpacePointStrips = NewTrackingCuts.MaxSeedsPerSP_Strips(
                )
                InDetSiSpacePointsSeedMaker.alwaysKeepConfirmedStripSeeds = NewTrackingCuts.KeepAllConfirmedStripSeeds(
                )
                InDetSiSpacePointsSeedMaker.maxdRadius = 150
                InDetSiSpacePointsSeedMaker.seedScoreBonusConfirmationSeed = -2000  #let's be generous

            if usePrdAssociationTool:
                # not all classes have that property !!!
                InDetSiSpacePointsSeedMaker.PRDtoTrackMap      = prefix+'PRDtoTrackMap'+suffix \
                                                                    if usePrdAssociationTool else ''
            if not InDetFlags.doCosmics():
                InDetSiSpacePointsSeedMaker.maxRadius1 = 0.75 * NewTrackingCuts.radMax(
                )
                InDetSiSpacePointsSeedMaker.maxRadius2 = NewTrackingCuts.radMax(
                )
                InDetSiSpacePointsSeedMaker.maxRadius3 = NewTrackingCuts.radMax(
                )
            if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                try:
                    InDetSiSpacePointsSeedMaker.pTmax = NewTrackingCuts.maxPT()
                except:
                    pass
                InDetSiSpacePointsSeedMaker.mindRadius = 4.0
            if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "SLHCConversionFinding":
                InDetSiSpacePointsSeedMaker.minRadius1 = 0
                InDetSiSpacePointsSeedMaker.minRadius2 = 0
                InDetSiSpacePointsSeedMaker.minRadius3 = 0
                InDetSiSpacePointsSeedMaker.maxRadius1 = 1000. * Units.mm
                InDetSiSpacePointsSeedMaker.maxRadius2 = 1000. * Units.mm
                InDetSiSpacePointsSeedMaker.maxRadius3 = 1000. * Units.mm
            if NewTrackingCuts.mode(
            ) == "ForwardTracks" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                InDetSiSpacePointsSeedMaker.checkEta = True
                InDetSiSpacePointsSeedMaker.etaMin = NewTrackingCuts.minEta()
                InDetSiSpacePointsSeedMaker.etaMax = NewTrackingCuts.maxEta()
                InDetSiSpacePointsSeedMaker.RapidityCut = NewTrackingCuts.maxEta(
                )
            if NewTrackingCuts.mode() == "DBM":
                InDetSiSpacePointsSeedMaker.etaMin = NewTrackingCuts.minEta()
                InDetSiSpacePointsSeedMaker.etaMax = NewTrackingCuts.maxEta()
                InDetSiSpacePointsSeedMaker.useDBM = True

            #InDetSiSpacePointsSeedMaker.OutputLevel = VERBOSE
            ToolSvc += InDetSiSpacePointsSeedMaker
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSiSpacePointsSeedMaker)

            #
            # --- Z-coordinates primary vertices finder (only for collisions)
            #
            if InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM":
                from SiZvertexTool_xk.SiZvertexTool_xkConf import InDet__SiZvertexMaker_xk
                InDetZvertexMaker = InDet__SiZvertexMaker_xk(
                    name='InDetZvertexMaker' + NewTrackingCuts.extension(),
                    Zmax=NewTrackingCuts.maxZImpact(),
                    Zmin=-NewTrackingCuts.maxZImpact(),
                    minRatio=0.17)  # not default
                InDetZvertexMaker.SeedMakerTool = InDetSiSpacePointsSeedMaker

                if InDetFlags.doHeavyIon():
                    InDetZvertexMaker.HistSize = 2000
                    ###InDetZvertexMaker.minContent = 200
                    InDetZvertexMaker.minContent = 30

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

            else:
                InDetZvertexMaker = None

            #
            # --- SCT and Pixel detector elements road builder
            #
            from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
            InDetSiDetElementsRoadMaker = InDet__SiDetElementsRoadMaker_xk(
                name='InDetSiRoadMaker' + NewTrackingCuts.extension(),
                PropagatorTool=InDetPatternPropagator,
                usePixel=NewTrackingCuts.usePixel(),
                PixManagerLocation=InDetKeys.PixelManager(),
                useSCT=NewTrackingCuts.useSCT(),
                SCTManagerLocation=InDetKeys.SCT_Manager(),
                RoadWidth=NewTrackingCuts.RoadWidth())
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSiDetElementsRoadMaker)
            # Condition algorithm for InDet__SiDetElementsRoadMaker_xk
            if DetFlags.haveRIO.pixel_on():
                # Condition algorithm for SiCombinatorialTrackFinder_xk
                from AthenaCommon.AlgSequence import AthSequencer
                condSeq = AthSequencer("AthCondSeq")
                if not hasattr(condSeq,
                               "InDetSiDetElementBoundaryLinksPixelCondAlg"):
                    from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiDetElementBoundaryLinksCondAlg_xk
                    condSeq += InDet__SiDetElementBoundaryLinksCondAlg_xk(
                        name="InDetSiDetElementBoundaryLinksPixelCondAlg",
                        ReadKey="PixelDetectorElementCollection",
                        WriteKey="PixelDetElementBoundaryLinks_xk",
                        UsePixelDetectorManager=True)

            if NewTrackingCuts.useSCT():
                from AthenaCommon.AlgSequence import AthSequencer
                condSeq = AthSequencer("AthCondSeq")
                if not hasattr(condSeq, "InDet__SiDetElementsRoadCondAlg_xk"):
                    from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadCondAlg_xk
                    condSeq += InDet__SiDetElementsRoadCondAlg_xk(
                        name="InDet__SiDetElementsRoadCondAlg_xk")

                if not hasattr(condSeq,
                               "InDetSiDetElementBoundaryLinksSCTCondAlg"):
                    from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiDetElementBoundaryLinksCondAlg_xk
                    condSeq += InDet__SiDetElementBoundaryLinksCondAlg_xk(
                        name="InDetSiDetElementBoundaryLinksSCTCondAlg",
                        ReadKey="SCT_DetectorElementCollection",
                        WriteKey="SCT_DetElementBoundaryLinks_xk")

            #
            # --- Local track finding using sdCaloSeededSSSpace point seed
            #
            # @TODO ensure that PRD association map is used if usePrdAssociationTool is set
            is_dbm = InDetFlags.doDBMstandalone() or NewTrackingCuts.extension(
            ) == 'DBM'
            rot_creator_digital = TrackingCommon.getInDetRotCreatorDigital(
            ) if not is_dbm else TrackingCommon.getInDetRotCreatorDBM()

            from SiCombinatorialTrackFinderTool_xk.SiCombinatorialTrackFinderTool_xkConf import InDet__SiCombinatorialTrackFinder_xk
            track_finder = InDet__SiCombinatorialTrackFinder_xk(
                name='InDetSiComTrackFinder' + NewTrackingCuts.extension(),
                PropagatorTool=InDetPatternPropagator,
                UpdatorTool=InDetPatternUpdator,
                RIOonTrackTool=rot_creator_digital,
                usePixel=DetFlags.haveRIO.pixel_on(),
                useSCT=DetFlags.haveRIO.SCT_on() if not is_dbm else False,
                PixelClusterContainer=InDetKeys.PixelClusters(),
                SCT_ClusterContainer=InDetKeys.SCT_Clusters())
            if is_dbm:
                track_finder.MagneticFieldMode = "NoField"
                track_finder.TrackQualityCut = 9.3

            if (DetFlags.haveRIO.SCT_on()):
                track_finder.SctSummaryTool = InDetSCT_ConditionsSummaryTool
            else:
                track_finder.SctSummaryTool = None

            ToolSvc += track_finder

            useBremMode = NewTrackingCuts.mode(
            ) == "Offline" or NewTrackingCuts.mode(
            ) == "SLHC" or NewTrackingCuts.mode() == "DBM"
            from SiTrackMakerTool_xk.SiTrackMakerTool_xkConf import InDet__SiTrackMaker_xk as SiTrackMaker
            InDetSiTrackMaker = SiTrackMaker(
                name='InDetSiTrackMaker' + NewTrackingCuts.extension(),
                useSCT=NewTrackingCuts.useSCT(),
                usePixel=NewTrackingCuts.usePixel(),
                RoadTool=InDetSiDetElementsRoadMaker,
                CombinatorialTrackFinder=track_finder,
                pTmin=NewTrackingCuts.minPT(),
                pTminBrem=NewTrackingCuts.minPTBrem(),
                pTminSSS=InDetFlags.pT_SSScut(),
                nClustersMin=NewTrackingCuts.minClusters(),
                nHolesMax=NewTrackingCuts.nHolesMax(),
                nHolesGapMax=NewTrackingCuts.nHolesGapMax(),
                SeedsFilterLevel=NewTrackingCuts.seedFilterLevel(),
                Xi2max=NewTrackingCuts.Xi2max(),
                Xi2maxNoAdd=NewTrackingCuts.Xi2maxNoAdd(),
                nWeightedClustersMin=NewTrackingCuts.nWeightedClustersMin(),
                CosmicTrack=InDetFlags.doCosmics(),
                Xi2maxMultiTracks=NewTrackingCuts.Xi2max(),  # was 3.
                useSSSseedsFilter=InDetFlags.doSSSfilter(),
                doMultiTracksProd=True,
                useBremModel=InDetFlags.doBremRecovery() and
                useBremMode,  # only for NewTracking the brem is debugged !!!
                doCaloSeededBrem=InDetFlags.doCaloSeededBrem(),
                doHadCaloSeedSSS=InDetFlags.doHadCaloSeededSSS(),
                phiWidth=NewTrackingCuts.phiWidthBrem(),
                etaWidth=NewTrackingCuts.etaWidthBrem(),
                InputClusterContainerName=InDetKeys.CaloClusterROIContainer(
                ),  # "InDetCaloClusterROIs" 
                InputHadClusterContainerName=InDetKeys.
                HadCaloClusterROIContainer(),  # "InDetCaloClusterROIs" 
                UseAssociationTool=usePrdAssociationTool)

            if NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "VeryForwardSLHCTracks":
                InDetSiTrackMaker.ITKGeometry = True

            if NewTrackingCuts.mode() == "DBM":
                InDetSiTrackMaker.MagneticFieldMode = "NoField"
                InDetSiTrackMaker.useBremModel = False
                InDetSiTrackMaker.doMultiTracksProd = False
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'
                InDetSiTrackMaker.pTminSSS = -1
                InDetSiTrackMaker.CosmicTrack = False
                InDetSiTrackMaker.useSSSseedsFilter = False
                InDetSiTrackMaker.doCaloSeededBrem = False
                InDetSiTrackMaker.doHadCaloSeedSSS = False

            elif InDetFlags.doCosmics():
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_Cosmic'

            elif InDetFlags.doHeavyIon():
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_HeavyIon'

            elif NewTrackingCuts.mode() == "LowPt":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LowMomentum'

            elif NewTrackingCuts.mode() == "VeryLowPt" or (
                    NewTrackingCuts.mode() == "Pixel"
                    and InDetFlags.doMinBias()):
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryLowMomentum'

            elif NewTrackingCuts.mode() == "BeamGas":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_BeamGas'

            elif NewTrackingCuts.mode() == "ForwardTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardTracks'

            elif NewTrackingCuts.mode() == "ForwardSLHCTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardSLHCTracks'

            elif NewTrackingCuts.mode() == "VeryForwardSLHCTracks":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryForwardSLHCTracks'

            elif NewTrackingCuts.mode() == "SLHCConversionFinding":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_SLHCConversionTracks'

            elif NewTrackingCuts.mode() == "LargeD0" or NewTrackingCuts.mode(
            ) == "R3LargeD0" or NewTrackingCuts.mode() == "LowPtLargeD0":
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LargeD0'

            else:
                InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'

            if InDetFlags.doStoreTrackSeeds():
                from SeedToTrackConversionTool.SeedToTrackConversionToolConf import InDet__SeedToTrackConversionTool
                InDet_SeedToTrackConversion = InDet__SeedToTrackConversionTool(
                    name="InDet_SeedToTrackConversion",
                    OutputName=InDetKeys.SiSPSeedSegments() +
                    NewTrackingCuts.extension())
                InDetSiTrackMaker.SeedToTrackConversion = InDet_SeedToTrackConversion
                InDetSiTrackMaker.SeedSegmentsWrite = True

            #InDetSiTrackMaker.OutputLevel = VERBOSE
            ToolSvc += InDetSiTrackMaker
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSiTrackMaker)
            #
            # set output track collection name
        #
            self.__SiTrackCollection = SiSPSeededTrackCollectionKey
            #
            # --- Setup Track finder using space points seeds
            #

            from SiSPSeededTrackFinder.SiSPSeededTrackFinderConf import InDet__SiSPSeededTrackFinder

            if NewTrackingCuts.mode(
            ) == "ForwardSLHCTracks" or NewTrackingCuts.mode(
            ) == "ForwardTracks":

                InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(name             = 'InDetSiSpTrackFinder'+NewTrackingCuts.extension(),
                                                                          TrackTool        = InDetSiTrackMaker,
                                                                          PRDtoTrackMap    = prefix+'PRDtoTrackMap'+suffix \
                                                                                             if usePrdAssociationTool else '',
                                                                          TrackSummaryTool = TrackingCommon.getInDetTrackSummaryToolNoHoleSearch(),
                                                                          TracksLocation   = self.__SiTrackCollection,
                                                                          SeedsTool        = InDetSiSpacePointsSeedMaker,
                                                                          useZvertexTool   = InDetFlags.useZvertexTool(),
                                                                          ZvertexTool      = InDetZvertexMaker,
                                                                          useNewStrategy   = False,
                                                                          useMBTSTimeDiff  = InDetFlags.useMBTSTimeDiff(),
                                                                          useZBoundFinding = False)
                if InDetFlags.doHeavyIon():
                    InDetSiSPSeededTrackFinder.FreeClustersCut = 2  #Heavy Ion optimization from Igor

            else:
                InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(name             = 'InDetSiSpTrackFinder'+NewTrackingCuts.extension(),
                                                                          TrackTool        = InDetSiTrackMaker,
                                                                          PRDtoTrackMap    = prefix+'PRDtoTrackMap'+suffix \
                                                                                             if usePrdAssociationTool else '',
                                                                          TrackSummaryTool = TrackingCommon.getInDetTrackSummaryToolNoHoleSearch(),
                                                                          TracksLocation   = self.__SiTrackCollection,
                                                                          SeedsTool        = InDetSiSpacePointsSeedMaker,
                                                                          useZvertexTool   = InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM",
                                                                          ZvertexTool      = InDetZvertexMaker,
                                                                          useNewStrategy   = InDetFlags.useNewSiSPSeededTF() and NewTrackingCuts.mode() != "DBM",
                                                                          useMBTSTimeDiff  = InDetFlags.useMBTSTimeDiff(),
                                                                          useZBoundFinding = NewTrackingCuts.doZBoundary() and NewTrackingCuts.mode() != "DBM")

                if InDetFlags.doHeavyIon():
                    InDetSiSPSeededTrackFinder.FreeClustersCut = 2  #Heavy Ion optimization from Igor

            #InDetSiSPSeededTrackFinder.OutputLevel =VERBOSE
            topSequence += InDetSiSPSeededTrackFinder
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetSiSPSeededTrackFinder)

            if not InDetFlags.doSGDeletion():
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__SiTrackCollection,
                        self.__SiTrackCollection + "DetailedTruth",
                        self.__SiTrackCollection + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__SiTrackCollection]

        # ------------------------------------------------------------
        #
        # ---------- Ambiguity solving
        #
        # ------------------------------------------------------------

        if InDetFlags.doAmbiSolving():
            #
            # --- load InnerDetector TrackSelectionTool
            #

            prob1 = InDetFlags.pixelClusterSplitProb1()
            prob2 = InDetFlags.pixelClusterSplitProb2()
            nhitsToAllowSplitting = 9

            from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags
            if CommonGeometryFlags.Run() == 1:
                prob1 = InDetFlags.pixelClusterSplitProb1_run1()
                prob2 = InDetFlags.pixelClusterSplitProb2_run1()
                nhitsToAllowSplitting = 8

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetDenseEnvAmbiTrackSelectionTool as AmbiTrackSelectionTool
            else:
                from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetAmbiTrackSelectionTool as AmbiTrackSelectionTool
            InDetAmbiTrackSelectionTool = AmbiTrackSelectionTool(
                name='InDetAmbiTrackSelectionTool' +
                NewTrackingCuts.extension(),
                DriftCircleCutTool=InDetTRTDriftCircleCut,
                AssociationTool=TrackingCommon.
                getInDetPRDtoTrackMapToolGangedPixels(),
                minHits=NewTrackingCuts.minClusters(),
                minNotShared=NewTrackingCuts.minSiNotShared(),
                maxShared=NewTrackingCuts.maxShared(),
                minTRTHits=0,  # used for Si only tracking !!!
                sharedProbCut=0.10,
                UseParameterization=False,
                Cosmics=InDetFlags.doCosmics(),
                doPixelSplitting=InDetFlags.doPixelClusterSplitting()
                and NewTrackingCuts.mode != "DBM")
            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                InDetAmbiTrackSelectionTool.sharedProbCut = prob1
                InDetAmbiTrackSelectionTool.sharedProbCut2 = prob2
                InDetAmbiTrackSelectionTool.minSiHitsToAllowSplitting = nhitsToAllowSplitting
                InDetAmbiTrackSelectionTool.minUniqueSCTHits = 4
                InDetAmbiTrackSelectionTool.minTrackChi2ForSharedHits = 3
                InDetAmbiTrackSelectionTool.InputHadClusterContainerName = InDetKeys.HadCaloClusterROIContainer(
                ) + "Bjet"
                InDetAmbiTrackSelectionTool.doHadCaloSeed = InDetFlags.doCaloSeededAmbi(
                )  #Do special cuts in region of interest
                InDetAmbiTrackSelectionTool.minPtSplit = InDetFlags.pixelClusterSplitMinPt(
                )  #Only allow split clusters on track withe pt greater than this MeV
                InDetAmbiTrackSelectionTool.maxSharedModulesInROI = 3  #Maximum number of shared modules for tracks in ROI
                InDetAmbiTrackSelectionTool.minNotSharedInROI = 2  #Minimum number of unique modules for tracks in ROI
                InDetAmbiTrackSelectionTool.minSiHitsToAllowSplittingInROI = 7  #Minimum number of Si hits to allow splittings for tracks in ROI
                InDetAmbiTrackSelectionTool.phiWidth = 0.1  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.etaWidth = 0.1  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.InputEmClusterContainerName = InDetKeys.CaloClusterROIContainer(
                )
                InDetAmbiTrackSelectionTool.doEmCaloSeed = False  #Only split in cluster in region of interest
                InDetAmbiTrackSelectionTool.minPtConv = 10000  #Only allow split clusters on track withe pt greater than this MeV
                InDetAmbiTrackSelectionTool.phiWidthEM = 0.05  #Split cluster ROI size
                InDetAmbiTrackSelectionTool.etaWidthEM = 0.05  #Split cluster ROI size

            if NewTrackingCuts.mode() == "DBM":
                InDetAmbiTrackSelectionTool.Cosmics = False
                InDetAmbiTrackSelectionTool.UseParameterization = False
                InDetAmbiTrackSelectionTool.doPixelSplitting = False
                InDetAmbiTrackSelectionTool.maxShared = 1000
                InDetAmbiTrackSelectionTool.maxTracksPerSharedPRD = 2
                InDetAmbiTrackSelectionTool.minHits = 0
                InDetAmbiTrackSelectionTool.minNotShared = 0
                InDetAmbiTrackSelectionTool.minScoreShareTracks = 0.0
                InDetAmbiTrackSelectionTool.minTRTHits = 0
                InDetAmbiTrackSelectionTool.sharedProbCut = 0.1

            # if NewTrackingCuts.mode() == "ForwardTracks":
            #    InDetAmbiTrackSelectionTool.OutputLevel = VERBOSE

            ToolSvc += InDetAmbiTrackSelectionTool
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetAmbiTrackSelectionTool)
            #
            # --- set up different Scoring Tool for collisions and cosmics
            #
            if InDetFlags.doCosmics() and NewTrackingCuts.mode() != "DBM":
                InDetAmbiScoringTool = TrackingCommon.getInDetCosmicsScoringTool(
                    NewTrackingCuts)
            elif (NewTrackingCuts.mode() == "R3LargeD0"
                  and InDetFlags.nnCutLargeD0Threshold > 0):
                # Set up NN config
                InDetAmbiScoringTool = TrackingCommon.getInDetNNScoringTool(
                    NewTrackingCuts)
            else:
                InDetAmbiScoringTool = TrackingCommon.getInDetAmbiScoringTool(
                    NewTrackingCuts)

            #
            # --- load Ambiguity Processor
            #
            useBremMode = NewTrackingCuts.mode(
            ) == "Offline" or NewTrackingCuts.mode() == "SLHC"

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode() == "DBM"):
                # DenseEnvironmentsAmbiguityProcessorTool
                from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__DenseEnvironmentsAmbiguityProcessorTool as ProcessorTool
                use_low_pt_fitter = True if NewTrackingCuts.mode(
                ) == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (
                    NewTrackingCuts.mode() == "Pixel"
                    and InDetFlags.doMinBias()) else False

                from AthenaCommon import CfgGetter
                from InDetRecExample.TrackingCommon import setDefaults
                if len(NewTrackingCuts.extension()) > 0:
                    fitter_args = setDefaults(
                        {},
                        SplitClusterMapExtension=NewTrackingCuts.extension())
                    fitter_list=[     CfgGetter.getPublicToolClone('InDetTrackFitter'+NewTrackingCuts.extension(), 'InDetTrackFitter',**fitter_args)    if not use_low_pt_fitter \
                                 else CfgGetter.getPublicToolClone('InDetTrackFitterLowPt'+NewTrackingCuts.extension(), 'InDetTrackFitterLowPt',**fitter_args)]
                else:
                    fitter_list=[     CfgGetter.getPublicTool('InDetTrackFitter')    if not use_low_pt_fitter \
                                 else CfgGetter.getPublicTool('InDetTrackFitterLowPt')]

                if InDetFlags.doRefitInvalidCov():
                    from AthenaCommon import CfgGetter
                    if len(NewTrackingCuts.extension()) > 0:
                        fitter_args = setDefaults(
                            {},
                            SplitClusterMapExtension=NewTrackingCuts.extension(
                            ))
                        fitter_list.append(
                            CfgGetter.getPublicToolClone(
                                'KalmanFitter' + NewTrackingCuts.extension(),
                                'KalmanFitter', **fitter_args))
                        fitter_list.append(
                            CfgGetter.getPublicToolClone(
                                'ReferenceKalmanFitter' +
                                NewTrackingCuts.extension(),
                                'ReferenceKalmanFitter', **fitter_args))
                    else:
                        fitter_list.append(
                            CfgGetter.getPublicTool('KalmanFitter'))
                        fitter_list.append(
                            CfgGetter.getPublicTool('ReferenceKalmanFitter'))

                InDetAmbiguityProcessor = ProcessorTool(
                    name='InDetAmbiguityProcessor' +
                    NewTrackingCuts.extension(),
                    Fitter=fitter_list,
                    AssociationTool=TrackingCommon.
                    getInDetPRDtoTrackMapToolGangedPixels(),
                    AssociationMapName='PRDToTrackMap' +
                    NewTrackingCuts.extension(),
                    TrackSummaryTool=TrackingCommon.getInDetTrackSummaryTool(),
                    ScoringTool=InDetAmbiScoringTool,
                    SelectionTool=InDetAmbiTrackSelectionTool,
                    SuppressHoleSearch=False,
                    tryBremFit=InDetFlags.doBremRecovery() and useBremMode
                    and NewTrackingCuts.mode() != "DBM",
                    caloSeededBrem=InDetFlags.doCaloSeededBrem()
                    and NewTrackingCuts.mode() != "DBM",
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=True,
                    doHadCaloSeed=InDetFlags.doCaloSeededRefit(),
                    InputHadClusterContainerName=InDetKeys.
                    HadCaloClusterROIContainer() + "Bjet")

                # DenseEnvironmentsAmbiguityScoreProcessorTool
                from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__DenseEnvironmentsAmbiguityScoreProcessorTool as ScoreProcessorTool
                InDetAmbiguityScoreProcessor = ScoreProcessorTool(
                    name='InDetAmbiguityScoreProcessor' +
                    NewTrackingCuts.extension(),
                    ScoringTool=InDetAmbiScoringTool,
                    SplitProbTool=NnPixelClusterSplitProbTool
                    if InDetFlags.doPixelClusterSplitting()
                    and 'NnPixelClusterSplitProbTool' in globals() else None,
                    AssociationTool=TrackingCommon.
                    getInDetPRDtoTrackMapToolGangedPixels(),
                    AssociationToolNotGanged=TrackingCommon.
                    getPRDtoTrackMapTool(),
                    AssociationMapName='PRDToTrackMap' +
                    NewTrackingCuts.extension(),
                    SelectionTool=InDetAmbiTrackSelectionTool)
                # hasScoreProcessorTool = True
            else:
                from AthenaCommon import CfgGetter
                from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__SimpleAmbiguityProcessorTool as ProcessorTool
                InDetAmbiguityProcessor = ProcessorTool(
                    name='InDetAmbiguityProcessor' +
                    NewTrackingCuts.extension(),
                    Fitter=CfgGetter.getPublicTool('InDetTrackFitter'),
                    AssociationTool=TrackingCommon.
                    getInDetPRDtoTrackMapToolGangedPixels(),
                    TrackSummaryTool=TrackingCommon.getInDetTrackSummaryTool(),
                    ScoringTool=InDetAmbiScoringTool,
                    SelectionTool=InDetAmbiTrackSelectionTool,
                    SuppressHoleSearch=False,
                    tryBremFit=InDetFlags.doBremRecovery() and useBremMode
                    and NewTrackingCuts.mode() != "DBM",
                    caloSeededBrem=InDetFlags.doCaloSeededBrem()
                    and NewTrackingCuts.mode() != "DBM",
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=True)
                InDetAmbiguityScoreProcessor = None

            if InDetFlags.doTIDE_Ambi() and not (
                    NewTrackingCuts.mode() == "ForwardSLHCTracks"
                    or NewTrackingCuts.mode() == "ForwardTracks"
                    or NewTrackingCuts.mode()
                    == "DBM") and 'NnPixelClusterSplitProbTool' in globals():
                if InDetAmbiguityScoreProcessor is not None:
                    InDetAmbiguityScoreProcessor.sharedProbCut = prob1
                    InDetAmbiguityScoreProcessor.sharedProbCut2 = prob2
                    if NewTrackingCuts.extension() == "":
                        InDetAmbiguityScoreProcessor.SplitClusterMap_old = ""
                    elif NewTrackingCuts.extension() == "Disappearing":
                        InDetAmbiguityScoreProcessor.SplitClusterMap_old = InDetKeys.SplitClusterAmbiguityMap(
                        )
                    InDetAmbiguityScoreProcessor.SplitClusterMap_new = InDetKeys.SplitClusterAmbiguityMap(
                    ) + NewTrackingCuts.extension()
                if InDetFlags.doTIDE_RescalePixelCovariances():
                    InDetAmbiguityProcessor.applydRcorrection = True

            if NewTrackingCuts.mode() == "Pixel" or NewTrackingCuts.mode(
            ) == "DBM":
                InDetAmbiguityProcessor.SuppressHoleSearch = True
            if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode(
            ) == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel"
                                 and InDetFlags.doMinBias()):
                if InDetAmbiguityProcessor.getName().find('Dense'):
                    pass
                else:
                    from AthenaCommon import CfgGetter
                    InDetAmbiguityProcessor.Fitter = CfgGetter.getPublicTool(
                        'InDetTrackFitterLowPt')

            if InDetFlags.materialInteractions():
                InDetAmbiguityProcessor.MatEffects = InDetFlags.materialInteractionsType(
                )
            else:
                InDetAmbiguityProcessor.MatEffects = 0

            # if NewTrackingCuts.mode() == "ForwardTracks":
            #    InDetAmbiguityProcessor.OutputLevel = VERBOSE

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

            # add InDetAmbiguityScoreProcessor
            if InDetAmbiguityScoreProcessor is not None:
                ToolSvc += InDetAmbiguityScoreProcessor

            #
            # --- set input and output collection
            #
            InputTrackCollection = self.__SiTrackCollection
            self.__SiTrackCollection = ResolvedTrackCollectionKey

            #
            # --- configure Ambiguity (score) solver
            #
            from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguityScore
            # from RecExConfig.hideInput import hideInput
            # hideInput ('TrackCollection', self.__SiTrackCollection)
            InDetAmbiguityScore = Trk__TrkAmbiguityScore(
                name='InDetAmbiguityScore' + NewTrackingCuts.extension(),
                TrackInput=[InputTrackCollection],
                TrackOutput='ScoredMap' + 'InDetAmbiguityScore' +
                NewTrackingCuts.extension(),
                AmbiguityScoreProcessor=InDetAmbiguityScoreProcessor
            )  ## TODO: check the case when it is None object
            topSequence += InDetAmbiguityScore
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetAmbiguityScore)

            #
            # --- configure Ambiguity solver
            #
            from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguitySolver
            from RecExConfig.hideInput import hideInput
            hideInput('TrackCollection', self.__SiTrackCollection)
            InDetAmbiguitySolver = Trk__TrkAmbiguitySolver(
                name='InDetAmbiguitySolver' + NewTrackingCuts.extension(),
                TrackInput='ScoredMap' + 'InDetAmbiguityScore' +
                NewTrackingCuts.extension(),
                TrackOutput=self.__SiTrackCollection,
                AmbiguityProcessor=InDetAmbiguityProcessor)
            topSequence += InDetAmbiguitySolver
            if (InDetFlags.doPrintConfigurables()):
                printfunc(InDetAmbiguitySolver)

            #
            # --- Delete Silicon Sp-Seeded tracks
            #
            from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
            InDetSGDeletionAlg(key=SiSPSeededTrackCollectionKey)

            if ((NewTrackingCuts.mode() in ["Pixel", "SCT"])
                    or not InDetFlags.doSGDeletion()):
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__SiTrackCollection,
                        self.__SiTrackCollection + "DetailedTruth",
                        self.__SiTrackCollection + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__SiTrackCollection]
Exemple #21
0
   def __init__(self, NewTrackingCuts = None, SiTrackCollection = None, ExtendedTrackCollection = None, ExtendedTracksMap = None, TrackCollectionKeys=[], TrackCollectionTruthKeys=[] , doPhase = True):
      
      from InDetRecExample.InDetJobProperties import InDetFlags
      from AthenaCommon.DetFlags              import DetFlags
      from InDetRecExample.InDetKeys          import InDetKeys
      
      import InDetRecExample.TrackingCommon   as TrackingCommon
      #
      # get ToolSvc and topSequence
      #
      from AthenaCommon.AppMgr                import ToolSvc
      from AthenaCommon.AlgSequence           import AlgSequence
      topSequence = AlgSequence()
      
      #    
      # ---------- TRT_TrackExtension
      #
      if InDetFlags.doTRTExtension() and InDetFlags.doTRTExtensionNew():


         #
         # Track extension to TRT algorithm
         #
         # set output extension map name
         OutputExtendedTracks = ExtendedTracksMap

         if doPhase:

           from TRT_TrackExtensionTool_xk.TRT_TrackExtensionTool_xkConf import InDet__TRT_TrackExtensionToolCosmics
           InDetTRTExtensionToolPhase = TrackingCommon.getInDetTRT_ExtensionToolPhase()


           from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
           InDetTRTExtensionPhase    = InDet__TRT_TrackExtensionAlg (name                   = 'InDetTRT_ExtensionPhase'+NewTrackingCuts.extension(),
                                                                     InputTracksLocation    = SiTrackCollection,
                                                                     ExtendedTracksLocation = OutputExtendedTracks,
                                                                     TrackExtensionTool     = InDetTRTExtensionToolPhase)

           topSequence += InDetTRTExtensionPhase
           if (InDetFlags.doPrintConfigurables()):
            printfunc (InDetTRTExtensionPhase)

         else:
          cuts_args = {}
          if NewTrackingCuts is not None :
             cuts_args={'TrackingCuts': NewTrackingCuts}
          from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
          InDetTRTExtension = InDet__TRT_TrackExtensionAlg(name                   = 'InDetTRT_Extension'+NewTrackingCuts.extension(),
                                                           InputTracksLocation    = SiTrackCollection,
                                                           ExtendedTracksLocation = OutputExtendedTracks,
                                                           TrackExtensionTool     = TrackingCommon.getInDetTRT_ExtensionTool(**cuts_args))
          #InDetTRTExtension.OutputLevel = VERBOSE
          topSequence += InDetTRTExtension
          if (InDetFlags.doPrintConfigurables()):
            printfunc (InDetTRTExtension)
   
      #
      # ------------ Track Extension Processor
      #
      if InDetFlags.doExtensionProcessor() and InDetFlags.doTRTExtensionNew():
            
         if InDetFlags.trtExtensionType() == 'DAF' :
            #
            # --- DAF Fitter setup
            #
            from TrkCompetingRIOsOnTrackTool.TrkCompetingRIOsOnTrackToolConf import Trk__CompetingRIOsOnTrackTool
            InDetCompetingRotCreator =  Trk__CompetingRIOsOnTrackTool( name                        = 'InDetCompetingRotCreator'+NewTrackingCuts.extension(),
                                                                       ToolForCompPixelClusters    = None,      # default
                                                                       ToolForCompSCT_Clusters     = None,      # default
                                                                       ToolForCompTRT_DriftCircles = InDetCompetingTRT_DC_Tool )
            ToolSvc += InDetCompetingRotCreator
            if (InDetFlags.doPrintConfigurables()):
               printfunc (InDetCompetingRotCreator)
            #
            from TrkDeterministicAnnealingFilter.TrkDeterministicAnnealingFilterConf import Trk__DeterministicAnnealingFilter
            InDetExtensionFitter =  Trk__DeterministicAnnealingFilter( name = 'InDetDAF'+NewTrackingCuts.extension(),
                                                                       ToolForExtrapolation           = InDetExtrapolator,
                                                                       ToolForCompetingROTsCreation   = InDetCompetingRotCreator,
                                                                       ToolForUpdating                = InDetUpdator,
                                                                       AnnealingScheme                = [200., 81., 9., 4., 1., 1., 1.],
                                                                       DropOutlierCutValue            = 1.E-7,
                                                                       OutlierCutValue                = 0.01 )
            ToolSvc += InDetExtensionFitter
            if (InDetFlags.doPrintConfigurables()):
               printfunc (InDetExtensionFitter)
         else:
            from AthenaCommon import CfgGetter
            InDetExtensionFitter = CfgGetter.getPublicTool('InDetTrackFitter' if NewTrackingCuts.mode() != "LowPt" else  'InDetTrackFitterLowPt')

         #
         # --- load scoring for extension
         #
         if InDetFlags.doCosmics():
            InDetExtenScoringTool = TrackingCommon.getInDetCosmicExtenScoringTool(NewTrackingCuts)
         else:
            InDetExtenScoringTool = TrackingCommon.getInDetExtenScoringTool(NewTrackingCuts)

         #
         # --- output track collection
         #
         self.__ForwardTrackCollection = ExtendedTrackCollection 
         #
         # --- get configured track extension processor
         #
         if doPhase:
         
          from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor   
          InDetExtensionProcessorPhase = InDet__InDetExtensionProcessor ( name               = "InDetExtensionProcessorPhase"+NewTrackingCuts.extension(),
                                                                    TrackName          = SiTrackCollection,
                                                                    Cosmics            = True,
                                                                    ExtensionMap       = OutputExtendedTracks,
                                                                    NewTrackName       = self.__ForwardTrackCollection,
                                                                    TrackFitter        = InDetExtensionFitter,
                                                                    TrackSummaryTool   = TrackingCommon.getInDetTrackSummaryTool(),
                                                                    ScoringTool        = InDetExtenScoringTool,
                                                                    suppressHoleSearch = False,  # does not work properly
                                                                    tryBremFit         = InDetFlags.doBremRecovery(),
                                                                    caloSeededBrem     = InDetFlags.doCaloSeededBrem(),
                                                                    pTminBrem          = NewTrackingCuts.minPTBrem(),
                                                                    RefitPrds          = not (InDetFlags.refitROT() or (InDetFlags.trtExtensionType() == 'DAF')))
         #InDetExtensionProcessor.OutputLevel = VERBOSE
          if InDetFlags.materialInteractions():
             InDetExtensionProcessorPhase.matEffects = InDetFlags.materialInteractionsType()
          else:
             InDetExtensionProcessorPhase.matEffects = 0
   
          topSequence += InDetExtensionProcessorPhase
          if (InDetFlags.doPrintConfigurables()):
              printfunc (InDetExtensionProcessorPhase)

         else:

          from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor   
          InDetExtensionProcessor = InDet__InDetExtensionProcessor ( name               = "InDetExtensionProcessor"+NewTrackingCuts.extension(),
                                                                    TrackName          = SiTrackCollection,
                                                                    Cosmics            = InDetFlags.doCosmics(),
                                                                    ExtensionMap       = OutputExtendedTracks,
                                                                    NewTrackName       = self.__ForwardTrackCollection,
                                                                    TrackFitter        = InDetExtensionFitter,
                                                                    TrackSummaryTool   = TrackingCommon.getInDetTrackSummaryTool(),
                                                                    ScoringTool        = InDetExtenScoringTool,
                                                                    suppressHoleSearch = False,  # does not work properly
                                                                    tryBremFit         = InDetFlags.doBremRecovery(),
                                                                    caloSeededBrem     = InDetFlags.doCaloSeededBrem(),
                                                                    pTminBrem          = NewTrackingCuts.minPTBrem(),
                                                                    RefitPrds          = not (InDetFlags.refitROT() or (InDetFlags.trtExtensionType() == 'DAF')))
          #InDetExtensionProcessor.OutputLevel = VERBOSE
          if InDetFlags.materialInteractions():
             InDetExtensionProcessor.matEffects = InDetFlags.materialInteractionsType()
          else:
             InDetExtensionProcessor.matEffects = 0
   
          topSequence += InDetExtensionProcessor

          if (InDetFlags.doPrintConfigurables()):
             printfunc (InDetExtensionProcessor)
         
         # --- Delete Resolved Si tracks and extension map
         from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg         
         InDetSGDeletionAlg(container = "TrackExtensionMap#", key = OutputExtendedTracks)
         if not InDetFlags.doMonitoringAlignment():
            InDetSGDeletionAlg(key = SiTrackCollection)
         
         #
         # ------------ Track truth.
         #
         if not InDetFlags.doSGDeletion():
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__ForwardTrackCollection,
                                                            self.__ForwardTrackCollection+"DetailedTruth",
                                                            self.__ForwardTrackCollection+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__ForwardTrackCollection ]
               
         #
      else:
         self.__ForwardTrackCollection = SiTrackCollection
    def __init__(self, InputTrackCollections = [], TRT_Segments_EC = None):
        
        from InDetRecExample.InDetJobProperties import InDetFlags
        from AthenaCommon.DetFlags import DetFlags
        from InDetRecExample.InDetKeys import InDetKeys
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        
        if InDetFlags.doPRDFormation() and DetFlags.makeRIO.TRT_on():

            #    
            # --- calculation of the event phase from all 3 input collections
            #

            useNewEP = True
            if globalflags.DataSource == 'data':
                if InDetFlags.doCosmics():
                    globalOffset = 8
                else:
                    globalOffset = 0
            else:
                globalOffset = -3.125
            cutWindowCenter  = -8.5
            numberIterations = 5
            cutWindowSize    = 7
                                                    
            #    
            # --- load tool
            #
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetCosmicsEventPhaseTool
            InDetCosmicsEventPhaseTool = InDet__InDetCosmicsEventPhaseTool(name              = "InDetCosmicsEventPhaseTool",
                                                                           UseTRTCalibration = True,
                                                                           UseNewEP          = useNewEP,
                                                                           GlobalOffset      = globalOffset
                                                                           )
                                                                           
            ToolSvc += InDetCosmicsEventPhaseTool
            if(InDetFlags.doPrintConfigurables()):
                print InDetCosmicsEventPhaseTool
            
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetFixedWindowTrackTimeTool
            InDetFixedWindowTrackTimeTool = InDet__InDetFixedWindowTrackTimeTool(name              = "InDetFixedWindowTrackTimeTool",
                                                                                 UseTRTCalibration = True,
                                                                                 UseNewEP          = useNewEP,
                                                                                 GlobalOffset      = globalOffset,
                                                                                 WindowCenter      = cutWindowCenter,
                                                                                 WindowSize        = cutWindowSize
                                                                                 )
                                                                           
            ToolSvc += InDetFixedWindowTrackTimeTool
            if(InDetFlags.doPrintConfigurables()):
                print InDetFixedWindowTrackTimeTool
            
            
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetSlidingWindowTrackTimeTool
            InDetSlidingWindowTrackTimeTool = InDet__InDetSlidingWindowTrackTimeTool(name              = "InDetSlidingWindowTrackTimeTool",
                                                                                     UseTRTCalibration = True,
                                                                                     UseNewEP          = useNewEP,
                                                                                     GlobalOffset      = globalOffset,
                                                                                     NumberIterations  = numberIterations,
                                                                                     WindowSize        = cutWindowSize
                                                                                     )
                                                                           
            ToolSvc += InDetSlidingWindowTrackTimeTool
            if(InDetFlags.doPrintConfigurables()):
                print InDetSlidingWindowTrackTimeTool

            #
            # --- load algorithm
            #
            from InDetCosmicsEventPhase.InDetCosmicsEventPhaseConf import InDet__InDetCosmicsEventPhase
            InDetCosmicsEventPhase = InDet__InDetCosmicsEventPhase(name              = "InDetCosmicsEventPhase",
                                                                   InputTracksNames  = InputTrackCollections,
                                                                 #  InputSegmentsName = TRT_Segments_EC,
                                                                   TrackSummaryTool  = InDetTrackSummaryTool,
                                                                   #EventPhaseTool    = InDetCosmicsEventPhaseTool)
                                                                   #EventPhaseTool    = InDetFixedWindowTrackTimeTool)
                                                                   EventPhaseTool    = InDetSlidingWindowTrackTimeTool)
            if InDetFlags.doCosmics():
                InDetCosmicsEventPhase.EventPhaseTool=InDetCosmicsEventPhaseTool
            topSequence += InDetCosmicsEventPhase
            if (InDetFlags.doPrintConfigurables()):
                print InDetCosmicsEventPhase
Exemple #23
0
    def __init__(self,
                 NewTrackingCuts=None,
                 SiTrackCollection=None,
                 ExtendedTrackCollection=None,
                 ExtendedTracksMap=None,
                 TrackCollectionKeys=[],
                 TrackCollectionTruthKeys=[],
                 doPhase=True):

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

        #
        # ---------- TRT_TrackExtension
        #
        if InDetFlags.doTRTExtension() and InDetFlags.doTRTExtensionNew():

            #
            # Track extension to TRT algorithm
            #
            # set output extension map name
            OutputExtendedTracks = ExtendedTracksMap

            if doPhase:

                from TRT_TrackExtensionTool_xk.TRT_TrackExtensionTool_xkConf import InDet__TRT_TrackExtensionToolCosmics
                InDetTRTExtensionToolPhase = InDet__TRT_TrackExtensionToolCosmics(
                    name='InDetTRT_ExtensionToolPhase',
                    Propagator=InDetPropagator,
                    Extrapolator=InDetExtrapolator,
                    TRT_ClustersContainer=InDetKeys.
                    TRT_DriftCirclesUncalibrated(),
                    SearchNeighbour=False,  #needs debugging!!!
                    RoadWidth=20.)

                ToolSvc += InDetTRTExtensionToolPhase

                from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
                InDetTRTExtensionPhase = InDet__TRT_TrackExtensionAlg(
                    name='InDetTRT_ExtensionPhase' +
                    NewTrackingCuts.extension(),
                    InputTracksLocation=SiTrackCollection,
                    ExtendedTracksLocation=OutputExtendedTracks,
                    TrackExtensionTool=InDetTRTExtensionToolPhase)

                topSequence += InDetTRTExtensionPhase
                if (InDetFlags.doPrintConfigurables()):
                    print InDetTRTExtensionPhase

            #
            else:
                from TRT_TrackExtensionAlg.TRT_TrackExtensionAlgConf import InDet__TRT_TrackExtensionAlg
                InDetTRTExtension = InDet__TRT_TrackExtensionAlg(
                    name='InDetTRT_Extension' + NewTrackingCuts.extension(),
                    InputTracksLocation=SiTrackCollection,
                    ExtendedTracksLocation=OutputExtendedTracks,
                    TrackExtensionTool=InDetTRTExtensionTool)
                #InDetTRTExtension.OutputLevel = VERBOSE
                topSequence += InDetTRTExtension
                if (InDetFlags.doPrintConfigurables()):
                    print InDetTRTExtension

        #
        # ------------ Track Extension Processor
        #
        if InDetFlags.doExtensionProcessor() and InDetFlags.doTRTExtensionNew(
        ):

            if InDetFlags.trtExtensionType() is 'DAF':
                #
                # --- DAF Fitter setup
                #
                from TrkCompetingRIOsOnTrackTool.TrkCompetingRIOsOnTrackToolConf import Trk__CompetingRIOsOnTrackTool
                InDetCompetingRotCreator = Trk__CompetingRIOsOnTrackTool(
                    name='InDetCompetingRotCreator' +
                    NewTrackingCuts.extension(),
                    ToolForCompPixelClusters=None,  # default
                    ToolForCompSCT_Clusters=None,  # default
                    ToolForCompTRT_DriftCircles=InDetCompetingTRT_DC_Tool)
                ToolSvc += InDetCompetingRotCreator
                if (InDetFlags.doPrintConfigurables()):
                    print InDetCompetingRotCreator
                #
                from TrkDeterministicAnnealingFilter.TrkDeterministicAnnealingFilterConf import Trk__DeterministicAnnealingFilter
                InDetExtensionFitter = Trk__DeterministicAnnealingFilter(
                    name='InDetDAF' + NewTrackingCuts.extension(),
                    ToolForExtrapolation=InDetExtrapolator,
                    ToolForCompetingROTsCreation=InDetCompetingRotCreator,
                    ToolForUpdating=InDetUpdator,
                    AnnealingScheme=[200., 81., 9., 4., 1., 1., 1.],
                    DropOutlierCutValue=1.E-7,
                    OutlierCutValue=0.01)
                ToolSvc += InDetExtensionFitter
                if (InDetFlags.doPrintConfigurables()):
                    print InDetExtensionFitter
            else:
                InDetExtensionFitter = InDetTrackFitter
                if NewTrackingCuts.mode() == "LowPt":
                    InDetExtensionFitter = InDetTrackFitterLowPt

            #
            # --- load scoring for extension
            #
            if InDetFlags.doCosmics():
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
                InDetExtenScoringTool = InDet__InDetCosmicScoringTool(
                    name='InDetCosmicExtenScoringTool',
                    nWeightedClustersMin=0,
                    minTRTHits=NewTrackingCuts.minTRTonTrk(),
                    SummaryTool=InDetTrackSummaryTool)

            else:
                from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
                InDetExtenScoringTool = InDet__InDetAmbiScoringTool(
                    name='InDetExtenScoringTool' + NewTrackingCuts.extension(),
                    Extrapolator=InDetExtrapolator,
                    SummaryTool=InDetTrackSummaryTool,
                    DriftCircleCutTool=InDetTRTDriftCircleCut,
                    useAmbigFcn=True,  # this is NewTracking  
                    useTRT_AmbigFcn=False,
                    minPt=NewTrackingCuts.minPT(),
                    maxRPhiImp=NewTrackingCuts.maxPrimaryImpact(),
                    maxZImp=NewTrackingCuts.maxZImpact(),
                    maxEta=NewTrackingCuts.maxEta(),
                    minSiClusters=NewTrackingCuts.minClusters(),
                    minPixel=NewTrackingCuts.minPixel(),
                    maxSiHoles=NewTrackingCuts.maxHoles(),
                    maxPixelHoles=NewTrackingCuts.maxPixelHoles(),
                    maxSCTHoles=NewTrackingCuts.maxSCTHoles(),
                    maxDoubleHoles=NewTrackingCuts.maxDoubleHoles(),
                    usePixel=NewTrackingCuts.usePixel(),
                    useSCT=NewTrackingCuts.useSCT(),
                    minTRTonTrk=NewTrackingCuts.minTRTonTrk(),
                    minTRTPrecisionFraction=NewTrackingCuts.minTRTPrecFrac())

                if InDetFlags.trackFitterType() in [
                        'KalmanFitter', 'KalmanDNAFitter',
                        'ReferenceKalmanFitter'
                ]:
                    InDetExtenScoringTool.minTRTPrecisionFraction = 0.2

            #InDetExtenScoringTool.OutputLevel = VERBOSE
            ToolSvc += InDetExtenScoringTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetExtenScoringTool

            #
            # --- output track collection
            #
            self.__ForwardTrackCollection = ExtendedTrackCollection
            #
            # --- get configured track extension processor
            #
            if doPhase:

                from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor
                InDetExtensionProcessorPhase = InDet__InDetExtensionProcessor(
                    name="InDetExtensionProcessorPhase" +
                    NewTrackingCuts.extension(),
                    TrackName=SiTrackCollection,
                    Cosmics=True,
                    ExtensionMap=OutputExtendedTracks,
                    NewTrackName=self.__ForwardTrackCollection,
                    TrackFitter=InDetExtensionFitter,
                    ScoringTool=InDetExtenScoringTool,
                    suppressHoleSearch=False,  # does not work properly
                    tryBremFit=InDetFlags.doBremRecovery(),
                    caloSeededBrem=InDetFlags.doCaloSeededBrem(),
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=not (InDetFlags.refitROT() or
                                   (InDetFlags.trtExtensionType() is 'DAF')))
                #InDetExtensionProcessor.OutputLevel = VERBOSE
                if InDetFlags.materialInteractions():
                    InDetExtensionProcessorPhase.matEffects = InDetFlags.materialInteractionsType(
                    )
                else:
                    InDetExtensionProcessorPhase.matEffects = 0

                topSequence += InDetExtensionProcessorPhase
                if (InDetFlags.doPrintConfigurables()):
                    print InDetExtensionProcessorPhase

            else:

                from InDetExtensionProcessor.InDetExtensionProcessorConf import InDet__InDetExtensionProcessor
                InDetExtensionProcessor = InDet__InDetExtensionProcessor(
                    name="InDetExtensionProcessor" +
                    NewTrackingCuts.extension(),
                    TrackName=SiTrackCollection,
                    Cosmics=InDetFlags.doCosmics(),
                    ExtensionMap=OutputExtendedTracks,
                    NewTrackName=self.__ForwardTrackCollection,
                    TrackFitter=InDetExtensionFitter,
                    ScoringTool=InDetExtenScoringTool,
                    suppressHoleSearch=False,  # does not work properly
                    tryBremFit=InDetFlags.doBremRecovery(),
                    caloSeededBrem=InDetFlags.doCaloSeededBrem(),
                    pTminBrem=NewTrackingCuts.minPTBrem(),
                    RefitPrds=not (InDetFlags.refitROT() or
                                   (InDetFlags.trtExtensionType() is 'DAF')))
                #InDetExtensionProcessor.OutputLevel = VERBOSE
                if InDetFlags.materialInteractions():
                    InDetExtensionProcessor.matEffects = InDetFlags.materialInteractionsType(
                    )
                else:
                    InDetExtensionProcessor.matEffects = 0

                topSequence += InDetExtensionProcessor

                if (InDetFlags.doPrintConfigurables()):
                    print InDetExtensionProcessor

            # --- Delete Resolved Si tracks and extension map
            from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
            InDetSGDeletionAlg(container="TrackExtensionMap#",
                               key=OutputExtendedTracks)
            if not InDetFlags.doMonitoringAlignment():
                InDetSGDeletionAlg(key=SiTrackCollection)

            #
            # ------------ Track truth.
            #
            if not InDetFlags.doSGDeletion():
                if InDetFlags.doTruth():
                    #
                    # set up the truth info for this container
                    #
                    include("InDetRecExample/ConfiguredInDetTrackTruth.py")
                    InDetTracksTruth = ConfiguredInDetTrackTruth(
                        self.__ForwardTrackCollection,
                        self.__ForwardTrackCollection + "DetailedTruth",
                        self.__ForwardTrackCollection + "TruthCollection")
                    #
                    # add final output for statistics
                    #
                    TrackCollectionKeys += [InDetTracksTruth.Tracks()]
                    TrackCollectionTruthKeys += [
                        InDetTracksTruth.TracksTruth()
                    ]
                else:
                    TrackCollectionKeys += [self.__ForwardTrackCollection]

            #
        else:
            self.__ForwardTrackCollection = SiTrackCollection
Exemple #24
0
    def __init__(self, useTimeInfo=True, usePhase=False):

        from InDetRecExample.InDetJobProperties import InDetFlags
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.GlobalFlags import globalflags
        from AthenaCommon.BeamFlags import jobproperties
        #
        # get ToolSvc and topSequence
        #
        from AthenaCommon.AppMgr import ToolSvc
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        if InDetFlags.doPRDFormation() and DetFlags.makeRIO.TRT_on(
        ) and InDetFlags.doTRT_PRDFormation():

            #
            # --- setup naming of tools and algs
            #
            if useTimeInfo:
                prefix = "InDetTRT_"
                collection = InDetKeys.TRT_DriftCircles()
                if InDetFlags.doSplitReco():
                    collectionPU = InDetKeys.TRT_PU_DriftCircles()
            else:
                prefix = "InDetTRT_noTime_"
                collection = InDetKeys.TRT_DriftCirclesUncalibrated()
                if InDetFlags.doSplitReco():
                    collectionPU = InDetKeys.TRT_PU_DriftCirclesUncalibrated()
            #
            # --- TRT_DriftFunctionTool
            #
            from TRT_DriftFunctionTool.TRT_DriftFunctionToolConf import TRT_DriftFunctionTool
            InDetTRT_DriftFunctionTool = TRT_DriftFunctionTool(
                name=prefix + "DriftFunctionTool",
                TRTCalDbTool=InDetTRTCalDbSvc)
            # --- overwrite for uncalibrated DC production
            if (not useTimeInfo) or InDetFlags.noTRTTiming():
                InDetTRT_DriftFunctionTool.DummyMode = True
                InDetTRT_DriftFunctionTool.UniversalError = 1.15
            # --- overwrite for calibration of MC
            if usePhase and jobproperties.Beam.beamType(
            ) == 'cosmics' and globalflags.DataSource == "geant4":
                InDetTRT_DriftFunctionTool.AllowDigiVersionOverride = True
                InDetTRT_DriftFunctionTool.ForcedDigiVersion = 9

            ToolSvc += InDetTRT_DriftFunctionTool
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_DriftFunctionTool
            #
            # --- TRT_DriftCircleTool
            #
            if usePhase:
                from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleToolCosmics as InDet__TRT_DriftCircleTool
            else:
                from TRT_DriftCircleTool.TRT_DriftCircleToolConf import InDet__TRT_DriftCircleTool

            #
            # set gating values for MC/DATA
            MinTrailingEdge = 11.0 * ns
            MaxDriftTime = 60.0 * ns
            LowGate = 14.0625 * ns  # 4.5*3.125 ns
            HighGate = 42.1875 * ns  # LowGate + 9*3.125 ns
            if InDetFlags.doCosmics():
                LowGate = 19.0 * ns
                HighGate = 44.0 * ns
            if globalflags.DataSource == 'data':
                MinTrailingEdge = 11.0 * ns
                MaxDriftTime = 60.0 * ns
                LowGate = 14.0625 * ns  # 4.5*3.125 ns
                HighGate = 42.1875 * ns  # LowGate + 9*3.125 ns
                if InDetFlags.doCosmics():
                    LowGate = 19.0 * ns
                    HighGate = 44.0 * ns

            InDetTRT_DriftCircleTool = InDet__TRT_DriftCircleTool(
                name=prefix + "DriftCircleTool",
                TRTDriftFunctionTool=InDetTRT_DriftFunctionTool,
                TrtDescrManageLocation=InDetKeys.TRT_Manager(),
                ConditionsSummaryTool=InDetTRTStrawStatusSummarySvc,
                #used to be InDetTRTConditionsSummaryService,
                UseConditionsStatus=True,
                UseConditionsHTStatus=True,
                SimpleOutOfTimePileupSupression=InDetFlags.doCosmics(),
                RejectIfFirstBit=False,  # fixes 50 nsec issue 
                MinTrailingEdge=MinTrailingEdge,
                MaxDriftTime=MaxDriftTime,
                ValidityGateSuppression=not InDetFlags.doCosmics(),
                LowGate=LowGate,
                HighGate=HighGate,
                MaskFirstHTBit=False,
                MaskMiddleHTBit=False,
                MaskLastHTBit=False,
                SimpleOutOfTimePileupSupressionArgon=InDetFlags.doCosmics(),
                RejectIfFirstBitArgon=False,  # fixes 50 nsec issue 
                MinTrailingEdgeArgon=MinTrailingEdge,
                MaxDriftTimeArgon=MaxDriftTime,
                ValidityGateSuppressionArgon=not InDetFlags.doCosmics(),
                LowGateArgon=LowGate,
                HighGateArgon=HighGate,
                MaskFirstHTBitArgon=False,
                MaskMiddleHTBitArgon=False,
                MaskLastHTBitArgon=False,
                useDriftTimeHTCorrection=True,
                useDriftTimeToTCorrection=True)  # reenable ToT

            from AthenaCommon.BeamFlags import jobproperties
            if InDetFlags.InDet25nsec() and jobproperties.Beam.beamType(
            ) == "collisions":
                InDetTRT_DriftCircleTool.ValidityGateSuppression = True
                InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression = False
            if jobproperties.Beam.beamType() == "cosmics":
                InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression = False


# --- overwrite for phase usage
            if usePhase:
                InDetTRT_DriftCircleTool.ComTimeName = "TRT_Phase"

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

            #
            # --- TRT_RIO_Maker Algorithm
            #
            from InDetPrepRawDataFormation.InDetPrepRawDataFormationConf import InDet__TRT_RIO_Maker
            InDetTRT_RIO_Maker = InDet__TRT_RIO_Maker(
                name=prefix + "RIO_Maker",
                TRT_DriftCircleTool=InDetTRT_DriftCircleTool,
                TrtDescrManageLocation=InDetKeys.TRT_Manager(),
                TRTRDOLocation=InDetKeys.TRT_RDOs(),
                TRTRIOLocation=collection)
            topSequence += InDetTRT_RIO_Maker
            if (InDetFlags.doPrintConfigurables()):
                print InDetTRT_RIO_Maker
            if InDetFlags.doSplitReco():
                InDetTRT_RIO_MakerPU = InDet__TRT_RIO_Maker(
                    name=prefix + "RIO_MakerPU",
                    TRT_DriftCircleTool=InDetTRT_DriftCircleTool,
                    TrtDescrManageLocation=InDetKeys.TRT_Manager(),
                    TRTRDOLocation=InDetKeys.TRT_PU_RDOs(),
                    TRTRIOLocation=collectionPU)
                topSequence += InDetTRT_RIO_MakerPU
                if (InDetFlags.doPrintConfigurables()):
                    print InDetTRT_RIO_MakerPU

            #
            #    Include alg to save the local occupancy inside xAOD::EventInfo
            #
            if InDetFlags.doTRTGlobalOccupancy():
                from TRT_ElectronPidTools.TRT_ElectronPidToolsConf import InDet__TRT_LocalOccupancy
                InDetTRT_LocalOccupancy = InDet__TRT_LocalOccupancy(
                    name="InDet_TRT_LocalOccupancy", isTrigger=False)

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

                from TRT_CalibAlgs.TRT_CalibAlgsConf import TRTOccupancyInclude
                TRTOccupancyInclude = TRTOccupancyInclude(
                    name=prefix + "TRTOccupancyInclude",
                    TRT_LocalOccupancyTool=InDetTRT_LocalOccupancy)

                topSequence += TRTOccupancyInclude
                if (InDetFlags.doPrintConfigurables()):
                    print TRTOccupancyInclude

            #
            # --- we need to do truth association if requested (not for uncalibrated hits in cosmics)
            #
            if InDetFlags.doTruth() and useTimeInfo:
                from InDetTruthAlgs.InDetTruthAlgsConf import InDet__PRD_MultiTruthMaker
                InDetPRD_MultiTruthMakerTRT = InDet__PRD_MultiTruthMaker(
                    name=prefix + "PRD_MultiTruthMaker",
                    PixelClusterContainerName="",
                    SCTClusterContainerName="",
                    TRTDriftCircleContainerName=InDetKeys.TRT_DriftCircles(),
                    SimDataMapNamePixel="",
                    SimDataMapNameSCT="",
                    SimDataMapNameTRT=InDetKeys.TRT_SDOs(),
                    TruthNamePixel="",
                    TruthNameSCT="",
                    TruthNameTRT=InDetKeys.TRT_DriftCirclesTruth())
                topSequence += InDetPRD_MultiTruthMakerTRT
                if (InDetFlags.doPrintConfigurables()):
                    print InDetPRD_MultiTruthMakerTRT

                if InDetFlags.doSplitReco():
                    InDetPRD_MultiTruthMakerTRTPU = InDet__PRD_MultiTruthMaker(
                        name=prefix + "PRD_MultiTruthMakerPU",
                        PixelClusterContainerName="",
                        SCTClusterContainerName="",
                        TRTDriftCircleContainerName=InDetKeys.
                        TRT_PU_DriftCircles(),
                        SimDataMapNamePixel="",
                        SimDataMapNameSCT="",
                        SimDataMapNameTRT=InDetKeys.TRT_PU_SDOs(),
                        TruthNamePixel="",
                        TruthNameSCT="",
                        TruthNameTRT=InDetKeys.TRT_PU_DriftCirclesTruth())
                    topSequence += InDetPRD_MultiTruthMakerTRTPU
                    if (InDetFlags.doPrintConfigurables()):
                        print InDetPRD_MultiTruthMakerTRTPU
Exemple #25
0
    name="InDetSiTrackMaker" + NewTrackingCuts.extension(),
    useSCT=NewTrackingCuts.useSCT(),
    usePixel=NewTrackingCuts.usePixel(),
    RoadTool=InDetSiDetElementsRoadMaker,
    CombinatorialTrackFinder=InDetSiComTrackFinder,
    pTmin=NewTrackingCuts.minPT(),
    pTminBrem=NewTrackingCuts.minPTBrem(),
    pTminSSS=InDetFlags.pT_SSScut(),
    nClustersMin=NewTrackingCuts.minClusters(),
    nHolesMax=NewTrackingCuts.nHolesMax(),
    nHolesGapMax=NewTrackingCuts.nHolesGapMax(),
    SeedsFilterLevel=NewTrackingCuts.seedFilterLevel(),
    Xi2max=NewTrackingCuts.Xi2max(),
    Xi2maxNoAdd=NewTrackingCuts.Xi2maxNoAdd(),
    nWeightedClustersMin=NewTrackingCuts.nWeightedClustersMin(),
    CosmicTrack=InDetFlags.doCosmics(),
    Xi2maxMultiTracks=NewTrackingCuts.Xi2max(),  # was 3.
    useSSSseedsFilter=InDetFlags.doSSSfilter(),
    doMultiTracksProd=True,
    useBremModel=InDetFlags.doBremRecovery()
    and useBremMode,  # only for NewTracking the brem is debugged !!!
    doCaloSeededBrem=InDetFlags.doCaloSeededBrem(),
    doHadCaloSeedSSS=InDetFlags.doHadCaloSeededSSS(),
    phiWidth=NewTrackingCuts.phiWidthBrem(),
    etaWidth=NewTrackingCuts.etaWidthBrem(),
    InputClusterContainerName=InDetKeys.CaloClusterROIContainer(
    ),  # "InDetCaloClusterROIs"
    InputHadClusterContainerName=InDetKeys.HadCaloClusterROIContainer(
    ),  # "InDetCaloClusterROIs"
    UseAssociationTool=usePrdAssociationTool)
InDetSiTrackMaker.TrackPatternRecoInfo = "SiSPSeededFinder"
   def __init__(self, InputCollections = None, ResolvedTrackCollectionKey = None, SiSPSeededTrackCollectionKey = None , NewTrackingCuts = None, TrackCollectionKeys=[] , TrackCollectionTruthKeys=[]):
      
      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()

      #
      # --- decide if use the association tool
      #
      if (len(InputCollections) > 0) and (NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or NewTrackingCuts.mode() == "LargeD0" or NewTrackingCuts.mode() == "BeamGas" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "ForwardSLHCTracks"  or NewTrackingCuts.mode() == "PixelPrdAssociation" or NewTrackingCuts.mode() == "VeryForwardSLHCTracks"):
         usePrdAssociationTool = True
      else:
         usePrdAssociationTool = False

      #
      # --- get list of already associated hits (always do this, even if no other tracking ran before)
      #
      if usePrdAssociationTool:
         from InDetTrackPRD_Association.InDetTrackPRD_AssociationConf import InDet__InDetTrackPRD_Association
         InDetPRD_Association = InDet__InDetTrackPRD_Association(name            = 'InDetPRD_Association'+NewTrackingCuts.extension(),
                                                                 AssociationTool = InDetPrdAssociationTool,
                                                                 TracksName      = list(InputCollections)) 
         topSequence += InDetPRD_Association
         if (InDetFlags.doPrintConfigurables()):
            print InDetPRD_Association

      # ------------------------------------------------------------
      #
      # ----------- SiSPSeededTrackFinder
      #
      # ------------------------------------------------------------

      if InDetFlags.doSiSPSeededTrackFinder():
         #
         # --- Space points seeds maker, use different ones for cosmics and collisions
         #
         if NewTrackingCuts.mode() == "DBM":
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker
         elif InDetFlags.doCosmics():
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_Cosmic as SiSpacePointsSeedMaker
         elif InDetFlags.doHeavyIon():
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_HeavyIon as SiSpacePointsSeedMaker
         elif NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()) :
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_LowMomentum as SiSpacePointsSeedMaker
         elif NewTrackingCuts.mode() == "BeamGas":
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_BeamGas as SiSpacePointsSeedMaker
         else:
            from SiSpacePointsSeedTool_xk.SiSpacePointsSeedTool_xkConf import InDet__SiSpacePointsSeedMaker_ATLxk as SiSpacePointsSeedMaker

         InDetSiSpacePointsSeedMaker = SiSpacePointsSeedMaker (name                   = "InDetSpSeedsMaker"+NewTrackingCuts.extension(),
                                                               pTmin                  = NewTrackingCuts.minPT(),
                                                               maxdImpact             = NewTrackingCuts.maxPrimaryImpact(),
                                                               maxZ                   = NewTrackingCuts.maxZImpact(),
                                                               minZ                   = -NewTrackingCuts.maxZImpact(),
                                                               usePixel               = NewTrackingCuts.usePixel(),
                                                               SpacePointsPixelName   = InDetKeys.PixelSpacePoints(),
                                                               # useSCT                 = NewTrackingCuts.useSCT(),
                                                               useSCT                 = (NewTrackingCuts.useSCT() and NewTrackingCuts.useSCTSeeding()),
                                                               SpacePointsSCTName     = InDetKeys.SCT_SpacePoints(),
                                                               # useOverlapSpCollection = NewTrackingCuts.useSCT(),
                                                               useOverlapSpCollection = (NewTrackingCuts.useSCT() and NewTrackingCuts.useSCTSeeding()),
                                                               SpacePointsOverlapName = InDetKeys.OverlapSpacePoints(),
                                                               radMax                 = NewTrackingCuts.radMax(),
                                                               RapidityCut            = NewTrackingCuts.maxEta())
            
         if NewTrackingCuts.mode() == "Offline" or InDetFlags.doHeavyIon() or  NewTrackingCuts.mode() == "ForwardTracks":
            InDetSiSpacePointsSeedMaker.maxdImpactPPS = NewTrackingCuts.maxdImpactPPSSeeds()
            InDetSiSpacePointsSeedMaker.maxdImpactSSS = NewTrackingCuts.maxdImpactSSSSeeds()
         if usePrdAssociationTool:
            # not all classes have that property !!!
            InDetSiSpacePointsSeedMaker.UseAssociationTool = True
            InDetSiSpacePointsSeedMaker.AssociationTool    = InDetPrdAssociationTool
         if not InDetFlags.doCosmics():
            InDetSiSpacePointsSeedMaker.maxRadius1         = 0.75*NewTrackingCuts.radMax()
            InDetSiSpacePointsSeedMaker.maxRadius2         = NewTrackingCuts.radMax()
            InDetSiSpacePointsSeedMaker.maxRadius3         = NewTrackingCuts.radMax()
         if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()):
            InDetSiSpacePointsSeedMaker.pTmax              = NewTrackingCuts.maxPT()
            InDetSiSpacePointsSeedMaker.mindRadius         = 4.0
         if NewTrackingCuts.mode() == "SLHC":
            InDetSiSpacePointsSeedMaker.minRadius1         = 0
            InDetSiSpacePointsSeedMaker.minRadius2         = 0
            InDetSiSpacePointsSeedMaker.minRadius3         = 0
            InDetSiSpacePointsSeedMaker.maxRadius1         =1000.*Units.mm
            InDetSiSpacePointsSeedMaker.maxRadius2         =1000.*Units.mm
            InDetSiSpacePointsSeedMaker.maxRadius3         =1000.*Units.mm
         if NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "VeryForwardSLHCTracks":
            InDetSiSpacePointsSeedMaker.checkEta           = True
            InDetSiSpacePointsSeedMaker.etaMin             = NewTrackingCuts.minEta()
            InDetSiSpacePointsSeedMaker.etaMax             = NewTrackingCuts.maxEta()
            InDetSiSpacePointsSeedMaker.RapidityCut        = NewTrackingCuts.maxEta()
         if NewTrackingCuts.mode() == "DBM":
            InDetSiSpacePointsSeedMaker.etaMin             = NewTrackingCuts.minEta()
            InDetSiSpacePointsSeedMaker.etaMax             = NewTrackingCuts.maxEta()
            InDetSiSpacePointsSeedMaker.useDBM = True

                    
         #InDetSiSpacePointsSeedMaker.OutputLevel = VERBOSE
         ToolSvc += InDetSiSpacePointsSeedMaker
         if (InDetFlags.doPrintConfigurables()):
            print InDetSiSpacePointsSeedMaker
            
         #
         # --- Z-coordinates primary vertices finder (only for collisions)
         #
         if InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM":
            from SiZvertexTool_xk.SiZvertexTool_xkConf import InDet__SiZvertexMaker_xk
            InDetZvertexMaker = InDet__SiZvertexMaker_xk(name          = 'InDetZvertexMaker'+NewTrackingCuts.extension(),
                                                         Zmax          = NewTrackingCuts.maxZImpact(),
                                                         Zmin          = -NewTrackingCuts.maxZImpact(),
                                                         minRatio      = 0.17) # not default
            InDetZvertexMaker.SeedMakerTool = InDetSiSpacePointsSeedMaker

            if InDetFlags.doHeavyIon():
               InDetZvertexMaker.HistSize = 2000
               ###InDetZvertexMaker.minContent = 200 
               InDetZvertexMaker.minContent = 30
               
            ToolSvc += InDetZvertexMaker
            if (InDetFlags.doPrintConfigurables()):
               print InDetZvertexMaker

         else:
            InDetZvertexMaker = None

         #
         # --- SCT and Pixel detector elements road builder
         #
         from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
         InDetSiDetElementsRoadMaker = InDet__SiDetElementsRoadMaker_xk(name               = 'InDetSiRoadMaker'+NewTrackingCuts.extension(),
                                                                        PropagatorTool     = InDetPatternPropagator,
                                                                        usePixel           = NewTrackingCuts.usePixel(),
                                                                        PixManagerLocation = InDetKeys.PixelManager(),
                                                                        useSCT             = NewTrackingCuts.useSCT(), 
                                                                        SCTManagerLocation = InDetKeys.SCT_Manager(),         
                                                                        RoadWidth          = NewTrackingCuts.RoadWidth())
         #InDetSiDetElementsRoadMaker.OutputLevel = VERBOSE
         ToolSvc += InDetSiDetElementsRoadMaker
         if (InDetFlags.doPrintConfigurables()):
            print      InDetSiDetElementsRoadMaker

         #
         # --- Local track finding using sdCaloSeededSSSpace point seed
         #

         useBremMode = NewTrackingCuts.mode() == "Offline" or NewTrackingCuts.mode() == "SLHC" or NewTrackingCuts.mode() == "DBM"
         from SiTrackMakerTool_xk.SiTrackMakerTool_xkConf import InDet__SiTrackMaker_xk as SiTrackMaker
         InDetSiTrackMaker = SiTrackMaker(name                      = 'InDetSiTrackMaker'+NewTrackingCuts.extension(),
                                          useSCT                    = NewTrackingCuts.useSCT(),
                                          usePixel                  = NewTrackingCuts.usePixel(),
                                          RoadTool                  = InDetSiDetElementsRoadMaker,
                                          CombinatorialTrackFinder  = InDetSiComTrackFinder,
                                          pTmin                     = NewTrackingCuts.minPT(),
                                          pTminBrem                 = NewTrackingCuts.minPTBrem(),
                                          pTminSSS                  = InDetFlags.pT_SSScut(),
                                          nClustersMin              = NewTrackingCuts.minClusters(),
                                          nHolesMax                 = NewTrackingCuts.nHolesMax(),
                                          nHolesGapMax              = NewTrackingCuts.nHolesGapMax(),
                                          SeedsFilterLevel          = NewTrackingCuts.seedFilterLevel(),
                                          Xi2max                    = NewTrackingCuts.Xi2max(),
                                          Xi2maxNoAdd               = NewTrackingCuts.Xi2maxNoAdd(),
                                          nWeightedClustersMin      = NewTrackingCuts.nWeightedClustersMin(),
                                          CosmicTrack               = InDetFlags.doCosmics(),
                                          Xi2maxMultiTracks         = NewTrackingCuts.Xi2max(), # was 3.
                                          useSSSseedsFilter         = InDetFlags.doSSSfilter(), 
                                          doMultiTracksProd         = True,
                                          useBremModel              = InDetFlags.doBremRecovery() and useBremMode, # only for NewTracking the brem is debugged !!!
                                          doCaloSeededBrem          = InDetFlags.doCaloSeededBrem(),
                                          doHadCaloSeedSSS          = InDetFlags.doHadCaloSeededSSS(),
                                          phiWidth                  = NewTrackingCuts.phiWidthBrem(),
                                          etaWidth                  = NewTrackingCuts.etaWidthBrem(),
                                          InputClusterContainerName = InDetKeys.CaloClusterROIContainer(), # "InDetCaloClusterROIs" 
                                          InputHadClusterContainerName = InDetKeys.HadCaloClusterROIContainer(), # "InDetCaloClusterROIs" 
                                          UseAssociationTool        = usePrdAssociationTool)
					  
         if NewTrackingCuts.mode() == "DBM":
            InDetSiTrackMaker.MagneticFieldMode = "NoField"
            InDetSiTrackMaker.useBremModel = False
            InDetSiTrackMaker.doMultiTracksProd = False
            InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'			
            InDetSiTrackMaker.pTminSSS = -1
            InDetSiTrackMaker.CosmicTrack = False
            InDetSiTrackMaker.useSSSseedsFilter = False
            InDetSiTrackMaker.doCaloSeededBrem = False
            InDetSiTrackMaker.doHadCaloSeedSSS = False
            InDetSiTrackMaker.UseAssociationTool = False
					
         elif InDetFlags.doCosmics():
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_Cosmic'
	   
         elif InDetFlags.doHeavyIon():
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_HeavyIon'
         
         elif NewTrackingCuts.mode() == "LowPt":
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LowMomentum'

         elif NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()):
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryLowMomentum'           

         elif NewTrackingCuts.mode() == "BeamGas":
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_BeamGas'
 
         elif NewTrackingCuts.mode() == "ForwardTracks":
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardTracks'

         elif NewTrackingCuts.mode() == "ForwardSLHCTracks":
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_ForwardSLHCTracks'

         elif NewTrackingCuts.mode() == "VeryForwardSLHCTracks": 
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_VeryForwardSLHCTracks' 

         elif NewTrackingCuts.mode() == "LargeD0":
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSpacePointsSeedMaker_LargeD0'
         
         else:
           InDetSiTrackMaker.TrackPatternRecoInfo = 'SiSPSeededFinder'
					  
         #InDetSiTrackMaker.OutputLevel = VERBOSE				  
         ToolSvc += InDetSiTrackMaker
         if (InDetFlags.doPrintConfigurables()):
            print InDetSiTrackMaker
         #
         # set output track collection name
         #
         self.__SiTrackCollection = SiSPSeededTrackCollectionKey
         #
         # --- Setup Track finder using space points seeds
         #

         from SiSPSeededTrackFinder.SiSPSeededTrackFinderConf import InDet__SiSPSeededTrackFinder

         if NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks":

          InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(name           = 'InDetSiSpTrackFinder'+NewTrackingCuts.extension(),
                                                                    TrackTool      = InDetSiTrackMaker,
                                                                    TracksLocation = self.__SiTrackCollection,
                                                                    SeedsTool      = InDetSiSpacePointsSeedMaker,
                                                                    useZvertexTool = InDetFlags.useZvertexTool(),
                                                                    ZvertexTool    = InDetZvertexMaker,
                                                                    useNewStrategy = False,
                                                                    useMBTSTimeDiff = InDetFlags.useMBTSTimeDiff(),
                                                                    useZBoundFinding = False)
         
         else:
          InDetSiSPSeededTrackFinder = InDet__SiSPSeededTrackFinder(name           = 'InDetSiSpTrackFinder'+NewTrackingCuts.extension(),
                                                                    TrackTool      = InDetSiTrackMaker,
                                                                    TracksLocation = self.__SiTrackCollection,
                                                                    SeedsTool      = InDetSiSpacePointsSeedMaker,
                                                                    useZvertexTool = InDetFlags.useZvertexTool() and NewTrackingCuts.mode() != "DBM",
                                                                    ZvertexTool    = InDetZvertexMaker,
                                                                    useNewStrategy = InDetFlags.useNewSiSPSeededTF() and NewTrackingCuts.mode() != "DBM",
                                                                    useMBTSTimeDiff = InDetFlags.useMBTSTimeDiff(),
                                                                    useZBoundFinding = NewTrackingCuts.doZBoundary() and NewTrackingCuts.mode() != "DBM")   

         #InDetSiSPSeededTrackFinder.OutputLevel =VERBOSE 
         topSequence += InDetSiSPSeededTrackFinder
         if (InDetFlags.doPrintConfigurables()):
            print InDetSiSPSeededTrackFinder

         if not InDetFlags.doSGDeletion():
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__SiTrackCollection,
                                                            self.__SiTrackCollection+"DetailedTruth",
                                                            self.__SiTrackCollection+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__SiTrackCollection ]
               
      # ------------------------------------------------------------
      #
      # ---------- Ambiguity solving
      #
      # ------------------------------------------------------------

      if InDetFlags.doAmbiSolving():
         #
         # --- load InnerDetector TrackSelectionTool
         #
         
         prob1 = InDetFlags.pixelClusterSplitProb1()
         prob2 = InDetFlags.pixelClusterSplitProb2()
         nhitsToAllowSplitting = 9

         if geoFlags.Run() == 1:
            prob1 = InDetFlags.pixelClusterSplitProb1_run1()
            prob2 = InDetFlags.pixelClusterSplitProb2_run1() 
            nhitsToAllowSplitting = 8

         if InDetFlags.doTIDE_Ambi() and not (NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "PixelPrdAssociation" or NewTrackingCuts.mode() == "DBM"):
           from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetDenseEnvAmbiTrackSelectionTool as AmbiTrackSelectionTool
         else:
           from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetAmbiTrackSelectionTool as AmbiTrackSelectionTool
         InDetAmbiTrackSelectionTool = AmbiTrackSelectionTool(name                = 'InDetAmbiTrackSelectionTool'+NewTrackingCuts.extension(),
                                                              AssociationTool     = InDetPrdAssociationTool,
                                                              DriftCircleCutTool  = InDetTRTDriftCircleCut,
                                                              minHits             = NewTrackingCuts.minClusters(),
                                                              minNotShared        = NewTrackingCuts.minSiNotShared(),
                                                              maxShared           = NewTrackingCuts.maxShared(),
                                                              minTRTHits          = 0, # used for Si only tracking !!!
                                                              sharedProbCut       = 0.10,
                                                              UseParameterization = False,
                                                              Cosmics             = InDetFlags.doCosmics(),
                                                              doPixelSplitting    = InDetFlags.doPixelClusterSplitting() and NewTrackingCuts.mode != "DBM")

         if InDetFlags.doTIDE_Ambi() and not (NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "PixelPrdAssociation" or NewTrackingCuts.mode() == "DBM"):
           InDetAmbiTrackSelectionTool.sharedProbCut             = prob1
           InDetAmbiTrackSelectionTool.sharedProbCut2            = prob2
           InDetAmbiTrackSelectionTool.minSiHitsToAllowSplitting = nhitsToAllowSplitting
           InDetAmbiTrackSelectionTool.minUniqueSCTHits          = 4
           InDetAmbiTrackSelectionTool.minTrackChi2ForSharedHits = 3
           InDetAmbiTrackSelectionTool.InputHadClusterContainerName = InDetKeys.HadCaloClusterROIContainer()
           InDetAmbiTrackSelectionTool.doHadCaloSeed             = False   #Only split in cluster in region of interest
           InDetAmbiTrackSelectionTool.minPtSplit                = InDetFlags.pixelClusterSplitMinPt()       #Only allow split clusters on track withe pt greater than this MeV
           InDetAmbiTrackSelectionTool.phiWidth                  = 0.2     #Split cluster ROI size
           InDetAmbiTrackSelectionTool.etaWidth                  = 0.2     #Split cluster ROI size
         if NewTrackingCuts.mode() == "DBM":
           InDetAmbiTrackSelectionTool.Cosmics = False
           InDetAmbiTrackSelectionTool.UseParameterization   = False
           InDetAmbiTrackSelectionTool.doPixelSplitting      = False
           InDetAmbiTrackSelectionTool.maxShared             = 1000
           InDetAmbiTrackSelectionTool.maxTracksPerSharedPRD = 2
           InDetAmbiTrackSelectionTool.minHits               = 0
           InDetAmbiTrackSelectionTool.minNotShared          = 0
           InDetAmbiTrackSelectionTool.minScoreShareTracks   = 0.0
           InDetAmbiTrackSelectionTool.minTRTHits            = 0
           InDetAmbiTrackSelectionTool.sharedProbCut         = 0.1
        
         # if NewTrackingCuts.mode() == "ForwardTracks":
         #    InDetAmbiTrackSelectionTool.OutputLevel = VERBOSE

         ToolSvc += InDetAmbiTrackSelectionTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetAmbiTrackSelectionTool
         #
         # --- set up different Scoring Tool for collisions and cosmics
         #
         if InDetFlags.doCosmics() and NewTrackingCuts.mode() != "DBM":
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
            InDetAmbiScoringTool = InDet__InDetCosmicScoringTool(name                 = 'InDetCosmicsScoringTool'+NewTrackingCuts.extension(),
                                                                 nWeightedClustersMin = NewTrackingCuts.nWeightedClustersMin(),
                                                                 minTRTHits           = 0,
                                                                 SummaryTool          = InDetTrackSummaryTool)
         else:
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
            InDetAmbiScoringTool = InDet__InDetAmbiScoringTool(name                    = 'InDetAmbiScoringTool'+NewTrackingCuts.extension(),
                                                               Extrapolator            = InDetExtrapolator,
                                                               SummaryTool             = InDetTrackSummaryTool,
                                                               DriftCircleCutTool      = InDetTRTDriftCircleCut,
                                                               useAmbigFcn             = True,  # this is NewTracking
                                                               useTRT_AmbigFcn         = False,
                                                               minPt                   = NewTrackingCuts.minPT(),
                                                               maxRPhiImp              = NewTrackingCuts.maxPrimaryImpact(),
                                                               maxZImp                 = NewTrackingCuts.maxZImpact(),
                                                               maxEta                  = NewTrackingCuts.maxEta(),
                                                               minSiClusters           = NewTrackingCuts.minClusters(),
                                                               minPixel                = NewTrackingCuts.minPixel(),                                     
                                                               maxSiHoles              = NewTrackingCuts.maxHoles(),
                                                               maxPixelHoles           = NewTrackingCuts.maxPixelHoles(),
                                                               maxSCTHoles             = NewTrackingCuts.maxSCTHoles(),
                                                               maxDoubleHoles          = NewTrackingCuts.maxDoubleHoles(),
                                                               usePixel                = NewTrackingCuts.usePixel(),
                                                               useSCT                  = NewTrackingCuts.useSCT(),
                                                               minTRTonTrk             = 0,
                                                               minTRTPrecisionFraction = 0);
            # allow for some overlap for low-pt tracking
            #if InDetFlags.doLowPt() and not NewTrackingCuts.mode() == "LowPt":
            #   InDetAmbiScoringTool.minPt = NewTrackingCuts.minPT()-100.*Units.MeV

         # if NewTrackingCuts.mode() == "ForwardTracks":
         #   InDetAmbiScoringTool.OutputLevel = VERBOSE   

         ToolSvc += InDetAmbiScoringTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetAmbiScoringTool
         #
         # --- load Ambiguity Processor
         #
         useBremMode = NewTrackingCuts.mode() == "Offline" or NewTrackingCuts.mode() == "SLHC"

         if InDetFlags.doTIDE_Ambi() and not (NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "PixelPrdAssociation" or NewTrackingCuts.mode() == "DBM"):
           from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__DenseEnvironmentsAmbiguityProcessorTool as ProcessorTool
         else:
           from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__SimpleAmbiguityProcessorTool as ProcessorTool
         InDetAmbiguityProcessor = ProcessorTool(name               = 'InDetAmbiguityProcessor'+NewTrackingCuts.extension(),
                                                 Fitter             = InDetTrackFitter,
                                                 ScoringTool        = InDetAmbiScoringTool,
                                                 SelectionTool      = InDetAmbiTrackSelectionTool,
                                                 SuppressHoleSearch = False,
                                                 tryBremFit         = InDetFlags.doBremRecovery() and useBremMode and NewTrackingCuts.mode() != "DBM",
                                                 caloSeededBrem     = InDetFlags.doCaloSeededBrem() and NewTrackingCuts.mode() != "DBM",
                                                 pTminBrem          = NewTrackingCuts.minPTBrem(),
                                                 RefitPrds          = not InDetFlags.refitROT())
         if InDetFlags.doTIDE_Ambi() and not (NewTrackingCuts.mode() == "ForwardSLHCTracks" or NewTrackingCuts.mode() == "ForwardTracks" or NewTrackingCuts.mode() == "PixelPrdAssociation" or NewTrackingCuts.mode() == "DBM"):
           InDetAmbiguityProcessor.sharedProbCut             = prob1
           InDetAmbiguityProcessor.sharedProbCut2            = prob2
           InDetAmbiguityProcessor.SplitClusterAmbiguityMap  = InDetKeys.SplitClusterAmbiguityMap()

         if NewTrackingCuts.mode() == "Pixel" or NewTrackingCuts.mode() == "DBM":
            InDetAmbiguityProcessor.SuppressHoleSearch = True
         if NewTrackingCuts.mode() == "LowPt" or NewTrackingCuts.mode() == "VeryLowPt" or (NewTrackingCuts.mode() == "Pixel" and InDetFlags.doMinBias()):
            InDetAmbiguityProcessor.Fitter = InDetTrackFitterLowPt
             
         if InDetFlags.materialInteractions():
            InDetAmbiguityProcessor.MatEffects = InDetFlags.materialInteractionsType()
         else:
            InDetAmbiguityProcessor.MatEffects = 0

         # if NewTrackingCuts.mode() == "ForwardTracks":
         #    InDetAmbiguityProcessor.OutputLevel = VERBOSE

         ToolSvc += InDetAmbiguityProcessor
         if (InDetFlags.doPrintConfigurables()):
            print InDetAmbiguityProcessor
         #
         # --- set input and output collection
         #
         InputTrackCollection     = self.__SiTrackCollection
         self.__SiTrackCollection = ResolvedTrackCollectionKey
         #
         # --- configure Ambiguity solver
         #
         from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguitySolver
         InDetAmbiguitySolver = Trk__TrkAmbiguitySolver(name               = 'InDetAmbiguitySolver'+NewTrackingCuts.extension(),
                                                        TrackInput         = [ InputTrackCollection ],
                                                        TrackOutput        = self.__SiTrackCollection,
                                                        AmbiguityProcessor = InDetAmbiguityProcessor)
         topSequence += InDetAmbiguitySolver
         if (InDetFlags.doPrintConfigurables()):
            print InDetAmbiguitySolver

         #
         # --- Delete Silicon Sp-Seeded tracks
         #
         from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
         InDetSGDeletionAlg(key = SiSPSeededTrackCollectionKey)

         if ( ( NewTrackingCuts.mode() in ["Pixel", "SCT"] ) or not InDetFlags.doSGDeletion()):
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__SiTrackCollection,
                                                            self.__SiTrackCollection+"DetailedTruth",
                                                            self.__SiTrackCollection+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__SiTrackCollection ]
   def __init__(self, InputCollections = None, NewTrackingCuts = None, TrackCollectionKeys=[] , TrackCollectionTruthKeys=[]):

      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()

      #
      # --- decide if use the association tool
      #
      if len(InputCollections) > 0:
         usePrdAssociationTool = True
      else:
         usePrdAssociationTool = False

      # --- the PRD association tool is filled by the Segment making
      #     no need to run again
      
      # ------------------------------------------------------------
      #
      # ---------- TRT Seeded Tracking
      #
      # ------------------------------------------------------------

      if InDetFlags.doTRTSeededTrackFinder():
         #
         # --- decide which TRT seed space point finder to use
         #
         if InDetFlags.loadTRTSeededSPFinder():
            #
            # --- defaul space point finder
            #
            from TRT_SeededSpacePointFinderTool.TRT_SeededSpacePointFinderToolConf import InDet__TRT_SeededSpacePointFinder_ATL
            InDetTRT_SeededSpacePointFinder = InDet__TRT_SeededSpacePointFinder_ATL(name                   = 'InDetTRT_SeededSpFinder'  ,
                                                                                    SpacePointsSCTName     = InDetKeys.SCT_SpacePoints(),
                                                                                    SpacePointsOverlapName = InDetKeys.OverlapSpacePoints(),
                                                                                    AssociationTool        = InDetPrdAssociationTool    ,
                                                                                    UseAssociationTool     = usePrdAssociationTool      ,
                                                                                    NeighborSearch         = True,
                                                                                    LoadFull               = False,
                                                                                    DoCosmics              = InDetFlags.doCosmics(),
                                                                                    pTmin                  = NewTrackingCuts.minSecondaryPt())
            #InDetTRT_SeededSpacePointFinder.OutputLevel = VERBOSE

         elif InDetFlags.loadSimpleTRTSeededSPFinder():
            #
            # --- alternative version using the region selector
            #
            from RegionSelector.RegSelSvcDefault import RegSelSvcDefault
            InDetRegSelSvc             = RegSelSvcDefault()
            InDetRegSelSvc.enablePixel = DetFlags.pixel_on()
            InDetRegSelSvc.enableSCT   = DetFlags.SCT_on()

            ServiceMgr += InDetRegSelSvc
            if (InDetFlags.doPrintConfigurables()):
               print InDetRegSelSvc
               
            from TRT_SeededSpacePointFinderTool.TRT_SeededSpacePointFinderToolConf import InDet__SimpleTRT_SeededSpacePointFinder_ATL
            InDetTRT_SeededSpacePointFinder = InDet__SimpleTRT_SeededSpacePointFinder_ATL(name                   = 'InDetTRT_SeededSpFinder'  ,
                                                                                          SpacePointsSCTName     = InDetKeys.SCT_SpacePoints(),
                                                                                          SpacePointsOverlapName = InDetKeys.OverlapSpacePoints(),
                                                                                          PerigeeCut             = 1000.,
                                                                                          DirectionPhiCut        = .3,
                                                                                          DirectionEtaCut        = 1.,
                                                                                          MaxHoles               = 2,
                                                                                          AssociationTool        = InDetPrdAssociationTool,
                                                                                          RestrictROI            = True)
            #InDetTRT_SeededSpacePointFinder.OutputLevel = VERBOSE
            if not usePrdAssociationTool:
               InDetTRT_SeededSpacePointFinder.AssociationTool = None 

         # add either into the Tool Service
         ToolSvc += InDetTRT_SeededSpacePointFinder
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededSpacePointFinder
         #
         # Silicon det elements road maker tool
         #
         from SiDetElementsRoadTool_xk.SiDetElementsRoadTool_xkConf import InDet__SiDetElementsRoadMaker_xk
         InDetTRT_SeededSiRoadMaker = InDet__SiDetElementsRoadMaker_xk(name               = 'InDetTRT_SeededSiRoad'  ,
                                                                       PropagatorTool     = InDetPatternPropagator   ,
                                                                       usePixel           = NewTrackingCuts.usePixel(),
                                                                       PixManagerLocation = InDetKeys.PixelManager() ,
                                                                       useSCT             = NewTrackingCuts.useSCT(), 
                                                                       SCTManagerLocation = InDetKeys.SCT_Manager()  ,
                                                                       RoadWidth          = 35.,
                                                                       MaxStep            = 20.)                       # NOT DEFAULT ?
         #InDetTRT_SeededSiRoadMaker.OutputLevel = VERBOSE
         if InDetFlags.doCosmics():
            InDetTRT_SeededSiRoadMaker.RoadWidth = 50
      
         ToolSvc += InDetTRT_SeededSiRoadMaker
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededSiRoadMaker
         #
         # --- TRT seeded back tracking tool
         #
         from TRT_SeededTrackFinderTool.TRT_SeededTrackFinderToolConf import InDet__TRT_SeededTrackFinder_ATL
         InDetTRT_SeededTrackTool =  InDet__TRT_SeededTrackFinder_ATL(name                     = 'InDetTRT_SeededTrackMaker',
                                                                      PropagatorTool           = InDetPatternPropagator,
                                                                      UpdatorTool              = InDetPatternUpdator,
                                                                      RoadTool                 = InDetTRT_SeededSiRoadMaker,
                                                                      SeedTool                 = InDetTRT_SeededSpacePointFinder,
                                                                      CombinatorialTrackFinder = InDetSiComTrackFinder,
                                                                      pTmin                    = NewTrackingCuts.minSecondaryPt(),
                                                                      nHolesMax                = NewTrackingCuts.SecondarynHolesMax(),
                                                                      # ME bugfix: nHolesGapMax             = 2*NewTrackingCuts.SecondarynHolesGapMax(),
                                                                      nHolesGapMax             = NewTrackingCuts.SecondarynHolesGapMax(),
                                                                      Xi2max                   = NewTrackingCuts.SecondaryXi2max(),
                                                                      Xi2maxNoAdd              = NewTrackingCuts.SecondaryXi2maxNoAdd(),
                                                                      ConsistentSeeds          = True,
                                                                      #BremCorrection           = True,
                                                                      BremCorrection           = False,
                                                                      UseAssociationTool       = usePrdAssociationTool)
         if InDetFlags.doCosmics():
            InDetTRT_SeededTrackTool.nWClustersMin = 0
      
         ToolSvc   += InDetTRT_SeededTrackTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededTrackTool

         #
         # --- Output key for the finder
         #
         self.__TRTSeededTracks = InDetKeys.TRTSeededTracks()
         #
         # TRT seeded back tracking algorithm
         #
         from TRT_SeededTrackFinder.TRT_SeededTrackFinderConf import InDet__TRT_SeededTrackFinder
         InDetTRT_SeededTrackFinder = InDet__TRT_SeededTrackFinder(name                  = 'InDetTRT_SeededTrackFinder',
                                                                   RefitterTool          = InDetTrackFitter,
                                                                   TrackTool             = InDetTRT_SeededTrackTool,
                                                                   TrackExtensionTool    = InDetTRTExtensionTool,
                                                                   MinTRTonSegment       = NewTrackingCuts.minSecondaryTRTonTrk(),
                                                                   MinTRTonly            = NewTrackingCuts.minTRTonly(),
                                                                   TrtExtension          = True,
                                                                   SiExtensionCuts       = NewTrackingCuts.SiExtensionCuts(),
                                                                   minPt                 = NewTrackingCuts.minSecondaryPt(),
                                                                   maxRPhiImp            = NewTrackingCuts.maxSecondaryImpact(),
                                                                   maxZImp               = NewTrackingCuts.maxZImpact(),
                                                                   maxEta                = NewTrackingCuts.maxEta(),
                                                                   Extrapolator          = InDetExtrapolator,
                                                                   RejectShortExtension  = NewTrackingCuts.rejectShortExtensions(),
                                                                   FinalRefit            = False,
                                                                   FinalStatistics       = False,
                                                                   OutputSegments        = False,
                                                                   InputSegmentsLocation = InDetKeys.TRT_Segments(),
                                                                   OutputTracksLocation  = self.__TRTSeededTracks)
         # InDetTRT_SeededTrackFinder.OutputLevel = VERBOSE
         topSequence += InDetTRT_SeededTrackFinder
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededTrackFinder
            
         #
         # ------------ Track truth.
         #
         if not InDetFlags.doSGDeletion():
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__TRTSeededTracks,
                                                            self.__TRTSeededTracks+"DetailedTruth",
                                                            self.__TRTSeededTracks+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__TRTSeededTracks ]
               
         # --- output track collection
         self.__BackTrackingTracks = self.__TRTSeededTracks

      # ------------------------------------------------------------
      #
      # --- Resolve back tracking tracks ? 
      #
      # ------------------------------------------------------------

      if InDetFlags.doResolveBackTracks():
         #
         # --- set up special Scoring Tool for TRT seeded tracks
         #
         if InDetFlags.doCosmics():
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
            InDetTRT_SeededScoringTool = InDet__InDetCosmicScoringTool(name                 = 'InDetCosmicScoringTool_TRT',
                                                                       nWeightedClustersMin = 0,
                                                                       minTRTHits           = NewTrackingCuts.minSecondaryTRTonTrk(),
                                                                       SummaryTool          = InDetTrackSummaryTool)
         else:
            from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
            InDetTRT_SeededScoringTool = InDet__InDetAmbiScoringTool(name                    = 'InDetTRT_SeededScoringTool',
                                                                     Extrapolator            = InDetExtrapolator,
                                                                     DriftCircleCutTool      = InDetTRTDriftCircleCut,
                                                                     SummaryTool             = InDetTrackSummaryTool,
                                                                     useTRT_AmbigFcn         = InDetFlags.doNewTracking(),     # full search => use NewT
                                                                     useAmbigFcn             = not InDetFlags.doNewTracking(), # full search => use NewT
                                                                     minPt                   = NewTrackingCuts.minSecondaryPt(),
                                                                     maxRPhiImp              = NewTrackingCuts.maxSecondaryImpact(),
                                                                     maxZImp                 = NewTrackingCuts.maxZImpact(),
                                                                     maxEta                  = NewTrackingCuts.maxEta(),
                                                                     minSiClusters           = NewTrackingCuts.minSecondaryClusters(),
                                                                     maxSiHoles              = NewTrackingCuts.maxSecondaryHoles(),
                                                                     maxPixelHoles           = NewTrackingCuts.maxSecondaryPixelHoles(),
                                                                     maxSCTHoles             = NewTrackingCuts.maxSecondarySCTHoles(),
                                                                     maxDoubleHoles          = NewTrackingCuts.maxSecondaryDoubleHoles(),
                                                                     usePixel                = NewTrackingCuts.usePixel(),
                                                                     useSCT                  = NewTrackingCuts.useSCT(),
                                                                     minTRTonTrk             = NewTrackingCuts.minSecondaryTRTonTrk(),
                                                                     minTRTPrecisionFraction = NewTrackingCuts.minSecondaryTRTPrecFrac())
         # InDetTRT_SeededScoringTool.OutputLevel = DEBUG
         ToolSvc += InDetTRT_SeededScoringTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededScoringTool
      
         #
         # --- Load selection tool
         #
         from InDetAmbiTrackSelectionTool.InDetAmbiTrackSelectionToolConf import InDet__InDetAmbiTrackSelectionTool
         InDetTRT_SeededAmbiTrackSelectionTool = InDet__InDetAmbiTrackSelectionTool(name                = 'InDetTRT_SeededAmbiTrackSelectionTool',
                                                                                    AssociationTool     =  InDetPrdAssociationTool,
                                                                                    DriftCircleCutTool  =  InDetTRTDriftCircleCut,
                                                                                    minScoreShareTracks = -1., # off !
                                                                                    minHits             = NewTrackingCuts.minSecondaryClusters(),
                                                                                    minNotShared        = NewTrackingCuts.minSecondarySiNotShared(),
                                                                                    maxShared           = NewTrackingCuts.maxSecondaryShared(),
                                                                                    minTRTHits          = NewTrackingCuts.minSecondaryTRTonTrk(),
                                                                                    UseParameterization = NewTrackingCuts.useParameterizedTRTCuts(),
                                                                                    Cosmics             = InDetFlags.doCosmics(),
                                                                                    doPixelSplitting    = InDetFlags.doPixelClusterSplitting())
      
         # InDetTRT_SeededAmbiTrackSelectionTool.OutputLevel = DEBUG
         ToolSvc += InDetTRT_SeededAmbiTrackSelectionTool
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededAmbiTrackSelectionTool

         #
         # --- load Ambiguity Processor
         #
         from TrkAmbiguityProcessor.TrkAmbiguityProcessorConf import Trk__SimpleAmbiguityProcessorTool
         InDetTRT_SeededAmbiguityProcessor = Trk__SimpleAmbiguityProcessorTool(name               = 'InDetTRT_SeededAmbiguityProcessor',
                                                                               Fitter             = InDetTrackFitter,          
                                                                               SelectionTool      = InDetTRT_SeededAmbiTrackSelectionTool,
                                                                               RefitPrds          = not InDetFlags.refitROT(),
                                                                               SuppressTrackFit   = False,
                                                                               SuppressHoleSearch = False,
                                                                               ScoringTool        = InDetTRT_SeededScoringTool)
         # InDetTRT_SeededAmbiguityProcessor.OutputLevel = DEBUG
         if InDetFlags.materialInteractions():
            InDetTRT_SeededAmbiguityProcessor.MatEffects = InDetFlags.materialInteractionsType()
         else:
            InDetTRT_SeededAmbiguityProcessor.MatEffects = 0
         #
         ToolSvc += InDetTRT_SeededAmbiguityProcessor
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededAmbiguityProcessor

         #
         # --- load the algorithm
         #
         self.__ResolvedTRTSeededTracks = InDetKeys.ResolvedTRTSeededTracks() 
         #
         from TrkAmbiguitySolver.TrkAmbiguitySolverConf import Trk__TrkAmbiguitySolver
         InDetTRT_SeededAmbiguitySolver = Trk__TrkAmbiguitySolver(name               = 'InDetTRT_SeededAmbiguitySolver',
                                                                  TrackInput         = [ self.__TRTSeededTracks ],
                                                                  TrackOutput        = self.__ResolvedTRTSeededTracks,
                                                                  AmbiguityProcessor = InDetTRT_SeededAmbiguityProcessor)
         topSequence += InDetTRT_SeededAmbiguitySolver
         if (InDetFlags.doPrintConfigurables()):
            print InDetTRT_SeededAmbiguitySolver

         # --- Delete (non-resloved) TRT seeded tracks
         from InDetRecExample.ConfiguredInDetSGDeletion import InDetSGDeletionAlg
         InDetSGDeletionAlg(key = InDetKeys.TRTSeededTracks())
         
         #
         # ------------ Track truth.
         #
         if not InDetFlags.doSGDeletion():
            if InDetFlags.doTruth():
               #
               # set up the truth info for this container
               #
               include ("InDetRecExample/ConfiguredInDetTrackTruth.py")
               InDetTracksTruth = ConfiguredInDetTrackTruth(self.__ResolvedTRTSeededTracks,
                                                            self.__ResolvedTRTSeededTracks+"DetailedTruth",
                                                            self.__ResolvedTRTSeededTracks+"TruthCollection")
               #
               # add final output for statistics
               #
               TrackCollectionKeys      += [ InDetTracksTruth.Tracks() ]
               TrackCollectionTruthKeys += [ InDetTracksTruth.TracksTruth() ]
            else:
               TrackCollectionKeys      += [ self.__ResolvedTRTSeededTracks ]
               
         # --- output track collection
         self.__BackTrackingTracks = self.__ResolvedTRTSeededTracks