ATLAS Offline Software
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 
8 
10 #include "Acts/Utilities/Enumerate.hpp"
12 
13 using namespace MuonR4;
14 namespace MuonML {
15  bool NodeFeatureList::isValid() const {
16  return m_connector && numFeatures();
17  }
18  bool NodeFeatureList::setConnector(const std::string& conName, MsgStream& msg) {
19  m_connector = Factory::makeConnector(conName , msg);
20  return m_connector != nullptr;
21  }
22 
23  void NodeFeatureList::setConnector(const std::string& conName, NodeConnector::Evaluator_t evalFunc) {
24  m_connector = std::make_unique<NodeConnector>(conName, evalFunc);
25  }
27  if (numFeatures() != other.numFeatures()) {
28  return false;
29  }
30  if (!m_connector || !other.m_connector || m_connector->name() != other.m_connector->name()) {
31  return false;
32  }
33  for (size_t f =0 ; f < numFeatures(); ++f) {
34  if (m_features[f]->name() != other.m_features[f]->name()) {
35  return false;
36  }
37  }
38  return true;
39  }
40  size_t NodeFeatureList::numFeatures() const {
41  return m_features.size();
42  }
43 
45  std::vector<std::string> NodeFeatureList::featureNames() const {
46  std::vector<std::string> names{};
47  std::ranges::transform(m_features,std::back_inserter(names),
48  [](const Feature_t& ft){ return ft->name();});
49  return names;
50  }
51 
52  bool NodeFeatureList::addFeature(const std::string& featName, MsgStream& msg) {
53  return addFeature(Factory::makeFeature(featName, msg), msg);
54  }
55 
56  bool NodeFeatureList::addFeature(const Feature_t& newFeat, MsgStream& msg) {
57  if (!newFeat) {
58  msg<<MSG::ERROR<<"No feature has been parsed. "<<endmsg;
59  return false;
60  }
61  if (std::ranges::find_if(m_features, [&newFeat](const Feature_t& known){
62  return known == newFeat || known->name() == newFeat->name();
63  }) != m_features.end()) {
64  msg<<MSG::ERROR<<" The feature "<<newFeat->name()<<" has already been added & "
65  <<" cannot be added again. "<<endmsg;
66  return false;
67  }
68  if (msg.level() <= MSG::DEBUG) {
69  msg<<MSG::DEBUG<<__FILE__<<":"<<__LINE__<<" - Add new feature "<< newFeat->name()<<endmsg;
70  }
71  m_features.push_back(newFeat);
72  return true;
73  }
74 
75  void NodeFeatureList::fillInData(const Bucket_t& bucket,
76  GraphRawData& prepGraph) const {
77  for (size_t sp = 0 ; sp < bucket.size(); ++sp) {
79  for(const Feature_t& feat : m_features) {
80  assert(prepGraph.currLeave != prepGraph.featureLeaves.end());
81  (*prepGraph.currLeave++) = feat->eval(bucket, sp);
82  }
83  for (size_t ot = 0; ot < sp; ++ot) {
84  size_t from = prepGraph.nodeIndex +sp;
85  size_t to = prepGraph.nodeIndex + ot;
86  if (m_connector->connect(bucket, sp, ot)) {
88  prepGraph.srcEdges.emplace_back(from);
89  prepGraph.desEdges.emplace_back(to);
91  prepGraph.srcEdges.emplace_back(to);
92  prepGraph.desEdges.emplace_back(from);
93  }
94  }
95  }
96  prepGraph.nodeIndex+=bucket.size();
97  }
98 
99 }
PlotCalibFromCool.ft
ft
Definition: PlotCalibFromCool.py:329
operator==
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
MuonML::NodeFeatureList::Feature_t
std::shared_ptr< const NodeFeature > Feature_t
Definition: NodeFeatureList.h:17
ReadFromCoolCompare.ot
ot
Definition: ReadFromCoolCompare.py:229
MuonML::NodeFeatureList
Definition: NodeFeatureList.h:14
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:872
MuonML::Factory::makeConnector
NodeFeatureList::Connector_t makeConnector(const std::string &connName, MsgStream &log)
Factory function that builds a connector relation between two edges in the bucket.
Definition: NodeFeatureFactory.cxx:126
NodeFeatureFactory.h
MatrixUtils.h
MuonML::GraphRawData::desEdges
EdgeCounterVec_t desEdges
Vect
Definition: GraphData.h:34
MuonML
Definition: GraphBucketFilterTool.cxx:9
MuonML::Factory::makeFeature
NodeFeatureList::Feature_t makeFeature(const std::string &featName, MsgStream &log)
Factory function that builds a NodeFeature from a predefined list of features.
Definition: NodeFeatureFactory.cxx:38
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
python.subdetectors.mmg.names
names
Definition: mmg.py:8
MuonML::LayerSpBucket
The LayerSpBucket is a space pointbucket where the points are internally sorted by their layer number...
Definition: LayerBucket.h:14
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
MuonML::GraphRawData::srcEdges
EdgeCounterVec_t srcEdges
Vector encoding the source index of the.
Definition: GraphData.h:32
MuonML::GraphRawData::featureLeaves
FeatureVec_t featureLeaves
Vector containing all features.
Definition: GraphData.h:30
hist_file_dump.f
f
Definition: hist_file_dump.py:140
MuonML::GraphRawData
Helper struct to ship the Graph from the space point buckets to ONNX.
Definition: GraphData.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonML::NodeConnector::Evaluator_t
std::function< bool(const Bucket_t &, size_t, size_t)> Evaluator_t
Function type to connect two space points in a bucket.
Definition: NodeConnector.h:25
GraphData.h
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:39
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
NodeFeatureList.h
known
Definition: TrigBStoxAODTool.cxx:107
MuonML::GraphRawData::currLeave
std::vector< float >::iterator currLeave
The following variables are needed to fill the consistently the raw data for the Graph Building.
Definition: GraphData.h:44
DEBUG
#define DEBUG
Definition: page_access.h:11
AthMessaging.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
MuonML::GraphRawData::nodeIndex
unsigned int nodeIndex
Number of the already filled nodes.
Definition: GraphData.h:46