ATLAS Offline Software
Loading...
Searching...
No Matches
NodeFeatureList.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
7
9#include "Acts/Utilities/Enumerate.hpp"
10
11using namespace MuonR4;
12namespace MuonML {
14 return m_connector && numFeatures();
15 }
16 bool NodeFeatureList::setConnector(const std::string& conName, MsgStream& msg) {
18 return m_connector != nullptr;
19 }
20
21 void NodeFeatureList::setConnector(const std::string& conName, NodeConnector::Evaluator_t evalFunc) {
22 m_connector = std::make_unique<NodeConnector>(conName, evalFunc);
23 }
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 }
39 return m_features.size();
40 }
41
43 std::vector<std::string> NodeFeatureList::featureNames() const {
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 }
49
50 bool NodeFeatureList::addFeature(const std::string& featName, MsgStream& msg) {
51 return addFeature(Factory::makeFeature(featName, msg), msg);
52 }
53
54 bool NodeFeatureList::addFeature(const Feature_t& newFeat, MsgStream& msg) {
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 }
72
74 GraphRawData& prepGraph) const {
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 }
96
97}
#define endmsg
static Double_t sp
std::function< bool(const Bucket_t &, size_t, size_t)> Evaluator_t
Function type to connect two space points in a bucket.
bool operator==(const NodeFeatureList &other) const
Returns true if the features have pairwise the same name.
std::shared_ptr< const NodeFeature > Feature_t
size_t numFeatures() const
Returns the number of features in the list.
bool setConnector(const std::string &conName, MsgStream &msg)
Tries to set the graph connector based on the connector name.
std::vector< Feature_t > m_features
NodeFeature::Bucket_t Bucket_t
bool isValid() const
Returns whether the NodeFeatureList is complete, i.e.
std::vector< std::string > featureNames() const
Returns the name of the features in the list.
NodeFeatureList()=default
Empty standard constructor.
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 GraphFeatureFacto...
NodeFeatureList::Connector_t makeConnector(const std::string &connName, MsgStream &log)
Factory function that builds a connector relation between two edges in the bucket.
NodeFeatureList::Feature_t makeFeature(const std::string &featName, MsgStream &log)
Factory function that builds a NodeFeature from a predefined list of features.
This header ties the generic definitions in this package.
Helper struct to ship the Graph from the space point buckets to ONNX.
Definition GraphData.h:25
FeatureVec_t featureLeaves
Vector containing all features.
Definition GraphData.h:30
unsigned int nodeIndex
Number of the already filled nodes.
Definition GraphData.h:52
std::vector< float >::iterator currLeave
The following variables are needed to fill the consistently the raw data for the Graph Building.
Definition GraphData.h:50
EdgeCounterVec_t srcEdges
Vector encoding the source index of the.
Definition GraphData.h:32
EdgeCounterVec_t desEdges
Vect.
Definition GraphData.h:34
MsgStream & msg
Definition testRead.cxx:32