ATLAS Offline Software
Loading...
Searching...
No Matches
Trig::MatchingImplementation Class Reference

#include <MatchingImplementation.h>

Inheritance diagram for Trig::MatchingImplementation:
Collaboration diagram for Trig::MatchingImplementation:

Public Member Functions

 MatchingImplementation (MatchingTool &mt, double threshold=0.4)
const Trig::TrigDecisionTooltdt () const
bool matchDistanceMatrix (const std::vector< std::vector< double > > &matrix, const Trig::MatchingStrategy::Strategy strategy=Trig::MatchingStrategy::MinimalSum, double threshold=0.0) const
void setThreshold (double in)
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

bool assocIsMatched (const IAssociationStrategy::index_assignment_t &association, const std::vector< std::vector< double > > &matrix, double threshold) const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

MatchingToolm_tool
std::map< Trig::MatchingStrategy::Strategy, std::unique_ptr< IAssociationStrategy > > m_strategies
double m_threshold
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

Definition at line 33 of file MatchingImplementation.h.

Constructor & Destructor Documentation

◆ MatchingImplementation()

Trig::MatchingImplementation::MatchingImplementation ( MatchingTool & mt,
double threshold = 0.4 )

Definition at line 12 of file MatchingImplementation.cxx.

12 : asg::AsgMessaging("MatchingImplementation"), m_tool(mt), m_threshold(threshold) {
13 m_strategies[Trig::MatchingStrategy::MinimalSum] = std::unique_ptr<IAssociationStrategy>(new MinimalSumAssociation());
14}
std::map< Trig::MatchingStrategy::Strategy, std::unique_ptr< IAssociationStrategy > > m_strategies

Member Function Documentation

◆ assocIsMatched()

bool Trig::MatchingImplementation::assocIsMatched ( const IAssociationStrategy::index_assignment_t & association,
const std::vector< std::vector< double > > & matrix,
double threshold ) const
private

Definition at line 20 of file MatchingImplementation.cxx.

20 {
21 int ndim = matrix.size();
22 if(!ndim) return false;
23
24 bool result = true;
25 for(auto trig_reco : association){
26 double distance = matrix[trig_reco.first][trig_reco.second];
27 bool single_assoc = distance < threshold;
28 result = result && single_assoc;
29 ATH_MSG_DEBUG("reco: " << trig_reco.first << " associated to trig: " << trig_reco.second <<
30 " with distance: " << distance << " ok: " << single_assoc << " overall: " << result);
31 }
32 return result;
33}
#define ATH_MSG_DEBUG(x)
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.

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

◆ matchDistanceMatrix()

bool Trig::MatchingImplementation::matchDistanceMatrix ( const std::vector< std::vector< double > > & matrix,
const Trig::MatchingStrategy::Strategy strategy = Trig::MatchingStrategy::MinimalSum,
double threshold = 0.0 ) const

Definition at line 35 of file MatchingImplementation.cxx.

35 {
36 int nrows = matrix.size();
37 int ncols = matrix.at(0).size();
38
39 ATH_MSG_DEBUG("matching a " << nrows << "x" << ncols << "matrix now");
40
41
42 auto MSG_MATRIX = MSG::DEBUG;
43 if(msgLvl(MSG_MATRIX)){
44 msg() << MSG_MATRIX << "===========" << endmsg;
45 for(auto& row : matrix){
46 msg() << MSG_MATRIX << "|";
47 for(auto distance : row){
48 msg() << MSG_MATRIX << distance << " , ";
49 }
50 msg() << MSG_MATRIX << "|" << endmsg;
51 }
52 msg() << MSG_MATRIX << "===========" << endmsg;
53 }
54
55
56 //require that every row contains an entry that is smaller than threshold, otherwise matching will obviously fail
57 for(auto& row : matrix) {
58 bool rowOk=false;
59 for(auto distance : row) {
60 if( distance < threshold ) { rowOk = true; break; }
61 }
62 if(!rowOk) {
63 ATH_MSG_DEBUG("row of matrix does not contain any distance below threshold. Return false"); return false;
64 }
65 }
66
67 auto association_map = m_strategies.at(strategy)->associate(matrix);
68 return assocIsMatched(association_map,matrix,threshold);
69}
#define endmsg
bool assocIsMatched(const IAssociationStrategy::index_assignment_t &association, const std::vector< std::vector< double > > &matrix, double threshold) const
MsgStream & msg() const
The standard message stream.
bool msgLvl(const MSG::Level lvl) const
Test the output level of the object.

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

◆ setThreshold()

void Trig::MatchingImplementation::setThreshold ( double in)
inline

Definition at line 38 of file MatchingImplementation.h.

38{ m_threshold=in; }

◆ tdt()

const Trig::TrigDecisionTool * Trig::MatchingImplementation::tdt ( ) const

Definition at line 16 of file MatchingImplementation.cxx.

16 {
17 return std::as_const(m_tool).m_trigDecTool.operator->();
18}

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.

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_strategies

std::map<Trig::MatchingStrategy::Strategy,std::unique_ptr<IAssociationStrategy> > Trig::MatchingImplementation::m_strategies
private

Definition at line 42 of file MatchingImplementation.h.

◆ m_threshold

double Trig::MatchingImplementation::m_threshold
private

Definition at line 43 of file MatchingImplementation.h.

◆ m_tool

MatchingTool& Trig::MatchingImplementation::m_tool
private

Definition at line 41 of file MatchingImplementation.h.


The documentation for this class was generated from the following files: