@@ -91,11 +91,11 @@ AllTracksterToSimTracksterAssociatorsByHitsProducer::AllTracksterToSimTracksterA
91
91
for (const auto & tracksterToken : tracksterCollectionTokens_) {
92
92
for (const auto & simTracksterToken : simTracksterCollectionTokens_) {
93
93
std::string instanceLabel = tracksterToken.first + " To" + simTracksterToken.first ;
94
- produces<ticl::AssociationMap<ticl::mapWithFractionAndScore ,
94
+ produces<ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore ,
95
95
std::vector<ticl::Trackster>,
96
96
std::vector<ticl::Trackster>>>(instanceLabel);
97
97
std::string reverseInstanceLabel = simTracksterToken.first + " To" + tracksterToken.first ;
98
- produces<ticl::AssociationMap<ticl::mapWithFractionAndScore ,
98
+ produces<ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore ,
99
99
std::vector<ticl::Trackster>,
100
100
std::vector<ticl::Trackster>>>(reverseInstanceLabel);
101
101
}
@@ -180,11 +180,13 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
180
180
const auto & simTracksterToHitMap = *simTracksterToHitMapHandle;
181
181
182
182
// Create the association maps
183
- auto tracksterToSimTracksterMap = std::make_unique<
184
- ticl::AssociationMap<ticl::mapWithFractionAndScore, std::vector<ticl::Trackster>, std::vector<ticl::Trackster>>>(
183
+ auto tracksterToSimTracksterMap = std::make_unique<ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore,
184
+ std::vector<ticl::Trackster>,
185
+ std::vector<ticl::Trackster>>>(
185
186
recoTrackstersHandle, simTrackstersHandle, iEvent);
186
- auto simTracksterToTracksterMap = std::make_unique<
187
- ticl::AssociationMap<ticl::mapWithFractionAndScore, std::vector<ticl::Trackster>, std::vector<ticl::Trackster>>>(
187
+ auto simTracksterToTracksterMap = std::make_unique<ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore,
188
+ std::vector<ticl::Trackster>,
189
+ std::vector<ticl::Trackster>>>(
188
190
simTrackstersHandle, recoTrackstersHandle, iEvent);
189
191
190
192
for (unsigned int tracksterIndex = 0 ; tracksterIndex < recoTracksters.size (); ++tracksterIndex) {
@@ -195,33 +197,37 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
195
197
recoTracksterHitsAndFractions.size ());
196
198
std::vector<unsigned int > associatedSimTracksterIndices;
197
199
for (unsigned int i = 0 ; i < recoTracksterHitsAndFractions.size (); ++i) {
198
- const auto & [hitIndex, recoFraction] = recoTracksterHitsAndFractions[i];
200
+ const auto & hitElement = recoTracksterHitsAndFractions[i];
201
+ unsigned int hitIndex = hitElement.index ();
202
+ float recoFraction = hitElement.fraction ();
199
203
const auto & recHit = rechitManager[hitIndex];
200
204
float squaredRecoFraction = recoFraction * recoFraction;
201
205
float rechitEnergy = recHit.energy ();
202
206
float squaredRecHitEnergy = rechitEnergy * rechitEnergy;
203
207
recoToSimScoresDenominator += squaredRecoFraction * squaredRecHitEnergy;
204
208
205
209
const auto & hitToSimTracksterVec = hitToSimTracksterMap[hitIndex];
206
- for (const auto & [simTracksterIndex, fraction] : hitToSimTracksterVec) {
210
+ for (const auto & simTracksterElement : hitToSimTracksterVec) {
211
+ auto simTracksterIndex = simTracksterElement.index ();
207
212
const auto & simTrackster = simTracksters[simTracksterIndex];
208
213
auto & seed = simTrackster.seedID ();
209
214
float simFraction = 0 ;
210
215
if (seed == caloParticlesHandle.id ()) {
211
216
unsigned int caloParticleIndex = simTrackster.seedIndex ();
212
- auto it = std::find_if (hitToCaloParticleMap[hitIndex].begin (),
213
- hitToCaloParticleMap[hitIndex].end (),
214
- [caloParticleIndex](const auto & pair) { return pair.first == caloParticleIndex; });
217
+ auto it =
218
+ std::find_if (hitToCaloParticleMap[hitIndex].begin (),
219
+ hitToCaloParticleMap[hitIndex].end (),
220
+ [caloParticleIndex](const auto & pair) { return pair.index () == caloParticleIndex; });
215
221
if (it != hitToCaloParticleMap[hitIndex].end ()) {
216
- simFraction = it->second ;
222
+ simFraction = it->fraction () ;
217
223
}
218
224
} else {
219
225
unsigned int simClusterIndex = simTracksters[simTracksterIndex].seedIndex ();
220
226
auto it = std::find_if (hitToSimClusterMap[hitIndex].begin (),
221
227
hitToSimClusterMap[hitIndex].end (),
222
- [simClusterIndex](const auto & pair) { return pair.first == simClusterIndex; });
228
+ [simClusterIndex](const auto & pair) { return pair.index () == simClusterIndex; });
223
229
if (it != hitToSimClusterMap[hitIndex].end ()) {
224
- simFraction = it->second ;
230
+ simFraction = it->fraction () ;
225
231
}
226
232
}
227
233
hitToAssociatedSimTracksterMap.insert (i, simTracksterIndex, simFraction);
@@ -235,11 +241,11 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
235
241
236
242
// Add missing sim tracksters with 0 shared energy to hitToAssociatedSimTracksterMap
237
243
for (unsigned int i = 0 ; i < recoTracksterHitsAndFractions.size (); ++i) {
238
- unsigned int hitId = recoTracksterHitsAndFractions[i].first ;
244
+ unsigned int hitId = recoTracksterHitsAndFractions[i].index () ;
239
245
const auto & simTracksterVec = hitToSimTracksterMap[hitId];
240
246
for (unsigned int simTracksterIndex : associatedSimTracksterIndices) {
241
247
if (std::find_if (simTracksterVec.begin (), simTracksterVec.end (), [simTracksterIndex](const auto & pair) {
242
- return pair.first == simTracksterIndex;
248
+ return pair.index () == simTracksterIndex;
243
249
}) == simTracksterVec.end ()) {
244
250
hitToAssociatedSimTracksterMap.insert (i, simTracksterIndex, 0 );
245
251
}
@@ -249,14 +255,16 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
249
255
const float invDenominator = 1 .f / recoToSimScoresDenominator;
250
256
251
257
for (unsigned int i = 0 ; i < recoTracksterHitsAndFractions.size (); ++i) {
252
- unsigned int hitIndex = recoTracksterHitsAndFractions[i].first ;
258
+ unsigned int hitIndex = recoTracksterHitsAndFractions[i].index () ;
253
259
const auto & recHit = rechitManager[hitIndex];
254
- float recoFraction = recoTracksterHitsAndFractions[i].second ;
260
+ float recoFraction = recoTracksterHitsAndFractions[i].fraction () ;
255
261
float squaredRecoFraction = recoFraction * recoFraction;
256
262
float squaredRecHitEnergy = recHit.energy () * recHit.energy ();
257
263
float recoSharedEnergy = recHit.energy () * recoFraction;
258
264
const auto & simTracksterVec = hitToAssociatedSimTracksterMap[i];
259
- for (const auto & [simTracksterIndex, simFraction] : simTracksterVec) {
265
+ for (const auto & simTracksterElement : simTracksterVec) {
266
+ auto simTracksterIndex = simTracksterElement.index ();
267
+ auto simFraction = simTracksterElement.fraction ();
260
268
edm::Ref<std::vector<ticl::Trackster>> simTracksterRef (simTrackstersHandle, simTracksterIndex);
261
269
float sharedEnergy = std::min (simFraction * recHit.energy (), recoSharedEnergy);
262
270
float squaredFraction =
@@ -281,17 +289,16 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
281
289
bool isSimTracksterFromCP = (seed == caloParticlesHandle.id ());
282
290
std::vector<float > simFractions (simTracksterHitsAndFractions.size (), 0 .f );
283
291
for (unsigned int i = 0 ; i < simTracksterHitsAndFractions.size (); ++i) {
284
- const auto & [hitIndex, simTracksterFraction] = simTracksterHitsAndFractions[i];
285
-
292
+ auto hitIndex = simTracksterHitsAndFractions[i].index ();
286
293
auto it = isSimTracksterFromCP
287
294
? (std::find_if (hitToCaloParticleMap[hitIndex].begin (),
288
295
hitToCaloParticleMap[hitIndex].end (),
289
- [simObjectIndex](const auto & pair) { return pair.first == simObjectIndex; }))
296
+ [simObjectIndex](const auto & pair) { return pair.index () == simObjectIndex; }))
290
297
: std::find_if (hitToSimClusterMap[hitIndex].begin (),
291
298
hitToSimClusterMap[hitIndex].end (),
292
- [simObjectIndex](const auto & pair) { return pair.first == simObjectIndex; });
299
+ [simObjectIndex](const auto & pair) { return pair.index () == simObjectIndex; });
293
300
if (it != hitToCaloParticleMap[hitIndex].end () and it != hitToSimClusterMap[hitIndex].end ()) {
294
- simFractions[i] = it->second ;
301
+ simFractions[i] = it->fraction () ;
295
302
}
296
303
float simFraction = simFractions[i];
297
304
const auto & recHit = rechitManager[hitIndex];
@@ -300,7 +307,9 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
300
307
simToRecoScoresDenominator += squaredSimFraction * squaredRecHitEnergy;
301
308
302
309
const auto & hitToRecoTracksterVec = hitToTracksterMap[hitIndex];
303
- for (const auto & [recoTracksterIndex, recoFraction] : hitToRecoTracksterVec) {
310
+ for (const auto & recoTracksterElement : hitToRecoTracksterVec) {
311
+ unsigned int recoTracksterIndex = recoTracksterElement.index ();
312
+ float recoFraction = recoTracksterElement.fraction ();
304
313
hitToAssociatedRecoTracksterMap.insert (i, recoTracksterIndex, recoFraction);
305
314
associatedRecoTracksterIndices.push_back (recoTracksterIndex);
306
315
}
@@ -312,12 +321,12 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
312
321
associatedRecoTracksterIndices.end ());
313
322
314
323
for (unsigned int i = 0 ; i < simTracksterHitsAndFractions.size (); ++i) {
315
- unsigned int hitIndex = simTracksterHitsAndFractions[i].first ;
324
+ unsigned int hitIndex = simTracksterHitsAndFractions[i].index () ;
316
325
const auto & hitToRecoTracksterVec = hitToTracksterMap[hitIndex];
317
326
for (unsigned int recoTracksterIndex : associatedRecoTracksterIndices) {
318
327
if (std::find_if (
319
328
hitToRecoTracksterVec.begin (), hitToRecoTracksterVec.end (), [recoTracksterIndex](const auto & pair) {
320
- return pair.first == recoTracksterIndex;
329
+ return pair.index () == recoTracksterIndex;
321
330
}) == hitToRecoTracksterVec.end ()) {
322
331
hitToAssociatedRecoTracksterMap.insert (i, recoTracksterIndex, 0 );
323
332
}
@@ -327,15 +336,17 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
327
336
const float invDenominator = 1 .f / simToRecoScoresDenominator;
328
337
329
338
for (unsigned int i = 0 ; i < simTracksterHitsAndFractions.size (); ++i) {
330
- const auto & [ hitIndex, simTracksterFraction] = simTracksterHitsAndFractions[i];
339
+ const auto & hitIndex = simTracksterHitsAndFractions[i]. index () ;
331
340
float simFraction = simFractions[i];
332
341
const auto & recHit = rechitManager[hitIndex];
333
342
float squaredSimFraction = simFraction * simFraction;
334
343
float squaredRecHitEnergy = recHit.energy () * recHit.energy ();
335
344
float simSharedEnergy = recHit.energy () * simFraction;
336
345
337
346
const auto & hitToRecoTracksterVec = hitToAssociatedRecoTracksterMap[i];
338
- for (const auto & [recoTracksterIndex, recoFraction] : hitToRecoTracksterVec) {
347
+ for (const auto & recoTracksterElement : hitToRecoTracksterVec) {
348
+ auto recoTracksterIndex = recoTracksterElement.index ();
349
+ float recoFraction = recoTracksterElement.fraction ();
339
350
edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef (recoTrackstersHandle, recoTracksterIndex);
340
351
float sharedEnergy = std::min (recoFraction * recHit.energy (), simSharedEnergy);
341
352
float squaredFraction =
@@ -346,8 +357,9 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
346
357
}
347
358
}
348
359
349
- tracksterToSimTracksterMap->sort (true );
350
- simTracksterToTracksterMap->sort (true );
360
+ // Sort the maps by score in ascending order
361
+ tracksterToSimTracksterMap->sort ([](const auto & a, const auto & b) { return a.score () < b.score (); });
362
+ simTracksterToTracksterMap->sort ([](const auto & a, const auto & b) { return a.score () < b.score (); });
351
363
352
364
// After populating the maps, store them in the event
353
365
iEvent.put (std::move (tracksterToSimTracksterMap), tracksterToken.first + " To" + simTracksterToken.first );
0 commit comments