ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14namespace {
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
28std::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
39 CookieCutterHelpers::CentralPosition cp0({&cluster}, mgr);
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,
66 }
67
68 const CaloClusterCellLink* cellLinks = cluster.getCellLinks();
69 CaloClusterCellLink::const_iterator cellItr = cellLinks->begin();
70 CaloClusterCellLink::const_iterator cellEnd = cellLinks->end();
71
72 for (; cellItr != cellEnd; ++cellItr) {
73 const float deltaEta = std::abs(eta - cellItr->eta());
74 const float deltaPhi = std::abs(P4Helpers::deltaPhi(phi, cellItr->phi()));
75
76 const float deltaEta2 = deltaEta * deltaEta;
77 const float deltaPhi2 = deltaPhi * deltaPhi;
78
79 const bool excludeCell = isEC ?
80 (deltaEta >= pars.maxDelEta || deltaPhi >= pars.maxDelPhi) :
81 (deltaEta2 + deltaPhi2 >= pars.maxDelR2);
82
83 if (!excludeCell) {
84 double w = pars.fixCellWeights ? 1. : cellItr.weight();
85 newCellLinks->addCell(cellItr.index(), w);
86 }
87 }
88
89 CaloClusterKineHelper::calculateKine(newCluster.get(), true, true);
90
91 return newCluster;
92}
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
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.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
This class provides the client interface for accessing the detector description information common to...
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
@ SECOND_ENG_DENS
Second Moment in E/V.
@ SECOND_LAMBDA
Second Moment in .
@ LATERAL
Normalized lateral moment.
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ SECOND_R
Second Moment in .
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ SIGNIFICANCE
Cluster significance.
@ CENTER_Z
Cluster Centroid ( )
@ CENTER_X
Cluster Centroid ( )
@ CENTER_Y
Cluster Centroid ( )
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
std::unique_ptr< xAOD::CaloCluster > cookieCut(const xAOD::CaloCluster &cluster, const CaloDetDescrManager &mgr, const DataLink< CaloCellContainer > &cellCont, const egammaClusterCookieCut::CookieCutPars &pars)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Find the reference position (eta, phi) relative to which cells are restricted.