ATLAS Offline Software
Loading...
Searching...
No Matches
electronSuperClusterBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6//
11#include "xAODEgamma/Egamma.h"
15
17
20
21#include <cmath>
22#include <memory>
23
24
25namespace{
26
27bool matchSameTrack(const xAOD::TrackParticle& seedTrack,
28 const egammaRec& sec) {
29 const xAOD::TrackParticle* secTrack = sec.trackParticle();
30 if (secTrack) {
31 // Check that the tracks are the same.
32 return seedTrack.index() == secTrack->index();
33 }
34 return false;
35}
36} // namespace
37
39 const std::string& name,
40 ISvcLocator* pSvcLocator)
41 : egammaSuperClusterBuilderBase(name, pSvcLocator)
42{
43}
44
45StatusCode
47{
48 ATH_MSG_DEBUG(" Initializing electronSuperClusterBuilder");
49
50 // Additional Window we search in
53
54 // retrieve track match builder
57 }
58
60}
61
62
64 // We need tracks
65 if (egRec->getNumberOfTrackParticles() == 0) {
66 return false;
67 }
68 const xAOD::TrackParticle *trackParticle = egRec->trackParticle(0);
70 // with possible pixel
71 uint8_t nPixelHits = summaryValueInt(*trackParticle, xAOD::numberOfPixelDeadSensors, 0);
72 nPixelHits += summaryValueInt(*trackParticle, xAOD::numberOfPixelHits, 0);
73 if (nPixelHits < m_numberOfPixelHits) {
74 return false;
75 }
76 // and with silicon (add SCT to pixel)
77 uint8_t nSiHits = nPixelHits;
78 nSiHits += summaryValueInt(*trackParticle, xAOD::numberOfSCTHits, 0);
79 return nSiHits >= m_numberOfSiHits;
80};
81
86
87StatusCode
89 const EventContext &ctx,
91) const {
93 ATH_CHECK(m_trackMatchBuilder->executeRec(ctx, newEgammaRecs.ptr()));
94 }
95
96 return StatusCode::SUCCESS;
97}
98
99std::vector<std::size_t>
101 const std::size_t seedIndex,
102 const EgammaRecContainer* egammaRecs,
103 std::vector<bool>& isUsed) const
104{
105 // assume egammaRecs != 0, since the ReadHadler is valid
106 // assume seed egammaRec has a valid cluster, since it has been already used
107 std::vector<std::size_t> secondaryIndices;
108
109 const auto* const seedEgammaRec = (*egammaRecs)[seedIndex];
110 const xAOD::CaloCluster* const seedCaloClus = seedEgammaRec->caloCluster();
111
112 const xAOD::TrackParticle* seedTrackParticle = seedEgammaRec->trackParticle();
113
114 // Now loop over the potential secondary clusters
115 for (std::size_t i = 0; i < egammaRecs->size(); ++i) {
116 // if already used continue
117 if (isUsed[i]) {
118 continue;
119 }
120
121 const auto* const secEgammaRec = (*egammaRecs)[i];
122 const xAOD::CaloCluster* const secClus = secEgammaRec->caloCluster();
123 // Now perform a number of tests to see if the cluster should be added
124
125 const auto seedSecdEta = std::abs(seedCaloClus->eta() - secClus->eta());
126 const auto seedSecdPhi =
127 std::abs(P4Helpers::deltaPhi(seedCaloClus->phi(), secClus->phi()));
128
129 const bool addCluster =
130 (matchesInWindow(seedCaloClus, secClus) ||
131 ((seedSecdEta < m_maxDelEta && seedSecdPhi < m_maxDelPhi) &&
132 (matchSameTrack(*seedTrackParticle, *secEgammaRec))));
133 // Add it to the list of secondary clusters if it matches.
134 if (addCluster) {
135 secondaryIndices.push_back(i);
136 isUsed[i] = true;
137 }
138 }
139 ATH_MSG_DEBUG("Found: " << secondaryIndices.size() << " secondaries");
140 return secondaryIndices;
141}
142
143
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...
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
size_type size() const noexcept
Returns the number of elements in the collection.
size_t index() const
Return the index of this element within its container.
pointer_type ptr()
Dereference the pointer.
Represent an egamma object for internal egamma usage during reconstruction.
Definition egammaRec.h:31
size_t getNumberOfTrackParticles() const
Return the number xAOD::TrackParticles that match the electron candidate.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Definition egammaRec.cxx:31
egammaSuperClusterBuilderBase(const std::string &name, ISvcLocator *pSvcLocator)
Protected constructor since this class should not be instantiated by itself.
bool matchesInWindow(const xAOD::CaloCluster *ref, const xAOD::CaloCluster *clus) const
Is clus in window center around ref?
virtual StatusCode initialize() override
should be called by the derived class in the initialize phase
virtual bool egammaRecPassesSelection(const egammaRec *egRec) const override final
Gaudi::Property< std::size_t > m_numberOfSiHits
virtual std::vector< std::size_t > searchForSecondaryClusters(const size_t i, const EgammaRecContainer *, std::vector< bool > &isUsed) const override final
Search for secondary clusters.
virtual StatusCode redoMatching(const EventContext &ctx, SG::WriteHandle< EgammaRecContainer > &newEgammaRecs) const override final
Gaudi::Property< int > m_maxDelEtaCells
Size of maximum search window in eta.
virtual xAOD::EgammaParameters::EgammaType getEgammaRecType(const egammaRec *egRec) const override final
virtual StatusCode initialize() override final
should be called by the derived class in the initialize phase
Gaudi::Property< std::size_t > m_numberOfPixelHits
electronSuperClusterBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< int > m_maxDelPhiCells
Size of maximum search window in phi.
Gaudi::Property< bool > m_doTrackMatching
private member flag to do the track matching
ToolHandle< IEMTrackMatchBuilder > m_trackMatchBuilder
Tool to perform track matching.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
DataVector< egammaRec > EgammaRecContainer
The container is a simple typedef for now.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
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...
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].