ATLAS Offline Software
Loading...
Searching...
No Matches
PFSubtractionEnergyRatioCalculator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "GaudiKernel/IMessageSvc.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/Bootstrap.h"
10
11
15
16void
18 const std::vector<std::pair<xAOD::CaloCluster*, bool>>&
19 clusterSubtractionList,
20 std::map<xAOD::CaloCluster*, double>& clusterEnergyMap,
21 std::vector<std::pair<float, float>>& clusterSubtractedEnergyRatios) const
22{
23
24 ATH_MSG_DEBUG("Setting subtracted energy ratios here");
25
26 for (const auto& thisCluster: clusterSubtractionList) {
27 ATH_MSG_DEBUG("Cluster energies are " << thisCluster.first->e() << " and " << clusterEnergyMap[thisCluster.first]);
28
29 //clusterEnergyMap[thisCluster.first can be zero, but this is only a problem if thisCluster.first.e() < 0 - this can happen if a cluster starts with E =0
30 //from a previous shower subtraction step and then we subtract more such that the new E is < 0. Then the ratio would cause an FPE due to the zero.
31 //If both thisCluster.first->e() and clusterEnergyMap[thisCluster.first] are zero we never enter this step.
32
33 if (std::abs(thisCluster.first->e() - clusterEnergyMap[thisCluster.first]) > 0.0001) {
34 if ( clusterEnergyMap[thisCluster.first] > 0) {
35 ATH_MSG_DEBUG("Subtracted energy ratio is " << thisCluster.first->e()/clusterEnergyMap[thisCluster.first]);
36 clusterSubtractedEnergyRatios.emplace_back(std::pair(thisCluster.first->e()/clusterEnergyMap[thisCluster.first],clusterEnergyMap[thisCluster.first]-thisCluster.first->e()));
37 }
38 //approximate zero with 0.0001 to avoid FPE and still give a meaningful ratio (e.g -100/0.0001)
39 else {
40 ATH_MSG_DEBUG("Subtracted energy ratio is " << thisCluster.first->e()/0.0001);
41 clusterSubtractedEnergyRatios.emplace_back(std::pair(thisCluster.first->e()/0.0001,clusterEnergyMap[thisCluster.first]-thisCluster.first->e()));
42 }
43 }
44 //else if the cluster enegry did not change then we use NAN to denote that no charged shower subtraction occurred.
45 else {
46 clusterSubtractedEnergyRatios.emplace_back(NAN,NAN);
47 ATH_MSG_DEBUG("Subtracted energy ratio is NAN ");
48 }
49 }//Loop over clusterSubtractionList
50}
51
52void
54 const std::vector<std::pair<xAOD::CaloCluster*, bool>>&
55 clusterSubtractionList,
56 std::map<xAOD::CaloCluster*, double>& clusterEnergyMap,
57 std::vector<std::pair<float, float>>& clusterSubtractedEnergyRatios) const
58{
59
60 ATH_MSG_DEBUG("Setting subtracted energy ratios for annih here");
61
62 for (const auto& thisCluster: clusterSubtractionList) {
63 ATH_MSG_DEBUG("Cluster energies are " << thisCluster.first->e() << " and " << clusterEnergyMap[thisCluster.first]);
64
65 //The energy can be zero if we previously "annihiliated" this cluster because we will have already set the energy to zero.
66 //We don't want to set the energy ratio to zero if we just change the energy from "0" to "0" - in effect in this case
67 //we don't subtract anything and we will set the value of the ratio to NAN which denotes that no subtraction was performed.
68 //So we build a list of indices of clusters which don't need to have the energy set to zero - we compare a floating point
69 //directly to zero, because in a previous annihilation we explicity set the energy to be exactly zero.
70 if (0 != clusterEnergyMap[thisCluster.first]) {
71 ATH_MSG_DEBUG("Setting cluster energy ratio to zero");
72 //We are removing the full energy, so set the subtracted energy to the cluster energy.
73 clusterSubtractedEnergyRatios.emplace_back(std::pair(0,clusterEnergyMap[thisCluster.first]));
74 }
75 else {
76 ATH_MSG_DEBUG("Setting cluster energy ratio to NAN");
77 clusterSubtractedEnergyRatios.emplace_back(NAN,NAN);
78 }
79
80 }
81}
#define ATH_MSG_DEBUG(x)
void calculateSubtractedEnergyRatiosForAnnih(const std::vector< std::pair< xAOD::CaloCluster *, bool > > &clusterSubtractionList, std::map< xAOD::CaloCluster *, double > &clusterEnergyMap, std::vector< std::pair< float, float > > &clusterSubtractedEnergyRatios) const
If we have decided to annihiliate all clusters in clusterSubtractionList we use this function to set ...
void calculateSubtractedEnergyRatios(const std::vector< std::pair< xAOD::CaloCluster *, bool > > &clusterSubtractionList, std::map< xAOD::CaloCluster *, double > &clusterEnergyMap, std::vector< std::pair< float, float > > &clusterSubtractedEnergyRatios) const
For each xAOD::CaloCluster in clusterSubtractionList we calculate the ratio of new to old energy afte...
AsgMessaging(const std::string &name)
Constructor with a name.