Commit dc1969b8 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

InDetConversionSelector : Remove un-needed TrackSummary Tool, Make...

InDetConversionSelector : Remove un-needed TrackSummary Tool, Make Extrapolator Private, update configs
parent 3f4ed5fa
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
......@@ -17,7 +17,6 @@ class ConfiguredSecVertexFinding:
TrackParticles=None,
SecVertices=None,
Extrapolator=None,
TrackSummaryTool=None,
MagFieldSvc=None,
printConfig=False):
......@@ -43,7 +42,6 @@ class ConfiguredSecVertexFinding:
FirstMeasuredPointLimit=VertexCuts.FirstMeasuredPointLimit(),
usePhiCnst=VertexCuts.usePhiCnst(),
useThetaCnst=VertexCuts.useThetaCnst())
ToolSvc += InDetSecVxFitterTool
if (printConfig):
print(InDetSecVxFitterTool)
#
......@@ -63,7 +61,6 @@ class ConfiguredSecVertexFinding:
InDet__ConversionFinderUtils)
InDetSecVxHelper = InDet__ConversionFinderUtils(
name=prefix+"FinderUtils")
ToolSvc += InDetSecVxHelper
if (printConfig):
print(InDetSecVxHelper)
#
......@@ -73,7 +70,6 @@ class ConfiguredSecVertexFinding:
InDet__InDetConversionTrackSelectorTool)
InDetSecVxTrackSelector = InDet__InDetConversionTrackSelectorTool(
name=prefix+"TrackSelector",
TrackSummaryTool=TrackSummaryTool,
Extrapolator=Extrapolator,
maxSiD0=VertexCuts.TrkSel_maxSiD0(),
maxTrtD0=VertexCuts.TrkSel_maxTrtD0(),
......@@ -88,7 +84,6 @@ class ConfiguredSecVertexFinding:
significanceD0_Si=VertexCuts.TrkSel_significanceD0_Si(),
RatioV0=VertexCuts.TrkSel_RatioV0())
ToolSvc += InDetSecVxTrackSelector
if (printConfig):
print(InDetSecVxTrackSelector)
#
......@@ -105,7 +100,6 @@ class ConfiguredSecVertexFinding:
MaxEta=VertexCuts.TrkPairSel_MaxEta(),
MaxInitDistance=VertexCuts.TrkPairSel_MaxInitDistance(),
MinTrackAngle=VertexCuts.TrkPairSel_MinTrackAngle())
ToolSvc += InDetSecVxTrackPairsSelector
if (printConfig):
print(InDetSecVxTrackPairsSelector)
#
......@@ -118,7 +112,6 @@ class ConfiguredSecVertexFinding:
MinDeltaR=VertexCuts.VtxPt_MinDeltaR(),
MaxDeltaR=VertexCuts.VtxPt_MaxDeltaR(),
MaxPhi=VertexCuts.VtxPt_MaxPhi())
ToolSvc += InDetSecVtxPointEstimator
if (printConfig):
print(InDetSecVtxPointEstimator)
#
......@@ -135,7 +128,6 @@ class ConfiguredSecVertexFinding:
MinPt=VertexCuts.SecVtxPost_MinPt(),
MaxdR=VertexCuts.SecVtxPost_MaxdR(),
MaxPhiVtxTrk=VertexCuts.SecVtxPost_MaxPhiVtxTrk())
ToolSvc += InDetSecVtxPostSelector
if (printConfig):
print(InDetSecVtxPostSelector)
#
......@@ -151,7 +143,6 @@ class ConfiguredSecVertexFinding:
MinInitialHitRadius=VertexCuts.SingleTrk_MinInitialHitRadius(),
MinInitialHitRadius_noBlay=VertexCuts.SingleTrk_MinInitialHitRadius_noBlay(),
MinRatioOfHLhits=VertexCuts.SingleTrk_MinRatioOfHLhits())
ToolSvc += InDetSingleTrackSecVtx
if (printConfig):
print(InDetSingleTrackSecVtx)
#
......@@ -175,7 +166,6 @@ class ConfiguredSecVertexFinding:
MaxDistVtxHit=VertexCuts.Finder_MaxDistVtxHit(),
MinFlightAngle=VertexCuts.Finder_MinFlightAngle(),
MinInitVtxR=VertexCuts.Finder_MinInitVtxR())
ToolSvc += InDetSecVtxFinderTool
if (printConfig):
print(InDetSecVtxFinderTool)
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef InDetTrackSelectorTool_InDetConversionTrackSelectorTool_H
#define InDetTrackSelectorTool_InDetConversionTrackSelectorTool_H
//#include "GaudiKernel/MsgStream.h"
#include "TrkToolInterfaces/ITrackSelectorTool.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "BeamSpotConditionsData/BeamSpotData.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TrkToolInterfaces/ITrackSelectorTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkExInterfaces/IExtrapolator.h"
#include "xAODTracking/TrackParticle.h"
#include "BeamSpotConditionsData/BeamSpotData.h"
/**
* A tool to be used for track preselection in conversion
* A tool to be used for track preselection in conversion
* vertex finding.
*
* Thomas Koffas <Thomas.Koffas@cern.ch>
* June 2008
*/
namespace Trk
{
class ITrackSummaryTool;
class Vertex;
class IExtrapolator;
class Track;
class TrackParticleBase;
namespace Trk {
class Vertex;
class Track;
class TrackParticleBase;
}
namespace InDet
namespace InDet {
class InDetConversionTrackSelectorTool
: virtual public Trk::ITrackSelectorTool
, public AthAlgTool
{
class InDetConversionTrackSelectorTool : virtual public Trk::ITrackSelectorTool, public AthAlgTool
{
public:
virtual StatusCode initialize() override;
InDetConversionTrackSelectorTool(const std::string& t, const std::string& n, const IInterface* p);
~InDetConversionTrackSelectorTool();
/** Select a Trk::Track */
virtual bool decision(const Trk::Track& track,const Trk::Vertex* vertex) const override;
/** Select a Trk::TrackParticleBase */
virtual bool decision(const Trk::TrackParticleBase& track,const Trk::Vertex* vertex) const override;
virtual bool decision(const xAOD::TrackParticle&,const xAOD::Vertex*) const override;
private:
int getCount( const xAOD::TrackParticle& tp, xAOD::SummaryType type ) const {
uint8_t val;
if( !tp.summaryValue(val,type) ) return 0;
return val > 0 ? val : 0;
}
Amg::Vector3D getPosOrBeamSpot(const xAOD::Vertex*) const;
ToolHandle <Trk::ITrackSummaryTool> m_trkSumTool; //!< Track summary tool
ToolHandle<Trk::IExtrapolator> m_extrapolator; //!< Extrapolator tool
SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
/** Properties for track selection:all cuts are ANDed */
double m_maxSiD0; //!< Maximal d0 at (0,0,0) for tracks with Si hits
double m_maxTrtD0; //!< Maximal d0 at (0,0,0) for standalone TRT tracks
double m_maxSiZ0; //!< Maximal z0 at (0,0,0)
double m_maxTrtZ0; //!< Maximal z0 at (0,0,0) for standalone TRT tracks
double m_minPt; //!< Minimum Pt of tracks
double m_trRatio1; //!< TR ratio for tracks with 15-20 TRT hits
double m_trRatio2; //!< TR ratio for tracks with 20-25 TRT hits
double m_trRatio3; //!< TR ratio for tracks with >25 TRT hits
double m_trRatioTRT;//!< TR ratio for TRT only tracks
double m_trRatioV0;//!< TR ratio for pion selection during V0 reconstruction
double m_sD0_Si; //!< Cut on D0 significance of Si tracks
double m_sD0_Trt; //!< Cut on D0 significance of TRT tracks
double m_sZ0_Trt; //!< Cut on Z0 significance of TRT tracks
bool m_isConv; //!< Conversion flag
bool m_PIDonlyForXe; //!< Only check TRT PID if all hits are Xe hits
}; //end of class definitions
} //end of namespace definitions
public:
virtual StatusCode initialize() override;
InDetConversionTrackSelectorTool(const std::string& t,
const std::string& n,
const IInterface* p);
virtual ~InDetConversionTrackSelectorTool() =default;
/** Select a Trk::Track */
virtual bool decision(const Trk::Track& track,
const Trk::Vertex* vertex) const override final;
/** Select a Trk::TrackParticleBase */
virtual bool decision(const Trk::TrackParticleBase& track,
const Trk::Vertex* vertex) const override final;
virtual bool decision(const xAOD::TrackParticle&,
const xAOD::Vertex*) const override final;
private:
int getCount(const xAOD::TrackParticle& tp, xAOD::SummaryType type) const
{
uint8_t val;
if (!tp.summaryValue(val, type))
return 0;
return val > 0 ? val : 0;
}
Amg::Vector3D getPosOrBeamSpot(const xAOD::Vertex*) const;
ToolHandle<Trk::IExtrapolator> m_extrapolator{ this,
"Extrapolator",
"",
"Extrapolator Tool" };
SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey{
this,
"BeamSpotKey",
"BeamSpotData",
"SG key for beam spot"
};
/** Properties for track selection:all cuts are ANDed */
double m_maxSiD0; //!< Maximal d0 at (0,0,0) for tracks with Si hits
double m_maxTrtD0; //!< Maximal d0 at (0,0,0) for standalone TRT tracks
double m_maxSiZ0; //!< Maximal z0 at (0,0,0)
double m_maxTrtZ0; //!< Maximal z0 at (0,0,0) for standalone TRT tracks
double m_minPt; //!< Minimum Pt of tracks
double m_trRatio1; //!< TR ratio for tracks with 15-20 TRT hits
double m_trRatio2; //!< TR ratio for tracks with 20-25 TRT hits
double m_trRatio3; //!< TR ratio for tracks with >25 TRT hits
double m_trRatioTRT; //!< TR ratio for TRT only tracks
double m_trRatioV0; //!< TR ratio for pion selection during V0 reconstruction
double m_sD0_Si; //!< Cut on D0 significance of Si tracks
double m_sD0_Trt; //!< Cut on D0 significance of TRT tracks
double m_sZ0_Trt; //!< Cut on Z0 significance of TRT tracks
bool m_isConv; //!< Conversion flag
bool m_PIDonlyForXe; //!< Only check TRT PID if all hits are Xe hits
}; // end of class definitions
} // end of namespace definitions
#endif
......@@ -3,8 +3,6 @@
*/
#include "InDetTrackSelectorTool/InDetConversionTrackSelectorTool.h"
#include "TrkToolInterfaces/ITrackSummaryTool.h"
#include "TrkExInterfaces/IExtrapolator.h"
#include "VxVertex/Vertex.h"
#include "TrkTrack/Track.h"
#include "TrkParticleBase/TrackParticleBase.h"
......@@ -22,8 +20,6 @@ namespace InDet
InDetConversionTrackSelectorTool::InDetConversionTrackSelectorTool(const std::string& t, const std::string& n, const IInterface* p)
:AthAlgTool(t,n,p),
m_trkSumTool("Trk::TrackSummaryTool"),
m_extrapolator("Trk::Extrapolator"),
m_maxSiD0 (35.),
m_maxTrtD0 (100.),
m_maxSiZ0 (200.),
......@@ -40,8 +36,6 @@ namespace InDet
m_isConv(true)
{
declareInterface<ITrackSelectorTool>(this);
declareProperty("TrackSummaryTool", m_trkSumTool);
declareProperty("Extrapolator", m_extrapolator);
declareProperty("maxSiD0", m_maxSiD0);
declareProperty("maxTrtD0", m_maxTrtD0);
declareProperty("maxSiZ0", m_maxSiZ0);
......@@ -60,27 +54,21 @@ namespace InDet
"Only check TRT PID if all hits are Xe hits");
}
InDetConversionTrackSelectorTool::~InDetConversionTrackSelectorTool()
{}
StatusCode InDetConversionTrackSelectorTool::initialize()
{
/* Get the track summary tool from ToolSvc */
ATH_CHECK( m_trkSumTool.retrieve());
/* Get the extrapolator tool from ToolSvc */
ATH_CHECK( m_extrapolator.retrieve() );
ATH_CHECK(m_beamSpotKey.initialize());
return StatusCode::SUCCESS;
}
bool InDetConversionTrackSelectorTool::decision(const Trk::Track& track,const Trk::Vertex* vx) const
{
{
bool pass = false;
const Trk::Perigee* perigee=dynamic_cast<const Trk::Perigee*>(track.perigeeParameters());
const bool vertexSuppliedByUser{vx!=nullptr};
const Trk::Vertex* myVertex=vx;
const Trk::Vertex* myVertex=vx;
//in case no Vertex is provided by the user, beam position will be used if available
if (not vertexSuppliedByUser) {
SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
......@@ -112,8 +100,7 @@ namespace InDet
}
const Trk::TrackParameters * extrapolatedParameters= m_extrapolator->extrapolate(*firstmeaspar,perigeeSurface,Trk::anyDirection,true,track.info().particleHypothesis() );
// const Trk::TrackParameters * extrapolatedParameters= firstmeaspar ? m_extrapolator->extrapolate(*firstmeaspar,perigeeSurface,Trk::anyDirection,true,track.info().particleHypothesis() ) : 0;
perigee = extrapolatedParameters ? dynamic_cast<const Trk::Perigee*>(extrapolatedParameters) : 0;
perigee = extrapolatedParameters ? dynamic_cast<const Trk::Perigee*>(extrapolatedParameters) : 0;
if (perigee==0 || !perigee->covariance() ) {
ATH_MSG_WARNING( "Track Selector failed to extrapolate track to the vertex: " << myVertex->position() );
if (extrapolatedParameters!=0) {
......@@ -130,7 +117,7 @@ namespace InDet
double pt = std::fabs(1./qOverP)*std::sin(perigee->parameters()[Trk::theta]);
double d0 = perigee->parameters()[Trk::d0];
double z0 = perigee->parameters()[Trk::z0];
std::unique_ptr<const Trk::TrackSummary> tSum = m_trkSumTool->summaryNoHoleSearch(track);
const Trk::TrackSummary* tSum = track.trackSummary();
if(tSum){
double ratioTrk = 1.0;
int nclus = tSum->get(Trk::numberOfPixelHits) + tSum->get(Trk::numberOfSCTHits);
......@@ -149,7 +136,7 @@ namespace InDet
if((ntrt<=15 && ratioTrk>=m_trRatio1) ||
(ntrt>15 && ntrt<=25 && ratioTrk>=m_trRatio2) ||
(ntrt>25 && ratioTrk>=m_trRatio3)) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
}
}
}
......@@ -213,7 +200,7 @@ namespace InDet
}
}
const Trk::TrackParameters * extrapolatedParameters= m_extrapolator->extrapolate(*firstmeaspar,perigeeSurface,Trk::anyDirection,true,Trk::pion );
perigee = extrapolatedParameters ? dynamic_cast<const Trk::Perigee*>(extrapolatedParameters) : 0;
perigee = extrapolatedParameters ? dynamic_cast<const Trk::Perigee*>(extrapolatedParameters) : 0;
if (perigee==0 || !perigee->covariance()) {
ATH_MSG_WARNING( "Track Selector failed to extrapolate track to the vertex: " << myVertex->position() );
if (extrapolatedParameters!=0) {
......@@ -225,7 +212,7 @@ namespace InDet
if (not vertexSuppliedByUser) delete myVertex;
return false;
}
double qOverP = perigee->parameters()[Trk::qOverP];
double pt = std::fabs(1./qOverP)*std::sin(perigee->parameters()[Trk::theta]);
double d0 = perigee->parameters()[Trk::d0];
......@@ -250,7 +237,7 @@ namespace InDet
if((ntrt<=15 && ratioTrk>=m_trRatio1) ||
(ntrt>15 && ntrt<=25 && ratioTrk>=m_trRatio2) ||
(ntrt>25 && ratioTrk>=m_trRatio3)) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
}
}
}
......@@ -275,10 +262,10 @@ namespace InDet
} else pass = false;
if (not vertexSuppliedByUser) delete myVertex;
if (perigee!=&(track.definingParameters())) delete perigee;
return pass;
}
Amg::Vector3D InDetConversionTrackSelectorTool::getPosOrBeamSpot(const xAOD::Vertex* vertex) const
{
if(vertex) return vertex->position();
......@@ -286,9 +273,9 @@ namespace InDet
if(beamSpotHandle.isValid()) return beamSpotHandle->beamVtx().position();
else return Amg::Vector3D(0,0,0);
}
// ---------------------------------------------------------------------
bool InDetConversionTrackSelectorTool::decision(const xAOD::TrackParticle& tp,const xAOD::Vertex* vertex) const
bool InDetConversionTrackSelectorTool::decision(const xAOD::TrackParticle& tp,const xAOD::Vertex* vertex) const
{
bool pass = false;
const Trk::Perigee& perigee=tp.perigeeParameters();
......@@ -316,7 +303,7 @@ namespace InDet
if(ntrt > 0 && (!m_PIDonlyForXe || nTrtXenonHits==ntrt) ){ // only check TRT PID if m_PIDonlyForXe is false or all TRT hits are Xenon hits
ratioTrk = tp.summaryValue(temp,xAOD::eProbabilityHT) ? temp: 0 ;
}
if ( pt >= m_minPt ) {
if ( (nclus==0 && std::fabs(d0)<=m_maxTrtD0) || (nclus>0 && std::fabs(d0)<=m_maxSiD0) ) {
if ( (nclus==0 && std::fabs(z0)<=m_maxTrtZ0) || (nclus>0 && std::fabs(z0)<=m_maxSiZ0) ) {
......@@ -324,7 +311,7 @@ namespace InDet
if((ntrt<=15 && ratioTrk>=m_trRatio1) ||
(ntrt>15 && ntrt<=25 && ratioTrk>=m_trRatio2) ||
(ntrt>25 && ratioTrk>=m_trRatio3)) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
} else if (ratioTrk>=m_trRatioTRT) pass = true;
}
}
}
......@@ -347,8 +334,8 @@ namespace InDet
if(ratioTrk>m_trRatioV0) pass = false;
}
delete extrapolatedParameters;
return pass;
}
}
}//end of namespace definitions
......@@ -4,35 +4,15 @@ __doc__ = """ToolFactory to instantiate EMVertexBuilder
with default configuration"""
__author__ = "Bruno Lenzi"
import InDetRecExample.TrackingCommon as TrackingCommon
from egammaAlgs import egammaAlgsConf
from egammaRec.Factories import FcnWrapper, AlgFactory
from egammaRec import egammaKeys
from egammaTrackTools.egammaTrackToolsFactories import EMExtrapolationTools
from egammaTools.egammaExtrapolators import AtlasPublicExtrapolator
from egammaTools.egammaExtrapolators import egammaExtrapolator
class VertexFinderToolInstance(FcnWrapper):
def __call__(self):
# In reality we do NOT need a summary tool
# but the confgured Secondary vertex
# still asks for one (TODO)
egammaVtxInDetTrackSummaryHelperTool = (
TrackingCommon.getInDetSummaryHelper(
name="egammaVtxInDetSummaryHelper",
AssoTool=None,
HoleSearch=None,
DoSharedHits=False,
private=True))
egammaVtxInDetTrackSummaryTool = (
TrackingCommon.getInDetTrackSummaryTool(
name="egammaVtxInDetTrackSummaryTool",
InDetSummaryHelperTool=egammaVtxInDetTrackSummaryHelperTool,
doSharedHits=False,
doHolesInDet=False))
#
# Configured conversion vertex reconstruction cuts
#
......@@ -50,8 +30,7 @@ class VertexFinderToolInstance(FcnWrapper):
VertexCuts=egammaConversionVertexCuts,
TrackParticles=egammaKeys.outputTrackParticleKey(),
SecVertices=egammaKeys.outputConversionKey(),
Extrapolator=AtlasPublicExtrapolator(),
TrackSummaryTool=egammaVtxInDetTrackSummaryTool,
Extrapolator=egammaExtrapolator(),
printConfig=False)
return theemvertexfindertool.toolInstance()
......
......@@ -2,7 +2,8 @@
from egammaRec.Factories import ToolFactory, PublicToolFactory
from TrkExTools.AtlasExtrapolator import AtlasExtrapolator
__doc__ = "ToolFactories to instantiate InDet tools for egamma with default configuration"
__doc__ = """ToolFactories to instantiate InDet tools
for egamma with default configuration"""
__author__ = "Bruno Lenzi"
# Tools for extrapolating to the calo
......@@ -76,13 +77,15 @@ egammaExtrapolator = ToolFactory(
AtlasExtrapolator,
name='egammaExtrapolator')
# The general use extrapolator same as ATLAS default public
# The general use extrapolator same as ATLAS default.
# Public as still needed due to some InnerDetector/Tracking
# tools
AtlasPublicExtrapolator = PublicToolFactory(
AtlasExtrapolator,
name='AtlasPublicExtrapolator')
# Specialized for e/gamma calo extrapolations i.e ignore material effect
# that are not that relevant in the calo side
# Extrapolator specialized for the e/gamma specific calo extrapolations
# i.e ignore material effect that are not relevant.
egammaCaloExtrapolator = ToolFactory(
AtlasExtrapolator,
postInit=[configureExtrapolator],
......
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