20#include "GaudiKernel/EventContext.h"
27 const std::string& name,
28 const IInterface* parent)
32 declareInterface<IEMTrackMatchBuilder>(
this);
49 return StatusCode::SUCCESS;
57 if (egammas ==
nullptr) {
58 return StatusCode::SUCCESS;
78 return StatusCode::SUCCESS;
87 if (!eg || !trackPC) {
89 "trackExecute: NULL pointer to egammaRec or TrackParticleContainer");
90 return StatusCode::SUCCESS;
96 ATH_MSG_WARNING(
"trackExecute: cluster ptr is null! Ignoring cluster.");
97 return StatusCode::SUCCESS;
99 if (cluster->
e() == 0.0) {
100 ATH_MSG_WARNING(
"trackExecute: cluster energy is 0.0! Ignoring cluster.");
101 return StatusCode::SUCCESS;
105 std::vector<TrackMatch> trkMatches;
107 for (
unsigned int trackNumber = 0; trkIt != trackPC->
end();
108 ++trkIt, ++trackNumber) {
118 inBroadWindow(ctx, trkMatches, *cluster, trackNumber, (**trkIt), caloDD);
122 if (!trkMatches.empty()) {
134 std::vector<EL> trackParticleLinks;
135 trackParticleLinks.reserve(trkMatches.size());
136 const std::string key =
EL(*trackPC, 0, ctx).dataID();
138 ATH_MSG_DEBUG(
"Match dR: " << m.dR <<
" second dR: " << m.seconddR
139 <<
" hasPix: " << m.hasPix
140 <<
" hitsScore: " << m.hitsScore);
142 trackParticleLinks.emplace_back(*trackPC, m.trackNumber, ctx);
144 trackParticleLinks.emplace_back(key, m.trackNumber, ctx);
149 return StatusCode::SUCCESS;
154 std::vector<TrackMatch>& trackMatches,
169 std::array<double, 4>
eta = { -999.0, -999.0, -999.0, -999.0 };
170 std::array<double, 4>
phi = { -999.0, -999.0, -999.0, -999.0 };
171 std::array<double, 4> deltaEta = { -999.0, -999.0, -999.0, -999.0 };
172 std::array<double, 4>
deltaPhi = { -999.0, -999.0, -999.0, -999.0 };
180 std::pair<std::vector<CaloSampling::CaloSample>,
181 std::vector<std::unique_ptr<Trk::Surface>>>
185 ->getMatchAtCalo(ctx,
188 layersAndSurfaces.first,
189 layersAndSurfaces.second,
201 std::array<double, 4> etaRes = { -999.0, -999.0, -999.0, -999.0 };
202 std::array<double, 4> phiRes = { -999.0, -999.0, -999.0, -999.0 };
203 std::array<double, 4> deltaEtaRes = { -999.0, -999.0, -999.0, -999.0 };
204 std::array<double, 4> deltaPhiRes = { -999.0, -999.0, -999.0, -999.0 };
207 ->getMatchAtCalo(ctx,
210 layersAndSurfaces.first,
211 layersAndSurfaces.second,
221 double deltaPhiRescale = deltaPhiRes[2];
249 <<
deltaPhi[2] <<
" / " << deltaEta[2]);
251 << deltaPhiRes[2] <<
" / " << deltaEtaRes[2]);
258 std::array<double, 4> eta1 = { -999.0, -999.0, -999.0, -999.0 };
259 std::array<double, 4> phi1 = { -999.0, -999.0, -999.0, -999.0 };
260 std::array<double, 4> deltaEta1 = { -999.0, -999.0, -999.0, -999.0 };
261 std::array<double, 4> deltaPhi1 = { -999.0, -999.0, -999.0, -999.0 };
264 ->getMatchAtCalo(ctx,
267 layersAndSurfaces.first,
268 layersAndSurfaces.second,
278 double deltaPhiLast = deltaPhi1[2];
307 <<
" deltaEta " << deltaEta[2]);
315 trkmatch.
hasPix = (nPixel > 0);
336 if (!expectNextToInnermostPixelLayerHit || nNextToInnerMost > 0) {
340 if (!expectInnermostPixelLayerHit || nInnerMost > 0) {
345 <<
" hitsScore : " << trkmatch.
hitsScore);
347 trackMatches.push_back(trkmatch);
362 const Trk::Perigee& candidatePerigee = track->perigeeParameters();
364 const double trkPhi = (!flip) ? candidatePerigee.parameters()[
Trk::phi]
365 : -candidatePerigee.parameters()[
Trk::phi];
366 const double trkEta =
367 (!flip) ? candidatePerigee.
eta() : -candidatePerigee.
eta();
368 const double z_perigee = candidatePerigee.
position().z();
369 const double r_perigee = candidatePerigee.
position().perp();
374 const double clusterEta = cluster->
eta();
376 const double Et = cluster->
e() / cosh(trkEta);
377 const double clusterPhi = cluster->
phi();
380 if (std::abs(clusterEta) > 10.0 || Et < 10) {
387 *cluster, PerigeeXYZPosition, isEndCap);
389 const double clusterEtaCorrected = XYZClusterWrtTrackPerigee.eta();
393 ATH_MSG_DEBUG(
" Fails broad window eta match (track eta, cluster eta, "
394 "cluster eta corrected): ( "
395 << trkEta <<
", " << clusterEta <<
", " << clusterEtaCorrected
402 Et, trkEta, track->charge(), r_perigee, isEndCap);
405 track->pt(), trkEta, track->charge(), r_perigee, isEndCap);
407 const double clusterPhiCorrected = XYZClusterWrtTrackPerigee.phi();
413 const double deltaPhiRescaled =
417 const double deltaPhiTrack =
426 "FAILS broad window phi match (track phi, phirotCluster , phiRotTrack , "
427 <<
"cluster phi corrected, cluster phi): ( " << trkPhi <<
", "
428 << phiRotRescaled <<
", " << phiRotTrack <<
", " << clusterPhiCorrected
429 <<
", " << clusterPhi <<
")");
442 if (match1.hasPix != match2.
hasPix) {
443 return match1.hasPix;
448 if (std::abs(match1.seconddR - match2.
seconddR) >
450 return match1.seconddR < match2.
seconddR;
452 if ((match1.hitsScore != match2.
hitsScore)) {
453 return match1.hitsScore > match2.
hitsScore;
457 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_DEBUG(x,...)
#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.
void setDeltaEta(const std::array< double, 4 > &deltaEtas)
set deltaEta at pre sampler(0) -> 3rd sampling(3)
void setDeltaPhiLast(double value)
set deltaPhi at sampling 2 from Last track Measurement
void setDeltaPhiRescaled(std::array< double, 4 > &deltaPhis)
set deltaPhi at sampling for rescaled momentum extrapolation from the perigee.
void setTrackParticles(const std::vector< ElementLink< xAOD::TrackParticleContainer > > &links)
Set the ElementLinks to the xAOD::TrackParticle/s that match the electron candidate.
void setDeltaPhi(const std::array< double, 4 > &deltaPhis)
set Phi of track extrapolated at pre sampler(0) -> 3rd sampling(3)
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
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