40 {
43
44 std::vector<Gep::GepCaloCell>
cells;
45
47 CHECK(h_gepCellsMap.isValid());
48 const auto & gepCellsMap = *h_gepCellsMap;
49
50 auto cell_map = gepCellsMap.getCellMap();
51
52
53 for (auto const& cell_itr : *cell_map) {
54 cells.push_back(cell_itr.second);
55 }
56
57
58 SG::WriteHandle<xAOD::CaloClusterContainer> h_outputCaloClusters =
60 CHECK(h_outputCaloClusters.
record(std::make_unique<xAOD::CaloClusterContainer>(),
61 std::make_unique<xAOD::CaloClusterAuxContainer>()));
62
63
64
65 std::vector<std::vector<unsigned int>> cell_ids;
66 auto customTowers = std::make_unique<xAOD::CaloTowerContainer>();
67 auto aux = std::make_unique<xAOD::CaloTowerAuxContainer>();
68 customTowers->setStore(aux.get());
69
70
71 static constexpr int nEta{98};
72 static constexpr int nPhi{64};
73 customTowers->configureGrid(nEta,-4.9,4.9,nPhi);
74
75 int nTowers = customTowers->nTowers();
76 cell_ids.resize(nTowers);
77
78 std::vector<std::vector<float>> layerEnergies;
79 layerEnergies.resize(nTowers);
80 for (
int iTower=0; iTower < nTowers; ++iTower) layerEnergies[iTower].
resize((
int)CaloSampling::Unknown);
81
82 for (int iTower=0; iTower < nTowers; ++iTower) {
83 auto tower = std::make_unique<xAOD::CaloTower>();
84 customTowers->push_back(std::move(tower));
85 customTowers->at(iTower)->reset();
86 }
87
88
89 for (const auto& cell : cells) {
90 if (
cell.isBadCell())
continue;
91
93 if (idx < 0) continue;
94
95
96
97
98
99
100
101
102
103
104
106 int countNeighbours=0;
107 int countNeighboursNotInLayer=0;
108 int count4sigNeighbours=0;
109
110 for (
unsigned int i_neighbour = 0; i_neighbour <
cell.neighbours.size(); ++i_neighbour) {
111
112 auto const& nghbr_itr = cell_map->find(
cell.neighbours[i_neighbour]);
113 if (nghbr_itr == cell_map->end()) continue;
114 Gep::GepCaloCell neighbour = nghbr_itr->second;
116 if (neighbour.
et<=0)
continue;
117 countNeighbours++;
118 if (neighbour.
sigma>=4) count4sigNeighbours++;
119 if (neighbour.
sampling!=
cell.sampling) countNeighboursNotInLayer++;
120 }
121
122 if (countNeighbours==0 &&
cell.sigma<4)
continue;
123 bool passStrictNNFilter = false;
124 if (
cell.sigma>4) passStrictNNFilter=
true;
125 if (
cell.sampling==0 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
126 if (
cell.sampling==1 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
127 if (
cell.sampling==2 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
128 if (
cell.sampling==4 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
129 if (
cell.sampling==5 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
130 if (
cell.sampling==6 && (countNeighbours>=2 || count4sigNeighbours>=1)) passStrictNNFilter=
true;
131 if ((
cell.sampling>=6 ||
cell.sampling==3) && countNeighbours>=1) passStrictNNFilter=
true;
133 if (
m_doNNFilter>=3 && (
cell.sampling==0 ||
cell.sampling==4 ||
cell.sampling==17) && countNeighboursNotInLayer==0)
continue;
134 }
135
136
137
138
139 customTowers->at(idx)->addEnergy(
cell.et);
141 cell_ids[
idx].push_back(
cell.id);
142 }
143
144
145 for(auto tower: *customTowers){
146 auto p4 = tower->p4();
147
148
149 if ( p4.E() <=
m_minEt )
continue;
150
151
152 auto *
ptr = h_outputCaloClusters->push_back(std::make_unique<xAOD::CaloCluster>());
153
154
155
156
157
158 double eta = p4.Eta();
159 double phi = p4.Phi();
160 double e = p4.E() * std::cosh(
eta);
161
162
163
164
165
166
171
176
177
178
179
180
181
183 for(
int i=0;
i<(
int)CaloSampling::Unknown;
i++) {
184 if (layerEnergies[tower->index()].at(i)!=0) samplingPattern |= (0x1U<<
i);
185 }
186
187 ptr->clearSamplingData();
188 ptr->setSamplingPattern(samplingPattern);
189
190
191 for(
int i=0;
i<(
int)CaloSampling::Unknown;
i++) {
193 if (layerEnergies[tower->index()].at(i)!=0)
ptr->setEnergy(sampling_i, layerEnergies[tower->index()].at(i) * std::cosh(
eta));
194 }
195
196 auto cccl = std::make_unique<CaloClusterCellLink>();
197
198 for (auto cell_id : cell_ids[tower->index()])
199 cccl->addCell(cell_map->at(cell_id).index, 1.0);
200
201 ptr->addCellLink(std::move(cccl));
202 }
203
205 return StatusCode::SUCCESS;
206}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
virtual void setFilterPassed(bool state, const EventContext &ctx) const
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputCellTowerKey
SG::ReadHandleKey< Gep::GepCellMap > m_gepCellsKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool resize(size_t sz) override
Change the size of all aux data vectors.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
constexpr int nEta
Default bin number of eta for vertex map.
constexpr int nPhi
Default bin number of phi for vertex map.