Belle II Software development
SubGraph< FilterType > Class Template Reference

contains all relevant stuff needed for dealing with a subGraph. More...

#include <SubGraph.h>

Public Types

using Iterator = typename std::unordered_map< FilterType, MinMax >::iterator
 for better readability.
 

Public Member Functions

bool operator== (const SubGraph< FilterType > &b) const
 overloaded '=='-operator
 
 SubGraph (SubGraphID &id, const std::vector< FilterType > &fIDs)
 constructor, mandatory iDChain musst at least contain one iD.
 
 ~SubGraph ()
 destructor
 
bool checkAndReplaceIfMinMax (FilterType fID, double value)
 add filter, if not added yet, checks value and replaces old ones if new one is better.
 
void wasFound ()
 increases found-counter.
 
unsigned getFound () const
 returns found-counter.
 
bool checkSharesTrunk (const SubGraph< FilterType > &b) const
 if both graphs have got the same IDs except the last one, they share a trunk.
 
std::string print () const
 "print" debugging information to a string
 
const SubGraphIDgetID () const
 returns iD of this graph
 
void prepareDataCollection (std::pair< double, double > quantiles)
 takes care of being able to use the data collector. please use for quantiles [min, max] min ~0 & max ~1 (range 0-1)
 
void addValue (FilterType fID, double value)
 adds value to rawDataCollector
 
const std::unordered_map< FilterType, MinMax > & getFinalQuantileValues ()
 this deletes the old min and max values stored and replaces them with the quantiles to be found.
 
unsigned idCheckAndUpdate (const std::vector< unsigned > &ids)
 for given vector of ids check if any of them is part of subGraphID. If yes, update their SubLayerID. returns number of updated secIDs
 
std::vector< FullSecIDgetSectorsOfSensor (const VxdID &sensor)
 returns vector containing all sectors for given sensor (if any) and empty vector if no sector of that sensor is here.
 

Protected Member Functions

void updateID (const SubGraphID &newID)
 set newID for this subgraph.
 

Protected Attributes

SubGraphID m_id
 contains the IDs in the correct order (from outer to inner) as a unique identifier for this graph.
 
std::unordered_map< FilterType, MinMaxm_minMaxValues
 contains all min- and max-values found so far for all filters relevant for this Graph. *‍/
 
unsigned m_found
 counts number of times this subgraph was found.
 
std::unordered_map< FilterType, RawDataCollectedMinMax > * m_rawDataCollected
 takes care of collecting the raw data.
 

Detailed Description

template<class FilterType>
class Belle2::SubGraph< FilterType >

contains all relevant stuff needed for dealing with a subGraph.

~ 404 bytes per subGraph.

Definition at line 30 of file SubGraph.h.

Member Typedef Documentation

◆ Iterator

using Iterator = typename std::unordered_map<FilterType, MinMax>::iterator

for better readability.

Definition at line 51 of file SubGraph.h.

Constructor & Destructor Documentation

◆ SubGraph()

SubGraph ( SubGraphID id,
const std::vector< FilterType > &  fIDs 
)
inline

constructor, mandatory iDChain musst at least contain one iD.

Definition at line 54 of file SubGraph.h.

54 : m_id(id), m_found(1), m_rawDataCollected(nullptr)
55 {
56 for (auto& iD : fIDs) {
57 m_minMaxValues.insert({iD, MinMax()});
58 }
59 }
std::unordered_map< FilterType, RawDataCollectedMinMax > * m_rawDataCollected
takes care of collecting the raw data.
Definition: SubGraph.h:39
SubGraphID m_id
contains the IDs in the correct order (from outer to inner) as a unique identifier for this graph.
Definition: SubGraph.h:32
std::unordered_map< FilterType, MinMax > m_minMaxValues
contains all min- and max-values found so far for all filters relevant for this Graph....
Definition: SubGraph.h:35
unsigned m_found
counts number of times this subgraph was found.
Definition: SubGraph.h:37

◆ ~SubGraph()

~SubGraph ( )
inline

destructor

Definition at line 62 of file SubGraph.h.

62{ if (m_rawDataCollected != nullptr) delete m_rawDataCollected; }

Member Function Documentation

◆ addValue()

void addValue ( FilterType  fID,
double  value 
)
inline

adds value to rawDataCollector

Definition at line 107 of file SubGraph.h.

108 {
109 if (m_rawDataCollected == nullptr) { B2FATAL("SubGraph::addValue: attempt to add data before prepareDataCollection(...) was executed! Aborting illegal procedure."); }
110 auto pos = m_rawDataCollected->find(fID);
111 if (pos == m_rawDataCollected->end()) {
112 B2WARNING("addValue: FilterID " << fID << " not known to this subgraph " << m_id.print() << " - nothing added!");
113 return;
114 }
115 pos->second.add(value);
116 return;
117 }
std::string print() const
returns string of entries.
Definition: SubGraphID.h:101

◆ checkAndReplaceIfMinMax()

bool checkAndReplaceIfMinMax ( FilterType  fID,
double  value 
)
inline

add filter, if not added yet, checks value and replaces old ones if new one is better.

returns true if minMax was updated.

Definition at line 65 of file SubGraph.h.

66 {
67 Iterator pos = m_minMaxValues.find(fID);
68 if (pos == m_minMaxValues.end()) {
69 B2WARNING("FilterID " << fID << " not known to this subgraph " << m_id.print() << " - nothing added!");
70 return false;
71 }
72 return pos->second.checkAndReplaceIfMinMax(value);
73 }
typename std::unordered_map< FilterType, MinMax >::iterator Iterator
for better readability.
Definition: SubGraph.h:51

◆ checkSharesTrunk()

bool checkSharesTrunk ( const SubGraph< FilterType > &  b) const
inline

if both graphs have got the same IDs except the last one, they share a trunk.

Definition at line 80 of file SubGraph.h.

80{ return (m_id.checkSharesTrunk(b.m_id)); }
bool checkSharesTrunk(const SubGraphID &b) const
if both graphs have got the same IDs except the last one, they share a trunk.
Definition: SubGraphID.h:87

◆ getFinalQuantileValues()

const std::unordered_map< FilterType, MinMax > & getFinalQuantileValues ( )
inline

this deletes the old min and max values stored and replaces them with the quantiles to be found.

Definition at line 120 of file SubGraph.h.

121 {
122 for (auto& entry : *m_rawDataCollected) {
123 std::pair<double, double> results = entry.second.getMinMax();
124 checkAndReplaceIfMinMax(entry.first, results.first);
125 checkAndReplaceIfMinMax(entry.first, results.second);
126 }
127
128 std::string out;
129 for (auto& entry : m_minMaxValues) {
130 out += entry.first + " " + entry.second.print() + " ";
131 }
132 B2DEBUG(20, "SubGraph::getFinalQuantileValues: minMaxFound:\n" << out);
133 return m_minMaxValues;
134 }
bool checkAndReplaceIfMinMax(FilterType fID, double value)
add filter, if not added yet, checks value and replaces old ones if new one is better.
Definition: SubGraph.h:65

◆ getFound()

unsigned getFound ( ) const
inline

returns found-counter.

Definition at line 77 of file SubGraph.h.

◆ getID()

const SubGraphID & getID ( ) const
inline

returns iD of this graph

Definition at line 93 of file SubGraph.h.

93{ return m_id; }

◆ getSectorsOfSensor()

std::vector< FullSecID > getSectorsOfSensor ( const VxdID sensor)
inline

returns vector containing all sectors for given sensor (if any) and empty vector if no sector of that sensor is here.

Definition at line 151 of file SubGraph.h.

152 {
153 std::vector<FullSecID> foundIDs;
154
155 for (auto& sector : m_id) {
156 if (sensor != FullSecID(sector).getVxdID()) continue;
157 foundIDs.push_back(FullSecID(sector));
158 }
159 return foundIDs;
160 }

◆ idCheckAndUpdate()

unsigned idCheckAndUpdate ( const std::vector< unsigned > &  ids)
inline

for given vector of ids check if any of them is part of subGraphID. If yes, update their SubLayerID. returns number of updated secIDs

Definition at line 137 of file SubGraph.h.

138 {
139 unsigned nUpdated = 0;
140 for (unsigned id : ids) {
141
142 if (m_id.hasElement(id)) {
143 m_id.updateID(id);
144 nUpdated++;
145 }
146 }
147 return nUpdated;
148 }
bool hasElement(unsigned b) const
checks if given raw secID is part of this, ignores subLayerID.
Definition: SubGraphID.h:132
bool updateID(unsigned newID)
if newID is element of this (ignoring subLayerID), oldID will be replaced by newID....
Definition: SubGraphID.h:171

◆ operator==()

bool operator== ( const SubGraph< FilterType > &  b) const
inline

overloaded '=='-operator

Definition at line 47 of file SubGraph.h.

48 { return (m_id == b.m_id); }

◆ prepareDataCollection()

void prepareDataCollection ( std::pair< double, double >  quantiles)
inline

takes care of being able to use the data collector. please use for quantiles [min, max] min ~0 & max ~1 (range 0-1)

Definition at line 96 of file SubGraph.h.

97 {
98 if (m_rawDataCollected != nullptr) delete m_rawDataCollected;
99 m_rawDataCollected = new std::unordered_map<FilterType, RawDataCollectedMinMax>();
100
101 for (const auto& entry : m_minMaxValues) {
102 m_rawDataCollected->insert({entry.first, RawDataCollectedMinMax(m_found, quantiles)});
103 }
104 }

◆ print()

std::string print ( ) const
inline

"print" debugging information to a string

Definition at line 83 of file SubGraph.h.

84 {
85 std::string out = "id: " + m_id.print() + " was found " + std::to_string(m_found) + " times. Filters with values collected:\n";
86 for (const auto& entry : m_minMaxValues) {
87 out += entry.first + " " + entry.second.print() + " _||_ ";
88 }
89 return out;
90 }

◆ updateID()

void updateID ( const SubGraphID newID)
inlineprotected

set newID for this subgraph.

Definition at line 42 of file SubGraph.h.

43 { m_id = newID; }

◆ wasFound()

void wasFound ( )
inline

increases found-counter.

Definition at line 75 of file SubGraph.h.

Member Data Documentation

◆ m_found

unsigned m_found
protected

counts number of times this subgraph was found.

Definition at line 37 of file SubGraph.h.

◆ m_id

SubGraphID m_id
protected

contains the IDs in the correct order (from outer to inner) as a unique identifier for this graph.

Definition at line 32 of file SubGraph.h.

◆ m_minMaxValues

std::unordered_map<FilterType, MinMax> m_minMaxValues
protected

contains all min- and max-values found so far for all filters relevant for this Graph. *‍/

Definition at line 35 of file SubGraph.h.

◆ m_rawDataCollected

std::unordered_map<FilterType, RawDataCollectedMinMax>* m_rawDataCollected
protected

takes care of collecting the raw data.

Definition at line 39 of file SubGraph.h.


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