ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkCalo
src
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
"
6
#include "
FourMomUtils/P4Helpers.h
"
7
#include "GaudiKernel/MsgStream.h"
8
#include "
xAODCaloEvent/CaloCluster.h
"
9
#include "
xAODEgamma/Egamma.h
"
10
#include "
xAODMuon/Muon.h
"
11
12
// Select for generic IParticle
13
void
14
DerivationFramework::ClustersInCone::select
(
15
const
xAOD::IParticle
* particle,
16
const
float
coneSize,
17
const
xAOD::CaloClusterContainer
* clusters,
18
std::vector<bool>& mask)
19
{
20
float
particleEta = particle->eta();
21
float
particlePhi = particle->phi();
22
unsigned
int
i(0);
23
for
(
xAOD::CaloClusterContainer::const_iterator
clIt = clusters->begin();
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
37
DerivationFramework::ClustersInCone::select
(
38
const
xAOD::Egamma
* particle,
39
const
float
coneSize,
40
const
xAOD::CaloClusterContainer
* clusters,
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);
46
for
(
xAOD::CaloClusterContainer::const_iterator
clIt = clusters->begin();
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
60
DerivationFramework::ClustersInCone::GetExtrapEtaPhi
(
const
xAOD::Muon
* mu,
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
90
DerivationFramework::ClustersInCone::select
(
91
const
xAOD::Muon
* particle,
92
const
float
coneSize,
93
const
xAOD::CaloClusterContainer
* clusters,
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;
105
for
(
xAOD::CaloClusterContainer::const_iterator
clIt = clusters->begin();
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
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
deltaPhi
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Definition
AmgMatrixBasePlugin.h:112
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ClustersInCone.h
Egamma.h
CaloCluster.h
Muon.h
P4Helpers.h
CaloSampling::CaloSample
CaloSample
Definition
Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
DataVector< CaloCluster_v1 >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DerivationFramework::ClustersInCone::GetExtrapEtaPhi
bool GetExtrapEtaPhi(const xAOD::Muon *mu, float &eta, float &phi)
Definition
ClustersInCone.cxx:60
DerivationFramework::ClustersInCone::select
void select(const xAOD::IParticle *particle, const float coneSize, const xAOD::CaloClusterContainer *clusters, std::vector< bool > &mask)
Definition
ClustersInCone.cxx:14
DerivationFramework::deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition
HIJetAugmentationTool.cxx:47
P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition
P4Helpers.h:34
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0