289 {
290
292
293 unsigned int nClusters = thisEflowCaloObject.
nClusters();
294 unsigned int nTrackMatches = thisEflowCaloObject.
nTracks();
295
296 ATH_MSG_DEBUG(
"Have got an eflowCaloObject with " << nClusters <<
" clusters and " << nTrackMatches <<
" track matches");
297
298 if (msgLevel(MSG::DEBUG)){
299 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack){
300 eflowRecTrack* thisTrack = thisEflowCaloObject.
efRecTrack(iTrack);
302 }
303 }
304
305
307
308
309 if (nTrackMatches < 1) return;
310
314
315
317 if (
isEOverPFail(expectedEnergy, expectedSigma, clusterEnergy))
return;
318 }
319
320 const std::vector<std::pair<eflowTrackClusterLink *, std::pair<float, float>>> &matchedTrackList = thisEflowCaloObject.
efRecLink();
321
322 ATH_MSG_DEBUG(
"Matched Track List has size " << matchedTrackList.size());
323
324 if (msgLevel(MSG::DEBUG))
325 {
326 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack)
327 {
329 ATH_MSG_DEBUG(
"eflowCaloObject has track match with E, pt and eta " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
" and " << thisTrack->
eta());
330 }
331 }
332
333 ATH_MSG_DEBUG(
"About to perform subtraction for this eflowCaloObject");
334
335 bool wasAnnihilated = false;
336
337
339
340 if (
canAnnihilate(expectedEnergy, expectedSigma, clusterEnergy)){
341
342 wasAnnihilated = true;
343
344 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterList;
345 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
346 unsigned nCluster = thisEflowCaloObject.
nClusters();
347 for (unsigned iCluster = 0; iCluster < nCluster; ++iCluster){
349 }
350
351 ATH_MSG_DEBUG(
"We are going to annihilate. ExpectedEnergy, expectedSigma and clusterEnergy are " << expectedEnergy <<
", " << expectedSigma <<
" and " << clusterEnergy);
352 if (msgLevel(MSG::DEBUG))
353 for (const auto& thisPair : clusterList)
354 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
355
357
358
360
362
363 if (msgLevel(MSG::DEBUG))
364 for (const auto& thisPair : clusterList)
365 ATH_MSG_DEBUG(
"Have Annihilated cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
366
367
368 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
369 eflowRecTrack *thisEfRecTrack = (matchedTrackList[iTrack].first)->getTrack();
371 }
372
373 }
374 }
376
377 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
378
379 eflowRecTrack *thisEfRecTrack = thisEflowCaloObject.
efRecTrack(iTrack);
380
383
384 if (!thisEfRecTrack->
hasBin())
continue;
385
387
389
390 ATH_MSG_DEBUG(
"Am not in dense environment for this eflowCaloObject");
391
392
393 std::vector<eflowRecCluster *> matchedClusters;
395 matchedClusters.reserve(
links.size());
396 for (auto* thisEFlowTrackClusterLink : links)
397 matchedClusters.push_back(thisEFlowTrackClusterLink->getCluster());
400 matchedClusters.end(),
401 eflowRecCluster::SortDescendingPt());
402
403 if (msgLvl(MSG::DEBUG)) {
404 for (auto* thisClus : matchedClusters)
406 "Haved matched cluster "
407 << thisClus->getCluster()->index() << " with e,pt, eta and phi of "
408 << thisClus->getCluster()->e() << ", "
409 << thisClus->getCluster()->pt() << ", "
410 << thisClus->getCluster()->eta() << " and "
411 << thisClus->getCluster()->phi() << " will be subtracted");
412 }
413
414
415 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterSubtractionList;
416 clusterSubtractionList.reserve(matchedClusters.size());
417 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
418 for (auto *thisEFlowRecCluster : matchedClusters){
420 clusterSubtractionList.emplace_back(thisCluster, false);
421 clusterEnergyMap[thisCluster] = thisCluster->
e();
422 }
423
424 ATH_MSG_DEBUG(
"Have filled clusterSubtractionList for this eflowCaloObject");
425
426 unsigned int trackIndex = thisEfRecTrack->
getTrack()->index();
427
428
429 auto sumClusEnergy = [](double accumulator, std::pair<xAOD::CaloCluster *, bool> thisPair){ return accumulator += thisPair.first->e();};
430 double totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
431
432
434
435 if (msgLevel(MSG::DEBUG))
436 for (const auto& thisPair : clusterSubtractionList)
437 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
438
439
441
443
444
445 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
447 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
448 }
449 else
450 {
451
452
454
455
456 totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
457
458
460
461 if (msgLevel(MSG::DEBUG))
462 for (const auto& thisPair : clusterSubtractionList){
463 ATH_MSG_DEBUG(
"Annihilating remnant cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
464 }
466
467 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
469 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
470 }
471 else
472 {
473 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
475 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
476 }
477
478 }
479
480 ATH_MSG_DEBUG(
"Have subtracted charged shower for this eflowRecTrack");
481
482
484
485 }
486 }
487
488}
double getExpectedVariance() const
double getClusterEnergy() const
unsigned nClusters() const
const std::vector< std::pair< eflowTrackClusterLink *, std::pair< float, float > > > & efRecLink() const
double getExpectedEnergy() const
const eflowRecCluster * efRecCluster(int i) const
xAOD::CaloCluster * getCluster()
double getEExpect() const
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
bool isSubtracted() const
const xAOD::TrackParticle * getTrack() const
bool isInDenseEnvironment() const
double getVarEExpect() const
static void annihilateClusters(std::vector< std::pair< xAOD::CaloCluster *, bool > > &clusters)