Commit 6a264d9a authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'InDetTrackScoringTools_master_create_ROIInfoVec_by_alg' into 'master'

Create ROIInfoVec by algorithm rather than on demand by the tool.

See merge request !29950
parents 183af9b9 9f611ab1
......@@ -15,6 +15,16 @@ def createAndAddCondAlg(creator, the_name, **kwargs) :
return
cond_seq += creator(**kwargs)
def createAndAddEventAlg(creator, the_name, **kwargs) :
from AthenaCommon.AlgSequence import AlgSequence
seq=AlgSequence()
log.debug('createAndAddEventAlg match ? %s == %s ? %s ', seq.getChildren(), the_name, hasattr(seq,the_name) )
if hasattr(seq,the_name) :
return getattr(seq,the_name)
alg = creator(the_name,**kwargs)
seq += alg
return alg
def setDefaults(kwargs, **def_kwargs) :
def_kwargs.update(kwargs)
return def_kwargs
......@@ -63,7 +73,6 @@ def makePublicTool(tool_creator) :
from AthenaCommon.AppMgr import ToolSvc
name=kwargs.pop('name',None)
private=kwargs.pop("private",False)
if len(args) == 1 :
if name is not None :
raise Exception('Name given as positional and keyword argument')
......@@ -74,6 +83,7 @@ def makePublicTool(tool_creator) :
orig_name = name
default_prefix,name=splitDefaultPrefix(name)
the_name = kwargs.get('namePrefix',default_prefix) + name + kwargs.get('nameSuffix','')
if private is True or the_name not in ToolSvc :
if len(args) > 1 :
raise Exception('Too many positional arguments')
......@@ -83,6 +93,7 @@ def makePublicTool(tool_creator) :
if the_name != tool.name() :
raise Exception('Tool has not the exepected name %s but %s' % (the_name, tool.name()))
if private is False :
print 'DEBUG add to ToolSvc %s' % (tool.name())
ToolSvc += tool
return tool
else :
......@@ -393,10 +404,10 @@ def getInDetSCT_ClusterOnTrackTool(name='InDetSCT_ClusterOnTrackTool', **kwargs)
kwargs = setDefaults(kwargs, LorentzAngleTool = getSCTLorentzAngleTool())
kwargs = setDefaults(kwargs,
# CorrectionStrategy = -1, # no position correction (test for bug #56477)
CorrectionStrategy = 0, # do correct position bias
ErrorStrategy = 2 # do use phi dependent errors
)
# CorrectionStrategy = -1, # no position correction (test for bug #56477)
CorrectionStrategy = 0, # do correct position bias
ErrorStrategy = 2 # do use phi dependent errors
)
from SiClusterOnTrackTool.SiClusterOnTrackToolConf import InDet__SCT_ClusterOnTrackTool
return InDet__SCT_ClusterOnTrackTool (the_name, **kwargs)
......@@ -1199,8 +1210,117 @@ def getInDetTRT_ExtensionTool(TrackingCuts=None, **kwargs) :
elif InDetFlags.trtExtensionType() == 'DAF' :
return getInDetTRT_TrackExtensionTool_DAF('InDetTRT_ExtensionTool',**kwargs)
def getTRT_DetElementsRoadCondAlg(**kwargs):
the_name=kwargs.pop("name","InDet__TRT_DetElementsRoadCondAlg_xk")
from TRT_DetElementsRoadTool_xk.TRT_DetElementsRoadTool_xkConf import InDet__TRT_DetElementsRoadCondAlg_xk
return InDet__TRT_DetElementsRoadCondAlg_xk(the_name, **kwargs)
def getInDetROIInfoVecCondAlg(name='InDetROIInfoVecCondAlg',**kwargs) :
the_name = makeName(name, kwargs)
from InDetRecExample.InDetKeys import InDetKeys
kwargs=setDefaults(kwargs,
InputEmClusterContainerName = InDetKeys.CaloClusterROIContainer(),
WriteKey = kwargs.get("namePrefix","")+"ROIInfoVec"+kwargs.get("nameSuffix",""),
minPtEM = 5000. # in MeV
)
from InDetTrackScoringTools.InDetTrackScoringToolsConf import ROIInfoVecAlg
return ROIInfoVecAlg(the_name,**kwargs)
@makePublicTool
def getInDetAmbiScoringToolBase(name='InDetAmbiScoringTool', **kwargs) :
NewTrackingCuts = kwargs.pop("NewTrackingCuts")
the_name=makeName(name,kwargs)
from InDetRecExample.InDetJobProperties import InDetFlags
from AthenaCommon.DetFlags import DetFlags
have_calo_rois = InDetFlags.doBremRecovery() and InDetFlags.doCaloSeededBrem() and DetFlags.detdescr.Calo_allOn()
if have_calo_rois :
alg=createAndAddEventAlg(getInDetROIInfoVecCondAlg,"InDetROIInfoVecCondAlg")
kwargs=setDefaults(kwargs, CaloROIInfoName = alg.WriteKey )
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
return InDet__InDetAmbiScoringTool(the_name,
**setDefaults(kwargs,
Extrapolator = getInDetExtrapolator(),
SummaryTool = getInDetTrackSummaryTool(),
DriftCircleCutTool = getInDetTRTDriftCircleCutForPatternReco(),
useAmbigFcn = True, # this is NewTracking
useTRT_AmbigFcn = False,
maxZImp = NewTrackingCuts.maxZImpact(),
maxEta = NewTrackingCuts.maxEta(),
usePixel = NewTrackingCuts.usePixel(),
useSCT = NewTrackingCuts.useSCT(),
doEmCaloSeed = have_calo_rois)
)
def getInDetAmbiScoringTool(NewTrackingCuts, name='InDetAmbiScoringTool', **kwargs) :
return getInDetAmbiScoringToolBase(name+NewTrackingCuts.extension(),
**setDefaults( kwargs,
NewTrackingCuts = NewTrackingCuts,
useAmbigFcn = True, # this is NewTracking
useTRT_AmbigFcn = False,
minTRTonTrk = 0,
minTRTPrecisionFraction = 0,
minPt = NewTrackingCuts.minPT(),
maxRPhiImp = NewTrackingCuts.maxPrimaryImpact(),
minSiClusters = NewTrackingCuts.minClusters(),
minPixel = NewTrackingCuts.minPixel(),
maxSiHoles = NewTrackingCuts.maxHoles(),
maxPixelHoles = NewTrackingCuts.maxPixelHoles(),
maxSCTHoles = NewTrackingCuts.maxSCTHoles(),
maxDoubleHoles = NewTrackingCuts.maxDoubleHoles()))
def getInDetTRT_SeededScoringTool(NewTrackingCuts, name='InDetTRT_SeededScoringTool',**kwargs) :
from InDetRecExample.InDetJobProperties import InDetFlags
return getInDetAmbiScoringToolBase('InDetTRT_SeededScoringTool',
**setDefaults(kwargs,
NewTrackingCuts = NewTrackingCuts,
useAmbigFcn = not InDetFlags.doNewTracking(), # full search => use NewT
useTRT_AmbigFcn = InDetFlags.doNewTracking(), # full search => use NewT
minTRTonTrk = NewTrackingCuts.minSecondaryTRTonTrk(),
minTRTPrecisionFraction = NewTrackingCuts.minSecondaryTRTPrecFrac(),
minPt = NewTrackingCuts.minSecondaryPt(),
maxRPhiImp = NewTrackingCuts.maxSecondaryImpact(),
minSiClusters = NewTrackingCuts.minSecondaryClusters(),
maxSiHoles = NewTrackingCuts.maxSecondaryHoles(),
maxPixelHoles = NewTrackingCuts.maxSecondaryPixelHoles(),
maxSCTHoles = NewTrackingCuts.maxSecondarySCTHoles(),
maxDoubleHoles = NewTrackingCuts.maxSecondaryDoubleHoles()))
def getInDetExtenScoringTool(NewTrackingCuts,name='InDetExtenScoringTool', **kwargs) :
from InDetRecExample.InDetJobProperties import InDetFlags
if InDetFlags.trackFitterType() in ['KalmanFitter', 'KalmanDNAFitter', 'ReferenceKalmanFitter']:
kwargs=setDefaults(kwargs, minTRTPrecisionFraction = 0.2)
return getInDetAmbiScoringTool(NewTrackingCuts,
name,
**setDefaults(kwargs,
minTRTonTrk = NewTrackingCuts.minTRTonTrk(),
minTRTPrecisionFraction = NewTrackingCuts.minTRTPrecFrac()))
@makePublicTool
def getInDetCosmicsScoringToolBase(name='InDetCosmicsScoringTool', **kwargs) :
NewTrackingCuts = kwargs.pop("NewTrackingCuts")
the_name=makeName(name,kwargs)
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
return InDet__InDetCosmicScoringTool(the_name,
**setDefaults(kwargs,
nWeightedClustersMin = NewTrackingCuts.nWeightedClustersMin(),
minTRTHits = 0,
SummaryTool = getInDetTrackSummaryTool()))
def getInDetCosmicsScoringTool(NewTrackingCuts,name='InDetCosmicsScoringTool', **kwargs) :
return getInDetCosmicsScoringToolBase(name+NewTrackingCuts.extension(),
**setDefaults(kwargs, NewTrackingCuts=NewTrackingCuts))
def getInDetCosmicExtenScoringTool(NewTrackingCuts, name='InDetCosmicExtenScoringTool',**kwargs) :
return getInDetCosmicsScoringToolBase('InDetCosmicExtenScoringTool',
**setDefaults(kwargs,
NewTrackingCuts = NewTrackingCuts,
nWeightedClustersMin = 0,
minTRTHits = NewTrackingCuts.minTRTonTrk()))
def getInDetCosmicScoringTool_TRT(NewTrackingCuts, name='InDetCosmicExtenScoringTool',**kwargs) :
return getInDetCosmicExtenScoringTool(NewTrackingCuts,
'InDetCosmicScoringTool_TRT',
**setDefaults(kwargs,
minTRTHits = NewTrackingCuts.minSecondaryTRTonTrk(),
SummaryTool = TrackingCommon.getInDetTrackSummaryToolNoHoleSearch()))
......@@ -220,41 +220,9 @@ class ConfiguredBackTracking:
# --- set up special Scoring Tool for TRT seeded tracks
#
if InDetFlags.doCosmics():
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
InDetTRT_SeededScoringTool = InDet__InDetCosmicScoringTool(name = 'InDetCosmicScoringTool_TRT',
nWeightedClustersMin = 0,
minTRTHits = NewTrackingCuts.minSecondaryTRTonTrk(),
SummaryTool = TrackingCommon.getInDetTrackSummaryToolNoHoleSearch())
InDetTRT_SeededScoringTool = TrackingCommon.getInDetCosmicScoringTool_TRT(NewTrackingCuts)
else:
have_calo_rois = InDetFlags.doBremRecovery() and InDetFlags.doCaloSeededBrem() and DetFlags.detdescr.Calo_allOn()
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
InDetTRT_SeededScoringTool = InDet__InDetAmbiScoringTool(name = 'InDetTRT_SeededScoringTool',
Extrapolator = TrackingCommon.getInDetExtrapolator(),
DriftCircleCutTool = InDetTRTDriftCircleCut,
SummaryTool = TrackingCommon.getInDetTrackSummaryTool(),
useTRT_AmbigFcn = InDetFlags.doNewTracking(), # full search => use NewT
useAmbigFcn = not InDetFlags.doNewTracking(), # full search => use NewT
minPt = NewTrackingCuts.minSecondaryPt(),
maxRPhiImp = NewTrackingCuts.maxSecondaryImpact(),
maxZImp = NewTrackingCuts.maxZImpact(),
maxEta = NewTrackingCuts.maxEta(),
minSiClusters = NewTrackingCuts.minSecondaryClusters(),
maxSiHoles = NewTrackingCuts.maxSecondaryHoles(),
maxPixelHoles = NewTrackingCuts.maxSecondaryPixelHoles(),
maxSCTHoles = NewTrackingCuts.maxSecondarySCTHoles(),
maxDoubleHoles = NewTrackingCuts.maxSecondaryDoubleHoles(),
usePixel = NewTrackingCuts.usePixel(),
useSCT = NewTrackingCuts.useSCT(),
minTRTonTrk = NewTrackingCuts.minSecondaryTRTonTrk(),
minTRTPrecisionFraction = NewTrackingCuts.minSecondaryTRTPrecFrac(),
doEmCaloSeed = have_calo_rois)
if not InDetTRT_SeededScoringTool.doEmCaloSeed:
InDetTRT_SeededScoringTool.InputEmClusterContainerName = ''
# InDetTRT_SeededScoringTool.OutputLevel = DEBUG
ToolSvc += InDetTRT_SeededScoringTool
if (InDetFlags.doPrintConfigurables()):
printfunc (InDetTRT_SeededScoringTool)
InDetTRT_SeededScoringTool = TrackingCommon.getInDetTRT_SeededScoringTool(NewTrackingCuts)
#
# --- Load selection tool
......
......@@ -451,48 +451,10 @@ class ConfiguredNewTrackingSiPattern:
# --- set up different Scoring Tool for collisions and cosmics
#
if InDetFlags.doCosmics() and NewTrackingCuts.mode() != "DBM":
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
InDetAmbiScoringTool = InDet__InDetCosmicScoringTool(name = 'InDetCosmicsScoringTool'+NewTrackingCuts.extension(),
nWeightedClustersMin = NewTrackingCuts.nWeightedClustersMin(),
minTRTHits = 0,
SummaryTool = TrackingCommon.getInDetTrackSummaryTool())
InDetAmbiScoringTool = TrackingCommon.getInDetCosmicsScoringTool(NewTrackingCuts)
else:
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
have_calo_rois = InDetFlags.doBremRecovery() and InDetFlags.doCaloSeededBrem() and DetFlags.detdescr.Calo_allOn()
InDetAmbiScoringTool = InDet__InDetAmbiScoringTool(name = 'InDetAmbiScoringTool'+NewTrackingCuts.extension(),
Extrapolator = TrackingCommon.getInDetExtrapolator(),
SummaryTool = TrackingCommon.getInDetTrackSummaryTool(),
DriftCircleCutTool = InDetTRTDriftCircleCut,
useAmbigFcn = True, # this is NewTracking
useTRT_AmbigFcn = False,
minPt = NewTrackingCuts.minPT(),
maxRPhiImp = NewTrackingCuts.maxPrimaryImpact(),
maxZImp = NewTrackingCuts.maxZImpact(),
maxEta = NewTrackingCuts.maxEta(),
minSiClusters = NewTrackingCuts.minClusters(),
minPixel = NewTrackingCuts.minPixel(),
maxSiHoles = NewTrackingCuts.maxHoles(),
maxPixelHoles = NewTrackingCuts.maxPixelHoles(),
maxSCTHoles = NewTrackingCuts.maxSCTHoles(),
maxDoubleHoles = NewTrackingCuts.maxDoubleHoles(),
usePixel = NewTrackingCuts.usePixel(),
useSCT = NewTrackingCuts.useSCT(),
InputEmClusterContainerName = InDetKeys.CaloClusterROIContainer(),
doEmCaloSeed = have_calo_rois,
minTRTonTrk = 0,
minTRTPrecisionFraction = 0)
if not InDetAmbiScoringTool.doEmCaloSeed:
InDetAmbiScoringTool.InputEmClusterContainerName = ''
# allow for some overlap for low-pt tracking
#if InDetFlags.doLowPt() and not NewTrackingCuts.mode() == "LowPt":
# InDetAmbiScoringTool.minPt = NewTrackingCuts.minPT()-100.*Units.MeV
InDetAmbiScoringTool = TrackingCommon.getInDetAmbiScoringTool(NewTrackingCuts)
# if NewTrackingCuts.mode() == "ForwardTracks":
# InDetAmbiScoringTool.OutputLevel = VERBOSE
ToolSvc += InDetAmbiScoringTool
if (InDetFlags.doPrintConfigurables()):
printfunc (InDetAmbiScoringTool)
#
# --- load Ambiguity Processor
#
......
......@@ -102,48 +102,10 @@ class ConfiguredNewTrackingTRTExtension:
# --- load scoring for extension
#
if InDetFlags.doCosmics():
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetCosmicScoringTool
InDetExtenScoringTool = InDet__InDetCosmicScoringTool(name = 'InDetCosmicExtenScoringTool',
nWeightedClustersMin = 0,
minTRTHits = NewTrackingCuts.minTRTonTrk(),
SummaryTool = InDetTrackSummaryTool)
InDetExtenScoringTool = TrackingCommon.getInDetCosmicExtenScoringTool(NewTrackingCuts)
else:
have_calo_rois = InDetFlags.doBremRecovery() and InDetFlags.doCaloSeededBrem() and DetFlags.detdescr.Calo_allOn()
from InDetTrackScoringTools.InDetTrackScoringToolsConf import InDet__InDetAmbiScoringTool
InDetExtenScoringTool = InDet__InDetAmbiScoringTool(name = 'InDetExtenScoringTool'+NewTrackingCuts.extension(),
Extrapolator = InDetExtrapolator,
SummaryTool = InDetTrackSummaryTool,
DriftCircleCutTool = InDetTRTDriftCircleCut,
useAmbigFcn = True, # this is NewTracking
useTRT_AmbigFcn = False,
minPt = NewTrackingCuts.minPT(),
maxRPhiImp = NewTrackingCuts.maxPrimaryImpact(),
maxZImp = NewTrackingCuts.maxZImpact(),
maxEta = NewTrackingCuts.maxEta(),
minSiClusters = NewTrackingCuts.minClusters(),
minPixel = NewTrackingCuts.minPixel(),
maxSiHoles = NewTrackingCuts.maxHoles(),
maxPixelHoles = NewTrackingCuts.maxPixelHoles(),
maxSCTHoles = NewTrackingCuts.maxSCTHoles(),
maxDoubleHoles = NewTrackingCuts.maxDoubleHoles(),
usePixel = NewTrackingCuts.usePixel(),
useSCT = NewTrackingCuts.useSCT(),
minTRTonTrk = NewTrackingCuts.minTRTonTrk(),
minTRTPrecisionFraction = NewTrackingCuts.minTRTPrecFrac(),
doEmCaloSeed = have_calo_rois)
if not InDetExtenScoringTool.doEmCaloSeed:
InDetExtenScoringTool.InputEmClusterContainerName = ''
if InDetFlags.trackFitterType() in ['KalmanFitter', 'KalmanDNAFitter', 'ReferenceKalmanFitter']:
InDetExtenScoringTool.minTRTPrecisionFraction = 0.2
InDetExtenScoringTool = TrackingCommon.getInDetExtenScoringTool(NewTrackingCuts)
#InDetExtenScoringTool.OutputLevel = VERBOSE
ToolSvc += InDetExtenScoringTool
if (InDetFlags.doPrintConfigurables()):
printfunc (InDetExtenScoringTool )
#
# --- output track collection
#
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////
......@@ -13,7 +13,7 @@
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "StoreGate/ReadHandleKey.h"
#include "TrkCaloClusterROI/CaloClusterROI_Collection.h"
#include "InDetTrackScoringTools/ROIInfoVec.h"
#include "TrkEventPrimitives/TrackScore.h"
#include "TrkToolInterfaces/ITrackScoringTool.h"
#include "TrkToolInterfaces/ITrackSummaryTool.h"
......@@ -23,6 +23,7 @@
#include <vector>
#include <string>
#include "BeamSpotConditionsData/BeamSpotData.h"
#include "ROIInfoVec.h"
namespace Trk {
class IExtrapolator;
......@@ -55,31 +56,13 @@ class InDetAmbiScoringTool : virtual public Trk::ITrackScoringTool,
virtual Trk::TrackScore simpleScore( const Trk::Track& track, const Trk::TrackSummary& trackSum ) const override;
Trk::TrackScore ambigScore( const Trk::Track& track, const Trk::TrackSummary& trackSum ) const;
struct ROIInfo {
ROIInfo (double the_emF,
//double the_emE,
double the_emR,
double the_emZ)
: emF(the_emF),
//emE(the_emE),
emR(the_emR),
emZ(the_emZ) {}
double emF;
//double emE;
double emR;
double emZ;
};
typedef std::vector<ROIInfo> ROIInfoVec;
private:
const ROIInfoVec* getInfo() const;
void setupScoreModifiers();
/** Check if the cluster is compatible with a EM cluster*/
bool isEmCaloCompatible(const Trk::Track& track,
const ROIInfoVec* info) const;
bool isEmCaloCompatible(const Trk::Track& track) const;
//these are used for ScoreModifiers
......@@ -136,12 +119,12 @@ class InDetAmbiScoringTool : virtual public Trk::ITrackScoringTool,
float m_phiWidthEm;
float m_etaWidthEm;
SG::ReadHandleKey<CaloClusterROI_Collection> m_inputEmClusterContainerName;
SG::ReadHandleKey<InDet::ROIInfoVec> m_caloROIInfoKey
{this,"CaloROIInfoName", "ROIInfoVec","Name of the calo cluster ROI vector."};
};
} // namespace InDet
CLASS_DEF (InDet::InDetAmbiScoringTool::ROIInfoVec, 169195041, 0)
#endif
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef _ROIInfoVec_h_
#define _ROIInfoVec_h_
#include <vector>
#include "AthenaKernel/CLASS_DEF.h"
namespace InDet {
struct ROIInfo {
ROIInfo (double the_emF,
double the_emR,
double the_emZ)
: emF(the_emF),
emR(the_emR),
emZ(the_emZ) {}
double emF;
double emR;
double emZ;
};
using ROIInfoVec = std::vector<ROIInfo>;
}
CLASS_DEF (InDet::ROIInfoVec, 165547689, 0)
#endif
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////
......@@ -83,13 +83,11 @@ InDet::InDetAmbiScoringTool::InDetAmbiScoringTool(const std::string& t,
declareProperty("SummaryTool" , m_trkSummaryTool);
declareProperty("DriftCircleCutTool",m_selectortool );
declareProperty("MagFieldSvc", m_magFieldSvc);
declareProperty("maxRPhiImpEM", m_maxRPhiImpEM = 50. );
declareProperty("doEmCaloSeed", m_useEmClusSeed = true );
declareProperty("minPtEM", m_minPtEm = 5000. ); // in MeV
declareProperty("phiWidthEM", m_phiWidthEm = 0.075 );
declareProperty("etaWidthEM", m_etaWidthEm = 0.05 );
declareProperty("InputEmClusterContainerName",m_inputEmClusterContainerName="InDetCaloClusterROIs");
//set values for scores
m_summaryTypeScore[Trk::numberOfPixelHits] = 20;
......@@ -173,7 +171,7 @@ StatusCode InDet::InDetAmbiScoringTool::initialize()
if (m_useAmbigFcn || m_useTRT_AmbigFcn) setupScoreModifiers();
ATH_CHECK( m_inputEmClusterContainerName.initialize(m_useEmClusSeed) );
ATH_CHECK( m_caloROIInfoKey.initialize(m_useEmClusSeed) );
return StatusCode::SUCCESS;
}
......@@ -325,37 +323,32 @@ Trk::TrackScore InDet::InDetAmbiScoringTool::simpleScore( const Trk::Track& trac
// uses perigee on track or extrapolates, no material in any case, we cut on impacts
// add back extrapolation without errors
const Trk::TrackParameters* parm = m_extrapolator->extrapolateDirectly(*input, perigeeSurface);
{
std::unique_ptr<const Trk::TrackParameters> parm( m_extrapolator->extrapolateDirectly(*input, perigeeSurface) );
const Trk::Perigee*extrapolatedPerigee = dynamic_cast<const Trk::Perigee*> (parm );
const Trk::Perigee*extrapolatedPerigee = dynamic_cast<const Trk::Perigee*> (parm.get());
if (!extrapolatedPerigee) {
msg(MSG::WARNING) << "Extrapolation of perigee failed, this should never happen" << endmsg;
delete parm;
return Trk::TrackScore(0);
ATH_MSG_WARNING( "Extrapolation of perigee failed, this should never happen" );
return Trk::TrackScore(0);
}
ATH_MSG_VERBOSE ("extrapolated perigee: "<<*extrapolatedPerigee);
if (fabs(extrapolatedPerigee->parameters()[Trk::z0]) > m_maxZImp) {
ATH_MSG_DEBUG ("Track Z impact > "<<m_maxZImp<<", reject it");
delete extrapolatedPerigee;
return Trk::TrackScore(0);
}
double maxD0 = m_maxRPhiImp;
if(m_useEmClusSeed) {
const ROIInfoVec* info = getInfo();
if (isEmCaloCompatible( track, info ) )
maxD0 = m_maxRPhiImpEM;
if (isEmCaloCompatible( track ) ) {
maxD0 = m_maxRPhiImpEM;
}
}
if (fabs(extrapolatedPerigee->parameters()[Trk::d0]) > maxD0) {
ATH_MSG_DEBUG ("Track Rphi impact > "<<m_maxRPhiImp<<", reject it");
delete extrapolatedPerigee;
return Trk::TrackScore(0);
}
delete extrapolatedPerigee;
}
//
// --- now start scoring
......@@ -904,44 +897,10 @@ void InDet::InDetAmbiScoringTool::setupScoreModifiers()
}
const InDet::InDetAmbiScoringTool::ROIInfoVec*
InDet::InDetAmbiScoringTool::getInfo() const
bool InDet::InDetAmbiScoringTool::isEmCaloCompatible(const Trk::Track& track) const
{
std::string roiname = name() + "ROIInfoVec";
SG::ReadHandle<ROIInfoVec> rh (roiname);
if (rh.isValid())
return rh.cptr();
if (m_useEmClusSeed) {
SG::ReadHandle<CaloClusterROI_Collection> calo(m_inputEmClusterContainerName);
auto info = std::make_unique<ROIInfoVec>();
for( const Trk::CaloClusterROI* ccROI : *calo) {
if( ccROI->energy() * sin(ccROI->globalPosition().theta()) < m_minPtEm){
continue;
}
info->emplace_back( ccROI->globalPosition().phi(),
ccROI->globalPosition().perp(),
ccROI->globalPosition().z() );
}
SG::WriteHandle<ROIInfoVec> wh (roiname);
return wh.put (std::move(info), true);
}
return nullptr;
}
//==========================================================================================
bool InDet::InDetAmbiScoringTool::isEmCaloCompatible(const Trk::Track& track,
const ROIInfoVec* info) const
{
const Trk::TrackParameters * Tp = track.trackParameters()->front();
//Switch to the track parameters of the first measurment instead of the perigee parameters
ATH_MSG_VERBOSE ("--> Looping over TSOS's");
for (auto tsos : *track.trackStateOnSurfaces() ) {
......@@ -956,27 +915,26 @@ bool InDet::InDetAmbiScoringTool::isEmCaloCompatible(const Trk::Track& track,
break;
}
}
const double pi = M_PI, pi2 = 2.*M_PI;
if(!info || info->empty()) return false;
double F = Tp->momentum().phi();
double E = Tp->momentum().eta();
double R = Tp->position().perp();
double Z = Tp->position().z();
for (const ROIInfo& i : *info) {
double df = fabs(F-(i.emF));
SG::ReadHandle<InDet::ROIInfoVec> calo(m_caloROIInfoKey);
for( const InDet::ROIInfo &ccROI : *calo) {