ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TauJetRNNUtils::VarCalc Class Reference

Tool to calculate input variables for the RNN-based tau identification. More...

#include <TauJetRNNUtils.h>

Inheritance diagram for TauJetRNNUtils::VarCalc:
Collaboration diagram for TauJetRNNUtils::VarCalc:

Public Types

using ScalarCalc = bool(*)(const xAOD::TauJet &, double &)
 
using TrackCalc = bool(*)(const xAOD::TauJet &, const xAOD::TauTrack &, double &)
 
using ClusterCalc = bool(*)(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &, double &)
 

Public Member Functions

 VarCalc ()
 
 ~VarCalc ()=default
 
bool compute (const std::string &name, const xAOD::TauJet &tau, double &out) const
 
bool compute (const std::string &name, const xAOD::TauJet &tau, const std::vector< const xAOD::TauTrack * > &tracks, std::vector< double > &out) const
 
bool compute (const std::string &name, const xAOD::TauJet &tau, const std::vector< xAOD::CaloVertexedTopoCluster > &clusters, std::vector< double > &out) const
 
void insert (const std::string &name, ScalarCalc func, const std::vector< std::string > &scalar_vars)
 
void insert (const std::string &name, TrackCalc func, const std::vector< std::string > &track_vars)
 
void insert (const std::string &name, ClusterCalc func, const std::vector< std::string > &cluster_vars)
 
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::unordered_map< std::string, ScalarCalcm_scalar_map
 
std::unordered_map< std::string, TrackCalcm_track_map
 
std::unordered_map< std::string, ClusterCalcm_cluster_map
 
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

Tool to calculate input variables for the RNN-based tau identification.

Used to calculate input variables of the RNN-based tau identification on the fly by providing a mapping between variable names (strings) and functions to calculate these variables.

Author
C. Deutsch
W. Davey

Definition at line 29 of file TauJetRNNUtils.h.

Member Typedef Documentation

◆ ClusterCalc

Definition at line 37 of file TauJetRNNUtils.h.

◆ ScalarCalc

Definition at line 32 of file TauJetRNNUtils.h.

◆ TrackCalc

Definition at line 34 of file TauJetRNNUtils.h.

Constructor & Destructor Documentation

◆ VarCalc()

TauJetRNNUtils::VarCalc::VarCalc ( )

Definition at line 12 of file TauJetRNNUtils.cxx.

12  : asg::AsgMessaging("TauJetRNNUtils::VarCalc") {
13 }

◆ ~VarCalc()

TauJetRNNUtils::VarCalc::~VarCalc ( )
default

Member Function Documentation

◆ compute() [1/3]

bool TauJetRNNUtils::VarCalc::compute ( const std::string &  name,
const xAOD::TauJet tau,
const std::vector< const xAOD::TauTrack * > &  tracks,
std::vector< double > &  out 
) const

Definition at line 30 of file TauJetRNNUtils.cxx.

32  {
33  out.clear();
34 
35  // Retrieve calculator function
36  TrackCalc func = nullptr;
37  try {
38  func = m_track_map.at(name);
39  } catch (const std::out_of_range &e) {
40  ATH_MSG_ERROR("Variable '" << name << "' not defined");
41  throw;
42  }
43 
44  // Calculate variables for selected tracks
45  bool success = true;
46  double value;
47  for (const auto *const trk : tracks) {
48  success = success && func(tau, *trk, value);
49  out.push_back(value);
50  }
51 
52  return success;
53 }

◆ compute() [2/3]

bool TauJetRNNUtils::VarCalc::compute ( const std::string &  name,
const xAOD::TauJet tau,
const std::vector< xAOD::CaloVertexedTopoCluster > &  clusters,
std::vector< double > &  out 
) const

Definition at line 55 of file TauJetRNNUtils.cxx.

57  {
58  out.clear();
59 
60  // Retrieve calculator function
61  ClusterCalc func = nullptr;
62  try {
63  func = m_cluster_map.at(name);
64  } catch (const std::out_of_range &e) {
65  ATH_MSG_ERROR("Variable '" << name << "' not defined");
66  throw;
67  }
68 
69  // Calculate variables for selected clusters
70  bool success = true;
71  double value;
72  for (const xAOD::CaloVertexedTopoCluster& cluster : clusters) {
73  success = success && func(tau, cluster, value);
74  out.push_back(value);
75  }
76 
77  return success;
78 }

◆ compute() [3/3]

bool TauJetRNNUtils::VarCalc::compute ( const std::string &  name,
const xAOD::TauJet tau,
double &  out 
) const

Definition at line 15 of file TauJetRNNUtils.cxx.

16  {
17  // Retrieve calculator function
18  ScalarCalc func = nullptr;
19  try {
20  func = m_scalar_map.at(name);
21  } catch (const std::out_of_range &e) {
22  ATH_MSG_ERROR("Variable '" << name << "' not defined");
23  throw;
24  }
25 
26  // Calculate variable
27  return func(tau, out);
28 }

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

◆ insert() [1/3]

void TauJetRNNUtils::VarCalc::insert ( const std::string &  name,
ClusterCalc  func,
const std::vector< std::string > &  cluster_vars 
)

Definition at line 100 of file TauJetRNNUtils.cxx.

100  {
101  if (std::find(cluster_vars.begin(), cluster_vars.end(), name) == cluster_vars.end()) {
102  return;
103  }
104  if (!func) {
105  throw std::invalid_argument("Nullptr passed to VarCalc::insert");
106  }
107  m_cluster_map[name] = func;
108 }

◆ insert() [2/3]

void TauJetRNNUtils::VarCalc::insert ( const std::string &  name,
ScalarCalc  func,
const std::vector< std::string > &  scalar_vars 
)

Definition at line 80 of file TauJetRNNUtils.cxx.

80  {
81  if (std::find(scalar_vars.begin(), scalar_vars.end(), name) == scalar_vars.end()) {
82  return;
83  }
84  if (!func) {
85  throw std::invalid_argument("Nullptr passed to VarCalc::insert");
86  }
87  m_scalar_map[name] = func;
88 }

◆ insert() [3/3]

void TauJetRNNUtils::VarCalc::insert ( const std::string &  name,
TrackCalc  func,
const std::vector< std::string > &  track_vars 
)

Definition at line 90 of file TauJetRNNUtils.cxx.

90  {
91  if (std::find(track_vars.begin(), track_vars.end(), name) == track_vars.end()) {
92  return;
93  }
94  if (!func) {
95  throw std::invalid_argument("Nullptr passed to VarCalc::insert");
96  }
97  m_track_map[name] = func;
98 }

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

std::unordered_map<std::string, ClusterCalc> TauJetRNNUtils::VarCalc::m_cluster_map
private

Definition at line 68 of file TauJetRNNUtils.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.

◆ m_scalar_map

std::unordered_map<std::string, ScalarCalc> TauJetRNNUtils::VarCalc::m_scalar_map
private

Definition at line 66 of file TauJetRNNUtils.h.

◆ m_track_map

std::unordered_map<std::string, TrackCalc> TauJetRNNUtils::VarCalc::m_track_map
private

Definition at line 67 of file TauJetRNNUtils.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
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
athena.value
value
Definition: athena.py:124
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_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TauJetRNNUtils::VarCalc::TrackCalc
bool(*)(const xAOD::TauJet &, const xAOD::TauTrack &, double &) TrackCalc
Definition: TauJetRNNUtils.h:35
TauJetRNNUtils::VarCalc::m_cluster_map
std::unordered_map< std::string, ClusterCalc > m_cluster_map
Definition: TauJetRNNUtils.h:68
TauJetRNNUtils::VarCalc::m_track_map
std::unordered_map< std::string, TrackCalc > m_track_map
Definition: TauJetRNNUtils.h:67
TauJetRNNUtils::VarCalc::m_scalar_map
std::unordered_map< std::string, ScalarCalc > m_scalar_map
Definition: TauJetRNNUtils.h:66
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
TauJetRNNUtils::VarCalc::ScalarCalc
bool(*)(const xAOD::TauJet &, double &) ScalarCalc
Definition: TauJetRNNUtils.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
TauJetRNNUtils::VarCalc::ClusterCalc
bool(*)(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &, double &) ClusterCalc
Definition: TauJetRNNUtils.h:38
xAOD::CaloVertexedTopoCluster
Evaluate cluster kinematics with a different vertex / signal state.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloVertexedTopoCluster.h:38
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7