Skip to content

Commit 9cbc5f7

Browse files
authored
Merge pull request #48148 from tcuisset/pr-fixSimToReco
TICL: change Trackster SimToReco score, to fix overlapping CaloParticle issues
2 parents 0b4cc5b + e5a9000 commit 9cbc5f7

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
@@ -391,18 +391,24 @@ void AllTracksterToSimTracksterAssociatorsByHitsProducer::produce(edm::StreamID,
391391
float simFraction = simFractions[i];
392392
const auto& recHit = rechitManager[hitIndex];
393393
float rechitEnergy = recHit.energy();
394-
float squaredSimFraction = simFraction * simFraction;
395394
float squaredRecHitEnergy = rechitEnergy * rechitEnergy;
396395
float simSharedEnergy = rechitEnergy * simFraction;
397396
const auto& hitToRecoTracksterVec = hitToAssociatedRecoTracksterMap[i];
398397
for (const auto& recoTracksterElement : hitToRecoTracksterVec) {
399398
auto recoTracksterIndex = recoTracksterElement.index();
400-
float recoFraction = recoTracksterElement.fraction();
399+
float recoFraction =
400+
recoTracksterElement.fraction(); // Either zero or one when no sharing of rechits between tracksters
401401
edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, recoTracksterIndex);
402402
float sharedEnergy = std::min(recoFraction * rechitEnergy, simSharedEnergy);
403-
float squaredFraction =
404-
std::min(squaredSimFraction, (recoFraction - simFraction) * (recoFraction - simFraction));
405-
float score = invDenominator * squaredFraction * squaredRecHitEnergy;
403+
/* SimToReco score logic:
404+
- simFraction = 0 && recoFraction >= 0 : trackster contains non-sim associated elements : ignore in simToReco
405+
- simFraction > 0 && recoFraction == 0 : simhits not present in reco trackster : penalty in score by simFraction*E
406+
- simFraction == 1 && recoFraction == 1 : good association
407+
- 1 > simFraction > recoFraction > 0 : we are missing some sim energy, penalty in score by the missing part : (simFraction-recoFraction)*E
408+
- 1 > recoFraction > simFraction > 0 : consider as good association, as there is enough reco to cover the sim
409+
*/
410+
float simMinusRecoFraction = std::max(0.f, simFraction - recoFraction);
411+
float score = invDenominator * simMinusRecoFraction * simMinusRecoFraction * squaredRecHitEnergy;
406412
simTracksterToTracksterMap->insert(simTracksterRef, recoTracksterRef, sharedEnergy, score);
407413
}
408414
}

SimCalorimetry/HGCalAssociatorProducers/plugins/AllTracksterToSimTracksterAssociatorsByLCsProducer.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ void AllTracksterToSimTracksterAssociatorsByLCsProducer::produce(edm::StreamID,
290290
unsigned int layerClusterId = layerClustersIds[i];
291291
const auto& layerCluster = layerClusters[layerClusterId];
292292
float simFraction = 1.f / simTrackster.vertex_multiplicity(i);
293-
float squaredSimFraction = simFraction * simFraction;
294293
float squaredLayerClusterEnergy = layerCluster.energy() * layerCluster.energy();
295294
float simSharedEnergy = layerCluster.energy() * simFraction;
296295
float invLayerClusterEnergy = 1.f / layerCluster.energy();
@@ -300,10 +299,18 @@ void AllTracksterToSimTracksterAssociatorsByLCsProducer::produce(edm::StreamID,
300299
float recoSharedEnergy = recoTracksterElement.sharedEnergy();
301300
edm::Ref<std::vector<ticl::Trackster>> recoTracksterRef(recoTrackstersHandle, recoTracksterIndex);
302301
float sharedEnergy = std::min(recoSharedEnergy, simSharedEnergy);
303-
float recoFraction = recoSharedEnergy * invLayerClusterEnergy;
304-
float score = invDenominator *
305-
std::min(squaredSimFraction, (simFraction - recoFraction) * (simFraction - recoFraction)) *
306-
squaredLayerClusterEnergy;
302+
float recoFraction =
303+
recoSharedEnergy *
304+
invLayerClusterEnergy; // Either zero or one when no sharing of rechits between tracksters
305+
/* SimToReco score logic:
306+
- simFraction = 0 && recoFraction >= 0 : trackster contains non-sim associated elements : ignore in simToReco
307+
- simFraction > 0 && recoFraction == 0 : simhits not present in reco trackster : penalty in score by simFraction*E
308+
- simFraction == 1 && recoFraction == 1 : good association
309+
- 1 > simFraction > recoFraction > 0 : we are missing some sim energy, penalty in score by the missing part : (simFraction-recoFraction)*E
310+
- 1 > recoFraction > simFraction > 0 : consider as good association, as there is enough reco to cover the sim
311+
*/
312+
float simMinusRecoFraction = std::max(0.f, simFraction - recoFraction);
313+
float score = invDenominator * simMinusRecoFraction * simMinusRecoFraction * squaredLayerClusterEnergy;
307314
simTracksterToTracksterMap->insert(tracksterIndex, recoTracksterIndex, sharedEnergy, score);
308315
}
309316
}

0 commit comments

Comments
 (0)