@@ -119,7 +119,8 @@ void TracksterLinkingbySuperClusteringDNN::linkTracksters(
119119 std::iota (trackstersIndicesPt.begin (), trackstersIndicesPt.end (), 0 );
120120 std::stable_sort (
121121 trackstersIndicesPt.begin (), trackstersIndicesPt.end (), [&inputTracksters](unsigned int i1, unsigned int i2) {
122- return inputTracksters[i1].raw_energy ()*std::sin (inputTracksters[i1].barycenter ().Theta ()) > inputTracksters[i2].raw_energy ()*std::sin (inputTracksters[i2].barycenter ().Theta ());
122+ return inputTracksters[i1].raw_energy () * std::sin (inputTracksters[i1].barycenter ().Theta ()) >
123+ inputTracksters[i2].raw_energy () * std::sin (inputTracksters[i2].barycenter ().Theta ());
123124 });
124125
125126 /* Evaluate in minibatches since running with trackster count = 3000 leads to a short-lived ~15GB memory allocation
@@ -149,8 +150,8 @@ void TracksterLinkingbySuperClusteringDNN::linkTracksters(
149150 Trackster const & ts_cand = inputTracksters[trackstersIndicesPt[ts_cand_idx_pt]];
150151
151152 if (ts_cand.raw_energy () < candidateEnergyThreshold_ ||
152- // !checkExplainedVarianceRatioCut(ts_cand)) // || !trackstersPassesPIDCut(ts_cand)
153- !checkExplainedVarianceRatioCut (ts_cand))// || !trackstersPassesPIDCut(ts_cand))
153+ // !checkExplainedVarianceRatioCut(ts_cand)) // || !trackstersPassesPIDCut(ts_cand)
154+ !checkExplainedVarianceRatioCut (ts_cand)) // || !trackstersPassesPIDCut(ts_cand))
154155 continue ;
155156
156157 auto & tracksterTiles = tracksterTilesBothEndcaps_pt[ts_cand.barycenter ().eta () > 0 ];
@@ -168,7 +169,7 @@ void TracksterLinkingbySuperClusteringDNN::linkTracksters(
168169
169170 Trackster const & ts_seed = inputTracksters[trackstersIndicesPt[ts_seed_idx_pt]];
170171
171- if (ts_seed.raw_energy ()* std::sin (ts_seed.barycenter ().Theta ()) < seedPtThreshold_)
172+ if (ts_seed.raw_energy () * std::sin (ts_seed.barycenter ().Theta ()) < seedPtThreshold_)
172173 break ; // All further seeds will have lower pT than threshold (due to pT sorting)
173174
174175 if (!checkExplainedVarianceRatioCut (ts_seed) || !trackstersPassesPIDCut (ts_seed))
@@ -249,95 +250,91 @@ void TracksterLinkingbySuperClusteringDNN::linkTracksters(
249250 Also mask seeds (only needed to add tracksters not in a supercluster to the output). */
250251 std::vector<bool > tracksterMask (tracksterCount, false );
251252
252-
253253 // ///////////////////////////////////////////////////////////////////////TRKBUILDINGMOD
254-
254+
255255 unsigned int previousCandTrackster_idx = std::numeric_limits<unsigned int >::max ();
256256 unsigned int bestSeedForCurrentCandidate_idx = std::numeric_limits<unsigned int >::max ();
257257 float bestSeedForCurrentCandidate_dnnScore = nnWorkingPoint_;
258-
258+
259259 // Track which tracksters were ever used as candidates
260260 std::vector<bool > usedAsCandidate (tracksterCount, false );
261-
262-
261+
263262 auto onCandidateTransition = [&](unsigned ts_cand_idx) {
264263 if (bestSeedForCurrentCandidate_idx < std::numeric_limits<unsigned int >::max ()) {
265- tracksterMask[ts_cand_idx] = true ; // Mask the candidate so it’s not reused as a seed
264+ tracksterMask[ts_cand_idx] = true ; // Mask the candidate so it’s not reused as a seed
266265 usedAsCandidate[ts_cand_idx] = true ;
267-
266+
268267 // Find the supercluster the seed belongs to (even if it's already used in another supercluster)
269268 // Find existing supercluster for the seed
270- auto seed_supercluster_it =
271- std::find_if (outputSuperclusters.begin (),
272- outputSuperclusters.end (),
273- [bestSeedForCurrentCandidate_idx](const std::vector<unsigned int >& sc) {
274- return sc[0 ] == bestSeedForCurrentCandidate_idx;
275- });
269+ auto seed_supercluster_it = std::find_if (outputSuperclusters.begin (),
270+ outputSuperclusters.end (),
271+ [bestSeedForCurrentCandidate_idx](const std::vector<unsigned int >& sc) {
272+ return sc[0 ] == bestSeedForCurrentCandidate_idx;
273+ });
276274 if (seed_supercluster_it == outputSuperclusters.end ()) {
277- // No supercluster exists for this seed, create one
278- outputSuperclusters.emplace_back (std::initializer_list<unsigned int >{bestSeedForCurrentCandidate_idx});
279- resultTracksters.emplace_back (inputTracksters[bestSeedForCurrentCandidate_idx]);
280- linkedTracksterIdToInputTracksterId.emplace_back (
281- std::initializer_list<unsigned int >{bestSeedForCurrentCandidate_idx});
282- seed_supercluster_it = outputSuperclusters.end () - 1 ;
283- tracksterMask[bestSeedForCurrentCandidate_idx] = true ;
275+ // No supercluster exists for this seed, create one
276+ outputSuperclusters.emplace_back (std::initializer_list<unsigned int >{bestSeedForCurrentCandidate_idx});
277+ resultTracksters.emplace_back (inputTracksters[bestSeedForCurrentCandidate_idx]);
278+ linkedTracksterIdToInputTracksterId.emplace_back (
279+ std::initializer_list<unsigned int >{bestSeedForCurrentCandidate_idx});
280+ seed_supercluster_it = outputSuperclusters.end () - 1 ;
281+ tracksterMask[bestSeedForCurrentCandidate_idx] = true ;
284282 }
285-
283+
286284 unsigned int indexIntoOutputTracksters = seed_supercluster_it - outputSuperclusters.begin ();
287285 seed_supercluster_it->push_back (ts_cand_idx);
288286 resultTracksters[indexIntoOutputTracksters].mergeTracksters (inputTracksters[ts_cand_idx]);
289287 linkedTracksterIdToInputTracksterId[indexIntoOutputTracksters].push_back (ts_cand_idx);
290-
288+
291289 assert (outputSuperclusters.size () == resultTracksters.size () &&
292- outputSuperclusters.size () == linkedTracksterIdToInputTracksterId.size ());
290+ outputSuperclusters.size () == linkedTracksterIdToInputTracksterId.size ());
293291 assert (seed_supercluster_it->size () == linkedTracksterIdToInputTracksterId[indexIntoOutputTracksters].size ());
294-
292+
295293 bestSeedForCurrentCandidate_idx = std::numeric_limits<unsigned int >::max ();
296294 bestSeedForCurrentCandidate_dnnScore = nnWorkingPoint_;
297295 }
298296 };
299-
297+
300298 // Iterate over minibatches
301299 for (unsigned int batchIndex = 0 ; batchIndex < batchOutputs.size (); batchIndex++) {
302300 std::vector<float > const & currentBatchOutputs = batchOutputs[batchIndex];
303-
301+
304302 for (unsigned int indexInBatch = 0 ; indexInBatch < tracksterIndicesUsedInDNN[batchIndex].size (); indexInBatch++) {
305303 assert (indexInBatch < static_cast <unsigned int >(batchOutputs[batchIndex].size ()));
306-
304+
307305 const unsigned int ts_seed_idx = tracksterIndicesUsedInDNN[batchIndex][indexInBatch].first ;
308306 const unsigned int ts_cand_idx = tracksterIndicesUsedInDNN[batchIndex][indexInBatch].second ;
309307 const float currentDnnScore = currentBatchOutputs[indexInBatch];
310-
308+
311309 if (previousCandTrackster_idx != std::numeric_limits<unsigned int >::max () &&
312- ts_cand_idx != previousCandTrackster_idx) {
313- onCandidateTransition (previousCandTrackster_idx);
310+ ts_cand_idx != previousCandTrackster_idx) {
311+ onCandidateTransition (previousCandTrackster_idx);
314312 }
315-
313+
316314 // Ignore seed if it was previously used as a candidate
317- if (currentDnnScore > bestSeedForCurrentCandidate_dnnScore && !usedAsCandidate[ts_seed_idx]) {
318- bestSeedForCurrentCandidate_idx = ts_seed_idx;
319- bestSeedForCurrentCandidate_dnnScore = currentDnnScore;
315+ if (currentDnnScore > bestSeedForCurrentCandidate_dnnScore && !usedAsCandidate[ts_seed_idx]) {
316+ bestSeedForCurrentCandidate_idx = ts_seed_idx;
317+ bestSeedForCurrentCandidate_dnnScore = currentDnnScore;
320318 }
321-
319+
322320 previousCandTrackster_idx = ts_cand_idx;
323321 }
324322 }
325323 onCandidateTransition (previousCandTrackster_idx);
326-
324+
327325 // Create singleton superclusters for unused tracksters with enough pt
328326 for (unsigned int ts_id = 0 ; ts_id < tracksterCount; ts_id++) {
329- if (!tracksterMask[ts_id] && inputTracksters[ts_id].raw_energy ()*std::sin (inputTracksters[ts_id].barycenter ().Theta ()) >= seedPtThreshold_) {
327+ if (!tracksterMask[ts_id] &&
328+ inputTracksters[ts_id].raw_energy () * std::sin (inputTracksters[ts_id].barycenter ().Theta ()) >=
329+ seedPtThreshold_) {
330330 outputSuperclusters.emplace_back (std::initializer_list<unsigned int >{ts_id});
331331 resultTracksters.emplace_back (inputTracksters[ts_id]);
332332 linkedTracksterIdToInputTracksterId.emplace_back (std::initializer_list<unsigned int >{ts_id});
333333 }
334334 }
335-
336-
337-
335+
338336 // ///////////////////////////////////////////////////////////////////////TRKBUILDINGMOD
339-
340-
337+
341338#ifdef EDM_ML_DEBUG
342339 for (std::vector<unsigned int > const & sc : outputSuperclusters) {
343340 std::ostringstream s;
0 commit comments