ATLAS Offline Software
egammaSuperClusterBuilder.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 
9 #include "StoreGate/ReadHandle.h"
10 #include "StoreGate/WriteHandle.h"
13 #include "xAODEgamma/Egamma.h"
14 #include "xAODEgamma/EgammaEnums.h"
16 
17 #include <cmath>
18 #include <memory>
19 
21  ISvcLocator* pSvcLocator)
22  : egammaSuperClusterBuilderBase(name, pSvcLocator)
23  , m_egTypeForCalibration(xAOD::EgammaParameters::electron)
24 {
25 }
26 
29 {
30  ATH_MSG_DEBUG(" Initializing egammaSuperClusterBuilder");
31 
32  // the data handle keys
33  if (m_calibrationType == "electron") {
35  } else if (m_calibrationType == "photon") {
37  } else {
38  ATH_MSG_ERROR("Unsupported calibration for " << m_calibrationType);
39  return StatusCode::FAILURE;
40  }
41 
43 }
44 
46 egammaSuperClusterBuilder::getEgammaRecType([[maybe_unused]]const egammaRec *egRec) const {
48 }
49 
50 // assume egammaRecs != 0, since the ReadHadler is valid
51 // assume seed egammaRec has a valid cluster, since it has been already used
52 std::vector<std::size_t>
54  std::size_t seedIndex,
55  const EgammaRecContainer* egammaRecs,
56  std::vector<bool>& isUsed) const
57 {
58 
59  std::vector<std::size_t> secondaryIndices;
60 
61  const auto* const seedEgammaRec = (*egammaRecs)[seedIndex];
62  const xAOD::CaloCluster* const seedCaloClus = seedEgammaRec->caloCluster();
63 
64  // for stats
65  int nWindowClusters = 0;
66  // Now loop over the potential secondary clusters
67  for (std::size_t i = 0; i < egammaRecs->size(); ++i) {
68  // if already used continue
69  if (isUsed[i]) {
70  continue;
71  }
72  const auto* const secEgammaRec = (*egammaRecs)[i];
73  const xAOD::CaloCluster* const secClus = secEgammaRec->caloCluster();
74  if (!secClus) {
76  "The potentially secondary egammaRec does not have a cluster");
77  continue;
78  }
79  bool addCluster = false;
80  if (matchesInWindow(seedCaloClus, secClus)) {
81  ATH_MSG_DEBUG("Cluster with Et: " << secClus->et()
82  << " matched in window");
83  ++nWindowClusters;
84  addCluster = true;
85  }
86  // Add it to the list of secondary clusters if it matches.
87  if (addCluster) {
88  secondaryIndices.push_back(i);
89  isUsed[i] = true;
90  }
91  }
92  ATH_MSG_DEBUG("Found: " << secondaryIndices.size() << " secondaries");
93  ATH_MSG_DEBUG("window clusters: " << nWindowClusters);
94  return secondaryIndices;
95 }
96 
egammaSuperClusterBuilder::initialize
virtual StatusCode initialize() override final
should be called by the derived class in the initialize phase
Definition: egammaSuperClusterBuilder.cxx:28
egammaSuperClusterBuilderBase::initialize
virtual StatusCode initialize() override
should be called by the derived class in the initialize phase
Definition: egammaSuperClusterBuilderBase.cxx:211
egammaSuperClusterBuilder::searchForSecondaryClusters
virtual std::vector< std::size_t > searchForSecondaryClusters(std::size_t egammaInd, const EgammaRecContainer *egammaRecs, std::vector< bool > &isUsed) const override final
Return extra clusters that can be added to make supercluster.
Definition: egammaSuperClusterBuilder.cxx:53
egammaSuperClusterBuilder.h
xAOD::CaloCluster_v1::et
double et() const
Definition: CaloCluster_v1.h:856
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
CaloClusterAuxContainer.h
egammaSuperClusterBuilder::egammaSuperClusterBuilder
egammaSuperClusterBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: egammaSuperClusterBuilder.cxx:20
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
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
EgammaxAODHelpers.h
egammaSuperClusterBuilder::m_calibrationType
Gaudi::Property< std::string > m_calibrationType
type to be assumed for calibration
Definition: egammaSuperClusterBuilder.h:92
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
egammaSuperClusterBuilder::m_egTypeForCalibration
xAOD::EgammaParameters::EgammaType m_egTypeForCalibration
Definition: egammaSuperClusterBuilder.h:89
CaloClusterStoreHelper.h
EgammaEnums.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
egammaSuperClusterBuilder::getEgammaRecType
virtual xAOD::EgammaParameters::EgammaType getEgammaRecType(const egammaRec *egRec) const override final
Definition: egammaSuperClusterBuilder.cxx:46
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
egammaSuperClusterBuilderBase
Base class for electronSuperClusterBuilder photonSuperClusterBuilder egammaSuperClusterBuilder This c...
Definition: egammaSuperClusterBuilderBase.h:47
egammaRec
Definition: egammaRec.h:31
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::EgammaParameters::unconvertedPhoton
@ unconvertedPhoton
Definition: EgammaEnums.h:19