InDetRecAlgorithms

Refitting tracks using ReadInDet _jobOptions.py

Here is how to refit tracks using ReadInDet _jobOption.py. I will summarize only important codes related to refitting. First, the jobOption is ReadInDet _jobOptions.py. The master code that lists Algorithm is InDetRecExample /InDetJobProperties.py.

From InDetRecExample /ReadInDet _jobOptions.py

# --- refit the EXISTING tracks in ESD (only possible if readESD = True)
doRefitTracks = True and readESD

# --- setup InDetJobProperties
from InDetRecExample.InDetJobProperties import InDetFlags
InDetFlags.doRefit            = doRefitTracks
#added for refit
InDetFlags.doPixelClusterSplitting = False      # False for refit, True for rePattern

from InDetRecExample.InDetKeys import InDetKeys
if readESD and not redoPatternRecoAndTracking:
  InDetKeys.UnslimmedTracks              = 'Tracks'
  InDetKeys.UnslimmedTracksTruth         = 'TrackTruthCollection'
if doWriteAOD:
  InDetKeys.OutputAODFileName = "InDetRecAOD_new.root"

#--------------------------------------------------------------
# load master joboptions file
#--------------------------------------------------------------

include("InDetRecExample/InDetRec_all.py")

From InDetRecExample /InDetRec_all.py

Now, ReadInDet _jobOptions.py calls InDetRec _all.py

# ------------------------------------------------------------
# persistency
# ------------------------------------------------------------

if doWriteESD or doWriteAOD or ('doCopyRDO' in dir() and doCopyRDO):
  # --- load setup
  from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream
  # --- check dictionary
  ServiceMgr.AthenaSealSvc.CheckDictionary = True
  # --- commit interval (test)
  ServiceMgr.AthenaPoolCnvSvc.CommitInterval = 10
  if doWriteAOD:
    # --- create stream
    StreamAOD            = AthenaPoolOutputStream ( "StreamAOD", InDetKeys.OutputAODFileName()) 
    # --- load list of objects
    include ( "InDetRecExample/WriteInDetAOD.py" )

From InDetRecExample /WriteInDetAOD.py

Now let's see what WriteInDetAOD.py does.

#+++++++++++++++++ Beginning of WriteInDetAOD.py

from InDetRecExample.InDetKeys import InDetKeys
InDetAODList = []
if InDetFlags.doxAOD():
  InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODTrackParticleContainer()]
  InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']
  InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODForwardTrackParticleContainer()]
  InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODForwardTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']
  InDetAODList+=['xAOD::VertexContainer#'+InDetKeys.xAODVertexContainer()]
  InDetAODList+=['xAOD::VertexAuxContainer#'+InDetKeys.xAODVertexContainer()+'Aux.-vxTrackAtVertex']
  InDetAODList+=['xAOD::VertexContainer#'+InDetKeys.xAODV0VertexContainer()]
  InDetAODList+=['xAOD::VertexAuxContainer#'+InDetKeys.xAODV0VertexContainer()+'Aux.-vxTrackAtVertex']
  InDetAODList+=['xAOD::VertexContainer#'+InDetKeys.xAODKshortVertexContainer()]
  InDetAODList+=['xAOD::VertexAuxContainer#'+InDetKeys.xAODKshortVertexContainer()+'Aux.-vxTrackAtVertex']
  InDetAODList+=['xAOD::VertexContainer#'+InDetKeys.xAODLambdaVertexContainer()]
  InDetAODList+=['xAOD::VertexAuxContainer#'+InDetKeys.xAODLambdaVertexContainer()+'Aux.-vxTrackAtVertex']
  InDetAODList+=['xAOD::VertexContainer#'+InDetKeys.xAODLambdabarVertexContainer()]
  InDetAODList+=['xAOD::VertexAuxContainer#'+InDetKeys.xAODLambdabarVertexContainer()+'Aux.-vxTrackAtVertex']
  if InDetFlags.doTrackSegmentsPixel():
    InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODPixelTrackParticleContainer()]
    InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODPixelTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']
  if InDetFlags.doTrackSegmentsPixelPrdAssociation():
    InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODPixelPrdAssociationTrackParticleContainer()]
    InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODPixelPrdAssociationTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']
  if InDetFlags.doTrackSegmentsSCT():
    InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODSCTTrackParticleContainer()]
    InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODSCTTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']
  if InDetFlags.doTrackSegmentsTRT():
    InDetAODList+=['xAOD::TrackParticleContainer#'+InDetKeys.xAODTRTTrackParticleContainer()]
    InDetAODList+=['xAOD::TrackParticleAuxContainer#'+InDetKeys.xAODTRTTrackParticleContainer()+'Aux.-caloExtension.-cellAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition']


# next is only for InDetRecExample stand alone! RecExCommon uses InDetAODList directly
StreamAOD.ItemList += InDetAODList
#+++++++++++++++++ End of WriteInDetAOD.py

From InDetRecExample /InDetRec_jobOptions.py

# ------------------------------------------------------------
    #
    # ----------- prepare output track collection for post processing
    #
    # ------------------------------------------------------------

    #
    # -- Pick one of the result collections and turn it into tracks
    #
    if InDetFlags.doNewTrackingPattern():
      InputTrackCollection = InDetKeys.UnslimmedTracks()
    else:
      # --- in case of reading from ESD, so we just set the Collection and truth
      InputTrackCollection      = InDetKeys.Tracks()
      InputTrackCollectionTruth = InDetKeys.TracksTruth()

# ---------------------------------------------------------------- 
    #
    # --- do we refit all tracks ?
    #
    # ---------------------------------------------------------------- 
    if InDetFlags.doRefit():
      from TrkRefitAlg.TrkRefitAlgConf import Trk__ReFitTrack
      InDetReFitTrack = Trk__ReFitTrack (name           = "InDetRefitTrack",
                                         FitterTool     = InDetTrackFitter,
                                         FitterToolTRT  = InDetTrackFitterTRT,
                                         SummaryTool    = InDetTrackSummaryToolSharedHits,
                                         AssoTool       = InDetPrdAssociationTool,
                                         TrackName      = InputTrackCollection,
                                         NewTrackName   = InDetKeys.RefittedTracks(),
                                         fitRIO_OnTrack = InDetFlags.refitROT(),
                                         useParticleHypothesisFromTrack = True)

      if InDetFlags.materialInteractions():
        InDetReFitTrack.matEffects = InDetFlags.materialInteractionsType()
      else:
        InDetReFitTrack.matEffects = 0

      topSequence += InDetReFitTrack
      if (InDetFlags.doPrintConfigurables()):
        print InDetReFitTrack
      # set input track name
      InputTrackCollection = InDetKeys.RefittedTracks()
      if InDetFlags.doTruth():
        InputDetailedTrackTruth   = InDetKeys.RefittedDetailedTracksTruth()
        InputTrackCollectionTruth = InDetKeys.RefittedTracksTruth()

# ------------------------------------------------------------
    #
    # ----------- now we do post-processing
    #
    # ------------------------------------------------------------
    #
    #
    # xAOD creation/conversion
    if (InDetFlags.doxAOD()):
      include("InDetRecExample/InDetxAODCreator.py")

    # Do post-processing algorithms (may depend on xAOD objects)
    include("InDetRecExample/InDetRecPostProcessing.py")

From InDetRecExample /InDetxAODCreator.py

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

if not InDetFlags.doVertexFinding():
 from xAODTrackingCnv.xAODTrackingCnvConf import xAODMaker__VertexCnvAlg
 xAODVertexCnvAlg = xAODMaker__VertexCnvAlg()
 xAODVertexCnvAlg.xAODContainerName = InDetKeys.xAODVertexContainer()
 xAODVertexCnvAlg.AODContainerName = InDetKeys.PrimaryVertices()
 xAODVertexCnvAlg.TPContainerName = InDetKeys.xAODTrackParticleContainer()
 topSequence += xAODVertexCnvAlg

From InDetRecExample /InDetRecPostProcessing.py

This code doesn't do anything. ConfiguredPriVtxAndPartCreation has no script related to refitting.

# ------------------------------------------------------------
#
# --- do primary vertexing and particle creation for default tracking
#
# ------------------------------------------------------------
include ("InDetRecExample/ConfiguredPriVtxAndPartCreation.py")
InDetPriVtxPartCreation = ConfiguredPriVtxAndPartCreation (extension                 = "",
                                                           #InputTrackCollection      = InputTrackCollection,
                                                           InputTrackCollection      = InDetKeys.xAODTrackParticleContainer(),
                                                           InputTrackCollectionTruth = InputTrackCollectionTruth,
                                                           VxCandidates              = InDetKeys.xAODVertexContainer(),
                                                           TrackParticles            = InDetKeys.TrackParticles(),
                                                           TrackParticlesTruth       = InDetKeys.TrackParticlesTruth())

From InDetRecExample /InDetKeys.py

class xAODTrackParticleContainer(JobProperty):
    """xAOD TrackParticle"""
    statusOn = True
    allowedTypes = ['str']
    StoredValue = "InDetTrackParticles"

jobproperties.InDetContainerKeys.add_JobProperty(xAODTrackParticleContainer)

From InDetRecExample /InDetJobProperties.py

class doRefit(InDetFlagsJobProperty):
    """Turn running of refitting on and off"""
    statusOn     = True
    allowedTypes = ['bool']
    StoredValue  = False

# --------------------------------------------------------------------
      # ---- Loading of Tools (depends on settings above)
      # --------------------------------------------------------------------
      #
      # control if to load the tools
      self.loadTools  = self.loadTools() or self.doPattern() or self.doRefit() or self.postProcessing() or \
                        self.doNtupleCreation() or self.doD3PDCreation() or self.doMonitoring()

# --------------------------------------------------------------------
      # ---- Refit of tracks
      # --------------------------------------------------------------------
      #
      if (self.trackFitterType() is not 'KalmanFitter' and self.trackFitterType() is not 'KalmanDNAFitter') :
         self.refitROT = True
      if not self.refitROT() and not self.redoTRT_LR() :
         print 'ConfiguredInDetFlags.py       WARNING refitROT and redoTRT_LR are both False, NOT RECOMMENDED!'
      #
      # refKF needs a new method in IUpdator, where there is currently only one implementation
      if (self.trackFitterType() is 'ReferenceKalmanFitter'):
          self.kalmanUpdator = 'amg'
      #
      # check if a valid fitter has been used
      if not (    (self.trackFitterType() is 'KalmanFitter')
               or (self.trackFitterType() is 'KalmanDNAFitter')
               or (self.trackFitterType() is 'ReferenceKalmanFitter')
               or (self.trackFitterType() is 'DistributedKalmanFilter')
               or (self.trackFitterType() is 'GlobalChi2Fitter' )
               or (self.trackFitterType() is 'GaussianSumFilter') ):
         print 'InDetJobProperties.py       WARNING unregistered or invalid track fitter setup.'
         print '                                      --> re-setting to TrkKalmanFitter.'
         self.trackFitterType = 'KalmanFitter'

# --------------------------------------------------------------------
      # ---- Track slimming
      # --------------------------------------------------------------------
      #
      # Turn off slimming if the refit is enabled (since this maybe done to unlsim
      # the tracks) unless explicitly set by the user
      if self.doRefit(): self.checkThenSet(self.doSlimming, False)

# -----------------------------------------
    if self.doRefit() :
       print '*'
       print '* do a refit of all tracks'

_list_InDetJobProperties = [Enabled,
                            doRefit,
                           ]
for j in _list_InDetJobProperties:
    jobproperties.InDetJobProperties.add_JobProperty(j)

-- SiinnChe - 2015-03-07

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2015-03-20 - SiinnChe
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback