ATLAS Offline Software
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 
16 #include "FourMomUtils/P4Helpers.h"
17 
18 #include "StoreGate/ReadHandle.h"
19 #include "StoreGate/WriteHandle.h"
20 
21 #include <cmath>
22 #include <memory>
23 
24 
25 namespace{
26 
27 bool 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 
47 {
48  ATH_MSG_DEBUG(" Initializing electronSuperClusterBuilder");
49 
50  // Additional Window we search in
53 
54  // retrieve track match builder
55  if (m_doTrackMatching) {
56  ATH_CHECK(m_trackMatchBuilder.retrieve());
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
72  nPixelHits += summaryValueInt(*trackParticle, xAOD::numberOfPixelHits, 0);
74  return false;
75  }
76  // and with silicon (add SCT to pixel)
78  nSiHits += summaryValueInt(*trackParticle, xAOD::numberOfSCTHits, 0);
79  return nSiHits >= m_numberOfSiHits;
80 };
81 
83 electronSuperClusterBuilder::getEgammaRecType([[maybe_unused]] const egammaRec *egRec) const {
85 }
86 
89  const EventContext &ctx,
91 ) const {
92  if (m_doTrackMatching) {
93  ATH_CHECK(m_trackMatchBuilder->executeRec(ctx, newEgammaRecs.ptr()));
94  }
95 
96  return StatusCode::SUCCESS;
97 }
98 
99 std::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 
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
electronSuperClusterBuilder::m_doTrackMatching
Gaudi::Property< bool > m_doTrackMatching
private member flag to do the track matching
Definition: electronSuperClusterBuilder.h:153
egammaSuperClusterBuilderBase::initialize
virtual StatusCode initialize() override
should be called by the derived class in the initialize phase
Definition: egammaSuperClusterBuilderBase.cxx:211
electronSuperClusterBuilder.h
electronSuperClusterBuilder::searchForSecondaryClusters
virtual std::vector< std::size_t > searchForSecondaryClusters(const size_t i, const EgammaRecContainer *, std::vector< bool > &isUsed) const override final
Search for secondary clusters.
Definition: electronSuperClusterBuilder.cxx:100
egammaSuperClusterBuilderBase::s_cellPhiSize
static constexpr float s_cellPhiSize
Definition: egammaSuperClusterBuilderBase.h:137
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
CaloClusterAuxContainer.h
IDTPM::nPixelHits
float nPixelHits(const U &p)
Definition: TrackParametersHelper.h:354
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
electronSuperClusterBuilder::m_maxDelPhi
float m_maxDelPhi
Definition: electronSuperClusterBuilder.h:160
xAOD::EgammaParameters::EgammaType
EgammaType
Definition: EgammaEnums.h:17
Egamma.h
WriteHandle.h
Handle class for recording to StoreGate.
egammaSuperClusterBuilderBase::matchesInWindow
bool matchesInWindow(const xAOD::CaloCluster *ref, const xAOD::CaloCluster *clus) const
Is clus in window center around ref?
Definition: egammaSuperClusterBuilderBase.cxx:409
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: P4Helpers.h:34
EgammaxAODHelpers.h
electronSuperClusterBuilder::electronSuperClusterBuilder
electronSuperClusterBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: electronSuperClusterBuilder.cxx:38
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
egammaRec::getNumberOfTrackParticles
size_t getNumberOfTrackParticles() const
Return the number xAOD::TrackParticles that match the electron candidate.
egammaRec::trackParticle
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Definition: egammaRec.cxx:31
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
electronSuperClusterBuilder::m_trackMatchBuilder
ToolHandle< IEMTrackMatchBuilder > m_trackMatchBuilder
Tool to perform track matching.
Definition: electronSuperClusterBuilder.h:145
xAOD::EgammaHelpers::summaryValueInt
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...
Definition: EgammaxAODHelpers.cxx:161
P4Helpers.h
electronSuperClusterBuilder::m_maxDelEta
float m_maxDelEta
Definition: electronSuperClusterBuilder.h:159
electronSuperClusterBuilder::initialize
virtual StatusCode initialize() override final
should be called by the derived class in the initialize phase
Definition: electronSuperClusterBuilder.cxx:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
electronSuperClusterBuilder::m_numberOfPixelHits
Gaudi::Property< std::size_t > m_numberOfPixelHits
Definition: electronSuperClusterBuilder.h:130
electronSuperClusterBuilder::m_maxDelPhiCells
Gaudi::Property< int > m_maxDelPhiCells
Size of maximum search window in phi.
Definition: electronSuperClusterBuilder.h:123
CaloClusterStoreHelper.h
TrackParticle.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
egammaSuperClusterBuilderBase::s_cellEtaSize
static constexpr float s_cellEtaSize
Definition: egammaSuperClusterBuilderBase.h:136
electronSuperClusterBuilder::getEgammaRecType
virtual xAOD::EgammaParameters::EgammaType getEgammaRecType(const egammaRec *egRec) const override final
Definition: electronSuperClusterBuilder.cxx:83
electronSuperClusterBuilder::m_numberOfSiHits
Gaudi::Property< std::size_t > m_numberOfSiHits
Definition: electronSuperClusterBuilder.h:137
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
egammaSuperClusterBuilderBase
Base class for electronSuperClusterBuilder photonSuperClusterBuilder egammaSuperClusterBuilder This c...
Definition: egammaSuperClusterBuilderBase.h:47
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
egammaRec
Definition: egammaRec.h:31
xAOD::numberOfPixelDeadSensors
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
Definition: TrackingPrimitives.h:266
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ReadHandle.h
Handle class for reading from StoreGate.
electronSuperClusterBuilder::redoMatching
virtual StatusCode redoMatching(const EventContext &ctx, SG::WriteHandle< EgammaRecContainer > &newEgammaRecs) const override final
Definition: electronSuperClusterBuilder.cxx:88
electronSuperClusterBuilder::egammaRecPassesSelection
virtual bool egammaRecPassesSelection(const egammaRec *egRec) const override final
Definition: electronSuperClusterBuilder.cxx:63
electronSuperClusterBuilder::m_maxDelEtaCells
Gaudi::Property< int > m_maxDelEtaCells
Size of maximum search window in eta.
Definition: electronSuperClusterBuilder.h:116
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrackParticleContainer.h
IDTPM::nSiHits
float nSiHits(const U &p)
Definition: TrackParametersHelper.h:427