132 {
133 FPGATrackSimHit clusterEquiv;
134 bool newHit;
135
136
137
138 for( auto& hit: moduleHits){
139 bool is_clustered_hit = false;
140 std::vector<FPGATrackSimCluster>::iterator it_added_clus;
141
142
143 for(std::vector<FPGATrackSimCluster>::iterator it = moduleClusters.begin(); it != moduleClusters.end(); ++it) {
144 if(hit->isPixel()) {
146 if (!is_clustered_hit) {
147 is_clustered_hit = true;
149 } else {
150 int cPhi =
it->getClusterEquiv().getPhiIndex();
151 int cPhiWidth =
it->getClusterEquiv().getPhiWidth();
152 int cEta =
it->getClusterEquiv().getEtaIndex();
153 int cEtaWidth =
it->getClusterEquiv().getEtaWidth();
154 int fCPhi = it_added_clus->getClusterEquiv().getPhiIndex();
155 int fCPhiWidth = it_added_clus->getClusterEquiv().getPhiWidth();
156 int fCEta = it_added_clus->getClusterEquiv().getEtaIndex();
157 int fCEtaWidth = it_added_clus->getClusterEquiv().getEtaWidth();
158
159 clusterEquiv = it_added_clus->getClusterEquiv();
160
161
162 if (cPhi < fCPhi) {
164 if (cPhi + cPhiWidth < fCPhi + fCPhiWidth)
165 clusterEquiv.
setPhiWidth(fCPhiWidth + (fCPhi - cPhi));
166 else
168 } else {
170 if (!(cPhi + cPhiWidth < fCPhi + fCPhiWidth))
171 clusterEquiv.
setPhiWidth(cPhiWidth + (cPhi - fCPhi));
172 else
174 }
175
176
177 if (cEta < fCEta) {
179 if (cEta + cEtaWidth < fCEta + fCEtaWidth)
180 clusterEquiv.
setEtaWidth(fCEtaWidth + (fCEta - cEta));
181 else
183 } else {
185 if (!(cEta + cEtaWidth < fCEta + fCEtaWidth))
186 clusterEquiv.
setEtaWidth(cEtaWidth + (cEta - fCEta));
187 else
189 }
190
191 it_added_clus->setClusterEquiv(clusterEquiv);
192
193 for (
auto& hit :
it->getHitList()) {
194 newHit = true;
195 for (auto& finalHit : it_added_clus->getHitList()) {
196 if (hit.getEtaIndex() == finalHit.getEtaIndex() &&
197 hit.getPhiIndex() == finalHit.getPhiIndex())
198 newHit = false;
199 }
200 if (newHit) {
202 clusterEquiv = it_added_clus->getClusterEquiv();
203 float xOld = clusterEquiv.
getX();
204 float yOld = clusterEquiv.
getY();
205 float zOld = clusterEquiv.
getZ();
210 float xNew = hit.getX();
211 float yNew = hit.getY();
212 float zNew = hit.getZ();
213 float xPhiNew = hit.getPhiCoord();
214 float xEtaNew = hit.getEtaCoord();
215 float cPhiNew = hit.getPhiIndex();
216 float cEtaNew = hit.getEtaIndex();
218 int totNew = hit.getToT();
220
221 int n = it_added_clus->getHitList().size();
222 clusterEquiv.
setX((xOld*n + xNew) / (n+1));
223 clusterEquiv.
setY((yOld*n + yNew) / (n+1));
224 clusterEquiv.
setZ((zOld*n + zNew) / (n+1));
225 clusterEquiv.
setPhiCoord((xPhiOld*n + xPhiNew) / (n+1));
226 clusterEquiv.
setEtaCoord((xEtaOld*n + xEtaNew) / (n+1));
229 } else {
230 clusterEquiv.
setX((xOld*tot + xNew*totNew) / (tot+totNew));
231 clusterEquiv.
setY((yOld*tot + yNew*totNew) / (tot+totNew));
232 clusterEquiv.
setZ((zOld*tot + zNew*totNew) / (tot+totNew));
233 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
234 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
237 }
238 clusterEquiv.
setToT(tot + totNew);
239 it_added_clus->setClusterEquiv(clusterEquiv);
240 it_added_clus->push_backHitList(hit);
241 }
242 }
243
244
245
246
247 if (it != moduleClusters.end() - 1) {
248 *
it = moduleClusters.back();
249 moduleClusters.pop_back();
251 } else {
252 moduleClusters.pop_back();
253 break;
254 }
255 }
256 }
257 }
258 if(hit->isStrip()){
260 is_clustered_hit = true;
261 }
262 }
263
264
265 if((!is_clustered_hit) || (moduleClusters.size() == 0)){
266 FPGATrackSimCluster cluster;
267 if(hit->isPixel()){
268
270 } else if(hit->isStrip()){
272 }
273
274 moduleClusters.push_back(cluster);
275 }
276 }
277 moduleHits.clear();
278}
void setEtaIndex(unsigned v)
void setPhiIndex(unsigned v)
float getPhiCoord() const
float getCentroidPhiIndex() const
void setPhiCoord(float v)
void setCentroidPhiIndex(float v)
float getEtaCoord() const
void setEtaCoord(float v)
void setEtaWidth(unsigned v)
void setPhiWidth(unsigned v)
float getCentroidEtaIndex() const
void setCentroidEtaIndex(float v)
bool updatePixelCluster(FPGATrackSimCluster ¤tCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
bool updateStripCluster(FPGATrackSimCluster ¤tCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
#define CXXUTILS_TRAPPING_FP