21#include "GaudiKernel/EventContext.h"
30 const std::string& name,
31 const IInterface* parent)
35 declareInterface<IEMTrackMatchBuilder>(
this);
52 return StatusCode::SUCCESS;
60 if (egammas ==
nullptr) {
61 return StatusCode::SUCCESS;
81 return StatusCode::SUCCESS;
90 if (!eg || !trackPC) {
92 "trackExecute: NULL pointer to egammaRec or TrackParticleContainer");
93 return StatusCode::SUCCESS;
98 if (cluster && cluster->
e() == 0.0) {
99 ATH_MSG_WARNING(
"trackExecute: cluster energy is 0.0! Ignoring cluster.");
100 return StatusCode::SUCCESS;
104 std::vector<TrackMatch> trkMatches;
106 for (
unsigned int trackNumber = 0; trkIt != trackPC->
end();
107 ++trkIt, ++trackNumber) {
117 inBroadWindow(ctx, trkMatches, *cluster, trackNumber, (**trkIt), caloDD);
121 if (!trkMatches.empty()) {
126 eg->setDeltaEta(bestTrkMatch.
deltaEta);
127 eg->setDeltaPhi(bestTrkMatch.
deltaPhi);
133 std::vector<EL> trackParticleLinks;
134 trackParticleLinks.reserve(trkMatches.size());
135 const std::string key =
EL(*trackPC, 0, ctx).dataID();
137 ATH_MSG_DEBUG(
"Match dR: " << m.dR <<
" second dR: " << m.seconddR
138 <<
" hasPix: " << m.hasPix
139 <<
" hitsScore: " << m.hitsScore);
141 trackParticleLinks.emplace_back(*trackPC, m.trackNumber, ctx);
143 trackParticleLinks.emplace_back(key, m.trackNumber, ctx);
146 eg->setTrackParticles(trackParticleLinks);
148 return StatusCode::SUCCESS;
153 std::vector<TrackMatch>& trackMatches,
168 std::array<double, 4>
eta = { -999.0, -999.0, -999.0, -999.0 };
169 std::array<double, 4>
phi = { -999.0, -999.0, -999.0, -999.0 };
170 std::array<double, 4> deltaEta = { -999.0, -999.0, -999.0, -999.0 };
171 std::array<double, 4>
deltaPhi = { -999.0, -999.0, -999.0, -999.0 };
179 std::pair<std::vector<CaloSampling::CaloSample>,
180 std::vector<std::unique_ptr<Trk::Surface>>>
184 ->getMatchAtCalo(ctx,
187 layersAndSurfaces.first,
188 layersAndSurfaces.second,
200 std::array<double, 4> etaRes = { -999.0, -999.0, -999.0, -999.0 };
201 std::array<double, 4> phiRes = { -999.0, -999.0, -999.0, -999.0 };
202 std::array<double, 4> deltaEtaRes = { -999.0, -999.0, -999.0, -999.0 };
203 std::array<double, 4> deltaPhiRes = { -999.0, -999.0, -999.0, -999.0 };
206 ->getMatchAtCalo(ctx,
209 layersAndSurfaces.first,
210 layersAndSurfaces.second,
220 double deltaPhiRescale = deltaPhiRes[2];
248 <<
deltaPhi[2] <<
" / " << deltaEta[2]);
250 << deltaPhiRes[2] <<
" / " << deltaEtaRes[2]);
257 std::array<double, 4> eta1 = { -999.0, -999.0, -999.0, -999.0 };
258 std::array<double, 4> phi1 = { -999.0, -999.0, -999.0, -999.0 };
259 std::array<double, 4> deltaEta1 = { -999.0, -999.0, -999.0, -999.0 };
260 std::array<double, 4> deltaPhi1 = { -999.0, -999.0, -999.0, -999.0 };
263 ->getMatchAtCalo(ctx,
266 layersAndSurfaces.first,
267 layersAndSurfaces.second,
277 double deltaPhiLast = deltaPhi1[2];
306 <<
" deltaEta " << deltaEta[2]);
314 trkmatch.
hasPix = (nPixel > 0);
335 if (!expectNextToInnermostPixelLayerHit || nNextToInnerMost > 0) {
339 if (!expectInnermostPixelLayerHit || nInnerMost > 0) {
344 <<
" hitsScore : " << trkmatch.
hitsScore);
346 trackMatches.push_back(trkmatch);
361 const Trk::Perigee& candidatePerigee = track->perigeeParameters();
363 const double trkPhi = (!flip) ? candidatePerigee.parameters()[
Trk::phi]
364 : -candidatePerigee.parameters()[
Trk::phi];
365 const double trkEta =
366 (!flip) ? candidatePerigee.
eta() : -candidatePerigee.
eta();
367 const double z_perigee = candidatePerigee.
position().z();
368 const double r_perigee = candidatePerigee.
position().perp();
373 const double clusterEta = cluster->
eta();
375 const double Et = cluster->
e() / cosh(trkEta);
376 const double clusterPhi = cluster->
phi();
379 if (std::abs(clusterEta) > 10.0 || Et < 10) {
386 *cluster, PerigeeXYZPosition, isEndCap);
388 const double clusterEtaCorrected = XYZClusterWrtTrackPerigee.eta();
392 ATH_MSG_DEBUG(
" Fails broad window eta match (track eta, cluster eta, "
393 "cluster eta corrected): ( "
394 << trkEta <<
", " << clusterEta <<
", " << clusterEtaCorrected
401 Et, trkEta, track->charge(), r_perigee, isEndCap);
404 track->pt(), trkEta, track->charge(), r_perigee, isEndCap);
406 const double clusterPhiCorrected = XYZClusterWrtTrackPerigee.phi();
412 const double deltaPhiRescaled =
416 const double deltaPhiTrack =
425 "FAILS broad window phi match (track phi, phirotCluster , phiRotTrack , "
426 <<
"cluster phi corrected, cluster phi): ( " << trkPhi <<
", "
427 << phiRotRescaled <<
", " << phiRotTrack <<
", " << clusterPhiCorrected
428 <<
", " << clusterPhi <<
")");
456 return match1.
dR < match2.
dR;
int summaryValueInt(const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, int deflt=-999)
return the summary value for a TrackParticle or default value (-999) (to be used mostly in python whe...
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
This class provides the client interface for accessing the detector description information common to...
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
function object to sort track matches based on quality
bool operator()(const TrackMatch &match1, const TrackMatch &match2) const
EMTrackMatchBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Gaudi::Property< bool > m_useScoring
Boolean to apply heuristic when tracks have close deltaR.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
double m_deltaPhiRescaleWeight
StatusCode initialize() override final
Gaudi algorithm hooks.
Gaudi::Property< double > m_narrowDeltaPhi
narrow cut on deltaPhiRescale
virtual StatusCode executeRec(const EventContext &ctx, EgammaRecContainer *egammas) const override final
execute method
Gaudi::Property< float > m_distanceForScore
The distance from which one goes from using better deltaR to using score.
ToolHandle< IEMExtrapolationTools > m_extrapolationTool
Gaudi::Property< double > m_MaxDeltaPhiRescale
@Maximum deltaPhi (Res) allowed for a match
bool isCandidateMatch(const xAOD::CaloCluster *cluster, const xAOD::TrackParticle *track, bool flip) const
Loose track-cluster matching.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackParticlesKey
name of TrackParticle container in TDS
Gaudi::Property< double > m_narrowDeltaPhiRescale
narrow cut on deltaPhiRescale
Gaudi::Property< bool > m_useCandidateMatch
flag to turn on/off use of isCandidateMatch
bool inBroadWindow(const EventContext &ctx, std::vector< TrackMatch > &trackMatches, const xAOD::CaloCluster &cluster, int trackNumber, const xAOD::TrackParticle &trkPB, const CaloDetDescrManager &caloDD) const
Compute for tracks passing the loose matching the distance between track extrapolated to 2nd sampling...
Gaudi::Property< double > m_narrowDeltaPhiRescaleBrem
narrow cut on deltaPhiRescale for electrons
Gaudi::Property< float > m_deltaPhiRescaleResolution
Gaudi::Property< float > m_deltaPhiResolution
Gaudi::Property< bool > m_useRescaleMetric
Boolean to use Rescale in the metric.
StatusCode trackExecute(const EventContext &ctx, egammaRec *eg, const xAOD::TrackParticleContainer *trackPC, const CaloDetDescrManager &caloDD) const
execute method
Gaudi::Property< double > m_narrowDeltaEta
narrow cut on deltaEta
Gaudi::Property< bool > m_SecondPassRescale
Boolean to do second pass with Rescale.
Gaudi::Property< double > m_broadDeltaEta
broad cut on deltaEta
Gaudi::Property< double > m_broadDeltaPhi
broad cut on deltaPhi
Gaudi::Property< float > m_deltaEtaResolution
The resolutions: might be good to split in barrel/end-cap in the future.
Gaudi::Property< double > m_narrowDeltaPhiBrem
narrow cut on deltaPhi for electrons
TrackMatchSorter m_sorter
ElementLink implementation for ROOT usage.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & position() const
Access method for the position.
Represent an egamma object for internal egamma usage during reconstruction.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
DataVector< egammaRec > EgammaRecContainer
The container is a simple typedef for now.
Eigen::Matrix< double, 3, 1 > Vector3D
double PhiROT(const double pt, const double eta, const int charge, const double r_start, const bool isEndCap)
Function to calculate the approximate rotation in phi/bending of a track until it reaches the calo.
Amg::Vector3D approxXYZwrtPoint(const xAOD::CaloCluster &cluster, const Amg::Vector3D &point, const bool isEndCap)
Function to get the (x,y,z) of the cluster wrt to a point (x0,y0,z0)
This module defines the arguments passed from the BATCH driver to the BATCH worker.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
int summaryValueInt(const xAOD::TrackParticle &tp, const xAOD::SummaryType &info, int deflt=-999)
return the summary value for a TrackParticle or default value (-999) (to be used mostly in python whe...
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
A structure for keeping track match information.
std::array< double, 4 > deltaPhiRescaled
std::array< double, 4 > deltaEta
std::array< double, 4 > deltaPhi