ATLAS Offline Software
Loading...
Searching...
No Matches
EMTrackMatchBuilder Class Referencefinal

EMTrackMatch data object builder. More...

#include <EMTrackMatchBuilder.h>

Inheritance diagram for EMTrackMatchBuilder:
Collaboration diagram for EMTrackMatchBuilder:

Classes

struct  TrackMatch
 A structure for keeping track match information. More...
class  TrackMatchSorter
 function object to sort track matches based on quality More...

Public Member Functions

 EMTrackMatchBuilder (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor.
virtual ~EMTrackMatchBuilder ()=default
 Destructor.
StatusCode initialize () override final
 Gaudi algorithm hooks.
virtual StatusCode executeRec (const EventContext &ctx, EgammaRecContainer *egammas) const override final
 execute method
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool interface methods.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode trackExecute (const EventContext &ctx, egammaRec *eg, const xAOD::TrackParticleContainer *trackPC, const CaloDetDescrManager &caloDD) const
 execute method
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 and cluster.
bool isCandidateMatch (const xAOD::CaloCluster *cluster, const xAOD::TrackParticle *track, bool flip) const
 Loose track-cluster matching.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackParticlesKey
 name of TrackParticle container in TDS
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Gaudi::Property< double > m_broadDeltaEta
 broad cut on deltaEta
Gaudi::Property< double > m_broadDeltaPhi
 broad cut on deltaPhi
Gaudi::Property< double > m_narrowDeltaEta
 narrow cut on deltaEta
Gaudi::Property< double > m_narrowDeltaPhi
 narrow cut on deltaPhiRescale
Gaudi::Property< double > m_narrowDeltaPhiBrem
 narrow cut on deltaPhi for electrons
Gaudi::Property< double > m_narrowDeltaPhiRescale
 narrow cut on deltaPhiRescale
Gaudi::Property< double > m_narrowDeltaPhiRescaleBrem
 narrow cut on deltaPhiRescale for electrons
Gaudi::Property< double > m_MaxDeltaPhiRescale
 @Maximum deltaPhi (Res) allowed for a match
Gaudi::Property< bool > m_useCandidateMatch
 flag to turn on/off use of isCandidateMatch
Gaudi::Property< bool > m_useScoring
 Boolean to apply heuristic when tracks have close deltaR.
Gaudi::Property< bool > m_useRescaleMetric
 Boolean to use Rescale in the metric.
Gaudi::Property< bool > m_SecondPassRescale
 Boolean to do second pass with Rescale.
Gaudi::Property< float > m_deltaEtaResolution
 The resolutions: might be good to split in barrel/end-cap in the future.
Gaudi::Property< float > m_deltaPhiResolution
Gaudi::Property< float > m_deltaPhiRescaleResolution
Gaudi::Property< float > m_distanceForScore
 The distance from which one goes from using better deltaR to using score.
ToolHandle< IEMExtrapolationTools > m_extrapolationTool
Gaudi::Property< bool > m_isCosmics
double m_deltaEtaWeight {}
double m_deltaPhiWeight {}
double m_deltaPhiRescaleWeight {}
TrackMatchSorter m_sorter
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

EMTrackMatch data object builder.

Author
H. Ma
RD schaffer
Thomas Koffas
Christos Anastopoulos The matching of a track to a cluster is driven by the EMTrackMatchBuilder tool located in the Reconstruction/egamma/egammaTools package.

Definition at line 39 of file EMTrackMatchBuilder.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ EMTrackMatchBuilder()

EMTrackMatchBuilder::EMTrackMatchBuilder ( const std::string & type,
const std::string & name,
const IInterface * parent )

Default constructor.

Definition at line 26 of file EMTrackMatchBuilder.cxx.

29 : AthAlgTool(type, name, parent)
30{
31 // declare interface
32 declareInterface<IEMTrackMatchBuilder>(this);
33}
AthAlgTool()
Default constructor:

◆ ~EMTrackMatchBuilder()

virtual EMTrackMatchBuilder::~EMTrackMatchBuilder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ executeRec()

StatusCode EMTrackMatchBuilder::executeRec ( const EventContext & ctx,
EgammaRecContainer * egammas ) const
finaloverridevirtual

execute method

Implements IEMTrackMatchBuilder.

Definition at line 53 of file EMTrackMatchBuilder.cxx.

55{
56 // protection against bad pointers
57 if (egammas == nullptr) {
58 return StatusCode::SUCCESS;
59 }
60 // retrieve the trackparticle container
61 SG::ReadHandle<xAOD::TrackParticleContainer> trackPC(m_TrackParticlesKey,
62 ctx);
63
64 SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
66 };
67 ATH_CHECK(caloDetDescrMgrHandle.isValid());
68
69 const CaloDetDescrManager* caloDD = *caloDetDescrMgrHandle;
70
71 // check is only used for serial running; remove when MT scheduler used
72 ATH_CHECK(trackPC.isValid());
73 // Loop over calling the trackExecute method
74 for (egammaRec* eg : *egammas) {
75 // retrieve the cluster
76 ATH_CHECK(trackExecute(ctx, eg, trackPC.cptr(), *caloDD));
77 }
78 return StatusCode::SUCCESS;
79}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackParticlesKey
name of TrackParticle container in TDS
StatusCode trackExecute(const EventContext &ctx, egammaRec *eg, const xAOD::TrackParticleContainer *trackPC, const CaloDetDescrManager &caloDD) const
execute method

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ inBroadWindow()

bool EMTrackMatchBuilder::inBroadWindow ( const EventContext & ctx,
std::vector< TrackMatch > & trackMatches,
const xAOD::CaloCluster & cluster,
int trackNumber,
const xAOD::TrackParticle & trkPB,
const CaloDetDescrManager & caloDD ) const
private

Compute for tracks passing the loose matching the distance between track extrapolated to 2nd sampling and cluster.

Definition at line 153 of file EMTrackMatchBuilder.cxx.

159{
160
163
164 // Now get the delta eta/phi and eta correction at the calorimeter
165 // final arrays that we will write
166 // Save the value of deltaPhiRescale. If we do not use rescaled
167 // perigee, we recalculate deltaPhi using rescaled momentum. This
168 // will be saved in EMTrackMatch
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 };
173
174 /*
175 * Try both from perigee
176 * and from perigee Rescale.
177 *
178 * We need anyhow both to be there at the end.
179 */
180 std::pair<std::vector<CaloSampling::CaloSample>,
181 std::vector<std::unique_ptr<Trk::Surface>>>
182 layersAndSurfaces =
183 m_extrapolationTool->getClusterLayerSurfaces(cluster, caloDD);
185 ->getMatchAtCalo(ctx,
186 cluster,
187 trkPB,
188 layersAndSurfaces.first,
189 layersAndSurfaces.second,
190 eta,
191 phi,
192 deltaEta,
193 deltaPhi,
194 extrapFrom)
195 .isFailure()) {
196 return false;
197 }
198
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 };
205
207 ->getMatchAtCalo(ctx,
208 cluster,
209 trkPB,
210 layersAndSurfaces.first,
211 layersAndSurfaces.second,
212 etaRes,
213 phiRes,
214 deltaEtaRes,
215 deltaPhiRes,
216 extrapFromRes)
217 .isFailure()) {
218 return false;
219 }
220
221 double deltaPhiRescale = deltaPhiRes[2];
222 /*
223 * Sanity check for very far away matches
224 * The assumption is when we rescale we should be in the
225 * correct neighborhood for a valid track-cluster pair.
226 */
227 if (std::abs(deltaPhiRes[2]) > m_MaxDeltaPhiRescale) {
228 ATH_MSG_DEBUG("DeltaPhiRescaled above maximum: "
229 << deltaPhiRes[2] << " (max: " << m_MaxDeltaPhiRescale
230 << ")");
231 return false;
232 }
233 /*
234 * Try to match : First standard way.
235 * If this fails and the cluster Et is larger than the track Pt
236 * it might get matched only under the rescaled assumption that
237 * should be less sensitive to radiative losses.
238 */
239 if (std::abs(deltaEta[2]) < m_narrowDeltaEta && deltaPhi[2] < m_narrowDeltaPhi &&
241 ATH_MSG_DEBUG("Matched with Perigee");
242 } else if (m_SecondPassRescale && cluster.et() > trkPB.pt() &&
243 std::abs(deltaEtaRes[2]) < m_narrowDeltaEta &&
244 deltaPhiRes[2] < m_narrowDeltaPhiRescale &&
245 deltaPhiRes[2] > -m_narrowDeltaPhiRescaleBrem) {
246 ATH_MSG_DEBUG("Not Perigee but matched with Rescale");
247 } else {
248 ATH_MSG_DEBUG("Normal matched Failed deltaPhi/deltaEta "
249 << deltaPhi[2] << " / " << deltaEta[2]);
250 ATH_MSG_DEBUG("Rescaled matched Failed deltaPhi/deltaEta "
251 << deltaPhiRes[2] << " / " << deltaEtaRes[2]);
252 return false;
253 }
254
255 // Always the deltaPhiLast will be from the last measurement
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 };
262
264 ->getMatchAtCalo(ctx,
265 cluster,
266 trkPB,
267 layersAndSurfaces.first,
268 layersAndSurfaces.second,
269 eta1,
270 phi1,
271 deltaEta1,
272 deltaPhi1,
273 extrapFrom1)
274 .isFailure()) {
275 ATH_MSG_DEBUG("Extrapolation from last measurement failed");
276 return false;
277 }
278 double deltaPhiLast = deltaPhi1[2];
279 ATH_MSG_DEBUG("Rescale dPhi " << deltaPhiRescale);
280 ATH_MSG_DEBUG("dPhi Last measurement " << deltaPhiLast);
281 /*
282 * Done with extrapolation
283 * Lets do the matching logic
284 */
285 TrackMatch trkmatch{};
286 // Add the matching variable to the TrackMAtch
287 trkmatch.deltaEta = deltaEta;
288 trkmatch.deltaPhi = deltaPhi;
289 trkmatch.deltaPhiRescaled = deltaPhiRes;
290 trkmatch.deltaPhiLast = deltaPhiLast;
291
292 // Variables used for the sorting. Note both dPhi's will be used.
293 trkmatch.trackNumber = trackNumber;
294 if (m_useRescaleMetric) {
295 trkmatch.dR = sqrt(std::pow(m_deltaEtaWeight * deltaEta[2], 2) +
296 std::pow(m_deltaPhiRescaleWeight * deltaPhiRescale, 2));
297 trkmatch.seconddR = sqrt(std::pow(m_deltaEtaWeight * deltaEta[2], 2) +
298 std::pow(m_deltaPhiWeight * deltaPhi[2], 2));
299 } else {
300 trkmatch.dR = sqrt(std::pow(m_deltaEtaWeight * deltaEta[2], 2) +
301 std::pow(m_deltaPhiWeight * deltaPhi[2], 2));
302 trkmatch.seconddR =
303 sqrt(std::pow(m_deltaEtaWeight * deltaEta[2], 2) +
304 std::pow(m_deltaPhiRescaleWeight * deltaPhiRescale, 2));
305 }
306 ATH_MSG_DEBUG(" DR " << trkmatch.dR << " deltaPhi " << deltaPhi[2]
307 << " deltaEta " << deltaEta[2]);
308 /*
309 * The first thing is
310 * Prefer pixel over SCT only
311 */
312 // Check number of pixel hits
313 int nPixel = summaryValueInt(trkPB, xAOD::numberOfPixelDeadSensors, 0);
314 nPixel += summaryValueInt(trkPB, xAOD::numberOfPixelHits, 0);
315 trkmatch.hasPix = (nPixel > 0);
316
317 /*
318 * Seconday hitsScore score based on hits to be used
319 * for track that are very close
320 * to each other at the calo i.e similar dR with cluster,
321 * pick the longest possible one
322 */
323 trkmatch.hitsScore = 0;
324 if (m_useScoring) {
325 // Check the 2 innermost layers
326 int nInnerMost = summaryValueInt(trkPB, xAOD::numberOfInnermostPixelLayerHits, 0);
328 int nNextToInnerMost = summaryValueInt(trkPB, xAOD::numberOfNextToInnermostPixelLayerHits, 0);
330
331 // Secondary score , find the longest track possible,
332 // i.e the one with the most inner hists in the pixel
333 // npixel*5
334 trkmatch.hitsScore += (nPixel * 5);
335 // Extra points for NextToInnermost
336 if (!expectNextToInnermostPixelLayerHit || nNextToInnerMost > 0) {
337 trkmatch.hitsScore += 5;
338 }
339 // Extra points for Innermost
340 if (!expectInnermostPixelLayerHit || nInnerMost > 0) {
341 trkmatch.hitsScore += 10;
342 }
343 }
344 ATH_MSG_DEBUG("hasPix : " << trkmatch.hasPix
345 << " hitsScore : " << trkmatch.hitsScore);
346
347 trackMatches.push_back(trkmatch);
348 return true;
349}
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_MSG_DEBUG(x,...)
Gaudi::Property< bool > m_useScoring
Boolean to apply heuristic when tracks have close deltaR.
Gaudi::Property< double > m_narrowDeltaPhi
narrow cut on deltaPhiRescale
ToolHandle< IEMExtrapolationTools > m_extrapolationTool
Gaudi::Property< double > m_MaxDeltaPhiRescale
@Maximum deltaPhi (Res) allowed for a match
Gaudi::Property< double > m_narrowDeltaPhiRescale
narrow cut on deltaPhiRescale
Gaudi::Property< double > m_narrowDeltaPhiRescaleBrem
narrow cut on deltaPhiRescale for electrons
Gaudi::Property< bool > m_useRescaleMetric
Boolean to use Rescale in the metric.
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_narrowDeltaPhiBrem
narrow cut on deltaPhi for electrons
TrkExtrapDef
Enum for track extrapolation to calo.
@ fromPerigee
from the perigee of TrackParticle
@ fromLastMeasurement
from the last measurement of TrackParticle
@ fromPerigeeRescaled
from the perigee of TrackParticle recaled by Ecluster
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition P4Helpers.h:66
@ deltaPhiLast
deltaPhi from the las point
@ deltaPhi1
difference between the cluster eta (1st sampling) and the eta of the track extrapolated to the 1st sa...
@ deltaEta1
difference between the cluster eta (first sampling) and the eta of the track extrapolated to the firs...
setEt setPhi setE277 setWeta2 eta1
@ 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.

◆ initialize()

StatusCode EMTrackMatchBuilder::initialize ( )
finaloverridevirtual

Gaudi algorithm hooks.

Implements IEMTrackMatchBuilder.

Definition at line 36 of file EMTrackMatchBuilder.cxx.

37{
38 ATH_CHECK(m_TrackParticlesKey.initialize());
39 ATH_CHECK(m_caloDetDescrMgrKey.initialize());
40 // the extrapolation tool
42
43 // set things up for the sorting
48
49 return StatusCode::SUCCESS;
50}
function object to sort track matches based on quality
Gaudi::Property< float > m_distanceForScore
The distance from which one goes from using better deltaR to using score.
Gaudi::Property< float > m_deltaPhiRescaleResolution
Gaudi::Property< float > m_deltaPhiResolution
Gaudi::Property< float > m_deltaEtaResolution
The resolutions: might be good to split in barrel/end-cap in the future.
TrackMatchSorter m_sorter

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & IEMTrackMatchBuilder::interfaceID ( )
inlinestaticinherited

AlgTool interface methods.

Definition at line 50 of file IEMTrackMatchBuilder.h.

51{
53}
static const InterfaceID IID_IEMTrackMatchBuilder("IEMTrackMatchBuilder", 1, 0)

◆ isCandidateMatch()

bool EMTrackMatchBuilder::isCandidateMatch ( const xAOD::CaloCluster * cluster,
const xAOD::TrackParticle * track,
bool flip ) const
private

Loose track-cluster matching.

Definition at line 352 of file EMTrackMatchBuilder.cxx.

355{
356 // loose cluster-track matching
357 if (!m_useCandidateMatch) {
358 return true;
359 }
360
361 // Tracking
362 const Trk::Perigee& candidatePerigee = track->perigeeParameters();
363 // Decide whether to try the opposite direction (cosmics)
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();
370 const Amg::Vector3D PerigeeXYZPosition(candidatePerigee.position().x(),
371 candidatePerigee.position().y(),
372 z_perigee);
373 // Cluster variables
374 const double clusterEta = cluster->eta();
375 const bool isEndCap = !xAOD::EgammaHelpers::isBarrel(cluster);
376 const double Et = cluster->e() / cosh(trkEta);
377 const double clusterPhi = cluster->phi();
378
379 // Avoid clusters with |eta| > 10 or Et less than 10 MeV
380 if (std::abs(clusterEta) > 10.0 || Et < 10) {
381 return false;
382 }
383 // Calculate the eta/phi of the cluster as would be seen from the perigee
384 // position of the Track
385 const Amg::Vector3D XYZClusterWrtTrackPerigee =
387 *cluster, PerigeeXYZPosition, isEndCap);
388
389 const double clusterEtaCorrected = XYZClusterWrtTrackPerigee.eta();
390 // check eta match . Both metrics need to fail in order to disgard the track
391 if ((std::abs(clusterEta - trkEta) > 2. * m_broadDeltaEta) &&
392 (std::abs(clusterEtaCorrected - trkEta) > 2. * m_broadDeltaEta)) {
393 ATH_MSG_DEBUG(" Fails broad window eta match (track eta, cluster eta, "
394 "cluster eta corrected): ( "
395 << trkEta << ", " << clusterEta << ", " << clusterEtaCorrected
396 << ")");
397 return false;
398 }
399 // Calculate the possible rotation of the track
400 // Once assuming the cluster Et being the better estimate (e.g big brem)
401 const double phiRotRescaled = CandidateMatchHelpers::PhiROT(
402 Et, trkEta, track->charge(), r_perigee, isEndCap);
403 // And also assuming the track Pt being correct
404 const double phiRotTrack = CandidateMatchHelpers::PhiROT(
405 track->pt(), trkEta, track->charge(), r_perigee, isEndCap);
406 //
407 const double clusterPhiCorrected = XYZClusterWrtTrackPerigee.phi();
408 // deltaPhi between the track and the cluster
409 const double deltaPhiStd = P4Helpers::deltaPhi(clusterPhiCorrected, trkPhi);
410 // deltaPhi between the track and the cluster accounting for rotation assuming
411 // cluster Et is a better estimator
412 const double trkPhiRescaled = P4Helpers::deltaPhi(trkPhi, phiRotRescaled);
413 const double deltaPhiRescaled =
414 P4Helpers::deltaPhi(clusterPhiCorrected, trkPhiRescaled);
415 // deltaPhi between the track and the cluster accounting for rotation
416 const double trkPhiCorrTrack = P4Helpers::deltaPhi(trkPhi, phiRotTrack);
417 const double deltaPhiTrack =
418 P4Helpers::deltaPhi(clusterPhiCorrected, trkPhiCorrTrack);
419
420 // It has to fail all phi metrics in order to be disgarded
421 if ((std::abs(deltaPhiRescaled) > 2. * m_broadDeltaPhi) &&
422 (std::abs(deltaPhiTrack) > 2. * m_broadDeltaPhi) &&
423 (std::abs(deltaPhiStd) > 2. * m_broadDeltaPhi)) {
424
426 "FAILS broad window phi match (track phi, phirotCluster , phiRotTrack , "
427 << "cluster phi corrected, cluster phi): ( " << trkPhi << ", "
428 << phiRotRescaled << ", " << phiRotTrack << ", " << clusterPhiCorrected
429 << ", " << clusterPhi << ")");
430
431 return false;
432 }
433 // if not false returned we end up here
434 return true;
435}
Gaudi::Property< bool > m_useCandidateMatch
flag to turn on/off use of isCandidateMatch
Gaudi::Property< double > m_broadDeltaEta
broad cut on deltaEta
Gaudi::Property< double > m_broadDeltaPhi
broad cut on deltaPhi
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & position() const
Access method for the position.
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.
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).
ConcurrentBitset & flip(bit_t bit)
Flip the value of one bit.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ phi
Definition ParamDefs.h:75
@ deltaPhiRescaled
difference between the cluster phi (sampling 2) and the phi of the track extrapolated from the perige...
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ trackExecute()

StatusCode EMTrackMatchBuilder::trackExecute ( const EventContext & ctx,
egammaRec * eg,
const xAOD::TrackParticleContainer * trackPC,
const CaloDetDescrManager & caloDD ) const
private

execute method

Definition at line 82 of file EMTrackMatchBuilder.cxx.

86{
87 if (!eg || !trackPC) {
89 "trackExecute: NULL pointer to egammaRec or TrackParticleContainer");
90 return StatusCode::SUCCESS;
91 }
92 // retrieve corresponding cluster
93 const xAOD::CaloCluster* cluster = eg->caloCluster();
94 // check if the cluster is sane
95 if (!cluster){
96 ATH_MSG_WARNING("trackExecute: cluster ptr is null! Ignoring cluster.");
97 return StatusCode::SUCCESS;
98 }
99 if (cluster->e() == 0.0) {
100 ATH_MSG_WARNING("trackExecute: cluster energy is 0.0! Ignoring cluster.");
101 return StatusCode::SUCCESS;
102 }
103
104 // Loop over tracks and fill TrackMatch vector
105 std::vector<TrackMatch> trkMatches;
107 for (unsigned int trackNumber = 0; trkIt != trackPC->end();
108 ++trkIt, ++trackNumber) {
109 // Avoid TRT alone
110 if (xAOD::EgammaHelpers::numberOfSiHits(*trkIt) < 4) {
111 continue;
112 }
113 /*
114 * Try with normal directions.
115 * For cosmics allow a retry with inverted direction.
116 */
117 if (isCandidateMatch(cluster, (*trkIt), false)) {
118 inBroadWindow(ctx, trkMatches, *cluster, trackNumber, (**trkIt), caloDD);
119 }
120 }
121
122 if (!trkMatches.empty()) {
123 // sort the track matches
124 std::sort(trkMatches.begin(), trkMatches.end(), m_sorter);
125 // set the matching values
126 TrackMatch bestTrkMatch = trkMatches.at(0);
127 eg->setDeltaEta(bestTrkMatch.deltaEta);
128 eg->setDeltaPhi(bestTrkMatch.deltaPhi);
129 eg->setDeltaPhiRescaled(bestTrkMatch.deltaPhiRescaled);
130 eg->setDeltaPhiLast(bestTrkMatch.deltaPhiLast);
131
132 // set the element Links
133 using EL = ElementLink<xAOD::TrackParticleContainer>;
134 std::vector<EL> trackParticleLinks;
135 trackParticleLinks.reserve(trkMatches.size());
136 const std::string key = EL(*trackPC, 0, ctx).dataID();
137 for (const TrackMatch& m : trkMatches) {
138 ATH_MSG_DEBUG("Match dR: " << m.dR << " second dR: " << m.seconddR
139 << " hasPix: " << m.hasPix
140 << " hitsScore: " << m.hitsScore);
141 if (key.empty()) {
142 trackParticleLinks.emplace_back(*trackPC, m.trackNumber, ctx);
143 } else {
144 trackParticleLinks.emplace_back(key, m.trackNumber, ctx);
145 }
146 }
147 eg->setTrackParticles(trackParticleLinks);
148 }
149 return StatusCode::SUCCESS;
150}
#define ATH_MSG_WARNING(x,...)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:861
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.
bool isCandidateMatch(const xAOD::CaloCluster *cluster, const xAOD::TrackParticle *track, bool flip) const
Loose track-cluster matching.
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...
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.
Definition egammaRec.cxx:8
ElementLink< CVec > EL
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinks(const xAOD::TauJet *tau, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_broadDeltaEta

Gaudi::Property<double> EMTrackMatchBuilder::m_broadDeltaEta
private
Initial value:
{ this,
"broadDeltaEta",
0.1,
"Value of broad cut for delta eta" }

broad cut on deltaEta

Definition at line 125 of file EMTrackMatchBuilder.h.

125 { this,
126 "broadDeltaEta",
127 0.1,
128 "Value of broad cut for delta eta" };

◆ m_broadDeltaPhi

Gaudi::Property<double> EMTrackMatchBuilder::m_broadDeltaPhi
private
Initial value:
{ this,
"broadDeltaPhi",
0.1,
"Value of broad cut for delta phi" }

broad cut on deltaPhi

Definition at line 131 of file EMTrackMatchBuilder.h.

131 { this,
132 "broadDeltaPhi",
133 0.1,
134 "Value of broad cut for delta phi" };

◆ m_caloDetDescrMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> EMTrackMatchBuilder::m_caloDetDescrMgrKey
private
Initial value:
{
this,
"CaloDetDescrManager",
"CaloDetDescrManager",
"SG Key for CaloDetDescrManager in the Condition Store"
}

Definition at line 117 of file EMTrackMatchBuilder.h.

117 {
118 this,
119 "CaloDetDescrManager",
120 "CaloDetDescrManager",
121 "SG Key for CaloDetDescrManager in the Condition Store"
122 };

◆ m_deltaEtaResolution

Gaudi::Property<float> EMTrackMatchBuilder::m_deltaEtaResolution
private
Initial value:
{ this,
"DeltaEtaResolution",
1.0,
"The deltaEta resolution" }

The resolutions: might be good to split in barrel/end-cap in the future.

Definition at line 213 of file EMTrackMatchBuilder.h.

213 { this,
214 "DeltaEtaResolution",
215 1.0,
216 "The deltaEta resolution" };

◆ m_deltaEtaWeight

double EMTrackMatchBuilder::m_deltaEtaWeight {}
private

Definition at line 256 of file EMTrackMatchBuilder.h.

256{};

◆ m_deltaPhiRescaleResolution

Gaudi::Property<float> EMTrackMatchBuilder::m_deltaPhiRescaleResolution
private
Initial value:
{
this,
"DeltaPhiRescaleResolution",
1.0,
"The deltaPhiRescale resolution"
}

Definition at line 223 of file EMTrackMatchBuilder.h.

223 {
224 this,
225 "DeltaPhiRescaleResolution",
226 1.0,
227 "The deltaPhiRescale resolution"
228 };

◆ m_deltaPhiRescaleWeight

double EMTrackMatchBuilder::m_deltaPhiRescaleWeight {}
private

Definition at line 258 of file EMTrackMatchBuilder.h.

258{};

◆ m_deltaPhiResolution

Gaudi::Property<float> EMTrackMatchBuilder::m_deltaPhiResolution
private
Initial value:
{ this,
"DeltaPhiResolution",
1.0,
"The deltaPhi resolution" }

Definition at line 218 of file EMTrackMatchBuilder.h.

218 { this,
219 "DeltaPhiResolution",
220 1.0,
221 "The deltaPhi resolution" };

◆ m_deltaPhiWeight

double EMTrackMatchBuilder::m_deltaPhiWeight {}
private

Definition at line 257 of file EMTrackMatchBuilder.h.

257{};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_distanceForScore

Gaudi::Property<float> EMTrackMatchBuilder::m_distanceForScore
private
Initial value:
{
this,
"DistanceForScore",
0.01,
"The distance from which one goes from using better deltaR to using score."
}

The distance from which one goes from using better deltaR to using score.

Note that this distance varies depending on the resolutions entered above. If you don't use resolutions (resolution = 1.0) this becomes deltaR distance.

Definition at line 235 of file EMTrackMatchBuilder.h.

235 {
236 this,
237 "DistanceForScore",
238 0.01,
239 "The distance from which one goes from using better deltaR to using score."
240 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_extrapolationTool

ToolHandle<IEMExtrapolationTools> EMTrackMatchBuilder::m_extrapolationTool
private
Initial value:
{
this,
"ExtrapolationTool",
"EMExtrapolationTools",
"Name of the extrapolation tool"
}

Definition at line 242 of file EMTrackMatchBuilder.h.

242 {
243 this,
244 "ExtrapolationTool",
245 "EMExtrapolationTools",
246 "Name of the extrapolation tool"
247 };

◆ m_isCosmics

Gaudi::Property<bool> EMTrackMatchBuilder::m_isCosmics
private
Initial value:
{ this,
"isCosmics",
false,
"Boolean for use of cosmics" }

Definition at line 250 of file EMTrackMatchBuilder.h.

250 { this,
251 "isCosmics",
252 false,
253 "Boolean for use of cosmics" };

◆ m_MaxDeltaPhiRescale

Gaudi::Property<double> EMTrackMatchBuilder::m_MaxDeltaPhiRescale
private
Initial value:
{
this,
"MaxDeltaPhiRescale",
0.25,
"Maximum Value of the deltaPhi rescale"
}

@Maximum deltaPhi (Res) allowed for a match

Definition at line 177 of file EMTrackMatchBuilder.h.

177 {
178 this,
179 "MaxDeltaPhiRescale",
180 0.25,
181 "Maximum Value of the deltaPhi rescale"
182 };

◆ m_narrowDeltaEta

Gaudi::Property<double> EMTrackMatchBuilder::m_narrowDeltaEta
private
Initial value:
{
this,
"narrowDeltaEta",
0.05,
"Value of narrow cut for delta eta"
}

narrow cut on deltaEta

Definition at line 137 of file EMTrackMatchBuilder.h.

137 {
138 this,
139 "narrowDeltaEta",
140 0.05,
141 "Value of narrow cut for delta eta"
142 };

◆ m_narrowDeltaPhi

Gaudi::Property<double> EMTrackMatchBuilder::m_narrowDeltaPhi
private
Initial value:
{
this,
"narrowDeltaPhi",
0.05,
"Value of the narrowd cut for delta phi"
}

narrow cut on deltaPhiRescale

Definition at line 145 of file EMTrackMatchBuilder.h.

145 {
146 this,
147 "narrowDeltaPhi",
148 0.05,
149 "Value of the narrowd cut for delta phi"
150 };

◆ m_narrowDeltaPhiBrem

Gaudi::Property<double> EMTrackMatchBuilder::m_narrowDeltaPhiBrem
private
Initial value:
{
this,
"narrowDeltaPhiBrem",
0.1,
"Value of the narrow cut for delta phi Brem"
}

narrow cut on deltaPhi for electrons

Definition at line 153 of file EMTrackMatchBuilder.h.

153 {
154 this,
155 "narrowDeltaPhiBrem",
156 0.1,
157 "Value of the narrow cut for delta phi Brem"
158 };

◆ m_narrowDeltaPhiRescale

Gaudi::Property<double> EMTrackMatchBuilder::m_narrowDeltaPhiRescale
private
Initial value:
{
this,
"narrowDeltaPhiRescale",
0.05,
"Value of the narrow cut for delta phi Rescale"
}

narrow cut on deltaPhiRescale

Definition at line 161 of file EMTrackMatchBuilder.h.

161 {
162 this,
163 "narrowDeltaPhiRescale",
164 0.05,
165 "Value of the narrow cut for delta phi Rescale"
166 };

◆ m_narrowDeltaPhiRescaleBrem

Gaudi::Property<double> EMTrackMatchBuilder::m_narrowDeltaPhiRescaleBrem
private
Initial value:
{
this,
"narrowDeltaPhiRescaleBrem",
0.1,
"Value of the narrow cut for delta phi Rescale Brem"
}

narrow cut on deltaPhiRescale for electrons

Definition at line 169 of file EMTrackMatchBuilder.h.

169 {
170 this,
171 "narrowDeltaPhiRescaleBrem",
172 0.1,
173 "Value of the narrow cut for delta phi Rescale Brem"
174 };

◆ m_SecondPassRescale

Gaudi::Property<bool> EMTrackMatchBuilder::m_SecondPassRescale
private
Initial value:
{ this,
"SecondPassRescale",
true,
"Do second pass with rescale" }

Boolean to do second pass with Rescale.

Definition at line 207 of file EMTrackMatchBuilder.h.

207 { this,
208 "SecondPassRescale",
209 true,
210 "Do second pass with rescale" };

◆ m_sorter

TrackMatchSorter EMTrackMatchBuilder::m_sorter
private

Definition at line 260 of file EMTrackMatchBuilder.h.

◆ m_TrackParticlesKey

SG::ReadHandleKey<xAOD::TrackParticleContainer> EMTrackMatchBuilder::m_TrackParticlesKey
private
Initial value:
{
this,
"TrackParticlesName",
"",
"Name of the input track particle container"
}

name of TrackParticle container in TDS

Definition at line 110 of file EMTrackMatchBuilder.h.

110 {
111 this,
112 "TrackParticlesName",
113 "",
114 "Name of the input track particle container"
115 };

◆ m_useCandidateMatch

Gaudi::Property<bool> EMTrackMatchBuilder::m_useCandidateMatch
private
Initial value:
{
this,
"useCandidateMatch",
true,
"Boolean to use candidate matching"
}

flag to turn on/off use of isCandidateMatch

Definition at line 185 of file EMTrackMatchBuilder.h.

185 {
186 this,
187 "useCandidateMatch",
188 true,
189 "Boolean to use candidate matching"
190 };

◆ m_useRescaleMetric

Gaudi::Property<bool> EMTrackMatchBuilder::m_useRescaleMetric
private
Initial value:
{ this,
"UseRescaleMetric",
true,
"Use Rescale Metric" }

Boolean to use Rescale in the metric.

Definition at line 201 of file EMTrackMatchBuilder.h.

201 { this,
202 "UseRescaleMetric",
203 true,
204 "Use Rescale Metric" };

◆ m_useScoring

Gaudi::Property<bool> EMTrackMatchBuilder::m_useScoring
private
Initial value:
{
this,
"useScoring",
true,
"Boolean to apply heuristic when tracks have close deltaR"
}

Boolean to apply heuristic when tracks have close deltaR.

Definition at line 193 of file EMTrackMatchBuilder.h.

193 {
194 this,
195 "useScoring",
196 true,
197 "Boolean to apply heuristic when tracks have close deltaR"
198 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: