ATLAS Offline Software
ClustersInCone.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ClustersInCone.h"
7 #include "GaudiKernel/MsgStream.h"
9 #include "xAODEgamma/Egamma.h"
10 #include "xAODMuon/Muon.h"
11 
12 // Select for generic IParticle
13 void
16  const float coneSize,
18  std::vector<bool>& mask)
19 {
20  float particleEta = particle->eta();
21  float particlePhi = particle->phi();
22  unsigned int i(0);
24  clIt != clusters->end();
25  ++clIt, ++i) {
26  float deltaEta = (*clIt)->eta() - particleEta;
27  float deltaPhi = P4Helpers::deltaPhi((*clIt)->phi(), particlePhi);
28  float deltaR = sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi);
29  if (deltaR < coneSize) {
30  mask[i] = true;
31  }
32  }
33  }
34 
35 // Overload for Egamma
36 void
38  const xAOD::Egamma* particle,
39  const float coneSize,
41  std::vector<bool>& mask)
42 {
43  float particleEta = particle->caloCluster()->etaBE(2);
44  float particlePhi = particle->caloCluster()->phiBE(2);
45  unsigned int i(0);
47  clIt != clusters->end();
48  ++clIt, ++i) {
49  float deltaEta = (*clIt)->eta() - particleEta;
50  float deltaPhi = P4Helpers::deltaPhi((*clIt)->phi(), particlePhi);
51  float deltaR = sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi);
52  if (deltaR < coneSize) {
53  mask[i] = true;
54  }
55  }
56  }
57 
58 // Helper for the muon overload
59 bool
61  float& eta,
62  float& phi)
63 {
64  const auto* cluster = mu->cluster();
65  if (cluster) {
66  float etaT = 0, phiT = 0;
67  int nSample = 0;
68  for (unsigned int i = 0; i < CaloSampling::Unknown; i++) {
69  auto s = static_cast<CaloSampling::CaloSample>(i);
70  if (!cluster->hasSampling(s))
71  continue;
72  etaT += cluster->etaSample(s);
73  phiT += cluster->phiSample(s);
74  nSample++;
75  }
76  if (nSample > 0) {
77  eta = etaT / nSample;
78  phi = phiT / nSample;
79  } else {
80  return false;
81  }
82  } else {
83  return false;
84  }
85  return true;
86 }
87 
88 // Overload for Muons
89 void
91  const xAOD::Muon* particle,
92  const float coneSize,
94  std::vector<bool>& mask,
95  MsgStream& msg)
96 {
97  float particleEta = particle->eta();
98  float particlePhi = particle->phi();
99  if (!GetExtrapEtaPhi(particle, particleEta, particlePhi)) {
100  msg << MSG::WARNING
101  << "Failed to get the eta-phi of the muon calo extention " << endmsg;
102  }
103  unsigned int i(0);
104  float coneSize2 = coneSize * coneSize;
106  clIt != clusters->end();
107  ++clIt, ++i) {
108  float deltaEta = (*clIt)->eta() - particleEta;
109  float deltaPhi = P4Helpers::deltaPhi((*clIt)->phi(), particlePhi);
110  if (deltaEta * deltaEta + deltaPhi * deltaPhi < coneSize2) {
111  mask[i] = true;
112  }
113  }
114  }
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
Muon.h
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:160
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
Egamma.h
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloCluster.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ClustersInCone.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
P4Helpers.h
DerivationFramework::ClustersInCone::GetExtrapEtaPhi
bool GetExtrapEtaPhi(const xAOD::Muon *mu, float &eta, float &phi)
Definition: ClustersInCone.cxx:60
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
DerivationFramework::ClustersInCone::select
void select(const xAOD::IParticle *particle, const float coneSize, const xAOD::CaloClusterContainer *clusters, std::vector< bool > &mask)
Definition: ClustersInCone.cxx:14
xAOD::Iso::coneSize
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
Definition: IsolationHelpers.h:27
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7