Skip to content

Commit e5a9000

Browse files
committed
Change trackster simToReco association score to handle overlapping simulated particles
When two CaloParticles were overlapping, the previous version of the simToReco score approached one (for ex. in the extreme case of two overlapping photons with same energy). The new score stays close to zero.
1 parent dc931b8 commit e5a9000

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

SimCalorimetry/HGCalAssociatorProducers/plugins/AllTracksterToSimTracksterAssociatorsByHitsProducer.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,24 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
342342
float simFraction = simFractions[i];
343343
const auto& recHit = rechitManager[hitIndex];
344344
float rechitEnergy = recHit.energy();
345-
float squaredSimFraction = simFraction * simFraction;
346345
float squaredRecHitEnergy = rechitEnergy * rechitEnergy;
347346
float simSharedEnergy = rechitEnergy * simFraction;
348347
const auto& hitToRecoTracksterVec = hitToAssociatedRecoTracksterMap[i];
349348
for (const auto& recoTracksterElement : hitToRecoTracksterVec) {
350349
auto recoTracksterIndex = recoTracksterElement.index();
351-
float recoFraction = recoTracksterElement.fraction();
350+
float recoFraction =
351+
recoTracksterElement.fraction(); // Either zero or one when no sharing of rechits between tracksters
352352
edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, recoTracksterIndex);
353353
float sharedEnergy = std::min(recoFraction * rechitEnergy, simSharedEnergy);
354-
float squaredFraction =
355-
std::min(squaredSimFraction, (recoFraction - simFraction) * (recoFraction - simFraction));
356-
float score = invDenominator * squaredFraction * squaredRecHitEnergy;
354+
/* SimToReco score logic:
355+
- simFraction = 0 && recoFraction >= 0 : trackster contains non-sim associated elements : ignore in simToReco
356+
- simFraction > 0 && recoFraction == 0 : simhits not present in reco trackster : penalty in score by simFraction*E
357+
- simFraction == 1 && recoFraction == 1 : good association
358+
- 1 > simFraction > recoFraction > 0 : we are missing some sim energy, penalty in score by the missing part : (simFraction-recoFraction)*E
359+
- 1 > recoFraction > simFraction > 0 : consider as good association, as there is enough reco to cover the sim
360+
*/
361+
float simMinusRecoFraction = std::max(0.f, simFraction - recoFraction);
362+
float score = invDenominator * simMinusRecoFraction * simMinusRecoFraction * squaredRecHitEnergy;
357363
simTracksterToTracksterMap->insert(simTracksterRef, recoTracksterRef, sharedEnergy, score);
358364
}
359365
}

SimCalorimetry/HGCalAssociatorProducers/plugins/AllTracksterToSimTracksterAssociatorsByLCsProducer.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ void AllTracksterToSimTracksterAssociatorsByLCsProducer::produce(edm::StreamID,
251251
unsigned int layerClusterId = layerClustersIds[i];
252252
const auto& layerCluster = layerClusters[layerClusterId];
253253
float simFraction = 1.f / simTrackster.vertex_multiplicity(i);
254-
float squaredSimFraction = simFraction * simFraction;
255254
float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
256255
float simSharedEnergy = layerCluster.energy() * simFraction;
257256
float invLayerClusterEnergy = 1.f / layerCluster.energy();
@@ -261,10 +260,18 @@ void AllTracksterToSimTracksterAssociatorsByLCsProducer::produce(edm::StreamID,
261260
float recoSharedEnergy = recoTracksterElement.sharedEnergy();
262261
edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, recoTracksterIndex);
263262
float sharedEnergy = std::min(recoSharedEnergy, simSharedEnergy);
264-
float recoFraction = recoSharedEnergy * invLayerClusterEnergy;
265-
float score = invDenominator *
266-
std::min(squaredSimFraction, (simFraction - recoFraction) * (simFraction - recoFraction)) *
267-
squaredLayerClusterEnergy;
263+
float recoFraction =
264+
recoSharedEnergy *
265+
invLayerClusterEnergy; // Either zero or one when no sharing of rechits between tracksters
266+
/* SimToReco score logic:
267+
- simFraction = 0 && recoFraction >= 0 : trackster contains non-sim associated elements : ignore in simToReco
268+
- simFraction > 0 && recoFraction == 0 : simhits not present in reco trackster : penalty in score by simFraction*E
269+
- simFraction == 1 && recoFraction == 1 : good association
270+
- 1 > simFraction > recoFraction > 0 : we are missing some sim energy, penalty in score by the missing part : (simFraction-recoFraction)*E
271+
- 1 > recoFraction > simFraction > 0 : consider as good association, as there is enough reco to cover the sim
272+
*/
273+
float simMinusRecoFraction = std::max(0.f, simFraction - recoFraction);
274+
float score = invDenominator * simMinusRecoFraction * simMinusRecoFraction * squaredLayerClusterEnergy;
268275
simTracksterToTracksterMap->insert(tracksterIndex, recoTracksterIndex, sharedEnergy, score);
269276
}
270277
}

0 commit comments

Comments
 (0)