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

This class contains a few functions to set the amount of energy removed from a xAOD::CaloCluster by a xAOD::Track in eflowRec. More...

#include <PFSubtractionStatusSetter.h>

Inheritance diagram for PFSubtractionStatusSetter:
Collaboration diagram for PFSubtractionStatusSetter:

Public Member Functions

 PFSubtractionStatusSetter ()
 
void markSubtractionStatus (const std::vector< std::pair< xAOD::CaloCluster *, bool >> &clusterList, std::vector< std::pair< float, float >> &clusterSubtractedEnergyRatios, eflowCaloObject &thisEflowCaloObject, unsigned int trackIndex) const
 Set the ratio of new to old cluster energy for each cluster matched to a track with trackIndex. More...
 
void markAllTracksAnnihStatus (eflowCaloObject &thisEflowCaloObject) const
 Set the ratio of new to old cluster energy, to zero, for all cluster matched to all tracks attached to the eflowCaloObject. 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

This class contains a few functions to set the amount of energy removed from a xAOD::CaloCluster by a xAOD::Track in eflowRec.

It can either set this for a specific track attached to an eflowCaloObject or set it for all tracks in an eflowCaloObject

Definition at line 19 of file PFSubtractionStatusSetter.h.

Constructor & Destructor Documentation

◆ PFSubtractionStatusSetter()

PFSubtractionStatusSetter::PFSubtractionStatusSetter ( )

Definition at line 14 of file PFSubtractionStatusSetter.cxx.

14 : AsgMessaging("PFSubtractionStatusSetter"){}

Member Function Documentation

◆ 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 }

◆ markAllTracksAnnihStatus()

void PFSubtractionStatusSetter::markAllTracksAnnihStatus ( eflowCaloObject thisEflowCaloObject) const

Set the ratio of new to old cluster energy, to zero, for all cluster matched to all tracks attached to the eflowCaloObject.

Definition at line 71 of file PFSubtractionStatusSetter.cxx.

73 {
74 
75  ATH_MSG_DEBUG("Executing markAllTracksAnnihStatus");
76 
77  const std::vector<std::pair<eflowTrackClusterLink*, std::pair<float,float> > >& matchedTrackList = thisEflowCaloObject.efRecLink();
78 
79  auto accumulateTrackEnergy = [](float sum, std::pair<eflowTrackClusterLink*, std::pair<float,float> > thisPair){ return sum + thisPair.first->getTrack()->getTrack()->e();};
80  float totalTrackE = std::accumulate(matchedTrackList.begin(),matchedTrackList.end(),0.0,accumulateTrackEnergy);
81 
82  unsigned int counter = 0;
83  for (const auto & thisTrackClusterLinkPair : matchedTrackList){
84  ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());
85  ATH_MSG_DEBUG("will annihilate cluster with e and eta " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->e() << " and " << thisTrackClusterLinkPair.first->getCluster()->getCluster()->eta());
86  float trackEFraction = thisTrackClusterLinkPair.first->getTrack()->getTrack()->e()/totalTrackE;
87  //We set the subtracted energy to the cluster energy multiplied by the fraction of total matched track energy belonging to this track
88  //whilst the ratio of new to old enegry is set to 0.0
89  thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, std::pair(0.0,trackEFraction*thisTrackClusterLinkPair.first->getCluster()->getCluster()->e()));
90  counter++;
91  }
92 }

◆ markSubtractionStatus()

void PFSubtractionStatusSetter::markSubtractionStatus ( const std::vector< std::pair< xAOD::CaloCluster *, bool >> &  clusterList,
std::vector< std::pair< float, float >> &  clusterSubtractedEnergyRatios,
eflowCaloObject thisEflowCaloObject,
unsigned int  trackIndex 
) const

Set the ratio of new to old cluster energy for each cluster matched to a track with trackIndex.

Definition at line 17 of file PFSubtractionStatusSetter.cxx.

22 {
23  // An eflowCaloObject may have one cluster and N tracks, and then one would
24  // have N eflowTrackClusterLink* for each track-cluster pair Hence there can
25  // be more entries in the track cluster link list due to duplication
26 
27  ATH_MSG_DEBUG("Executing markSubtractionStatus and have clusterList of size " << clusterList.size() << ", clusterSubtractedEnergyRatios of size " << clusterSubtractedEnergyRatios.size() << " and trackIndex of " << trackIndex);
28 
29  const std::vector<std::pair<eflowTrackClusterLink*, std::pair<float,float> > >& matchedTrackList = thisEflowCaloObject.efRecLink();
30 
31  unsigned int clusCounter = 0;
32  for (auto thisClusterPair : clusterList){
33  xAOD::CaloCluster* thisCluster = thisClusterPair.first;
34  ATH_MSG_DEBUG("Cluster with e and eta " << thisCluster->e() << " and " << thisCluster->eta());
35  unsigned int counter = 0;
36  for (const auto & thisTrackClusterLinkPair : matchedTrackList){
37 
38  if (trackIndex != thisTrackClusterLinkPair.first->getTrack()->getTrack()->index()){
39  counter++;
40  continue;
41  }
42 
43  ATH_MSG_DEBUG("Track with e and eta " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->e() << " and " << thisTrackClusterLinkPair.first->getTrack()->getTrack()->eta());
44 
45  //if the subtraction status is already true, then no need to update it
46  if (!std::isnan(thisTrackClusterLinkPair.second.first)) {
47  counter++;
48  continue;
49  }
50 
51  ATH_MSG_DEBUG("Not already subtracted");
52 
53  //eflowTrackCluster link returns an eflowRecCluster pointer, which in turn returns an xAOD:;CaloCluster* pointer
54  xAOD::CaloCluster* thisMatchedTrackCluster = (thisTrackClusterLinkPair.first)->getCluster()->getCluster();
55  //Now we can do a pointer comparison of the two clusters to see if we have a match
56  ATH_MSG_DEBUG("Comparing clusters with energies " << thisCluster->e() << " and " << thisMatchedTrackCluster->e());
57  if (thisCluster == thisMatchedTrackCluster){
58  ATH_MSG_DEBUG("Passed cluster energy check");
59  if (thisClusterPair.second && !std::isnan(clusterSubtractedEnergyRatios[clusCounter].first)) {
60  ATH_MSG_DEBUG("Will set ratio to be " << clusterSubtractedEnergyRatios[clusCounter].first);
61  thisEflowCaloObject.setTrackClusterLinkSubtractionStatus(counter, clusterSubtractedEnergyRatios[clusCounter]);
62  }
63  }//if have a match of the cluster
64  counter++;
65  }//loop on track cluster link pairs
66  clusCounter++;
67  }//loop on cluster pair list
68 }

◆ 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
eflowCaloObject::efRecLink
const std::vector< std::pair< eflowTrackClusterLink *, std::pair< float, float > > > & efRecLink() const
Definition: eflowCaloObject.h:65
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
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
eflowCaloObject::setTrackClusterLinkSubtractionStatus
void setTrackClusterLinkSubtractionStatus(unsigned int index, std::pair< float, float > energyRatio_energyValPair)
Definition: eflowCaloObject.h:49
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ClusterDistanceHelper::getCluster
const TrigMatch::clusterTraits< T >::type * getCluster(const T *t)
Definition: ClusterDistanceFunctor.h:33
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
DeMoScan.first
bool first
Definition: DeMoScan.py:536
test_pyathena.counter
counter
Definition: test_pyathena.py:15
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265