Commit fc678d2b authored by Justin Griffiths's avatar Justin Griffiths Committed by Graeme Stewart
Browse files

new tag (tauRec-05-00-06)

	* merge tauRec-05-00-03-branch with current trunk
	* 20.7 and lower release updates should branch off tauRec-05-00-04
parent d8a0cffb
......@@ -591,11 +591,59 @@ def getInDetTrackSelectorTool():
return InDetTrackSelectorTool
#########################################################################
def getInDetTrackSelectionToolForTJVA():
_name = sPrefix + 'InDetTrackSelectionToolForTJVA'
if _name in cached_instances:
return cached_instances[_name]
#Configures tau track selector tool (should eventually check whether an existing one is available)
from InDetTrackSelectionTool.InDetTrackSelectionToolConf import InDet__InDetTrackSelectionTool
InDetTrackSelectionToolForTJVA = InDet__InDetTrackSelectionTool(name = _name,
minPt = 1000.,
maxD0 = 9999.*mm,
maxZ0 = 9999.*mm,
minNPixelHits = 2, # PixelHits + PixelDeadSensors
minNSctHits = 0, # SCTHits + SCTDeadSensors
minNSiHits = 7, # PixelHits + SCTHits + PixelDeadSensors + SCTDeadSensors
minNTrtHits = 0)
#fitChi2OnNdfMax = 99999,
#TrackSummaryTool = None,
#Extrapolator = getAtlasExtrapolator())
from AthenaCommon.AppMgr import ToolSvc
ToolSvc += InDetTrackSelectionToolForTJVA
cached_instances[_name] = InDetTrackSelectionToolForTJVA
return InDetTrackSelectionToolForTJVA
############################################################################
def getInDetTrackSelectorToolxAOD():
_name = sPrefix + 'IInDetTrackSelectionTool'
if _name in cached_instances:
return cached_instances[_name]
#Configures tau track selection tool (should eventually check whether an existing one is available)
from InDetTrackSelectionTool.InDetTrackSelectionToolConf import InDet__InDetTrackSelectionTool
myInDetTrackSelectionTool = InDet__InDetTrackSelectionTool(name = _name,
CutLevel="TightPrimary",
)
from AthenaCommon.AppMgr import ToolSvc
ToolSvc += myInDetTrackSelectionTool
cached_instances[_name] = myInDetTrackSelectionTool
return myInDetTrackSelectionTool
############################################################################
# setup up JVA tools
def setupTauJVFTool():
from AthenaCommon.AppMgr import ToolSvc
#Configures tau track selection tool for TJVA
"""
#Configures tau track selector tool for TJVA
from InDetTrackSelectorTool.InDetTrackSelectorToolConf import InDet__InDetDetailedTrackSelectorTool
......@@ -630,7 +678,8 @@ def setupTauJVFTool():
TrackVertexAssociation="JetTrackVtxAssoc_forTaus",
VertexContainer= _DefaultVertexContainer,
MaxTransverseDistance = 2.5 *mm,
MaxLongitudinalDistance = 2 *mm,
#MaxLongitudinalDistance = 2 *mm,
MaxZ0SinTheta = 3.0 *mm,
#OutputLevel=2
)
#jetTrackAlg.Tools = [ToolSvc.JetTrackSelectionTool , ToolSvc.TrackVertexAssociationTool ]
......@@ -656,7 +705,8 @@ def getTauVertexFinder(doUseTJVA=False):
UseTJVA = doUseTJVA,
PrimaryVertexContainer = _DefaultVertexContainer,
AssociatedTracks="GhostTrack", # OK??
TrackVertexAssociation="JetTrackVtxAssoc_forTaus"
TrackVertexAssociation="JetTrackVtxAssoc_forTaus",
InDetTrackSelectionToolForTJVA = getInDetTrackSelectionToolForTJVA()
)
cached_instances[_name] = TauVertexFinder
......@@ -681,7 +731,7 @@ def getTrackToVertexTool():
########################################################################
# Tau-Track Association
def getTauTrackFinder():
def getTauTrackFinder(removeDuplicateTracks=True):
_name = sPrefix + 'TauTrackFinder'
if _name in cached_instances:
......@@ -692,9 +742,11 @@ def getTauTrackFinder():
MaxJetDrTau = 0.2,
MaxJetDrWide = 0.4,
TrackSelectorToolTau = getInDetTrackSelectorTool(),
#TrackSelectorToolTauxAOD = getInDetTrackSelectorToolxAOD(),
TrackParticleContainer = _DefaultTrackContainer,
TrackToVertexTool = getTrackToVertexTool(),
ParticleCaloExtensionTool = getParticleCaloExtensionTool()
ParticleCaloExtensionTool = getParticleCaloExtensionTool(),
removeDuplicateCoreTracks = removeDuplicateTracks,
#maxDeltaZ0wrtLeadTrk = 2, #in mm
#removeTracksOutsideZ0wrtLeadTrk = True
)
......@@ -722,7 +774,6 @@ def getTauGenericPi0Cone():
#end
########################################################################
# MvaTESVariableDecorator
def getMvaTESVariableDecorator():
......@@ -751,12 +802,80 @@ def getCombinedP4FromRecoTaus():
WeightFileName = 'CombinedP4CalibWeightsFile.root')
cached_instances[_name] = CombinedP4FromRecoTaus
return CombinedP4FromRecoTaus
#########################################################################
def getTauTrackClassifier():
_name = sPrefix + 'TauTrackClassifier'
if _name in cached_instances:
return cached_instances[_name]
from AthenaCommon.AppMgr import ToolSvc
from tauRecTools.tauRecToolsConf import tauRecTools__TauTrackClassifier as TauTrackClassifier
from tauRecTools.tauRecToolsConf import tauRecTools__TrackMVABDT as TrackMVABDT
import PyUtils.RootUtils as ru
ROOT = ru.import_root()
import cppyy
cppyy.loadDictionary('xAODTauDict')
ROOT.xAOD.TauJet_v3 #needed to see TauJetParameters
# =========================================================================
_BDT_TTCT_ITFT_0 = TrackMVABDT(name = _name + "_0",
#InputWeightsPath = "/home/duschi/workspace/TauRec/InstallArea/share/tauRecTools/00-00-00/TMVAClassification_BDT.weights.xml",
InputWeightsPath = "tauRecTools/00-00-00/TMVAClassification_BDT.weights.xml",
Threshold = -0.005,
# ExpectedFlag = 9, # unclassified
# SignalType = 5, # charged
# BackgroundType = 7 # isolation
ExpectedFlag = ROOT.xAOD.TauJetParameters.unclassified, # unclassified
SignalType = ROOT.xAOD.TauJetParameters.classifiedCharged, # charged
BackgroundType = ROOT.xAOD.TauJetParameters.classifiedIsolation # isolation
)
ToolSvc += _BDT_TTCT_ITFT_0
cached_instances[_BDT_TTCT_ITFT_0.name] = _BDT_TTCT_ITFT_0
_BDT_TTCT_ITFT_0_0 = TrackMVABDT(name = _name + "_0_0",
#InputWeightsPath = "/home/duschi/workspace/TauRec/InstallArea/share/tauRecTools/00-00-00/TMVAClassification_BDT_0.weights.xml",
InputWeightsPath = "tauRecTools/00-00-00/TMVAClassification_BDT_0.weights.xml",
Threshold = -0.0074,
# ExpectedFlag = 5, # charged
# SignalType = 5, # charged
# BackgroundType = 6 # conversion
ExpectedFlag = ROOT.xAOD.TauJetParameters.classifiedCharged, # charged
SignalType = ROOT.xAOD.TauJetParameters.classifiedCharged, # charged
BackgroundType = ROOT.xAOD.TauJetParameters.classifiedConversion # conversion
)
ToolSvc += _BDT_TTCT_ITFT_0_0
cached_instances[_BDT_TTCT_ITFT_0_0.name] = _BDT_TTCT_ITFT_0_0
_BDT_TTCT_ITFT_0_1 = TrackMVABDT(name = _name + "_0_1",
#InputWeightsPath = "/home/duschi/workspace/TauRec/InstallArea/share/tauRecTools/00-00-00/TMVAClassification_BDT_1.weights.xml",
InputWeightsPath = "tauRecTools/00-00-00/TMVAClassification_BDT_1.weights.xml",
Threshold = 0.0005,
# ExpectedFlag = 7, # isolation
# SignalType = 7, # isolation
# BackgroundType = 8 # fake
ExpectedFlag = ROOT.xAOD.TauJetParameters.classifiedIsolation, # isolation
SignalType = ROOT.xAOD.TauJetParameters.classifiedIsolation, # isolation
BackgroundType = ROOT.xAOD.TauJetParameters.classifiedFake # fake
)
ToolSvc += _BDT_TTCT_ITFT_0_1
cached_instances[_BDT_TTCT_ITFT_0_1.name] = _BDT_TTCT_ITFT_0_1
# create tool alg
myTauTrackClassifier = TauTrackClassifier( name = _name,
Classifiers = [_BDT_TTCT_ITFT_0, _BDT_TTCT_ITFT_0_0, _BDT_TTCT_ITFT_0_1] )
#ToolSvc += TauTrackClassifier #only add to tool service sub tools to your tool, the main tool will be added via TauRecConfigured
cached_instances[_name] = myTauTrackClassifier
return myTauTrackClassifier
""" obsolete methods
#end
""" obsolete methods
########################################################################
# Tau Origin Cell Correction Tool
......
......@@ -83,27 +83,49 @@ class TauRecAODProcessor ( TauRecConfigured ) :
## ATTENTION ##################################################################################
# running these tau tools on AODs will lead to inconsistency with standard tau reconstruction
###############################################################################################
tools.append(taualgs.getMvaTESVariableDecorator())
tools.append(taualgs.getMvaTESEvaluator())
tools.append(taualgs.getCombinedP4FromRecoTaus())
tools.append(taualgs.getIDPileUpCorrection())
# TauDiscriminant:
from tauRec.tauRecFlags import tauFlags
if tauFlags.doRunTauDiscriminant() :
import TauDiscriminant.TauDiscriGetter as tauDisc
tauDiscTools=tauDisc.getTauDiscriminantTools(mlog)
if len(tauDiscTools)==0:
try: import DOESNOTEXIST
except Exception:
mlog.error("No TauDiscriminantTools appended")
print traceback.format_exc()
return False
try :
if InDetFlags.doVertexFinding():
tools.append(taualgs.getTauVertexFinder(doUseTJVA=True))
pass
tools+=tauDiscTools
pass
except : pass
tools.append(taualgs.getTauAxis()) ##needed to set correct variables for energy calibration
#tools.append(taualgs.getTauTrackFinder())
tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
tools.append(taualgs.getTauTrackFilter()) #TauTrackFilter
tools.append(taualgs.getTauGenericPi0Cone()) #TauGenericPi0Cone
# Run the conversion tagger if flagged to do so
import tauRec.TauConversionAlgorithms
from tauRec.tauRecFlags import jobproperties
if jobproperties.tauRecFlags.useNewPIDBasedConvFinder():
tools.append(tauRec.TauConversionAlgorithms.getTauConversionTaggerTool())
else:
#Need to run together, they will select either PID or vertex based on another flag
tools.append(tauRec.TauConversionAlgorithms.getPhotonConversionTool())
tools.append(tauRec.TauConversionAlgorithms.getTauConversionFinderTool())
pass
#this tool cannot recreate a 2nd vertex w/o ESD style tracks
#tools.append(taualgs.getTauVertexVariables())
tools.append(taualgs.getTauCommonCalcVars())
tools.append(taualgs.getTauSubstructure())
tools.append(taualgs.getPi0ClusterScaler()) #TauPi0ClusterScaler
tools.append(taualgs.getPi0ScoreCalculator()) #TauPi0ScoreCalculator
tools.append(taualgs.getPi0Selector()) #TauPi0Selector
tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
tools.append(taualgs.getIDPileUpCorrection())
tools.append(taualgs.getMvaTESVariableDecorator())
tools.append(taualgs.getMvaTESEvaluator())
# for testing purpose
#tools.append(taualgs.getTauTestDump())
TauRecConfigured.AddToolsToToolSvc(self, tools)
self.TauProcessorHandle().Tools = tools
......
......@@ -99,10 +99,14 @@ class TauRecCoreBuilder ( TauRecConfigured ) :
# run vertex finder only in case vertexing is available. This check can also be done in TauAlgorithmsHolder instead doing it here.
from InDetRecExample.InDetJobProperties import InDetFlags
from tauRec.tauRecFlags import jobproperties
doMVATrackClassification = jobproperties.tauRecFlags.tauRecMVATrackClassification()
if InDetFlags.doVertexFinding():
tools.append(taualgs.getTauVertexFinder(doUseTJVA=self.do_TJVA))
tools.append(taualgs.getTauAxis())
tools.append(taualgs.getTauTrackFinder())
tools.append(taualgs.getTauTrackFinder(removeDuplicateTracks=(not doMVATrackClassification) ))
if doMVATrackClassification : tools.append(taualgs.getTauTrackClassifier())
tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
tools.append(taualgs.getCellVariables())
tools.append(taualgs.getElectronVetoVars())
......@@ -273,16 +277,26 @@ class TauRecVariablesProcessor ( TauRecConfigured ) :
# SWITCHED OFF SELECTOR< SINCE NO CHARGED PFOS AVAILABLE ATM
tools.append(taualgs.getPi0Selector())
tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
tools.append(taualgs.getMvaTESVariableDecorator())
tools.append(taualgs.getMvaTESEvaluator())
tools.append(taualgs.getIDPileUpCorrection())
#
## for testing purpose
#tools.append(taualgs.getTauTestDump())
#
# TauDiscriminant:
from tauRec.tauRecFlags import tauFlags
# PanTau:
if tauFlags.doPanTau() :
import PanTauAlgs.JobOptions_Main_PanTau as pantau
tools.append(pantau.getPanTau())
pass
#these tools need pantau info
tools.append(taualgs.getMvaTESVariableDecorator())
tools.append(taualgs.getMvaTESEvaluator())
# TauDiscriminant:
if tauFlags.doRunTauDiscriminant() :
import TauDiscriminant.TauDiscriGetter as tauDisc
tauDiscTools=tauDisc.getTauDiscriminantTools(mlog)
......@@ -295,8 +309,8 @@ class TauRecVariablesProcessor ( TauRecConfigured ) :
pass
tools+=tauDiscTools
pass
tools+=tauFlags.tauRecToolsDevToolListProcessor()
## lock tau containers -> must be the last tau tool!!
#tools.append(taualgs.getContainerLock())
......
......@@ -31,6 +31,13 @@ class doTauRec(JobProperty):
def get_Value(self):
return self.statusOn and self.StoredValue and jobproperties.tauRecFlags.Enabled()
class tauRecMVATrackClassification(JobProperty):
"""Run the MVA Track Classifier
"""
statusOn=True
allowedTypes=['bool']
StoredValue=True
class tauRecSeedMaxEta(JobProperty):
""" max allowed abs_eta of jet seed
"""
......@@ -140,7 +147,7 @@ class tauRecFlags(JobPropertyContainer):
jobproperties.add_Container(tauRecFlags)
# I want always the following flags in the Rec container
_list_tau=[Enabled,doTauRec,tauRecSeedMaxEta,tauRecToolsDevToolList,tauRecToolsDevToolListProcessor,doRunTauDiscriminant,useVertexBasedConvFinder,useNewPIDBasedConvFinder,doPanTau,doPi0,pi0EtCuts,pi0MVACuts_1prong,pi0MVACuts_mprong,shotPtCut_1Photon,shotPtCut_2Photons,useOldVertexFitterAPI]
_list_tau=[Enabled,doTauRec,tauRecMVATrackClassification,tauRecSeedMaxEta,tauRecToolsDevToolList,tauRecToolsDevToolListProcessor,doRunTauDiscriminant,useVertexBasedConvFinder,useNewPIDBasedConvFinder,doPanTau,doPi0,pi0EtCuts,pi0MVACuts_1prong,pi0MVACuts_mprong,shotPtCut_1Photon,shotPtCut_2Photons,useOldVertexFitterAPI]
for j in _list_tau:
jobproperties.tauRecFlags.add_JobProperty(j)
del _list_tau
......
......@@ -35,7 +35,14 @@ TauAODList += [ "xAOD::CaloClusterAuxContainer#TauPi0ClustersAux." ]
# TauRec main xAOD containers
#------------------------------------------------------------------------------
TauAODList += [ "xAOD::TauJetContainer#TauJets" ]
TauAODList += [ "xAOD::TauJetAuxContainer#TauJetsAux.-ABS_ETA_LEAD_TRACK.-CORRCENTFRAC.-CORRFTRK.-EMFRACTIONATEMSCALE_MOVEE3.-HADLEAKET.-NUMTRACK.-TAU_ABSDELTAETA.-TAU_ABSDELTAPHI.-TAU_SEEDTRK_SECMAXSTRIPETOVERPT.-TAU_TRT_NHT_OVER_NLT.-NUMVERTICES" ]
#TauAODList += [ "xAOD::TauJetAuxContainer#TauJetsAux.-ABS_ETA_LEAD_TRACK.-CORRCENTFRAC.-CORRFTRK.-EMFRACTIONATEMSCALE_MOVEE3.-HADLEAKET.-NUMTRACK.-TAU_ABSDELTAETA.-TAU_ABSDELTAPHI.-TAU_SEEDTRK_SECMAXSTRIPETOVERPT.-TAU_TRT_NHT_OVER_NLT.-NUMVERTICES" ]
TauAODList += [ "xAOD::TauJetAuxContainer#TauJetsAux." ]
#------------------------------------------------------------------------------
# TauRec tauTrack xAOD containers
#------------------------------------------------------------------------------
TauAODList += [ "xAOD::TauTrackContainer#TauTracks" ]
TauAODList += [ "xAOD::TauTrackAuxContainer#TauTracksAux." ]
#------------------------------------------------------------------------------
# Secondary Vertex for Tau Decay
......@@ -43,6 +50,12 @@ TauAODList += [ "xAOD::TauJetAuxContainer#TauJetsAux.-ABS_ETA_LEAD_TRACK.-CORRCE
TauAODList += [ "xAOD::VertexContainer#TauSecondaryVertices" ]
TauAODList += [ "xAOD::VertexAuxContainer#TauSecondaryVerticesAux.-vxTrackAtVertex" ]
#------------------------------------------------------------------------------
# Final reconstructed 4-vectors of Pi0s
#------------------------------------------------------------------------------
TauAODList += [ "xAOD::ParticleContainer#finalTauPi0s" ]
TauAODList += [ "xAOD::ParticleAuxContainer#finalTauPi0sAux." ]
#------------------------------------------------------------------------------
# Shot ParticleFlowObjects
#------------------------------------------------------------------------------
......
......@@ -51,13 +51,20 @@ TauESDList += [ "CaloCellContainer#TauCommonPi0Cells" ]
TauESDList += [ "xAOD::TauJetContainer#TauJets" ]
TauESDList += [ "xAOD::TauJetAuxContainer#TauJetsAux." ]
#------------------------------------------------------------------------------
# TauRec tauTrack xAOD containers
#------------------------------------------------------------------------------
TauESDList += [ "xAOD::TauTrackContainer#TauTracks" ]
TauESDList += [ "xAOD::TauTrackAuxContainer#TauTracksAux." ]
#------------------------------------------------------------------------------
# Secondary Vertex for Tau Decay
#------------------------------------------------------------------------------
TauESDList += [ "xAOD::VertexContainer#TauSecondaryVertices" ]
TauESDList += [ "xAOD::VertexAuxContainer#TauSecondaryVerticesAux.-vxTrackAtVertex" ]
TauESDList += [ "xAOD::ParticleContainer#finalTauPi0s" ]
TauESDList += [ "xAOD::ParticleAuxContainer#finalTauPi0sAux." ]
##------------------------------------------------------------------------------
## Tau shot clusters
##------------------------------------------------------------------------------
......
......@@ -38,6 +38,34 @@ if rec.readAOD() :
print traceback.format_exc()
treatException("Could not set up merged tauRec. Switched off !")
if not _tauFail:
# commenting out for now, so we can reactivate possibly later
# call eflowRec in tau mode now
#if recAlgs.doEFlow():
# try:
# include("eflowRec/eflowRec_config_DC14_Tau.py")
# except Exception:
# treatException("could not setup eflowRec")
#jobproperties.tauRecFlags.doPanTau=False
# call PanTau now
# if jobproperties.tauRecFlags.doPanTau():
# try:
# include("PanTauAnalysis/JobOptions_Main_PanTau.py")
# except Exception:
# treatException("Could not setup PanTau")
# jobproperties.tauRecFlags.doPanTau = False
# call TauDiscriminant
if jobproperties.tauRecFlags.doRunTauDiscriminant():
try:
include("TauDiscriminant/TauDiscri_jobOptions.py" )
except Exception:
treatException("Could not set up TauDiscriminant. Switched off !")
# if _tauFail and jobproperties.tauRecFlags.doTauRec():
# jobproperties.tauRecFlags.doTauRec=False
# del _tauFail
else:
if jobproperties.tauRecFlags.doTauRec():
jobproperties.tauRecFlags.doTauRec=False
......
......@@ -49,12 +49,12 @@ if jobproperties.tauRecFlags.doTauRec() and ( rec.readESD() or ( DetFlags.haveR
#jobproperties.tauRecFlags.doPanTau=False
# call PanTau now
if jobproperties.tauRecFlags.doPanTau():
try:
include("PanTauAnalysis/JobOptions_Main_PanTau.py")
except Exception:
treatException("Could not setup PanTau")
jobproperties.tauRecFlags.doPanTau = False
# if jobproperties.tauRecFlags.doPanTau():
# try:
# include("PanTauAnalysis/JobOptions_Main_PanTau.py")
# except Exception:
# treatException("Could not setup PanTau")
# jobproperties.tauRecFlags.doPanTau = False
# call TauDiscriminant
# if jobproperties.tauRecFlags.doRunTauDiscriminant():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment