Ejemplo n.º 1
0
def addDecorator():
    '''
  Add the track particle decoration algorithm to the top sequence. 
  The algorithm is to be run on RAW/RDO since it depends on full hit information
  which is generally not available at later stages. The decorations added by this
  algorithm are used by InDetPhysValMonitoring tool.
  '''

    decorators = []

    decorators.append(InDetPhysValDecoratorAlg.InDetPhysValDecoratorAlg())

    from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
    InDetPhysValFlags.init()
    if InDetPhysValFlags.doValidateGSFTracks():
        # cannot add the decorator for GSF tracks at this moment because the egamma algorithm has not been
        # constructed yet.
        # so this does not work: decorators.append( InDetPhysValDecoratorAlg.InDetPhysValDecoratorAlgGSF() )
        # Can only schedule a user algorithm :
        from RecExConfig.RecFlags import rec
        rec.UserExecs += [
            'from InDetPhysValMonitoring.InDetPhysValDecoration import addGSFTrackDecoratorAlg;addGSFTrackDecoratorAlg();'
        ]

    # from  InDetRecExample.InDetJobProperties import InDetFlags
    from InDetRecExample.InDetKeys import InDetKeys
    # for backward compatibility check whether DBM has been added already
    if InDetPhysValFlags.doValidateDBMTracks() and hasattr(
            InDetKeys, 'DBMTrackParticles'):
        # and InDetFlags.doDBM()
        decorators.append(
            InDetPhysValDecoratorAlg.InDetPhysValDecoratorAlgDBM())

    _addDecorators(decorators)
Ejemplo n.º 2
0
def addExtraMonitoring():
    '''
  IF monitoring is wished for GSF or DBM TrackParticles find the monitoring manager and 
  add the corresponding monitoring tools.
  '''
    # hack to add monitors for DBM and GSF
    # the job option fragment which adds the InDetPhysValMonitoringTool for the default tracks
    # will call this method, so can abuse this method to also add the monitoring tools for DBM and GSF tracks
    try:
        from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
        # flags are at this stage already initialised, so do not need to  InDetPhysValFlags.init()
        if InDetPhysValFlags.doValidateGSFTracks(
        ) or InDetPhysValFlags.doValidateDBMTracks(
        ) or InDetPhysValFlags.doValidateTightPrimaryTracks():
            mon_index = findMonMan()
            if mon_index != None:
                from AthenaCommon.AlgSequence import AlgSequence
                topSequence = AlgSequence()
                mon_manager = topSequence.getChildren()[mon_index]
                from InDetPhysValMonitoring.InDetPhysValMonitoringTool import InDetPhysValMonitoringTool

    except ImportError:
        import sys, traceback
        exc_type, exc_value, exc_traceback = sys.exc_info()
        print "*** print_tb:"
        traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
        print "*** print_exception:"
        traceback.print_exception(exc_type,
                                  exc_value,
                                  exc_traceback,
                                  limit=2,
                                  file=sys.stdout)
        print "*** print_exc:"
        traceback.print_exc()
        raise
Ejemplo n.º 3
0
def addGSFTrackDecoratorAlg():
    '''
   Search egamma algorithm and add the GSF TrackParticle decorator after the it.
   '''
    from InDetPhysValMonitoring.InDetPhysValDecoration import _addDecorators

    from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
    if InDetPhysValFlags.doValidateGSFTracks():
        # print ('DEBUG add addGSFTrackDecoratorAlg')
        decorators = getGSFTrackDecorators()
        from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
        from InDetPhysValMonitoring.ConfigUtils import extractCollectionPrefix
        for col in InDetPhysValFlags.validateExtraTrackCollections():
            prefix = extractCollectionPrefix(col)
            decorators += getTrackDecorators(
                TrackParticleContainerName=prefix + "TrackParticles")
        # add the InDetPhysValDecoratorAlgGSF after the egamma algorithms ran
        # they build the GSF track particles.
        _addDecorators(decorators, ['egamma', 'egammaTruthAssociationAlg'])

        # To allow for proper decoration of GSF TrackParticles
        #  - have to switch of slimming for GSF Tracks at time of creation
        #  - must slim GSF Tracks after decoration since the unslimmed GSF Tracks cannot be persistified

        from AthenaCommon.AppMgr import ToolSvc
        # print (ToolSvc)
        # print ('DEBUG has EMBremCollectionBuilder %s' % hasattr(ToolSvc,'EMBremCollectionBuilder'))
        if hasattr(ToolSvc, 'EMBremCollectionBuilder'):
            decor_index = findAlg([decorators[0].getName()],
                                  search_outputstream_otherwise=False)
            if decor_index is not None:
                from TrkTrackSlimmer.TrkTrackSlimmerConf import Trk__TrackSlimmer as ConfigurableTrackSlimmer
                slimmer = ConfigurableTrackSlimmer(
                    name="RealGSFTrackSlimmer",
                    TrackLocation=[InDetPhysValKeys.GSFTracksUnslimmed],
                    SlimmedTrackLocation=[InDetPhysValKeys.GSFTracks],
                    TrackSlimmingTool=ToolSvc.EMBremCollectionBuilder.
                    TrackSlimmingTool)

                from InDetPhysValMonitoring.InDetPhysValMonitoringConf import DummyTrackSlimmingTool
                slimming_tool = DummyTrackSlimmingTool()
                ToolSvc += slimming_tool
                ToolSvc.EMBremCollectionBuilder.TrackSlimmingTool = slimming_tool
                ToolSvc.EMBremCollectionBuilder.OutputTrackContainerName = InDetPhysValKeys.GSFTracksUnslimmed
                # ToolSvc.ResidualPullCalculator.OutputLevel = 1

                from AthenaCommon.AlgSequence import AlgSequence
                topSequence = AlgSequence()
                topSequence.insert(decor_index + 1, slimmer)
Ejemplo n.º 4
0
import InDetPhysValMonitoring.InDetPhysValDecoration
decoration = InDetPhysValMonitoring.InDetPhysValDecoration.addDecoratorIfNeeded()

# add ID physics validation monitoring tool

from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
import InDetPhysValMonitoring.InDetPhysValMonitoringTool as InDetPhysValMonitoringTool

mons=[ (True                                             , InDetPhysValMonitoringTool.getInDetPhysValMonitoringTool),
       (InDetPhysValFlags.doValidateLooseTracks()        , InDetPhysValMonitoringTool.getInDetPhysValMonitoringToolLoose),
       (InDetPhysValFlags.doValidateTightPrimaryTracks() , InDetPhysValMonitoringTool.getInDetPhysValMonitoringToolTightPrimary),
       (InDetPhysValFlags.doValidateDBMTracks()          , InDetPhysValMonitoringTool.getInDetPhysValMonitoringToolDBM),
       (InDetPhysValFlags.doValidateGSFTracks()          , InDetPhysValMonitoringTool.getInDetPhysValMonitoringToolGSF)
     ]

for enabled, creator in mons :
    if enabled :
        monMan.AthenaMonTools += [ creator() ]


from InDetPhysValMonitoring.InDetPhysValMonitoringTool import getInDetPhysValMonitoringTool
from  InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags
from  InDetPhysValMonitoring.ConfigUtils import extractCollectionPrefix
for col in InDetPhysValFlags.validateExtraTrackCollections() :
    prefix=extractCollectionPrefix(col)
    monMan.AthenaMonTools += [ getInDetPhysValMonitoringTool(name                       = 'InDetPhysValMonitoringTool'+prefix,
                                                             SubFolder                  = prefix+'Tracks/',
                                                             TrackParticleContainerName = prefix+'TrackParticles') ]
Ejemplo n.º 5
0
# add ID physics validation monitoring tool

from InDetPhysValMonitoring.InDetPhysValMonitoringTool import InDetPhysValMonitoringTool
from InDetPhysValMonitoring.InDetPhysValJobProperties import InDetPhysValFlags

indet_mon_tool = InDetPhysValMonitoringTool.InDetPhysValMonitoringTool()
ToolSvc += [indet_mon_tool]
monMan.AthenaMonTools += [indet_mon_tool]

if InDetPhysValFlags.doValidateDBMTracks():
    indet_mon_tool_DBM = InDetPhysValMonitoringTool.InDetPhysValMonitoringToolDBM(
    )
    ToolSvc += [indet_mon_tool_DBM]
    monMan.AthenaMonTools += [indet_mon_tool_DBM]

if InDetPhysValFlags.doValidateGSFTracks():
    indet_mon_tool_GSF = InDetPhysValMonitoringTool.InDetPhysValMonitoringToolGSF(
    )
    ToolSvc += [indet_mon_tool_GSF]
    monMan.AthenaMonTools += [indet_mon_tool_GSF]

if InDetPhysValFlags.doValidateLooseTracks():
    indet_mon_tool_Loose = InDetPhysValMonitoringTool.InDetPhysValMonitoringToolLoose(
    )
    ToolSvc += [indet_mon_tool_Loose]
    monMan.AthenaMonTools += [indet_mon_tool_Loose]

if InDetPhysValFlags.doValidateTightPrimaryTracks():
    indet_mon_tool_TightPrimary = InDetPhysValMonitoringTool.InDetPhysValMonitoringToolTightPrimary(
    )
    ToolSvc += [indet_mon_tool_TightPrimary]