ATLAS Offline Software
Loading...
Searching...
No Matches
MuonML::NodeFeatureList Class Reference

#include <NodeFeatureList.h>

Collaboration diagram for MuonML::NodeFeatureList:

Public Types

using Feature_t = std::shared_ptr<const NodeFeature>
using Connector_t = std::shared_ptr<const NodeConnector>
using Bucket_t = NodeFeature::Bucket_t

Public Member Functions

 NodeFeatureList ()=default
 Empty standard constructor.
bool operator== (const NodeFeatureList &other) const
 Returns true if the features have pairwise the same name.
bool isValid () const
 Returns whether the NodeFeatureList is complete, i.e.
size_t numFeatures () const
 Returns the number of features in the list.
std::vector< std::string > featureNames () const
 Returns the name of the features in the list.
void fillInData (const Bucket_t &bucket, GraphRawData &graphData) const
bool addFeature (const std::string &featName, MsgStream &msg)
 Tries to add a new feature to the list using the predefined list of features in the GraphFeatureFactory.
bool addFeature (const Feature_t &featPtr, MsgStream &msg)
 Tries to add a particular feature to the list.
bool setConnector (const std::string &conName, MsgStream &msg)
 Tries to set the graph connector based on the connector name.
void setConnector (const std::string &conName, NodeConnector::Evaluator_t evalFunc)
 Sets the.

Private Attributes

std::vector< Feature_tm_features {}
Connector_t m_connector {}

Detailed Description

Definition at line 14 of file NodeFeatureList.h.

Member Typedef Documentation

◆ Bucket_t

◆ Connector_t

using MuonML::NodeFeatureList::Connector_t = std::shared_ptr<const NodeConnector>

Definition at line 18 of file NodeFeatureList.h.

◆ Feature_t

using MuonML::NodeFeatureList::Feature_t = std::shared_ptr<const NodeFeature>

Definition at line 17 of file NodeFeatureList.h.

Constructor & Destructor Documentation

◆ NodeFeatureList()

MuonML::NodeFeatureList::NodeFeatureList ( )
default

Empty standard constructor.

Member Function Documentation

◆ addFeature() [1/2]

bool MuonML::NodeFeatureList::addFeature ( const Feature_t & featPtr,
MsgStream & msg )

Tries to add a particular feature to the list.

Parameters
featPtrPointer to the instantiated feature
msgReference to the message stream object for logging.

Definition at line 54 of file NodeFeatureList.cxx.

54 {
55 if (!newFeat) {
56 msg<<MSG::ERROR<<"No feature has been parsed. "<<endmsg;
57 return false;
58 }
59 if (std::ranges::find_if(m_features, [&newFeat](const Feature_t& known){
60 return known == newFeat || known->name() == newFeat->name();
61 }) != m_features.end()) {
62 msg<<MSG::ERROR<<" The feature "<<newFeat->name()<<" has already been added & "
63 <<" cannot be added again. "<<endmsg;
64 return false;
65 }
66 if (msg.level() <= MSG::DEBUG) {
67 msg<<MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" - Add new feature "<< newFeat->name()<<endmsg;
68 }
69 m_features.push_back(newFeat);
70 return true;
71 }
#define endmsg
std::shared_ptr< const NodeFeature > Feature_t
std::vector< Feature_t > m_features
MsgStream & msg
Definition testRead.cxx:32

◆ addFeature() [2/2]

bool MuonML::NodeFeatureList::addFeature ( const std::string & featName,
MsgStream & msg )

Tries to add a new feature to the list using the predefined list of features in the GraphFeatureFactory.

Parameters
featNameName of the feature in the factory
msgReference to the message stream object for logging.

Definition at line 50 of file NodeFeatureList.cxx.

50 {
51 return addFeature(Factory::makeFeature(featName, msg), msg);
52 }
bool addFeature(const std::string &featName, MsgStream &msg)
Tries to add a new feature to the list using the predefined list of features in the GraphFeatureFacto...
NodeFeatureList::Feature_t makeFeature(const std::string &featName, MsgStream &log)
Factory function that builds a NodeFeature from a predefined list of features.

◆ featureNames()

std::vector< std::string > MuonML::NodeFeatureList::featureNames ( ) const

Returns the name of the features in the list.

Definition at line 43 of file NodeFeatureList.cxx.

43 {
44 std::vector<std::string> names{};
45 std::ranges::transform(m_features,std::back_inserter(names),
46 [](const Feature_t& ft){ return ft->name();});
47 return names;
48 }

◆ fillInData()

void MuonML::NodeFeatureList::fillInData ( const Bucket_t & bucket,
GraphRawData & graphData ) const

Fill the graph features

Connection i->j

Connection j-> i

Definition at line 73 of file NodeFeatureList.cxx.

74 {
75 for (size_t sp = 0 ; sp < bucket.size(); ++sp) {
77 for(const Feature_t& feat : m_features) {
78 assert(prepGraph.currLeave != prepGraph.featureLeaves.end());
79 (*prepGraph.currLeave++) = feat->eval(bucket, sp);
80 }
81 for (size_t ot = 0; ot < sp; ++ot) {
82 size_t from = prepGraph.nodeIndex +sp;
83 size_t to = prepGraph.nodeIndex + ot;
84 if (m_connector->connect(bucket, sp, ot)) {
86 prepGraph.srcEdges.emplace_back(from);
87 prepGraph.desEdges.emplace_back(to);
89 prepGraph.srcEdges.emplace_back(to);
90 prepGraph.desEdges.emplace_back(from);
91 }
92 }
93 }
94 prepGraph.nodeIndex+=bucket.size();
95 }
static Double_t sp
CONT to(RANGE &&r)
Definition ranges.h:39

◆ isValid()

bool MuonML::NodeFeatureList::isValid ( ) const

Returns whether the NodeFeatureList is complete, i.e.

it must have at least one feature and the node connector

Definition at line 13 of file NodeFeatureList.cxx.

13 {
14 return m_connector && numFeatures();
15 }
size_t numFeatures() const
Returns the number of features in the list.

◆ numFeatures()

size_t MuonML::NodeFeatureList::numFeatures ( ) const

Returns the number of features in the list.

Definition at line 38 of file NodeFeatureList.cxx.

38 {
39 return m_features.size();
40 }

◆ operator==()

bool MuonML::NodeFeatureList::operator== ( const NodeFeatureList & other) const

Returns true if the features have pairwise the same name.

Definition at line 24 of file NodeFeatureList.cxx.

24 {
25 if (numFeatures() != other.numFeatures()) {
26 return false;
27 }
28 if (!m_connector || !other.m_connector || m_connector->name() != other.m_connector->name()) {
29 return false;
30 }
31 for (size_t f =0 ; f < numFeatures(); ++f) {
32 if (m_features[f]->name() != other.m_features[f]->name()) {
33 return false;
34 }
35 }
36 return true;
37 }

◆ setConnector() [1/2]

bool MuonML::NodeFeatureList::setConnector ( const std::string & conName,
MsgStream & msg )

Tries to set the graph connector based on the connector name.

Parameters
conNameName of the connector to extract from the factory
msgReference to the message stream object for logging.

Definition at line 16 of file NodeFeatureList.cxx.

16 {
18 return m_connector != nullptr;
19 }
NodeFeatureList::Connector_t makeConnector(const std::string &connName, MsgStream &log)
Factory function that builds a connector relation between two edges in the bucket.

◆ setConnector() [2/2]

void MuonML::NodeFeatureList::setConnector ( const std::string & conName,
NodeConnector::Evaluator_t evalFunc )

Sets the.

Definition at line 21 of file NodeFeatureList.cxx.

21 {
22 m_connector = std::make_unique<NodeConnector>(conName, evalFunc);
23 }

Member Data Documentation

◆ m_connector

Connector_t MuonML::NodeFeatureList::m_connector {}
private

Definition at line 57 of file NodeFeatureList.h.

57{};

◆ m_features

std::vector<Feature_t> MuonML::NodeFeatureList::m_features {}
private

Definition at line 56 of file NodeFeatureList.h.

56{};

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