ATLAS Offline Software
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 
7 std::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  std::vector<Gep::GepCaloCell> cluster_cells = clusterFromCells(cell_itr.second, caloCellsMap, seenSeedCells);
21 
22  Gep::Cluster cluster = getClusterFromListOfCells(cluster_cells);
23  clusters.push_back(cluster);
24  }
25 
26  // Order topo clusters according to their Et
27  std::sort(clusters.begin(), clusters.end(),[](const auto &c1, const auto &c2) {return c1.et() > c2.et();});
28 
29  return clusters;
30 }
31 
32 
33 bool Gep::BasicGepClusterMaker::isSeedCell (const Gep::GepCaloCell& cell, const std::vector<unsigned int> &seenSeedCells) const {
34 
35  if (cell.isBadCell()) return false;
36  if (cell.sigma < m_seed_threshold) return false;
37  if (!isNewCell(cell.id, seenSeedCells)) return false;
38  if (!isInAllowedSampling(cell.sampling, m_disallowed_seed_samplings)) return false;
39 
40  return true;
41 }
42 
43 
44 bool Gep::BasicGepClusterMaker::isInAllowedSampling(int sampling, const std::vector<int>& list_of_samplings) const {
45 
46  for (unsigned int i = 0; i < list_of_samplings.size(); ++i) {
47  if (list_of_samplings[i] == sampling) return false;
48  }
49  return true;
50 }
51 
52 
53 bool Gep::BasicGepClusterMaker::isNewCell(unsigned int id, const std::vector<unsigned int>& seenCells) const {
54 
55  for (unsigned int i = 0; i < seenCells.size(); ++i) {
56  if (id == seenCells[i]) return false;
57  }
58 
59  return true;
60 }
61 
62 
63 std::vector<Gep::GepCaloCell>
65  const pGepCellMap& caloCellsMap, std::vector<unsigned int> &seenSeedCells) const {
66 
67  std::vector<Gep::GepCaloCell> v_clusterCells;
68 
69  std::vector<Gep::GepCaloCell> cellsNextLayer, cellsThisLayer;
70  std::vector<unsigned int> seenCells;
71 
72  // Fill seed into supporting vectors
73  v_clusterCells.push_back(seed);
74  cellsNextLayer.push_back(seed);
75  seenCells.push_back(seed.id);
76  seenSeedCells.push_back(seed.id);
77 
78  int i_shell = 1;
79 
80  while (!cellsNextLayer.empty() && i_shell <= m_max_shells) {
81 
82  cellsThisLayer.swap(cellsNextLayer);
83  cellsNextLayer.clear();
84  ++i_shell;
85 
86  // Loop over all cells in this shell
87  for (unsigned int i_cell = 0; i_cell < cellsThisLayer.size(); ++i_cell) {
88 
89  // Go through list of neighbouring cells and check whether they are part of the cluster
90  for (unsigned int i_neighbour = 0; i_neighbour < (cellsThisLayer[i_cell]).neighbours.size(); ++i_neighbour) {
91 
92  // Check whether this neighbouring cell was sent to the GEP
93  auto const& nghbr_itr = caloCellsMap->find((cellsThisLayer[i_cell]).neighbours[i_neighbour]);
94  if (nghbr_itr == caloCellsMap->end()) continue;
95 
96  Gep::GepCaloCell neighbour = nghbr_itr->second;
97 
98  // reject if bad cell
99  if (neighbour.isBadCell()) continue;
100 
101  // Reject if cell is not above clustering threshold
102  if (neighbour.sigma < m_clustering_threshold) continue;
103 
104  // Reject if cell was already considered
105  if (!isNewCell(neighbour.id, seenCells)) continue;
106 
107  // Ignore cells in disallowed samplings
108  if (!isInAllowedSampling(neighbour.sampling, m_disallowed_clustering_samplings)) continue;
109 
110  seenCells.push_back(neighbour.id);
111  cellsNextLayer.push_back(neighbour);
112  v_clusterCells.push_back(neighbour);
113 
114  // If the cell is another seed cell, we write it into the list of seen seed cells to not reconstruct this cluster again
115  if (neighbour.sigma > m_seed_threshold) seenSeedCells.push_back(neighbour.id);
116  }
117  }
118  cellsThisLayer.clear();
119  }
120 
121  return v_clusterCells;
122 }
123 
124 
125 Gep::Cluster Gep::BasicGepClusterMaker::getClusterFromListOfCells(const std::vector<Gep::GepCaloCell>& cells) const {
126 
127  Gep::Cluster cluster;
128  std::vector<unsigned int> v_cellIDs;
129 
130  TLorentzVector tlv_cluster;
131  for (unsigned int i_cell = 0; i_cell < cells.size(); ++i_cell) {
132  TLorentzVector cell;
133  cell.SetPtEtaPhiE(cells[i_cell].et, cells[i_cell].eta, cells[i_cell].phi, cells[i_cell].et*std::cosh(cells[i_cell].eta));
134 
135  tlv_cluster += cell;
136 
137  v_cellIDs.push_back(cells[i_cell].id);
138  }
139 
140  cluster.ncells = cells.size();
141  cluster.time = cells[0].time; // Take time of seed cell
142  cluster.cell_id = std::move(v_cellIDs);
143  cluster.setEtEtaPhi(tlv_cluster.Et(), tlv_cluster.Eta(), tlv_cluster.Phi());
144 
145  return cluster;
146 }
147 
148 
150  return "GEPBasic";
151 }
Gep::GepCaloCell::sigma
float sigma
Definition: GepCaloCell.h:22
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
et
Extra patterns decribing particle interation process.
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
Gep::GepCaloCell::isBadCell
bool isBadCell() const
Definition: GepCaloCell.h:59
Gep::Cluster::setEtEtaPhi
void setEtEtaPhi(double et, double eta, double phi)
Definition: Trigger/TrigT1/TrigGepPerf/src/Cluster.h:28
Gep::Cluster::ncells
int ncells
Definition: Trigger/TrigT1/TrigGepPerf/src/Cluster.h:33
extractSporadic.c1
c1
Definition: extractSporadic.py:133
Gep::Cluster
Definition: Trigger/TrigT1/TrigGepPerf/src/Cluster.h:13
Gep::GepCaloCell::sampling
unsigned int sampling
Definition: GepCaloCell.h:49
Gep::BasicGepClusterMaker::clusterFromCells
std::vector< Gep::GepCaloCell > clusterFromCells(const Gep::GepCaloCell &seed, const pGepCellMap &, std::vector< unsigned int > &seenSeedCells) const
Definition: BasicGepClusterMaker.cxx:64
Gep::BasicGepClusterMaker::getName
std::string getName() const override
Definition: BasicGepClusterMaker.cxx:149
Gep::BasicGepClusterMaker::makeClusters
std::vector< Gep::Cluster > makeClusters(const pGepCellMap &) const override
Definition: BasicGepClusterMaker.cxx:8
Gep::BasicGepClusterMaker::isInAllowedSampling
bool isInAllowedSampling(int sampling, const std::vector< int > &list_of_samplings) const
Definition: BasicGepClusterMaker.cxx:44
pGepCellMap
std::unique_ptr< GepCellMap > pGepCellMap
Definition: IClusterMaker.h:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
Gep::GepCaloCell::id
unsigned int id
Definition: GepCaloCell.h:50
Gep::Cluster::cell_id
std::vector< unsigned int > cell_id
Definition: Trigger/TrigT1/TrigGepPerf/src/Cluster.h:36
Gep::GepCaloCell
Definition: GepCaloCell.h:13
Gep::BasicGepClusterMaker::isNewCell
bool isNewCell(unsigned int id, const std::vector< unsigned int > &seenCells) const
Definition: BasicGepClusterMaker.cxx:53
BasicGepClusterMaker.h
python.DataFormatRates.c2
c2
Definition: DataFormatRates.py:123
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
Gep::BasicGepClusterMaker::isSeedCell
bool isSeedCell(const Gep::GepCaloCell &cell, const std::vector< unsigned int > &seenSeedCells) const
Definition: BasicGepClusterMaker.cxx:33
Gep::BasicGepClusterMaker::getClusterFromListOfCells
Gep::Cluster getClusterFromListOfCells(const std::vector< Gep::GepCaloCell > &cells) const
Definition: BasicGepClusterMaker.cxx:125
Gep::Cluster::time
float time
Definition: Trigger/TrigT1/TrigGepPerf/src/Cluster.h:34