287 {
288
290
291 unsigned int nClusters = thisEflowCaloObject.
nClusters();
292 unsigned int nTrackMatches = thisEflowCaloObject.
nTracks();
293
294 ATH_MSG_DEBUG(
"Have got an eflowCaloObject with " << nClusters <<
" clusters and " << nTrackMatches <<
" track matches");
295
296 if (msgLevel(MSG::DEBUG)){
297 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack){
298 eflowRecTrack* thisTrack = thisEflowCaloObject.
efRecTrack(iTrack);
300 }
301 }
302
303
305
306
307 if (nTrackMatches < 1) return;
308
312
313
315 if (
isEOverPFail(expectedEnergy, expectedSigma, clusterEnergy))
return;
316 }
317
318 const std::vector<std::pair<eflowTrackClusterLink *, std::pair<float, float>>> &matchedTrackList = thisEflowCaloObject.
efRecLink();
319
320 ATH_MSG_DEBUG(
"Matched Track List has size " << matchedTrackList.size());
321
322 if (msgLevel(MSG::DEBUG))
323 {
324 for (unsigned int iTrack = 0; iTrack < nTrackMatches; ++iTrack)
325 {
327 ATH_MSG_DEBUG(
"eflowCaloObject has track match with E, pt and eta " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
" and " << thisTrack->
eta());
328 }
329 }
330
331 ATH_MSG_DEBUG(
"About to perform subtraction for this eflowCaloObject");
332
333 bool wasAnnihilated = false;
334
335
337
338 if (
canAnnihilate(expectedEnergy, expectedSigma, clusterEnergy)){
339
340 wasAnnihilated = true;
341
342 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterList;
343 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
344 unsigned nCluster = thisEflowCaloObject.
nClusters();
345 for (unsigned iCluster = 0; iCluster < nCluster; ++iCluster){
347 }
348
349 ATH_MSG_DEBUG(
"We are going to annihilate. ExpectedEnergy, expectedSigma and clusterEnergy are " << expectedEnergy <<
", " << expectedSigma <<
" and " << clusterEnergy);
350 if (msgLevel(MSG::DEBUG))
351 for (const auto& thisPair : clusterList)
352 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
353
355
356
358
360
361 if (msgLevel(MSG::DEBUG))
362 for (const auto& thisPair : clusterList)
363 ATH_MSG_DEBUG(
"Have Annihilated cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
364
365
366 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
367 eflowRecTrack *thisEfRecTrack = (matchedTrackList[iTrack].first)->getTrack();
369 }
370
371 }
372 }
374
375 for (
unsigned iTrack = 0; iTrack < thisEflowCaloObject.
nTracks(); ++iTrack){
376
377 eflowRecTrack *thisEfRecTrack = thisEflowCaloObject.
efRecTrack(iTrack);
378
381
382 if (!thisEfRecTrack->
hasBin())
continue;
383
385
387
388 ATH_MSG_DEBUG(
"Am not in dense environment for this eflowCaloObject");
389
390
391 std::vector<eflowRecCluster *> matchedClusters;
393 matchedClusters.reserve(
links.size());
394 for (auto* thisEFlowTrackClusterLink : links)
395 matchedClusters.push_back(thisEFlowTrackClusterLink->getCluster());
398 matchedClusters.end(),
399 eflowRecCluster::SortDescendingPt());
400
401 if (msgLvl(MSG::DEBUG)) {
402 for (auto* thisClus : matchedClusters)
404 "Haved matched cluster "
405 << thisClus->getCluster()->index() << " with e,pt, eta and phi of "
406 << thisClus->getCluster()->e() << ", "
407 << thisClus->getCluster()->pt() << ", "
408 << thisClus->getCluster()->eta() << " and "
409 << thisClus->getCluster()->phi() << " will be subtracted");
410 }
411
412
413 std::vector<std::pair<xAOD::CaloCluster *, bool>> clusterSubtractionList;
414 clusterSubtractionList.reserve(matchedClusters.size());
415 std::map<xAOD::CaloCluster *, double> clusterEnergyMap;
416 for (auto *thisEFlowRecCluster : matchedClusters){
418 clusterSubtractionList.emplace_back(thisCluster, false);
419 clusterEnergyMap[thisCluster] = thisCluster->
e();
420 }
421
422 ATH_MSG_DEBUG(
"Have filled clusterSubtractionList for this eflowCaloObject");
423
424 unsigned int trackIndex = thisEfRecTrack->
getTrack()->index();
425
426
427 auto sumClusEnergy = [](double accumulator, std::pair<xAOD::CaloCluster *, bool> thisPair){ return accumulator += thisPair.first->e();};
428 double totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
429
430
432
433 if (msgLevel(MSG::DEBUG))
434 for (const auto& thisPair : clusterSubtractionList)
435 ATH_MSG_DEBUG(
"Annihilating cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
436
437
439
441
442
443 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
445 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
446 }
447 else
448 {
449
450
452
453
454 totalClusterEnergy = std::accumulate(clusterSubtractionList.begin(),clusterSubtractionList.end(),0.0,sumClusEnergy);
455
456
458
459 if (msgLevel(MSG::DEBUG))
460 for (const auto& thisPair : clusterSubtractionList){
461 ATH_MSG_DEBUG(
"Annihilating remnant cluster with E and eta " << thisPair.first->e() <<
" and " << thisPair.first->eta());
462 }
464
465 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
467 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
468 }
469 else
470 {
471 std::vector<std::pair<float, float>> clusterSubtractedEnergyRatios;
473 m_pfSubtractionStatusSetter.markSubtractionStatus(clusterSubtractionList, clusterSubtractedEnergyRatios, thisEflowCaloObject, trackIndex);
474 }
475
476 }
477
478 ATH_MSG_DEBUG(
"Have subtracted charged shower for this eflowRecTrack");
479
480
482
483 }
484 }
485
486}
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)