ATLAS Offline Software
Loading...
Searching...
No Matches
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
using ClusterCalc

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.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Private Member Functions

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

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

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

Initial value:
bool (*)(const xAOD::TauJet &,
const xAOD::CaloVertexedTopoCluster &, double &)
Evaluate cluster kinematics with a different vertex / signal state.
TauJet_v3 TauJet
Definition of the current "tau version".

Definition at line 37 of file TauJetRNNUtils.h.

◆ ScalarCalc

using TauJetRNNUtils::VarCalc::ScalarCalc = bool (*)(const xAOD::TauJet &, double &)

Definition at line 32 of file TauJetRNNUtils.h.

◆ TrackCalc

Initial value:
bool (*)(const xAOD::TauJet &, const xAOD::TauTrack &,
double &)
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16

Definition at line 34 of file TauJetRNNUtils.h.

Constructor & Destructor Documentation

◆ VarCalc()

TauJetRNNUtils::VarCalc::VarCalc ( )

Definition at line 11 of file TauJetRNNUtils.cxx.

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

◆ ~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 29 of file TauJetRNNUtils.cxx.

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

◆ 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 54 of file TauJetRNNUtils.cxx.

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

◆ compute() [3/3]

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

Definition at line 14 of file TauJetRNNUtils.cxx.

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

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ insert() [1/3]

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

Definition at line 99 of file TauJetRNNUtils.cxx.

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

◆ insert() [2/3]

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

Definition at line 79 of file TauJetRNNUtils.cxx.

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

◆ insert() [3/3]

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

Definition at line 89 of file TauJetRNNUtils.cxx.

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

◆ 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
51 return ::AthMessaging::msg();
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
59 return ::AthMessaging::msg( lvl );
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.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

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