Belle II Software development
SubGraphID Class Reference

stores the ID of a subgraph, which is basically a chain of FullSecID coded as unsigned ints. More...

#include <SubGraphID.h>

Public Member Functions

bool operator== (const SubGraphID &b) const
 overloaded '=='-operator
 
bool operator< (const SubGraphID &b) const
 overloaded '<'-operator for sorting algorithms
 
 SubGraphID (const std::vector< unsigned > &idChain)
 constructor, mandatory iDChain musst at least contain one iD.
 
unsigned size () const
 returns chainLength of this id.
 
std::vector< unsigned >::const_iterator begin () const
 returns first entry of IDchain.
 
std::vector< unsigned >::const_iterator end () const
 returns last entry of IDchain.
 
bool checkSharesTrunk (const SubGraphID &b) const
 if both graphs have got the same IDs except the last one, they share a trunk.
 
std::string print () const
 returns string of entries.
 
unsigned isElementOf (const SubGraphID &b) const
 checks if given sectorPack ( >= 1 sector) is part of this, ignores subLayerID.
 
unsigned isElementOf (const std::vector< unsigned > &b) const
 checks if given sectorPack ( >= 1 sector) is part of this, ignores subLayerID.
 
bool hasElement (unsigned b) const
 checks if given raw secID is part of this, ignores subLayerID.
 
bool areTheSameSectors (const SubGraphID &b) const
 checks if sectors are identical (while ignoring the subLayerID)
 
std::vector< unsigned > hasSharedLayer () const
 returns raw IDs of entries being outer friend of sectors on same layer.
 
bool updateID (unsigned newID)
 if newID is element of this (ignoring subLayerID), oldID will be replaced by newID. returns true, if an ID was replaced.
 
std::vector< FullSecIDgetFullSecIDs () const
 returns SecIDs coded as FullSecIDs:
 

Protected Member Functions

bool areTheSameSector (unsigned a, unsigned b) const
 checks if two given ids are the same sector (while ignoring the sublayerID).
 

Protected Attributes

std::vector< unsigned > m_idChain
 ids of this SubGraphID.
 

Detailed Description

stores the ID of a subgraph, which is basically a chain of FullSecID coded as unsigned ints.

Definition at line 24 of file SubGraphID.h.

Constructor & Destructor Documentation

◆ SubGraphID()

SubGraphID ( const std::vector< unsigned > &  idChain)
inlineexplicit

constructor, mandatory iDChain musst at least contain one iD.

Sectors should be sorted from outer to inner sectors, please take care of that yourself since this is not checked internally.

Definition at line 68 of file SubGraphID.h.

68 : m_idChain(idChain)
69 {
70 if (m_idChain.empty()) { B2FATAL("SubGraphID-Constructor, given idChain is empty - illegal usage!"); }
71 }
std::vector< unsigned > m_idChain
ids of this SubGraphID.
Definition: SubGraphID.h:26

Member Function Documentation

◆ areTheSameSector()

bool areTheSameSector ( unsigned  a,
unsigned  b 
) const
inlineprotected

checks if two given ids are the same sector (while ignoring the sublayerID).

Definition at line 30 of file SubGraphID.h.

31 {
32 FullSecID idA(a);
33 FullSecID idB(b);
34 return idA.getVxdID() == idB.getVxdID() and idA.getSecID() == idB.getSecID();
35 }

◆ areTheSameSectors()

bool areTheSameSectors ( const SubGraphID b) const
inline

checks if sectors are identical (while ignoring the subLayerID)

Definition at line 142 of file SubGraphID.h.

143 {
144 if (size() != b.size()) return false;
145 for (unsigned i = 0; i < size(); i++) {
146 if (areTheSameSector(m_idChain[i], b.m_idChain[i]) == false) return false;
147 }
148 return true;
149 }
unsigned size() const
returns chainLength of this id.
Definition: SubGraphID.h:75
bool areTheSameSector(unsigned a, unsigned b) const
checks if two given ids are the same sector (while ignoring the sublayerID).
Definition: SubGraphID.h:30

◆ begin()

std::vector< unsigned >::const_iterator begin ( ) const
inline

returns first entry of IDchain.

Definition at line 79 of file SubGraphID.h.

79{ return m_idChain.begin(); }

◆ checkSharesTrunk()

bool checkSharesTrunk ( const SubGraphID b) const
inline

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

Definition at line 87 of file SubGraphID.h.

88 {
89 unsigned chainsize = m_idChain.size();
90 if (b.size() != chainsize) { return false; }
91
92 for (unsigned i = 0; i < chainsize - 1; i++) {
93 if (b.m_idChain[i] != m_idChain[i]) { return false; }
94 }
95
96 return true;
97 }

◆ end()

std::vector< unsigned >::const_iterator end ( ) const
inline

returns last entry of IDchain.

Definition at line 83 of file SubGraphID.h.

83{ return m_idChain.end(); }

◆ getFullSecIDs()

std::vector< FullSecID > getFullSecIDs ( ) const
inline

returns SecIDs coded as FullSecIDs:

Definition at line 185 of file SubGraphID.h.

186 {
187 std::vector<FullSecID> ids;
188
189 for (auto& id : m_idChain) {
190 ids.push_back(FullSecID(id));
191 }
192 return ids;
193 }

◆ hasElement()

bool hasElement ( unsigned  b) const
inline

checks if given raw secID is part of this, ignores subLayerID.

returns number of identical sectors

Definition at line 132 of file SubGraphID.h.

133 {
134 for (unsigned idA : m_idChain) {
135 if (areTheSameSector(idA, b)) return true;
136 }
137 return false;
138 }

◆ hasSharedLayer()

std::vector< unsigned > hasSharedLayer ( ) const
inline

returns raw IDs of entries being outer friend of sectors on same layer.

This function assumes that the ids are sorted from outermost (= first) to innermost (= last) iD.

Definition at line 153 of file SubGraphID.h.

154 {
155 B2DEBUG(20, "hasSharedLayer-start with iD " << print() << ":");
156 std::vector<unsigned> outerOnes;
157 for (unsigned i = 0; i < size() - 1; i++) { // i: outer iD i+1: inner iD
158 B2DEBUG(20, "found layerIDs for outer/inner: " << FullSecID(m_idChain[i]).getLayerID() << "/" << FullSecID(
159 m_idChain[i + 1]).getLayerID());
160 if (FullSecID(m_idChain[i]).getLayerID() == FullSecID(m_idChain[i + 1]).getLayerID()) {
161 outerOnes.push_back(m_idChain[i]);
162 B2DEBUG(20, "hasSharedLayer good combi found with inner: " << FullSecID(m_idChain[i + 1]).getFullSecString() << ", storing outer: "
163 << FullSecID(m_idChain[i]).getFullSecString());
164 }
165 }
166 return outerOnes;
167 }
std::string print() const
returns string of entries.
Definition: SubGraphID.h:101

◆ isElementOf() [1/2]

unsigned isElementOf ( const std::vector< unsigned > &  b) const
inline

checks if given sectorPack ( >= 1 sector) is part of this, ignores subLayerID.

returns number of identical sectors

Definition at line 117 of file SubGraphID.h.

118 {
119 if (size() < b.size()) return 0;
120
121 unsigned nIdentical = 0;
122 for (unsigned idA : m_idChain) {
123 for (unsigned idB : b) {
124 if (areTheSameSector(idA, idB)) nIdentical++;
125 }
126 }
127 return nIdentical;
128 }

◆ isElementOf() [2/2]

unsigned isElementOf ( const SubGraphID b) const
inline

checks if given sectorPack ( >= 1 sector) is part of this, ignores subLayerID.

returns number of identical sectors

Definition at line 112 of file SubGraphID.h.

113 { return isElementOf(b.m_idChain); }
unsigned isElementOf(const SubGraphID &b) const
checks if given sectorPack ( >= 1 sector) is part of this, ignores subLayerID.
Definition: SubGraphID.h:112

◆ operator<()

bool operator< ( const SubGraphID b) const
inline

overloaded '<'-operator for sorting algorithms

Definition at line 54 of file SubGraphID.h.

55 {
56 // sorting: if outermost (== first) sector > of b.outermost this > b. If outermost == b.outermost, step is repeated until end of chain length is reached. last straw: longer chain is bigger.
57 unsigned chainsize = m_idChain.size() < b.size() ? m_idChain.size() : b.size();
58 for (unsigned i = 0 ; i < chainsize; i++) {
59 if (m_idChain[i] < b.m_idChain[i]) return true;
60 if (m_idChain[i] == b.m_idChain[i]) continue;
61 return false;
62 }
63 return m_idChain.size() < b.size();
64 }

◆ operator==()

bool operator== ( const SubGraphID b) const
inline

overloaded '=='-operator

Definition at line 40 of file SubGraphID.h.

41 {
42 unsigned chainsize = m_idChain.size();
43 if (b.size() != chainsize) { return false; }
44
45 for (unsigned i = 0; i < chainsize; i++) {
46 if (b.m_idChain[i] != m_idChain[i]) { return false; }
47 }
48
49 return true;
50 }

◆ print()

std::string print ( ) const
inline

returns string of entries.

Definition at line 101 of file SubGraphID.h.

102 {
103 std::string out;
104 for (unsigned iD : m_idChain) {
105 out += FullSecID(iD).getFullSecString() + " ";
106 }
107 return out;
108 }

◆ size()

unsigned size ( ) const
inline

returns chainLength of this id.

Definition at line 75 of file SubGraphID.h.

75{ return m_idChain.size(); }

◆ updateID()

bool updateID ( unsigned  newID)
inline

if newID is element of this (ignoring subLayerID), oldID will be replaced by newID. returns true, if an ID was replaced.

Definition at line 171 of file SubGraphID.h.

172 {
173 for (unsigned& secID : m_idChain) {
174 if (areTheSameSector(newID, secID) == false) continue;
175 FullSecID tempID(secID);
176 secID = FullSecID(tempID.getVxdID(), true, tempID.getSecID()).getFullSecID();
177 return true;
178 }
179
180 return false;
181 }

Member Data Documentation

◆ m_idChain

std::vector<unsigned> m_idChain
protected

ids of this SubGraphID.

Definition at line 26 of file SubGraphID.h.


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