diff --git a/Event/xAOD/xAODTau/Root/TauTrack_v1.cxx b/Event/xAOD/xAODTau/Root/TauTrack_v1.cxx index 253665627e41915b6f35b6dceb91648d494704e9..24ef62ab567e7e00c5fce891bc346c01ea24be33 100644 --- a/Event/xAOD/xAODTau/Root/TauTrack_v1.cxx +++ b/Event/xAOD/xAODTau/Root/TauTrack_v1.cxx @@ -103,6 +103,7 @@ namespace xAOD { // AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TauTrack_v1, float, rConvII, setRConvII) // AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TauTrack_v1, float, dRJetSeedAxis, setDRJetSeedAxis) + // superseded by z0sinthetaTJVA() float TauTrack_v1::z0sinThetaTJVA(const xAOD::IParticle& part ) const{ const xAOD::TrackParticle* xTrackParticle = this->track(); const xAOD::TauJet* tau = dynamic_cast<const xAOD::TauJet*> (&part); @@ -119,14 +120,32 @@ namespace xAOD { } } - float TauTrack_v1::rConv(const xAOD::IParticle& ) const{ - const xAOD::TrackParticle* xTrackParticle = this->track(); - return std::sqrt(std::fabs(xTrackParticle->d0())*xTrackParticle->pt()/(.3 /*0.15*2.*/)); + static const SG::AuxElement::Accessor< float > d0TJVAAcc( "d0TJVA" ); + float TauTrack_v1::d0TJVA() const { + return d0TJVAAcc(*this); } - float TauTrack_v1::rConvII(const xAOD::IParticle& ) const{ - const xAOD::TrackParticle* xTrackParticle = this->track(); - return std::sqrt( std::fabs( xTrackParticle->d0() * xTrackParticle->pt() ) / (0.3) )*(xTrackParticle->d0()/fabs(xTrackParticle->d0()))*xTrackParticle->charge(); + static const SG::AuxElement::Accessor< float > d0SigTJVAAcc( "d0SigTJVA" ); + float TauTrack_v1::d0SigTJVA() const { + return d0SigTJVAAcc(*this); + } + + static const SG::AuxElement::Accessor< float > z0sinthetaTJVAAcc( "z0sinthetaTJVA" ); + float TauTrack_v1::z0sinthetaTJVA() const { + return z0sinthetaTJVAAcc(*this); + } + + static const SG::AuxElement::Accessor< float > z0sinthetaSigTJVAAcc( "z0sinthetaSigTJVA" ); + float TauTrack_v1::z0sinthetaSigTJVA() const { + return z0sinthetaSigTJVAAcc(*this); + } + + float TauTrack_v1::rConv() const{ + return std::sqrt(std::fabs(this->d0TJVA())*this->pt()/(0.3 /*0.15*2.*/)); + } + + float TauTrack_v1::rConvII() const{ + return std::sqrt( std::fabs( this->d0TJVA() * this->pt() ) / (0.3) )*(this->d0TJVA()/fabs(this->d0TJVA()))*this->track()->charge(); } float TauTrack_v1::dRJetSeedAxis(const xAOD::IParticle& part) const{ diff --git a/Event/xAOD/xAODTau/xAODTau/versions/TauTrack_v1.h b/Event/xAOD/xAODTau/xAODTau/versions/TauTrack_v1.h index fe831abb9c9f4693307eef4485c8876c1c739f26..b197f37ae760d613adc383446569b4d50d2162f9 100644 --- a/Event/xAOD/xAODTau/xAODTau/versions/TauTrack_v1.h +++ b/Event/xAOD/xAODTau/xAODTau/versions/TauTrack_v1.h @@ -1,7 +1,5 @@ -// Dear emacs, this is -*- c++ -*- - /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef XAODTAU_VERSIONS_TAUTRACK_V1_H @@ -67,9 +65,16 @@ namespace xAOD { // additional bdt input variables float z0sinThetaTJVA(const xAOD::IParticle&) const; // void setZ0sinThetaTJVA(float z0sinThetaTJVA); - float rConv(const xAOD::IParticle&) const; + + // track IP w.r.t. TJVA vertex + float d0TJVA() const; + float d0SigTJVA() const; + float z0sinthetaTJVA() const; + float z0sinthetaSigTJVA() const; + + float rConv() const; // void setRConv(float rConv); - float rConvII(const xAOD::IParticle&) const; + float rConvII() const; // void setRConvII(float rConvII); float dRJetSeedAxis(const xAOD::IParticle&) const; // void setDRJetSeedAxis(float dRJetSeedAxis); diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py index bd7199b0e90289eca4f5636468e592cf2ea70016..080de883f7f8e4aa29fa7a48b4d2a22f8ceb40e1 100644 --- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py +++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py @@ -291,7 +291,6 @@ def getTauVertexVariables(): from tauRecTools.tauRecToolsConf import TauVertexVariables TauVertexVariables = TauVertexVariables( name = _name, - TrackToVertexIPEstimator = getTauTrackToVertexIPEstimator(), VertexFitter = getTauAdaptiveVertexFitter(), SeedFinder = getTauCrossDistancesSeedFinder(), ) @@ -665,6 +664,7 @@ def getTauTrackFinder(removeDuplicateTracks=True): tauParticleCache = getParticleCache(), removeDuplicateCoreTracks = removeDuplicateTracks, Key_trackPartInputContainer = _DefaultTrackContainer, + TrackToVertexIPEstimator = getTauTrackToVertexIPEstimator(), #maxDeltaZ0wrtLeadTrk = 2, #in mm #removeTracksOutsideZ0wrtLeadTrk = True ) diff --git a/Reconstruction/tauRec/python/TauRecRunConfigured.py b/Reconstruction/tauRec/python/TauRecRunConfigured.py index e43f0143ed5f00a3a28c82719d743c729bcb3f99..1112fdd4f3ecf35d9537fa341a6ee916e7b8001a 100644 --- a/Reconstruction/tauRec/python/TauRecRunConfigured.py +++ b/Reconstruction/tauRec/python/TauRecRunConfigured.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration ################################################################################ ## @@ -57,13 +57,8 @@ class TauRecRunConfigured ( Configured ) : from AthenaCommon.AppMgr import ToolSvc from tauRec.tauRecFlags import tauFlags for tool in tools : - # if tool.__slots__['calibFolder'].count('TauDiscriminant'): - # tool.calibFolder = tauFlags.TauDiscriminantCVMFSPath() - # else : - # tool.calibFolder = tauFlags.tauRecToolsCVMFSPath() tool.calibFolder = tauFlags.tauRecToolsCVMFSPath() if tool not in ToolSvc : ToolSvc += tool - pass def TauRunnerAlgHandle(self): return self._TauRunnerAlgHandle diff --git a/Reconstruction/tauRec/python/TauRecRunner.py b/Reconstruction/tauRec/python/TauRecRunner.py index 42613a673f93231b430ff386d9576abe8a37ece2..45af59f4640d5af97b29cdcc4189e69ed2828777 100644 --- a/Reconstruction/tauRec/python/TauRecRunner.py +++ b/Reconstruction/tauRec/python/TauRecRunner.py @@ -42,10 +42,9 @@ class TauRecRunner ( TauRecRunConfigured ) : _output = { _outputType:_outputKey , _outputAuxType:_outputAuxKey } - def __init__(self, name = "TauRecRunner",doPi0Clus=False, doTJVA=False): + def __init__(self, name = "TauRecRunner",doPi0Clus=False): self.name = name self.doPi0Clus = doPi0Clus - self.do_TJVA = doTJVA # not used in the TauRecRunner? TauRecRunConfigured.__init__(self, name) diff --git a/Reconstruction/tauRec/share/tauRec_jobOptions.py b/Reconstruction/tauRec/share/tauRec_jobOptions.py index 7523c60066c9d03320841f9c11780d5c344b6468..fb791607f514c928a4f89c303f29893d198eb1fc 100644 --- a/Reconstruction/tauRec/share/tauRec_jobOptions.py +++ b/Reconstruction/tauRec/share/tauRec_jobOptions.py @@ -27,4 +27,4 @@ if _doPi0Clus: include("tauRec/Pi0ClusterMaker_jobOptions.py") from tauRec.TauRecRunner import TauRecRunner -TauRecRunner(doPi0Clus=_doPi0Clus, doTJVA=_doTJVA) +TauRecRunner(doPi0Clus=_doPi0Clus) diff --git a/Reconstruction/tauRec/src/TauProcessorAlg.cxx b/Reconstruction/tauRec/src/TauProcessorAlg.cxx index 3d7d313906c4dacb1fec5a8f9cb3a2dfca46fdfb..717b5996e3dd242c13b317fb99784f1c00b4cefd 100644 --- a/Reconstruction/tauRec/src/TauProcessorAlg.cxx +++ b/Reconstruction/tauRec/src/TauProcessorAlg.cxx @@ -7,7 +7,6 @@ #include "xAODJet/Jet.h" #include "xAODJet/JetContainer.h" -#include "xAODTau/TauJetContainer.h" #include "xAODTau/TauJetAuxContainer.h" #include "xAODTau/TauDefs.h" #include "xAODTau/TauTrackContainer.h" @@ -17,7 +16,6 @@ #include "StoreGate/ReadHandle.h" #include "StoreGate/WriteHandle.h" -#include "CaloInterface/ICaloCellMakerTool.h" #include "NavFourMom/INavigable4MomentumCollection.h" using Gaudi::Units::GeV; diff --git a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx index 1c6e8997e49690e65c71567650bfd72241c504e6..b2606be19621dc043ebb987a7cfcb939ab2e9e1c 100644 --- a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx +++ b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx @@ -35,10 +35,8 @@ StatusCode TauIDVarCalculator::initialize() StatusCode TauIDVarCalculator::execute(xAOD::TauJet& tau) const { static const SG::AuxElement::Accessor<float> acc_absipSigLeadTrk("absipSigLeadTrk"); - float ipSigLeadTrk=0.; - if(!tau.detail(xAOD::TauJetParameters::ipSigLeadTrk, ipSigLeadTrk)) - return StatusCode::FAILURE; - acc_absipSigLeadTrk(tau) = std::abs(ipSigLeadTrk); + + acc_absipSigLeadTrk(tau) = (tau.nTracks()>0) ? std::abs(tau.track(0)->d0SigTJVA()) : 0.; if(inTrigger()) return StatusCode::SUCCESS; diff --git a/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx b/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx index 2e3737ceb981fcbdde700356accde7d38ade26bc..5418e2a5db42b42019b6e1447df5de3225d5b738 100644 --- a/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx +++ b/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx @@ -187,10 +187,9 @@ bool innerTrkAvgDist(const xAOD::TauJet &tau, double &out) { } bool absipSigLeadTrk(const xAOD::TauJet &tau, double &out) { - float ipSigLeadTrk; - const auto success = tau.detail(TauDetail::ipSigLeadTrk, ipSigLeadTrk); - out = std::min(TMath::Abs(ipSigLeadTrk), 30.0f); - return success; + float ipSigLeadTrk = (tau.nTracks()>0) ? tau.track(0)->d0SigTJVA() : 0.; + out = std::min(std::abs(ipSigLeadTrk), 30.0f); + return true; } bool SumPtTrkFrac(const xAOD::TauJet &tau, double &out) { @@ -360,13 +359,13 @@ bool pt_jetseed_log(const xAOD::TauJet &tau, const xAOD::TauTrack& /*track*/, bool d0_abs_log(const xAOD::TauJet& /*tau*/, const xAOD::TauTrack &track, double &out) { - out = std::log10(TMath::Abs(track.track()->d0()) + 1e-6); + out = std::log10(TMath::Abs(track.d0TJVA()) + 1e-6); return true; } -bool z0sinThetaTJVA_abs_log(const xAOD::TauJet& tau, const xAOD::TauTrack &track, +bool z0sinThetaTJVA_abs_log(const xAOD::TauJet& /*tau*/, const xAOD::TauTrack &track, double &out) { - out = std::log10(TMath::Abs(track.z0sinThetaTJVA(tau)) + 1e-6); + out = std::log10(TMath::Abs(track.z0sinthetaTJVA()) + 1e-6); return true; } @@ -496,7 +495,7 @@ bool CENTER_LAMBDA(const xAOD::TauJet& /*tau*/, const xAOD::CaloCluster &cluster return success; } -bool SECOND_LAMBDAOverClustersMeanSecondLambda (const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out){ +bool SECOND_LAMBDAOverClustersMeanSecondLambda(const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out) { float ClustersMeanSecondLambda = tau.auxdata<float>("ClustersMeanSecondLambda"); double secondLambda(0); @@ -507,7 +506,7 @@ bool SECOND_LAMBDAOverClustersMeanSecondLambda (const xAOD::TauJet &tau, const return success; } -bool CENTER_LAMBDAOverClustersMeanCenterLambda (const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out){ +bool CENTER_LAMBDAOverClustersMeanCenterLambda(const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out) { float ClustersMeanCenterLambda = tau.auxdata<float>("ClustersMeanCenterLambda"); double centerLambda(0); @@ -524,7 +523,7 @@ bool CENTER_LAMBDAOverClustersMeanCenterLambda (const xAOD::TauJet &tau, const } -bool FirstEngDensOverClustersMeanFirstEngDens (const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out){ +bool FirstEngDensOverClustersMeanFirstEngDens(const xAOD::TauJet &tau, const xAOD::CaloCluster &cluster, double &out) { // the ClustersMeanFirstEngDens is the log10 of the energy weighted average of the First_ENG_DENS // divided by ETot to make it dimension-less, // so we need to evaluate the differance of log10(clusterFirstEngDens/clusterTotalEnergy) and the ClustersMeanFirstEngDens diff --git a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx index d669aabd04fa6695c9deea0a0e6180e28b20efa4..f320f1f94a764c0769bfe4cafe43bd7455d0373e 100644 --- a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx +++ b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx @@ -81,7 +81,6 @@ StatusCode TauTrackClassifier::executeTrackClassifier(xAOD::TauJet& xTau, xAOD:: } xTau.setDetail(xAOD::TauJetParameters::nModifiedIsolationTracks, (int) xTau.nTracks(xAOD::TauJetParameters::modifiedIsolationTrack)); - return StatusCode::SUCCESS; } @@ -198,14 +197,14 @@ StatusCode TrackMVABDT::calculateVariables(const xAOD::TauTrack& xTrack, const x valueMap["TracksAuxDyn.jetSeedPt"] = xTau.ptJetSeed(); valueMap["TracksAuxDyn.tauPt"] = xTau.ptIntermediateAxis(); valueMap["TracksAuxDyn.tauEta"] = xTau.etaIntermediateAxis(); - valueMap["TracksAuxDyn.z0sinThetaTJVA"] = xTrack.z0sinThetaTJVA(xTau); - valueMap["TracksAuxDyn.rConv"] = xTrack.rConv(xTau); - valueMap["TracksAuxDyn.rConvII"] = xTrack.rConvII(xTau); - valueMap["TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII"] = xTrack.rConv(xTau)/xTrack.rConvII(xTau); + valueMap["TracksAuxDyn.z0sinThetaTJVA"] = xTrack.z0sinthetaTJVA(); + valueMap["TracksAuxDyn.rConv"] = xTrack.rConv(); + valueMap["TracksAuxDyn.rConvII"] = xTrack.rConvII(); + valueMap["TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII"] = xTrack.rConv()/xTrack.rConvII(); valueMap["TracksAuxDyn.DRJetSeedAxis"] = xTrack.dRJetSeedAxis(xTau); valueMap["TracksAuxDyn.dRJetSeedAxis"] = xTrack.dRJetSeedAxis(xTau); valueMap["TracksAuxDyn.trackEta"] = xTrackParticle->eta(); - valueMap["TracksAux.d0"] = xTrackParticle->d0(); + valueMap["TracksAux.d0"] = xTrack.d0TJVA(); valueMap["TracksAux.qOverP"] = xTrackParticle->qOverP(); valueMap["TracksAux.theta"] = xTrackParticle->theta(); valueMap["TracksAux.eProbabilityHT"] = fTracksEProbabilityHT; @@ -224,13 +223,13 @@ StatusCode TrackMVABDT::calculateVariables(const xAOD::TauTrack& xTrack, const x valueMap["TauTracksAuxDyn.jetSeedPt"] = xTau.ptJetSeed(); valueMap["TauTracksAuxDyn.tauPt"] = xTau.ptIntermediateAxis(); valueMap["TauTracksAuxDyn.tauEta"] = xTau.etaIntermediateAxis(); - valueMap["TauTracksAuxDyn.z0sinThetaTJVA"] = xTrack.z0sinThetaTJVA(xTau); - valueMap["TauTracksAuxDyn.rConv"] = xTrack.rConv(xTau); - valueMap["TauTracksAuxDyn.rConvII"] = xTrack.rConvII(xTau); - valueMap["TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII"] = xTrack.rConv(xTau)/xTrack.rConvII(xTau); + valueMap["TauTracksAuxDyn.z0sinThetaTJVA"] = xTrack.z0sinthetaTJVA(); + valueMap["TauTracksAuxDyn.rConv"] = xTrack.rConv(); + valueMap["TauTracksAuxDyn.rConvII"] = xTrack.rConvII(); + valueMap["TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII"] = xTrack.rConv()/xTrack.rConvII(); valueMap["TauTracksAuxDyn.dRJetSeedAxis"] = xTrack.dRJetSeedAxis(xTau); valueMap["TauTracksAuxDyn.trackEta"] = xTrackParticle->eta(); - valueMap["TauTracksAuxDyn.d0"] = xTrackParticle->d0(); + valueMap["TauTracksAuxDyn.d0"] = xTrack.d0TJVA(); valueMap["TauTracksAuxDyn.qOverP"] = xTrackParticle->qOverP(); valueMap["TauTracksAuxDyn.theta"] = xTrackParticle->theta(); valueMap["TauTracksAuxDyn.eProbabilityHT"] = fTracksEProbabilityHT; diff --git a/Reconstruction/tauRecTools/Root/TauTrackRNNClassifier.cxx b/Reconstruction/tauRecTools/Root/TauTrackRNNClassifier.cxx index 71b34dc43e82131b42d9f4264c24e79f73ec576c..d779e8d230dedf83747954545f10c70fb0dcd53c 100644 --- a/Reconstruction/tauRecTools/Root/TauTrackRNNClassifier.cxx +++ b/Reconstruction/tauRecTools/Root/TauTrackRNNClassifier.cxx @@ -272,11 +272,11 @@ StatusCode TrackRNN::calulateVars(const std::vector<xAOD::TauTrack*>& vTracks, c double fTrackPt = xTrackParticle->pt(); double fTrackEta = xTrackParticle->eta(); double fTrackCharge = xTrackParticle->charge(); - double fZ0SinthetaTJVA = xTrack->z0sinThetaTJVA(xTau); - double fRConv = xTrack->rConv(xTau); - double fRConvII = xTrack->rConvII(xTau); + double fZ0SinthetaTJVA = xTrack->z0sinthetaTJVA(); + double fRConv = xTrack->rConv(); + double fRConvII = xTrack->rConvII(); double fDRJetSeedAxis = xTrack->dRJetSeedAxis(xTau); - double fD0 = xTrackParticle->d0(); + double fD0 = xTrack->d0TJVA(); double fQoverP = xTrackParticle->qOverP(); uint8_t iTracksNumberOfInnermostPixelLayerHits = 0; ATH_CHECK( xTrackParticle->summaryValue(iTracksNumberOfInnermostPixelLayerHits, xAOD::numberOfInnermostPixelLayerHits) ); @@ -306,7 +306,7 @@ StatusCode TrackRNN::calulateVars(const std::vector<xAOD::TauTrack*>& vTracks, c valueMap["log(rConv)"][i] = std::log(fRConv); valueMap["tanh(rConvII/500)"][i] = std::tanh(fRConvII/500.0); valueMap["dRJetSeedAxis"][i] = fDRJetSeedAxis; - valueMap["tanh(d0/10)"][i] = std::tanh(fD0/10); + valueMap["tanh(d0/10)"][i] = std::tanh(fD0/10.); valueMap["qOverP*1000"][i] = fQoverP*1000.0; valueMap["numberOfInnermostPixelLayerHits"][i] = (float) iTracksNumberOfInnermostPixelLayerHits; valueMap["numberOfPixelSharedHits"][i] = (float) iTracksNPixelSharedHits; diff --git a/Reconstruction/tauRecTools/src/TauTrackFinder.cxx b/Reconstruction/tauRecTools/src/TauTrackFinder.cxx index 7819dcef8aa05844bcb2feec8e85f9c9bd08eeb5..829ba59ab80c080cb78c031304f04e4b2951e69e 100644 --- a/Reconstruction/tauRecTools/src/TauTrackFinder.cxx +++ b/Reconstruction/tauRecTools/src/TauTrackFinder.cxx @@ -30,13 +30,18 @@ StatusCode TauTrackFinder::initialize() { ATH_CHECK( m_trackSelectorTool_tau.retrieve() ); ATH_CHECK( m_trackToVertexTool.retrieve() ); ATH_CHECK( m_caloExtensionTool.retrieve() ); - + ATH_CHECK( m_trackToVertexIPEstimator.retrieve() ); + // initialize ReadHandleKey // allow empty for trigger ATH_CHECK( m_trackPartInputContainer.initialize(SG::AllowEmpty) ); // use CaloExtensionTool when key is empty ATH_CHECK( m_ParticleCacheKey.initialize(SG::AllowEmpty) ); + if (inTrigger()) { + ATH_CHECK(m_beamSpotKey.initialize()); + } + return StatusCode::SUCCESS; } @@ -198,6 +203,53 @@ StatusCode TauTrackFinder::executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrack ATH_MSG_DEBUG("numTrack: " << "/" << pTau.nTracks()); ATH_MSG_DEBUG("charge: " << "/" << pTau.charge()); + // impact parameter variables w.r.t. tau vertex + const xAOD::Vertex* vxcand = nullptr; + + xAOD::Vertex theBeamspot; + theBeamspot.makePrivateStore(); + + if (inTrigger()) { // online: use beamspot + SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; + if(beamSpotHandle.isValid()) { + theBeamspot.setPosition(beamSpotHandle->beamPos()); + const auto& cov = beamSpotHandle->beamVtx().covariancePosition(); + theBeamspot.setCovariancePosition(cov); + vxcand = &theBeamspot; + } + else { + ATH_MSG_DEBUG("No Beamspot object in tau candidate"); + } + } + else if (pTau.vertexLink().isValid() && pTau.vertex()->vertexType() != xAOD::VxType::NoVtx) { + vxcand = pTau.vertex(); + } + + static const SG::AuxElement::Decorator<float> dec_d0TJVA("d0TJVA"); + static const SG::AuxElement::Decorator<float> dec_z0sinthetaTJVA("z0sinthetaTJVA"); + static const SG::AuxElement::Decorator<float> dec_d0SigTJVA("d0SigTJVA"); + static const SG::AuxElement::Decorator<float> dec_z0sinthetaSigTJVA("z0sinthetaSigTJVA"); + + for(auto track : pTau.allTracks()) { + dec_d0TJVA(*track) = track->track()->d0(); + dec_z0sinthetaTJVA(*track) = track->z0sinThetaTJVA(pTau); + dec_d0SigTJVA(*track) = -999.; + dec_z0sinthetaSigTJVA(*track) = -999.; + + // in the trigger, z0sintheta and corresponding significance are meaningless if we use the beamspot + if(vxcand) { + std::unique_ptr<const Trk::ImpactParametersAndSigma> myIPandSigma + = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(track->track(), vxcand)); + + if(myIPandSigma) { + dec_d0TJVA(*track) = myIPandSigma->IPd0; + dec_z0sinthetaTJVA(*track) = myIPandSigma->IPz0SinTheta; + dec_d0SigTJVA(*track) = (myIPandSigma->sigmad0 != 0.) ? (float)( myIPandSigma->IPd0 / myIPandSigma->sigmad0 ) : -999.; + dec_z0sinthetaSigTJVA(*track) = (myIPandSigma->sigmaz0SinTheta != 0.) ? (float)( myIPandSigma->IPz0SinTheta / myIPandSigma->sigmaz0SinTheta ) : -999.; + } + } + } + // extrapolate core tracks to calorimeter surface // store information only in ExtraDetailsContainer if(!m_bypassExtrapolator) diff --git a/Reconstruction/tauRecTools/src/TauTrackFinder.h b/Reconstruction/tauRecTools/src/TauTrackFinder.h index 42888b9073833d5985a4689dedb7aa273e40fade..0850ce3b5f3ab278801a985f1abd963ed0957e79 100644 --- a/Reconstruction/tauRecTools/src/TauTrackFinder.h +++ b/Reconstruction/tauRecTools/src/TauTrackFinder.h @@ -16,11 +16,11 @@ #include "xAODTracking/TrackParticle.h" #include "xAODTracking/TrackParticleContainer.h" -#include "VxVertex/RecVertex.h" - #include "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" #include "TrkToolInterfaces/ITrackSelectorTool.h" #include "RecoToolInterfaces/IParticleCaloExtensionTool.h" +#include "TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h" +#include "BeamSpotConditionsData/BeamSpotData.h" ///////////////////////////////////////////////////////////////////////////// @@ -95,23 +95,22 @@ private: ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtensionTool {this, "ParticleCaloExtensionTool", "Trk::ParticleCaloExtensionTool/ParticleCaloExtensionTool", "Tool for the extrapolation of charged tracks"}; ToolHandle<Trk::ITrackSelectorTool> m_trackSelectorTool_tau {this, "TrackSelectorToolTau", "", "Tool for track selection"}; ToolHandle<Reco::ITrackToVertex> m_trackToVertexTool {this, "TrackToVertexTool", "Reco::TrackToVertex"}; - //output particle calo extension collection - SG::ReadHandleKey<CaloExtensionCollection> m_ParticleCacheKey{this, - "tauParticleCache", "ParticleCaloExtension", "Name of the particle measurement extrapolation cache for TauTrackFinder"}; + ToolHandle<Trk::ITrackToVertexIPEstimator> m_trackToVertexIPEstimator {this, "TrackToVertexIPEstimator", ""}; Gaudi::Property<double> m_maxJetDr_tau {this, "MaxJetDrTau", 0.2}; - Gaudi::Property<double> m_maxJetDr_wide {this, "MaxJetDrWide", 0.4}; - + Gaudi::Property<double> m_maxJetDr_wide {this, "MaxJetDrWide", 0.4}; Gaudi::Property<bool> m_applyZ0cut {this, "removeTracksOutsideZ0wrtLeadTrk", false}; - Gaudi::Property<float> m_z0maxDelta {this, "maxDeltaZ0wrtLeadTrk", 1000}; - + Gaudi::Property<float> m_z0maxDelta {this, "maxDeltaZ0wrtLeadTrk", 1000}; Gaudi::Property<bool> m_storeInOtherTrks {this, "StoreRemovedCoreWideTracksInOtherTracks", true}; Gaudi::Property<bool> m_removeDuplicateCoreTracks {this, "removeDuplicateCoreTracks", true}; Gaudi::Property<bool> m_bypassSelector {this, "BypassSelector", false}; Gaudi::Property<bool> m_bypassExtrapolator {this, "BypassExtrapolator", false}; SG::ReadHandleKey<xAOD::TrackParticleContainer> m_trackPartInputContainer{this,"Key_trackPartInputContainer", "InDetTrackParticles", "input track particle container key"}; + SG::ReadHandleKey<CaloExtensionCollection> m_ParticleCacheKey{this,"tauParticleCache", "ParticleCaloExtension", "Name of the particle measurement extrapolation cache for TauTrackFinder"}; + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; + std::set<CaloSampling::CaloSample> m_EMSamplings; std::set<CaloSampling::CaloSample> m_HadSamplings; }; diff --git a/Reconstruction/tauRecTools/src/TauVertexVariables.cxx b/Reconstruction/tauRecTools/src/TauVertexVariables.cxx index b8ce1f397581e49384995debcfcd836857929a7f..5af776c5628a26c60d9132f9b4969193806c65ba 100644 --- a/Reconstruction/tauRecTools/src/TauVertexVariables.cxx +++ b/Reconstruction/tauRecTools/src/TauVertexVariables.cxx @@ -35,14 +35,9 @@ TauVertexVariables::~TauVertexVariables() { StatusCode TauVertexVariables::initialize() { - ATH_CHECK( m_trackToVertexIPEstimator.retrieve() ); ATH_CHECK( m_fitTool.retrieve() ); ATH_CHECK( m_SeedFinder.retrieve() ); - if (inTrigger()) { - ATH_CHECK(m_beamSpotKey.initialize()); - } - return StatusCode::SUCCESS; } @@ -51,76 +46,6 @@ StatusCode TauVertexVariables::initialize() { //----------------------------------------------------------------------------- StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD::VertexContainer& pSecVtxContainer) const { - // impact parameter variables for standard tracks - if (pTau.nTracks() > 0) { - - std::unique_ptr<const Trk::ImpactParametersAndSigma> myIPandSigma; - const xAOD::Vertex* vxcand = nullptr; - - xAOD::Vertex theBeamspot; - theBeamspot.makePrivateStore(); - - if (inTrigger()) { // online: use beamspot - SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey }; - if(beamSpotHandle.isValid()){ - theBeamspot.setPosition(beamSpotHandle->beamPos()); - const auto& cov = beamSpotHandle->beamVtx().covariancePosition(); - theBeamspot.setCovariancePosition(cov); - vxcand = &theBeamspot; - - myIPandSigma = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(pTau.track(0)->track(), vxcand)); - } - else { - ATH_MSG_DEBUG("No Beamspot object in tau candidate"); - } - } - else if (pTau.vertexLink().isValid()) { // offline: obtain tau vertex by link - vxcand = pTau.vertex() ; - //check if vertex has a valid type (skip if vertex has type NoVtx) - if (vxcand->vertexType() != xAOD::VxType::NoVtx) { - myIPandSigma = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(pTau.track(0)->track(), vxcand)); - } - } - - if (myIPandSigma) { - // kept for now, but will be discontinued as we now store these for all tracks, not only the leading one - pTau.setDetail(xAOD::TauJetParameters::ipSigLeadTrk, (float)( myIPandSigma->IPd0 / myIPandSigma->sigmad0 )); - pTau.setDetail(xAOD::TauJetParameters::ipZ0SinThetaSigLeadTrk, (float)( myIPandSigma->IPz0SinTheta / myIPandSigma->sigmaz0SinTheta )); - } - else { - ATH_MSG_DEBUG("trackToVertexIPestimator failed for a standard track!"); - pTau.setDetail(xAOD::TauJetParameters::ipSigLeadTrk, (float)(-999.)); - pTau.setDetail(xAOD::TauJetParameters::ipZ0SinThetaSigLeadTrk, (float)(-999.)); - } - - // in the trigger, z0sintheta IP and corresponding significance are meaningless if we use the beamspot - if(vxcand && (inTrigger() || (!inTrigger() && vxcand->vertexType() != xAOD::VxType::NoVtx))) { - static const SG::AuxElement::Decorator<float> dec_d0_TV("d0_TV"); - static const SG::AuxElement::Decorator<float> dec_z0sintheta_TV("z0sintheta_TV"); - static const SG::AuxElement::Decorator<float> dec_d0_sig_TV("d0_sig_TV"); - static const SG::AuxElement::Decorator<float> dec_z0sintheta_sig_TV("z0sintheta_sig_TV"); - - for(auto track : pTau.allTracks()) { - myIPandSigma = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(track->track(), vxcand)); - if(myIPandSigma) { - dec_d0_TV(*track) = myIPandSigma->IPd0; - dec_z0sintheta_TV(*track) = myIPandSigma->IPz0SinTheta; - dec_d0_sig_TV(*track) = (myIPandSigma->sigmad0 != 0.) ? (float)( myIPandSigma->IPd0 / myIPandSigma->sigmad0 ) : -999.; - dec_z0sintheta_sig_TV(*track) = (myIPandSigma->sigmaz0SinTheta != 0.) ? (float)( myIPandSigma->IPz0SinTheta / myIPandSigma->sigmaz0SinTheta ) : -999.; - } - else { - dec_d0_TV(*track) = -999.; - dec_z0sintheta_TV(*track) = -999.; - dec_d0_sig_TV(*track) = -999.; - dec_z0sintheta_sig_TV(*track) = -999.; - } - } - } - } - else { - ATH_MSG_DEBUG("Tau has no tracks"); - } - pTau.setDetail(xAOD::TauJetParameters::trFlightPathSig, (float)(-1111.)); // try to find secondary vertex if more than 1 track and the tau vertex is available @@ -135,20 +60,15 @@ StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD:: // reconstruction from xAOD uses Trk::TrackParameters (Trk::Track not available) std::vector<const Trk::TrackParameters*> origTrackParameters; - for (unsigned i = 0; i < pTau.nTracks(); ++i) { - xaodTracks.push_back(pTau.track(i)->track()); - - if (pTau.track(i)->track()) { - if(pTau.track(i)->track()->track()) { - origTracks.push_back(pTau.track(i)->track()->track()); - } - else { - const Trk::Perigee& perigee = pTau.track(i)->track()->perigeeParameters(); - origTrackParameters.push_back(static_cast<const Trk::TrackParameters*>(&perigee)); - } + for (const xAOD::TauTrack* track : pTau.tracks()) { + xaodTracks.push_back(track->track()); + + if(track->track()->track()) { + origTracks.push_back(track->track()->track()); } else { - ATH_MSG_WARNING("No TrackParticle found."); + const Trk::Perigee& perigee = track->track()->perigeeParameters(); + origTrackParameters.push_back(static_cast<const Trk::TrackParameters*>(&perigee)); } } diff --git a/Reconstruction/tauRecTools/src/TauVertexVariables.h b/Reconstruction/tauRecTools/src/TauVertexVariables.h index a54aadb3ad39dbc09b47520b8099d5bb1a7e97c7..469cee574aa4d71b3ec641e2633ae9c6c39a6919 100644 --- a/Reconstruction/tauRecTools/src/TauVertexVariables.h +++ b/Reconstruction/tauRecTools/src/TauVertexVariables.h @@ -10,8 +10,6 @@ #include "tauRecTools/TauRecToolBase.h" #include "GaudiKernel/ToolHandle.h" -#include "BeamSpotConditionsData/BeamSpotData.h" -#include "TrkVertexFitterInterfaces/ITrackToVertexIPEstimator.h" #include "TrkVertexFitterInterfaces/IVertexFitter.h" #include "TrkVertexFitterInterfaces/IVertexSeedFinder.h" @@ -41,11 +39,8 @@ public: double trFlightPathSig(const xAOD::TauJet& pTau, const xAOD::Vertex& secVertex) const; private: - ToolHandle<Trk::ITrackToVertexIPEstimator> m_trackToVertexIPEstimator {this, "TrackToVertexIPEstimator", ""}; ToolHandle<Trk::IVertexFitter> m_fitTool {this, "VertexFitter", "Trk::AdaptiveVertexFitter"}; ToolHandle<Trk::IVertexSeedFinder> m_SeedFinder {this, "SeedFinder", "Trk::CrossDistancesSeedFinder"}; - - SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; }; #endif /* TAUREC_TAUVERTEXVARIABLES_H */ diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py index 322a14c5c333671cbbbdafd80668ddd9babb9e44..551d1853df1860e15f6f9708e7205047783043e2 100644 --- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py +++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py @@ -364,7 +364,6 @@ def getTauVertexVariables(): from tauRecTools.tauRecToolsConf import TauVertexVariables TauVertexVariables = TauVertexVariables( name = _name, - TrackToVertexIPEstimator = getTauTrackToVertexIPEstimator(), VertexFitter = getTauAdaptiveVertexFitter(), SeedFinder = getTauCrossDistancesSeedFinder(), ) @@ -708,7 +707,8 @@ def getTauTrackFinder(applyZ0cut=False, maxDeltaZ0=2, noSelector = False, prefix removeTracksOutsideZ0wrtLeadTrk = applyZ0cut, ParticleCaloExtensionTool = getParticleCaloExtensionTool(), BypassSelector = noSelector, - BypassExtrapolator = True + BypassExtrapolator = True, + TrackToVertexIPEstimator = getTauTrackToVertexIPEstimator() ) # Selector not needed for fast-tracks # Extrapolator never needed