ATLAS Offline Software
egammaClusterCookieCut.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3  */
4 
7 
12 #include "FourMomUtils/P4Helpers.h"
13 
14 namespace {
15  template <typename... T>
16  void copyMoments(const xAOD::CaloCluster& src,
17  std::unique_ptr<xAOD::CaloCluster>& dest,
18  T... momentIds) {
19  for (const auto& momentId : {momentIds...}) {
20  double moment {};
21  if (src.retrieveMoment(momentId, moment)) {
22  dest->insertMoment(momentId, moment);
23  }
24  }
25  }
26 }
27 
28 std::unique_ptr<xAOD::CaloCluster> egammaClusterCookieCut::cookieCut(
29  const xAOD::CaloCluster& cluster,
30  const CaloDetDescrManager& mgr,
31  const DataLink<CaloCellContainer>& cellCont,
33 ) {
34  if (!cluster.hasSampling(CaloSampling::EME2) &&
35  !cluster.hasSampling(CaloSampling::FCAL0)) {
36  return nullptr;
37  }
38 
40 
41  const bool isEC = cp0.emaxEC >= cp0.emaxF;
42  const float eta = isEC ? cp0.etaEC : cp0.etaF;
43  const float phi = isEC ? cp0.phiEC : cp0.phiF;
44 
45  auto newCluster = CaloClusterStoreHelper::makeCluster(cellCont);
46 
47  if (!newCluster) {
48  return nullptr;
49  }
50 
51  CaloClusterCellLink* newCellLinks = newCluster->getOwnCellLinks();
52  if (!pars.recomputeMoments) {
53  copyMoments(cluster,
54  newCluster,
63  }
64 
65  const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
66  CaloClusterCellLink::const_iterator cellItr = cellLinks->begin();
67  CaloClusterCellLink::const_iterator cellEnd = cellLinks->end();
68 
69  for (; cellItr != cellEnd; ++cellItr) {
70  const float deltaEta = std::abs(eta - cellItr->eta());
71  const float deltaPhi = std::abs(P4Helpers::deltaPhi(phi, cellItr->phi()));
72 
73  const float deltaEta2 = deltaEta * deltaEta;
74  const float deltaPhi2 = deltaPhi * deltaPhi;
75 
76  const bool excludeCell = isEC ?
77  (deltaEta >= pars.maxDelEta || deltaPhi >= pars.maxDelPhi) :
78  (deltaEta2 + deltaPhi2 >= pars.maxDelR2);
79 
80  if (!excludeCell) {
81  newCellLinks->addCell(cellItr.index(), cellItr.weight());
82  }
83  }
84 
85  CaloClusterKineHelper::calculateKine(newCluster.get(), true, true);
86 
87  return newCluster;
88 }
CaloClusterStoreHelper::makeCluster
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Definition: CaloClusterStoreHelper.cxx:13
xAOD::CaloCluster_v1::SECOND_R
@ SECOND_R
Second Moment in .
Definition: CaloCluster_v1.h:126
CookieCutterHelpers::CentralPosition
Find the reference position (eta, phi) relative to which cells are restricted.
Definition: CookieCutterHelpers.h:19
CaloClusterKineHelper.h
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:369
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:161
xAOD::EgammaParameters::deltaEta2
@ deltaEta2
difference between the cluster eta (second sampling) and the eta of the track extrapolated to the sec...
Definition: EgammaEnums.h:187
xAOD::CaloCluster_v1::CENTER_LAMBDA
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
Definition: CaloCluster_v1.h:139
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
xAOD::CaloCluster_v1::ENG_FRAC_MAX
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
Definition: CaloCluster_v1.h:143
xAOD::CaloCluster_v1::SECOND_LAMBDA
@ SECOND_LAMBDA
Second Moment in .
Definition: CaloCluster_v1.h:127
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
egammaClusterCookieCut.h
xAOD::CaloCluster_v1::SECOND_ENG_DENS
@ SECOND_ENG_DENS
Second Moment in E/V.
Definition: CaloCluster_v1.h:147
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: P4Helpers.h:34
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
CaloCluster.h
egammaClusterCookieCut::cookieCut
std::unique_ptr< xAOD::CaloCluster > cookieCut(const xAOD::CaloCluster &cluster, const CaloDetDescrManager &mgr, const DataLink< CaloCellContainer > &cellCont, const egammaClusterCookieCut::CookieCutPars &pars)
Definition: egammaClusterCookieCut.cxx:28
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:859
P4Helpers.h
CookieCutterHelpers.h
xAOD::EgammaParameters::deltaPhi2
@ deltaPhi2
difference between the cluster phi (second sampling) and the phi of the track extrapolated to the sec...
Definition: EgammaEnums.h:204
CaloClusterStoreHelper.h
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
xAOD::CaloCluster_v1::SIGNIFICANCE
@ SIGNIFICANCE
Cluster significance.
Definition: CaloCluster_v1.h:160
CaloClusterKineHelper::calculateKine
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
Definition: CaloClusterKineHelper.cxx:223
xAOD::CaloCluster_v1::LATERAL
@ LATERAL
Normalized lateral moment.
Definition: CaloCluster_v1.h:140
xAOD::CaloCluster_v1::hasSampling
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
Definition: CaloCluster_v1.h:882
xAOD::CaloCluster_v1::LONGITUDINAL
@ LONGITUDINAL
Normalized longitudinal moment.
Definition: CaloCluster_v1.h:141
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
CookieCutterHelpers::CentralPosition::emaxEC
float emaxEC
Definition: CookieCutterHelpers.h:25
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
egammaClusterCookieCut::CookieCutPars
Definition: egammaClusterCookieCut.h:11
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:376