ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PFSubtractionEnergyRatioCalculator Class Reference

Class to calculate the ratio of new to old energies of CaloClusters after the particle flow charged shower subtraction has been run. More...

#include <PFSubtractionEnergyRatioCalculator.h>

Inheritance diagram for PFSubtractionEnergyRatioCalculator:
Collaboration diagram for PFSubtractionEnergyRatioCalculator:

Public Member Functions

 PFSubtractionEnergyRatioCalculator ()
 
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 after the charged shower subtraction, which is added in clusterSubtractedEnergyRatios. More...
 
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 all ratios to zero in clusterEnergySubtractionRatios. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Class to calculate the ratio of new to old energies of CaloClusters after the particle flow charged shower subtraction has been run.

Definition at line 19 of file PFSubtractionEnergyRatioCalculator.h.

Constructor & Destructor Documentation

◆ PFSubtractionEnergyRatioCalculator()

PFSubtractionEnergyRatioCalculator::PFSubtractionEnergyRatioCalculator ( )

Definition at line 8 of file PFSubtractionEnergyRatioCalculator.cxx.

9  : AsgMessaging("PFSubtractionEnergyRatioCalculator")
10 {}

Member Function Documentation

◆ calculateSubtractedEnergyRatios()

void PFSubtractionEnergyRatioCalculator::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 after the charged shower subtraction, which is added in clusterSubtractedEnergyRatios.

clusterEnergyMap contains the cluster energy prior to the charged shower energy subtraction

Definition at line 13 of file PFSubtractionEnergyRatioCalculator.cxx.

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 }

◆ calculateSubtractedEnergyRatiosForAnnih()

void PFSubtractionEnergyRatioCalculator::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 all ratios to zero in clusterEnergySubtractionRatios.

If the old energy, in clusterEnergyMap, was zero we instead set the ratio to NAN to denote that no energy was removed from that xAOD::CaloCluster

Definition at line 49 of file PFSubtractionEnergyRatioCalculator.cxx.

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 }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49  {
50 #ifndef XAOD_STANDALONE
52 #else // not XAOD_STANDALONE
53  return m_msg;
54 #endif // not XAOD_STANDALONE
55  }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level  lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57  {
58 #ifndef XAOD_STANDALONE
60 #else // not XAOD_STANDALONE
61  m_msg << lvl;
62  return m_msg;
63 #endif // not XAOD_STANDALONE
64  }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level  lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41  {
42 #ifndef XAOD_STANDALONE
43  return ::AthMessaging::msgLvl( lvl );
44 #else // not XAOD_STANDALONE
45  return m_msg.msgLevel( lvl );
46 #endif // not XAOD_STANDALONE
47  }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
asg::AsgMessaging::AsgMessaging
AsgMessaging(const std::string &name)
Constructor with a name.
Definition: AsgMessaging.cxx:17
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7