ATLAS Offline Software
Loading...
Searching...
No Matches
Gep::WFSClusterMaker Class Reference

#include <WFSClusterMaker.h>

Inheritance diagram for Gep::WFSClusterMaker:
Collaboration diagram for Gep::WFSClusterMaker:

Public Member Functions

 WFSClusterMaker ()
virtual ~WFSClusterMaker ()=default
std::vector< Gep::ClustermakeClusters (const pGepCellMap &) const override
std::string getName () const override

Private Member Functions

bool isSeedCell (const Gep::GepCaloCell &cell) const
bool isInAllowedSampling (int sampling, const std::vector< int > &list_of_samplings) const
bool isNewCell (unsigned int id, const std::vector< unsigned int > &seenCells) const
std::vector< Gep::GepCaloCellclusterFromCells (const Gep::GepCaloCell &seed, const pGepCellMap &) const
Gep::Cluster getClusterFromListOfCells (const std::vector< Gep::GepCaloCell > &cells) const
double calculateClusterPhi (double seed_phi, double delta_phi) const
void orderClustersInEt (std::vector< Gep::Cluster > &v_clusters) const
double getDeltaPhi (double phi, double seed_phi) const

Private Attributes

float m_seed_threshold = 4.0
float m_clustering_threshold = 2.0
int m_max_shells = 8
std::vector< int > m_allowed_seed_samplings = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
std::vector< int > m_allowed_clustering_samplings = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

Detailed Description

Definition at line 14 of file WFSClusterMaker.h.

Constructor & Destructor Documentation

◆ WFSClusterMaker()

Gep::WFSClusterMaker::WFSClusterMaker ( )
inline

Definition at line 18 of file WFSClusterMaker.h.

18{}

◆ ~WFSClusterMaker()

virtual Gep::WFSClusterMaker::~WFSClusterMaker ( )
virtualdefault

Member Function Documentation

◆ calculateClusterPhi()

double Gep::WFSClusterMaker::calculateClusterPhi ( double seed_phi,
double delta_phi ) const
private

Definition at line 163 of file WFSClusterMaker.cxx.

163 {
164 double phi = seed_phi + delta_phi;
165 if (phi > TMath::Pi()) phi = -1.0*TMath::Pi() + (phi - TMath::Pi());
166 if (phi < (-1.0)*TMath::Pi()) phi = TMath::Pi() + (phi + TMath::Pi());
167 return phi;
168}
Scalar phi() const
phi method
delta_phi(phi1, phi2)
Definition eFEXNTuple.py:14

◆ clusterFromCells()

std::vector< Gep::GepCaloCell > Gep::WFSClusterMaker::clusterFromCells ( const Gep::GepCaloCell & seed,
const pGepCellMap & caloCellsMap ) const
private

Definition at line 62 of file WFSClusterMaker.cxx.

63 {
64
65 std::vector<Gep::GepCaloCell> v_clusterCells;
66
67 std::vector<Gep::GepCaloCell> cellsNextLayer, cellsThisLayer;
68 std::vector<unsigned int> seenCells;
69
70 // Fill seed into supporting vectors
71 v_clusterCells.push_back(seed);
72 cellsNextLayer.push_back(seed);
73 seenCells.push_back(seed.id);
74
75 int i_shell = 1;
76
77 while (!cellsNextLayer.empty() && i_shell <= m_max_shells) {
78
79 cellsThisLayer = cellsNextLayer;
80 cellsNextLayer.clear();
81 ++i_shell;
82
83 // Loop over all cells in this shell
84 for (unsigned int i_cell = 0; i_cell < cellsThisLayer.size(); ++i_cell) {
85
86 // Go through list of neighbouring cells and check whether they are part of the cluster
87 for (unsigned int i_neighbour = 0; i_neighbour < (cellsThisLayer[i_cell]).neighbours.size(); ++i_neighbour) {
88
89 // Check whether this neighbouring cell was sent to the GEP
90 auto const& nghbr_itr = caloCellsMap->find((cellsThisLayer[i_cell]).neighbours[i_neighbour]);
91 if (nghbr_itr == caloCellsMap->end()) continue;
92
93 Gep::GepCaloCell neighbour = nghbr_itr->second;//caloCellsMap->at((cellsThisLayer[i_cell]).neighbours[i_neighbour]);
94
95 // reject if bad cell
96 if (neighbour.isBadCell()) continue;
97
98 // Reject if cell is not above clustering threshold
99 if (std::fabs(neighbour.sigma) < m_clustering_threshold) continue;
100
101 // Reject if cell was already considered
102 if (!isNewCell(neighbour.id, seenCells)) continue;
103
104 // Ignore cells in disallowed samplings
106
107 seenCells.push_back(neighbour.id);
108 cellsNextLayer.push_back(neighbour);
109 v_clusterCells.push_back(std::move(neighbour));
110 }
111 }
112 cellsThisLayer.clear();
113 }
114
115 return v_clusterCells;
116}
std::vector< int > m_allowed_clustering_samplings
bool isNewCell(unsigned int id, const std::vector< unsigned int > &seenCells) const
bool isInAllowedSampling(int sampling, const std::vector< int > &list_of_samplings) const
unsigned int sampling
Definition GepCaloCell.h:49
unsigned int id
Definition GepCaloCell.h:50
bool isBadCell() const
Definition GepCaloCell.h:59

◆ getClusterFromListOfCells()

Gep::Cluster Gep::WFSClusterMaker::getClusterFromListOfCells ( const std::vector< Gep::GepCaloCell > & cells) const
private

Definition at line 119 of file WFSClusterMaker.cxx.

119 {
120
121 Gep::Cluster cluster;
122
123 std::vector<unsigned int> v_cellIDs;
124 double cluster_e = 0.0;
125 double etaSum = 0.0;
126 double phiSum = 0.0;
127 double abs_e = 0.0;
128 float weight = 0.0;
129
130 double seed_phi = cells[0].phi;
131 for (unsigned int i_cell = 0; i_cell < cells.size(); ++i_cell) {
132 float cell_e = cells[i_cell].et * TMath::CosH(cells[i_cell].eta);
133 cluster_e += cell_e;
134 abs_e += std::fabs(cell_e);
135 v_cellIDs.push_back(cells[i_cell].id);
136 etaSum += std::fabs(cell_e) * cells[i_cell].eta;
137 phiSum += std::fabs(cell_e) * getDeltaPhi(cells[i_cell].phi, seed_phi);
138 if (std::fabs(cells[i_cell].sigma) > m_seed_threshold) weight += 1.0;
139 }
140
141 cluster.ncells = cells.size();
142 cluster.time = cells[0].time; // Take time of seed cell
143 cluster.cell_id = std::move(v_cellIDs);
144 if (abs_e == 0.) [[unlikely]] throw std::runtime_error("Gep::WFSClusterMaker::getClusterFromListOfCells: abs_e is zero");
145 double cluster_eta = etaSum / abs_e;
146 double cluster_phi = calculateClusterPhi(seed_phi, phiSum / abs_e);
147 if (weight == 0.) [[unlikely]] throw std::runtime_error("Gep::WFSClusterMaker::getClusterFromListOfCells: weight is zero");
148 double cluster_et = (cluster_e * (1.0 / std::cosh(cluster_eta))) / weight;
149 cluster.setEtEtaPhi(cluster_et, cluster_eta, cluster_phi);
150
151 return cluster;
152}
Scalar eta() const
pseudorapidity method
double getDeltaPhi(double phi, double seed_phi) const
double calculateClusterPhi(double seed_phi, double delta_phi) const
#define unlikely(x)
Definition dictionary.h:41
std::vector< unsigned int > cell_id
void setEtEtaPhi(double et, double eta, double phi)

◆ getDeltaPhi()

double Gep::WFSClusterMaker::getDeltaPhi ( double phi,
double seed_phi ) const
private

Definition at line 155 of file WFSClusterMaker.cxx.

155 {
156 double delta_phi = std::fabs(std::fabs( std::fabs( phi - seed_phi ) - TMath::Pi() ) - TMath::Pi());
157 if (phi < seed_phi) delta_phi *= -1.00;
158 // Taking care of the -pi/pi split
159 if ((std::fabs(phi + seed_phi) < TMath::Pi()) && (std::fabs(phi) + std::fabs(seed_phi) > 5.0)) delta_phi *= -1.00;
160 return delta_phi;
161}

◆ getName()

std::string Gep::WFSClusterMaker::getName ( ) const
overridevirtual

Implements Gep::IClusterMaker.

Definition at line 202 of file WFSClusterMaker.cxx.

202 {
203 return "CaloWFS";
204}

◆ isInAllowedSampling()

bool Gep::WFSClusterMaker::isInAllowedSampling ( int sampling,
const std::vector< int > & list_of_samplings ) const
private

Definition at line 42 of file WFSClusterMaker.cxx.

42 {
43
44 for (unsigned int i = 0; i < list_of_samplings.size(); ++i) {
45 if (list_of_samplings[i] == sampling) return true;
46 }
47 return false;
48}

◆ isNewCell()

bool Gep::WFSClusterMaker::isNewCell ( unsigned int id,
const std::vector< unsigned int > & seenCells ) const
private

Definition at line 51 of file WFSClusterMaker.cxx.

51 {
52
53 for (unsigned int i = 0; i < seenCells.size(); ++i) {
54 if (id == seenCells[i]) return false;
55 }
56
57 return true;
58}

◆ isSeedCell()

bool Gep::WFSClusterMaker::isSeedCell ( const Gep::GepCaloCell & cell) const
private

Definition at line 32 of file WFSClusterMaker.cxx.

32 {
33
34 if (cell.isBadCell()) return false;
35 if (std::fabs(cell.sigma) < m_seed_threshold) return false;
36 if (!isInAllowedSampling(cell.sampling, m_allowed_seed_samplings)) return false;
37
38 return true;
39}
std::vector< int > m_allowed_seed_samplings

◆ makeClusters()

std::vector< Gep::Cluster > Gep::WFSClusterMaker::makeClusters ( const pGepCellMap & caloCellsMap) const
overridevirtual

Implements Gep::IClusterMaker.

Definition at line 10 of file WFSClusterMaker.cxx.

10 {
11
12 std::vector<Gep::Cluster> clusters;
13
14 // Loop over all cells
15 for (auto const& cell_itr : *caloCellsMap) {
16
17 // Select only seed cells
18 if (!isSeedCell(cell_itr.second)) continue;
19
20 // Clustering
21 std::vector<Gep::GepCaloCell> cluster_cells = clusterFromCells(cell_itr.second, caloCellsMap);
22 clusters.push_back(getClusterFromListOfCells(cluster_cells));
23 }
24
25 // Order topo clusters according to their et
26 orderClustersInEt(clusters);
27
28 return clusters;
29}
std::vector< Gep::GepCaloCell > clusterFromCells(const Gep::GepCaloCell &seed, const pGepCellMap &) const
Gep::Cluster getClusterFromListOfCells(const std::vector< Gep::GepCaloCell > &cells) const
bool isSeedCell(const Gep::GepCaloCell &cell) const
void orderClustersInEt(std::vector< Gep::Cluster > &v_clusters) const

◆ orderClustersInEt()

void Gep::WFSClusterMaker::orderClustersInEt ( std::vector< Gep::Cluster > & v_clusters) const
private

Definition at line 171 of file WFSClusterMaker.cxx.

171 {
172
173 std::vector<Gep::Cluster> v_ordered;
174 for (unsigned int i_cluster = 0; i_cluster < v_clusters.size(); ++i_cluster) {
175 float et = v_clusters[i_cluster].et();
176
177 // Fill first cluster
178 if (v_ordered.empty()) {
179 v_ordered.push_back(v_clusters[i_cluster]);
180 continue;
181 }
182
183 // Find correct position for filling
184 for (unsigned int i = 0; i < v_ordered.size(); ++i) {
185 if (v_ordered[i].et() < et) {
186 v_ordered.insert(v_ordered.begin()+i, v_clusters[i_cluster]);
187 break;
188 }
189 }
190
191 // If cluster has smallest et so far, it wasn't filled at all so we need to take care of it
192 if (v_ordered.size() != i_cluster+1) v_ordered.push_back(v_clusters[i_cluster]);
193 }
194
195 v_clusters = std::move(v_ordered);
196
197 return;
198
199}
float et(const xAOD::jFexSRJetRoI *j)

Member Data Documentation

◆ m_allowed_clustering_samplings

std::vector<int> Gep::WFSClusterMaker::m_allowed_clustering_samplings = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
private

Definition at line 32 of file WFSClusterMaker.h.

32{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

◆ m_allowed_seed_samplings

std::vector<int> Gep::WFSClusterMaker::m_allowed_seed_samplings = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
private

Definition at line 31 of file WFSClusterMaker.h.

31{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

◆ m_clustering_threshold

float Gep::WFSClusterMaker::m_clustering_threshold = 2.0
private

Definition at line 29 of file WFSClusterMaker.h.

◆ m_max_shells

int Gep::WFSClusterMaker::m_max_shells = 8
private

Definition at line 30 of file WFSClusterMaker.h.

◆ m_seed_threshold

float Gep::WFSClusterMaker::m_seed_threshold = 4.0
private

Definition at line 28 of file WFSClusterMaker.h.


The documentation for this class was generated from the following files: