ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
eflowRec
src
EtaPhiLUT.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <cmath>
6
#include <algorithm>
7
8
#include "
EtaPhiLUT.h
"
9
10
namespace
eflowRec
{
11
13
static
constexpr
float
TWOPI
= 2*
M_PI
;
14
16
float
phiInRange
(
float
phi
) {
17
while
(
phi
>=
M_PI
)
phi
-=
TWOPI
;
18
while
(
phi
< -
M_PI
)
phi
+=
TWOPI
;
19
return
phi
;
20
}
21
23
unsigned
int
phiIndex
(
float
phi
,
float
binsize) {
return
(
phi
+
M_PI
)/binsize; }
24
25
EtaPhiLUT::EtaPhiLUT
(
unsigned
int
nbins ) :
26
m_nphiBins
(nbins),
27
m_phiBinSize
(
TWOPI
/
m_nphiBins
),
28
m_phiBinnedLookUpTable
(
m_nphiBins
)
29
{}
30
31
void
EtaPhiLUT::fill
(
eflowRecClusterContainer
& clustersin)
32
{
33
for
(
eflowRecCluster
* cluster : clustersin) {
34
int
index
=
phiIndex
(cluster->getCluster()->phi(),
m_phiBinSize
);
35
m_phiBinnedLookUpTable
[
index
].push_back(cluster);
36
}
37
38
for
(
auto
&
vec
:
m_phiBinnedLookUpTable
) {
39
std::stable_sort
(
vec
.begin(),
vec
.end(),[](
const
eflowRecCluster
* c1,
const
eflowRecCluster
* c2) { return c1->getCluster()->eta() < c2->getCluster()->eta(); });
40
}
41
}
42
43
std::vector<eflowRecCluster*>
EtaPhiLUT::clustersInCone
(
float
eta
,
float
phi
,
float
dr )
const
{
44
std::vector<eflowRecCluster*> result;
45
46
// Indices corresponding to phi range
47
unsigned
int
iPhiMin =
phiIndex
(
phiInRange
(
phi
-dr),
m_phiBinSize
);
48
unsigned
int
iPhiMax =
phiIndex
(
phiInRange
(
phi
+dr),
m_phiBinSize
);
49
50
// Extract index ranges to iterate over
51
std::vector< std::pair<int,int> > iPhiRanges;
52
if
( iPhiMin < iPhiMax ) {
53
iPhiRanges.emplace_back(iPhiMin,iPhiMax );
54
}
else
{
// special treatment for phi-wrapping
55
iPhiRanges.emplace_back(0,iPhiMax );
56
iPhiRanges.emplace_back(iPhiMin,
m_nphiBins
-1 );
57
}
58
59
float
dr2Cut = dr*dr;
60
61
// loop over ranges
62
for
(
auto
& range : iPhiRanges ){
63
unsigned
int
indexMin = range.first;
64
unsigned
int
indexMax = range.second;
65
for
( ; indexMin <= indexMax; ++indexMin ){
66
const
std::vector<eflowRecCluster*>& phiClusters =
m_phiBinnedLookUpTable
[indexMin];
67
68
// Get iterators for clusters in relevant eta range
69
auto
it_min = std::lower_bound (phiClusters.begin(), phiClusters.end(),
eta
-dr, [] (
const
eflowRecCluster
* cl,
float
etaval) {return cl->getCluster()->eta()<etaval;} );
70
auto
it_max = std::upper_bound (it_min, phiClusters.end(),
eta
+dr, [] (
float
etaval,
const
eflowRecCluster
* cl) {return etaval<cl->getCluster()->eta();} );
71
72
// Apply deltaR cut
73
for
( ;it_min!=it_max;++it_min ){
74
const
xAOD::CaloCluster
& xcluster = *(*it_min)->getCluster();
75
float
deta =
eta
- xcluster.
eta
();
76
float
dphi =
phiInRange
(
phi
- xcluster.
phi
());
77
float
dr2 = deta*deta + dphi*dphi;
78
if
( dr2 < dr2Cut ) result.push_back(*it_min);
79
}
80
}
81
}
82
return
result;
83
}
84
85
}
// namespace
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
EtaPhiLUT.h
eflowRecClusterContainer
Definition
eflowRecCluster.h:275
eflowRecCluster
This class extends the information about a xAOD::CaloCluster.
Definition
eflowRecCluster.h:40
eflowRec::EtaPhiLUT::m_phiBinnedLookUpTable
std::vector< std::vector< eflowRecCluster * > > m_phiBinnedLookUpTable
bin size
Definition
EtaPhiLUT.h:40
eflowRec::EtaPhiLUT::m_nphiBins
unsigned int m_nphiBins
Definition
EtaPhiLUT.h:38
eflowRec::EtaPhiLUT::fill
void fill(eflowRecClusterContainer &clustersin)
Definition
EtaPhiLUT.cxx:31
eflowRec::EtaPhiLUT::EtaPhiLUT
EtaPhiLUT(unsigned int nbins=50)
constructor taking the desired binsize
Definition
EtaPhiLUT.cxx:25
eflowRec::EtaPhiLUT::m_phiBinSize
float m_phiBinSize
number of bins
Definition
EtaPhiLUT.h:39
eflowRec::EtaPhiLUT::clustersInCone
std::vector< eflowRecCluster * > clustersInCone(float eta, float phi, float dr) const
collect eflowRecClusters in a given cone
Definition
EtaPhiLUT.cxx:43
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition
CaloCluster_v1.cxx:251
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition
CaloCluster_v1.cxx:256
eflowRec
Definition
EtaPhiLUT.cxx:10
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition
EtaPhiLUT.cxx:23
eflowRec::phiInRange
float phiInRange(float phi)
hepler function to ensure phi is within +-Pi
Definition
EtaPhiLUT.cxx:16
eflowRec::TWOPI
static constexpr float TWOPI
define 2*Pi
Definition
EtaPhiLUT.cxx:13
index
Definition
index.py:1
std::stable_sort
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
Definition
DVL_algorithms.h:644
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.17.0