ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 

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. More...
 

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. 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

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 }

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 }

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

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

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

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

◆ 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_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:
xAOD::strategy
strategy
Definition: L2CombinedMuon_v1.cxx:107
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
query_example.row
row
Definition: query_example.py:24
get_generator_info.result
result
Definition: get_generator_info.py:21
asg::AsgMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level of the object.
Definition: AsgMessaging.cxx:41
Trig::MatchingImplementation::m_tool
MatchingTool & m_tool
Definition: MatchingImplementation.h:41
Trig::distance
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.
Definition: BunchCrossing.cxx:402
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
Trig::MatchingStrategy::MinimalSum
@ MinimalSum
Definition: MatchingImplementation.h:27
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MinimalSumAssociation
Definition: MinimalSumAssociation.h:14
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::association
@ association
Definition: TrackingGeometry.h:46
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessaging.cxx:49
Trig::MatchingImplementation::assocIsMatched
bool assocIsMatched(const IAssociationStrategy::index_assignment_t &association, const std::vector< std::vector< double > > &matrix, double threshold) const
Definition: MatchingImplementation.cxx:20
Trig::MatchingImplementation::m_strategies
std::map< Trig::MatchingStrategy::Strategy, std::unique_ptr< IAssociationStrategy > > m_strategies
Definition: MatchingImplementation.h:42
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
threshold
Definition: chainparser.cxx:74
Trig::MatchingImplementation::m_threshold
double m_threshold
Definition: MatchingImplementation.h:43
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
DEBUG
#define DEBUG
Definition: page_access.h:11
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34