ATLAS Offline Software
Loading...
Searching...
No Matches
PFSubtractionEnergyRatioCalculator.cxx
Go to the documentation of this file.
2
3#include "GaudiKernel/IMessageSvc.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/Bootstrap.h"
6
7
11
12void
14 const std::vector<std::pair<xAOD::CaloCluster*, bool>>&
15 clusterSubtractionList,
16 std::map<xAOD::CaloCluster*, double>& clusterEnergyMap,
17 std::vector<std::pair<float, float>>& clusterSubtractedEnergyRatios) const
18{
19
20 ATH_MSG_DEBUG("Setting subtracted energy ratios here");
21
22 for (auto thisCluster: clusterSubtractionList) {
23 ATH_MSG_DEBUG("Cluster energies are " << thisCluster.first->e() << " and " << clusterEnergyMap[thisCluster.first]);
24
25 //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
26 //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.
27 //If both thisCluster.first->e() and clusterEnergyMap[thisCluster.first] are zero we never enter this step.
28
29 if (std::abs(thisCluster.first->e() - clusterEnergyMap[thisCluster.first]) > 0.0001) {
30 if ( clusterEnergyMap[thisCluster.first] > 0) {
31 ATH_MSG_DEBUG("Subtracted energy ratio is " << thisCluster.first->e()/clusterEnergyMap[thisCluster.first]);
32 clusterSubtractedEnergyRatios.emplace_back(std::pair(thisCluster.first->e()/clusterEnergyMap[thisCluster.first],clusterEnergyMap[thisCluster.first]-thisCluster.first->e()));
33 }
34 //approximate zero with 0.0001 to avoid FPE and still give a meaningful ratio (e.g -100/0.0001)
35 else {
36 ATH_MSG_DEBUG("Subtracted energy ratio is " << thisCluster.first->e()/0.0001);
37 clusterSubtractedEnergyRatios.emplace_back(std::pair(thisCluster.first->e()/0.0001,clusterEnergyMap[thisCluster.first]-thisCluster.first->e()));
38 }
39 }
40 //else if the cluster enegry did not change then we use NAN to denote that no charged shower subtraction occurred.
41 else {
42 clusterSubtractedEnergyRatios.emplace_back(NAN,NAN);
43 ATH_MSG_DEBUG("Subtracted energy ratio is NAN ");
44 }
45 }//Loop over clusterSubtractionList
46}
47
48void
50 const std::vector<std::pair<xAOD::CaloCluster*, bool>>&
51 clusterSubtractionList,
52 std::map<xAOD::CaloCluster*, double>& clusterEnergyMap,
53 std::vector<std::pair<float, float>>& clusterSubtractedEnergyRatios) const
54{
55
56 ATH_MSG_DEBUG("Setting subtracted energy ratios for annih here");
57
58 for (auto thisCluster: clusterSubtractionList) {
59 ATH_MSG_DEBUG("Cluster energies are " << thisCluster.first->e() << " and " << clusterEnergyMap[thisCluster.first]);
60
61 //The energy can be zero if we previously "annihiliated" this cluster because we will have already set the energy to zero.
62 //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
63 //we don't subtract anything and we will set the value of the ratio to NAN which denotes that no subtraction was performed.
64 //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
65 //directly to zero, because in a previous annihilation we explicity set the energy to be exactly zero.
66 if (0 != clusterEnergyMap[thisCluster.first]) {
67 ATH_MSG_DEBUG("Setting cluster energy ratio to zero");
68 //We are removing the full energy, so set the subtracted energy to the cluster energy.
69 clusterSubtractedEnergyRatios.emplace_back(std::pair(0,clusterEnergyMap[thisCluster.first]));
70 }
71 else {
72 ATH_MSG_DEBUG("Setting cluster energy ratio to NAN");
73 clusterSubtractedEnergyRatios.emplace_back(NAN,NAN);
74 }
75
76 }
77}
#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.