ATLAS Offline Software
Loading...
Searching...
No Matches
BasicGepClusterMaker.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
6
7std::vector<Gep::Cluster>
9
10 std::vector<Gep::Cluster> clusters;
11
12 // Loop over all cells
13 std::vector<unsigned int> seenSeedCells;
14 for (auto const& cell_itr : *caloCellsMap) {
15
16 // Select only seed cells
17 if (!isSeedCell(cell_itr.second, seenSeedCells)) continue;
18
19 // Clustering
20 const std::vector<Gep::GepCaloCell> & cluster_cells = clusterFromCells(cell_itr.second, caloCellsMap, seenSeedCells);
21 clusters.push_back(getClusterFromListOfCells(cluster_cells));
22 }
23
24 // Order topo clusters according to their Et
25 std::sort(clusters.begin(), clusters.end(),[](const auto &c1, const auto &c2) {return c1.et() > c2.et();});
26
27 return clusters;
28}
29
30
31bool Gep::BasicGepClusterMaker::isSeedCell (const Gep::GepCaloCell& cell, const std::vector<unsigned int> &seenSeedCells) const {
32
33 if (cell.isBadCell()) return false;
34 if (cell.sigma < m_seed_threshold) return false;
35 if (!isNewCell(cell.id, seenSeedCells)) return false;
36 if (!isInAllowedSampling(cell.sampling, m_disallowed_seed_samplings)) return false;
37
38 return true;
39}
40
41
42bool Gep::BasicGepClusterMaker::isInAllowedSampling(int sampling, const std::vector<int>& list_of_samplings) const {
43
44 for (unsigned int i = 0; i < list_of_samplings.size(); ++i) {
45 if (list_of_samplings[i] == sampling) return false;
46 }
47 return true;
48}
49
50
51bool Gep::BasicGepClusterMaker::isNewCell(unsigned int id, const std::vector<unsigned int>& seenCells) const {
52
53 for (unsigned int i = 0; i < seenCells.size(); ++i) {
54 if (id == seenCells[i]) return false;
55 }
56
57 return true;
58}
59
60
61std::vector<Gep::GepCaloCell>
63 const pGepCellMap& caloCellsMap, std::vector<unsigned int> &seenSeedCells) const {
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 seenSeedCells.push_back(seed.id);
75
76 int i_shell = 1;
77
78 while (!cellsNextLayer.empty() && i_shell <= m_max_shells) {
79
80 cellsThisLayer.swap(cellsNextLayer);
81 cellsNextLayer.clear();
82 ++i_shell;
83
84 // Loop over all cells in this shell
85 for (unsigned int i_cell = 0; i_cell < cellsThisLayer.size(); ++i_cell) {
86
87 // Go through list of neighbouring cells and check whether they are part of the cluster
88 for (unsigned int i_neighbour = 0; i_neighbour < (cellsThisLayer[i_cell]).neighbours.size(); ++i_neighbour) {
89
90 // Check whether this neighbouring cell was sent to the GEP
91 auto const& nghbr_itr = caloCellsMap->find((cellsThisLayer[i_cell]).neighbours[i_neighbour]);
92 if (nghbr_itr == caloCellsMap->end()) continue;
93
94 Gep::GepCaloCell neighbour = nghbr_itr->second;
95
96 // reject if bad cell
97 if (neighbour.isBadCell()) continue;
98
99 // Reject if cell is not above clustering threshold
100 if (neighbour.sigma < m_clustering_threshold) continue;
101
102 // Reject if cell was already considered
103 if (!isNewCell(neighbour.id, seenCells)) continue;
104
105 // Ignore cells in disallowed samplings
107
108 seenCells.push_back(neighbour.id);
109 cellsNextLayer.push_back(neighbour);
110 v_clusterCells.push_back(neighbour);
111
112 // If the cell is another seed cell, we write it into the list of seen seed cells to not reconstruct this cluster again
113 if (neighbour.sigma > m_seed_threshold) seenSeedCells.push_back(neighbour.id);
114 }
115 }
116 cellsThisLayer.clear();
117 }
118
119 return v_clusterCells;
120}
121
122
123Gep::Cluster Gep::BasicGepClusterMaker::getClusterFromListOfCells(const std::vector<Gep::GepCaloCell>& cells) const {
124
125 Gep::Cluster cluster;
126 std::vector<unsigned int> v_cellIDs;
127
128 TLorentzVector tlv_cluster;
129 for (unsigned int i_cell = 0; i_cell < cells.size(); ++i_cell) {
130 TLorentzVector cell;
131 cell.SetPtEtaPhiE(cells[i_cell].et, cells[i_cell].eta, cells[i_cell].phi, cells[i_cell].et*std::cosh(cells[i_cell].eta));
132
133 tlv_cluster += cell;
134
135 v_cellIDs.push_back(cells[i_cell].id);
136 }
137
138 cluster.ncells = cells.size();
139 cluster.time = cells[0].time; // Take time of seed cell
140 cluster.cell_id = std::move(v_cellIDs);
141 cluster.setEtEtaPhi(tlv_cluster.Et(), tlv_cluster.Eta(), tlv_cluster.Phi());
142
143 return cluster;
144}
145
146
148 return "GEPBasic";
149}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::unique_ptr< GepCellMap > pGepCellMap
bool isNewCell(unsigned int id, const std::vector< unsigned int > &seenCells) const
const std::vector< int > m_disallowed_seed_samplings
std::vector< Gep::Cluster > makeClusters(const pGepCellMap &) const override
bool isSeedCell(const Gep::GepCaloCell &cell, const std::vector< unsigned int > &seenSeedCells) const
const std::vector< int > m_disallowed_clustering_samplings
bool isInAllowedSampling(int sampling, const std::vector< int > &list_of_samplings) const
std::vector< Gep::GepCaloCell > clusterFromCells(const Gep::GepCaloCell &seed, const pGepCellMap &, std::vector< unsigned int > &seenSeedCells) const
Gep::Cluster getClusterFromListOfCells(const std::vector< Gep::GepCaloCell > &cells) const
std::string getName() const override
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
std::vector< unsigned int > cell_id
void setEtEtaPhi(double et, double eta, double phi)
unsigned int sampling
Definition GepCaloCell.h:49
unsigned int id
Definition GepCaloCell.h:50
bool isBadCell() const
Definition GepCaloCell.h:59
Extra patterns decribing particle interation process.