Belle II Software development
HitPatternVXD Class Reference

Hit pattern of the VXD within a track. More...

#include <HitPatternVXD.h>

Public Types

enum class  PXDMode : unsigned short {
  normal = static_cast<unsigned short>(0) ,
  gated = 1
}
 PXD modes. More...
 

Public Member Functions

 HitPatternVXD ()
 Create empty pattern.
 
 HitPatternVXD (const unsigned int initValue)
 Initialize the pattern with an integer.
 
unsigned int getInteger () const
 Getter for the underlying integer.
 
unsigned short getNdf () const
 Get degrees of freedom in PXD and SVD.
 
unsigned short getNVXDLayers (const PXDMode &pxdmode=PXDMode::normal) const
 Return the total number of activated layers in the VXD depending on the mode of the PXD.
 
void setSVDLayer (const unsigned short layerId, unsigned short uHits, unsigned short vHits)
 Set the number of hits in a specific layer of the SVD.
 
std::pair< const unsigned short, const unsigned short > getSVDLayer (const unsigned short layerId) const
 Get the number of hits in a specific layer of the SVD.
 
void resetSVDLayer (const unsigned short layerId)
 Reset the number of hits in a specific layer of the SVD.
 
unsigned short getNSVDHits () const
 Get total number of hits in the SVD.
 
unsigned short getNSVDLayers () const
 Returns the total number of activated layers of the SVD.
 
short getFirstSVDLayer () const
 Get the first activated SVD layer index.
 
short getLastSVDLayer () const
 Get the last activated SVD layer index.
 
void setPXDLayer (const unsigned short layerId, unsigned short nHits, const PXDMode &mode=PXDMode::normal)
 Set the number of hits in a specific layer of the PXD.
 
unsigned short getPXDLayer (const unsigned short layerId, const PXDMode &mode=PXDMode::normal) const
 Get the number of hits in a specific layer of the PXD.
 
void resetPXDLayer (const unsigned short layerId, const PXDMode &mode=PXDMode::normal)
 Reset the number of hits in a specific layer of the PXD.
 
unsigned short getNPXDHits () const
 Get total number of hits in the PXD.
 
unsigned short getNPXDLayers (const PXDMode &mode=PXDMode::normal) const
 Returns the total number of activated layers of the PXD.
 
short getFirstPXDLayer (const PXDMode &mode=PXDMode::normal) const
 Returns the first activated layer of the PXD depending on the mode.
 
short getLastPXDLayer (const PXDMode &mode=PXDMode::normal) const
 Returns the last activated layer of the PXD depending on the mode.
 
void setInnermostHitShareStatus (const unsigned short innermostHitShareStatus)
 Set the innermost hit share flags for V0 daughters.
 
unsigned short getInnermostHitShareStatus () const
 Get the innermost hit share flags for V0 daughters.
 
void resetInnermostHitShareStatus ()
 Reset the innermost hit share flags for V0 daughters.
 
std::string __str__ () const
 String for printing in python.
 

Private Member Functions

std::bitset< 32 > getBitset () const
 Getter for underlying bitset.
 
std::bitset< 32 > getLayerMask (const unsigned short layerId) const
 Getter for the proper layer masks.
 

Private Attributes

std::bitset< 32 > m_pattern
 Storing of actual hit pattern.
 

Static Private Attributes

static const std::bitset< 32 > s_LayerMasks [6]
 Masks to zero out all bits from other layers.
 
static const std::bitset< 32 > s_PXDModeMasks [2]
 Mask to zero out all bits from other layers.
 
static const std::bitset< 32 > s_SVDuvMasks [2]
 Mask to zero out all bits from other layers.
 
static const std::bitset< 32 > s_V0DaughterMask
 Mask to zero out all bits from other layers.
 
static const std::bitset< 32 > s_infoLayerMask
 Mask to zero out all bits from other layers.
 
static const std::list< unsigned short > s_PXDLayerNumbers = {1, 2}
 For iterating through layers.
 
static const std::list< unsigned short > s_SVDLayerNumbers = {3, 4, 5, 6}
 For iterating through layers.
 
static const unsigned int s_svdUshift = 8
 for internal shifting to the SVD bits.
 
static const unsigned int s_svdVshift = 10
 for internal shifting to the SVD bits.
 

Friends

class HitPatternVXDTest_General_Test
 
class HitPatternVXDTest_NumberingScheme_Test
 
class HitPatternVXDTest_SVDSetterAndGetter_Test
 
class HitPatternVXDTest_PXDSetterAndGetter_Test
 

Detailed Description

Hit pattern of the VXD within a track.

The pattern is stored using a std::bitset. This allows to use the STL, which is very efficiently programmed.

Only hits from the outgoing arm are stored. For each layer there are two bits. The layer counting is:

  • PXD: layers 1 and 2;
  • SVD: layers 3, 4, 5 and 6.

The numbering scheme in this class is equivalent to the one defined in the note BELLE2-NOTE-TE-2015-010: https://docs.belle2.org/record/243

See also
HitPatternCDC

32 Bits are reserved. 4 Bits for each layer: 2 Bits for each PXD normal/gated-mode, 2 Bits for each SVD U/V-side. In total 24 Bits are used to represent hit patterns. Remaining upper 8 Bits are resevered for information. Lowest 2 Bits for V0 daughters (innermost hit share status), assigned in V0Finder. 0x1(0x2) bit represents V/z(U/r-phi)-hit share.

Definition at line 37 of file HitPatternVXD.h.

Member Enumeration Documentation

◆ PXDMode

enum class PXDMode : unsigned short
strong

PXD modes.

Definition at line 46 of file HitPatternVXD.h.

46: unsigned short { normal = static_cast<unsigned short>(0), gated = 1 };

Constructor & Destructor Documentation

◆ HitPatternVXD() [1/2]

HitPatternVXD ( )
inline

Create empty pattern.

Definition at line 49 of file HitPatternVXD.h.

49: m_pattern(0) {}
std::bitset< 32 > m_pattern
Storing of actual hit pattern.

◆ HitPatternVXD() [2/2]

HitPatternVXD ( const unsigned int  initValue)
inlineexplicit

Initialize the pattern with an integer.

Definition at line 52 of file HitPatternVXD.h.

52: m_pattern(initValue) {}

Member Function Documentation

◆ __str__()

std::string __str__ ( ) const

String for printing in python.

Definition at line 205 of file HitPatternVXD.cc.

206{
207 return m_pattern.to_string();
208}

◆ getBitset()

std::bitset< 32 > getBitset ( ) const
inlineprivate

Getter for underlying bitset.

Definition at line 233 of file HitPatternVXD.h.

233{ return m_pattern; }

◆ getFirstPXDLayer()

short getFirstPXDLayer ( const PXDMode mode = PXDMode::normal) const

Returns the first activated layer of the PXD depending on the mode.

If there is no hit in the PXD pattern, -1 is returned.

Parameters
modenormal or gated
See also
HitPatternVXD::PXDMode
Returns
Index of first layer.

Definition at line 166 of file HitPatternVXD.cc.

167{
168 for (const auto layerId : s_PXDLayerNumbers) {
169 if (getPXDLayer(layerId, mode) > 0) return layerId;
170 }
171 return -1;
172}
static const std::list< unsigned short > s_PXDLayerNumbers
For iterating through layers.
unsigned short getPXDLayer(const unsigned short layerId, const PXDMode &mode=PXDMode::normal) const
Get the number of hits in a specific layer of the PXD.

◆ getFirstSVDLayer()

short getFirstSVDLayer ( ) const

Get the first activated SVD layer index.

If there is no hit in the SVD pattern, -1 is returned.

Returns
Index of first layer.

Definition at line 103 of file HitPatternVXD.cc.

104{
105 for (const auto layerId : s_SVDLayerNumbers) {
106 std::pair<const unsigned short, const unsigned short> hits(getSVDLayer(layerId));
107 if ((hits.first + hits.second) > 0) return layerId;
108 }
109 return -1;
110}
static const std::list< unsigned short > s_SVDLayerNumbers
For iterating through layers.
std::pair< const unsigned short, const unsigned short > getSVDLayer(const unsigned short layerId) const
Get the number of hits in a specific layer of the SVD.

◆ getInnermostHitShareStatus()

unsigned short getInnermostHitShareStatus ( ) const

Get the innermost hit share flags for V0 daughters.

Returns
Innermost hit share status flags.

Definition at line 194 of file HitPatternVXD.cc.

195{
196 std::bitset<32> hits(m_pattern & s_V0DaughterMask);
197 return (hits >> (4 * 6)).to_ulong();
198}
static const std::bitset< 32 > s_V0DaughterMask
Mask to zero out all bits from other layers.

◆ getInteger()

unsigned int getInteger ( ) const
inline

Getter for the underlying integer.

Returns
Hit pattern encoded as integer.

Definition at line 58 of file HitPatternVXD.h.

58{ return m_pattern.to_ulong(); }

◆ getLastPXDLayer()

short getLastPXDLayer ( const PXDMode mode = PXDMode::normal) const

Returns the last activated layer of the PXD depending on the mode.

If there is no hit in the PXD pattern, -1 is returned.

Parameters
modenormal or gated
See also
HitPatternVXD::PXDMode
Returns
Index of last layer.

Definition at line 174 of file HitPatternVXD.cc.

175{
176 for (auto rit = s_PXDLayerNumbers.rbegin(); rit != s_PXDLayerNumbers.rend(); ++rit) {
177 const auto layerId = *rit;
178 if (getPXDLayer(layerId, mode) > 0) return layerId;
179 }
180 return -1;
181}

◆ getLastSVDLayer()

short getLastSVDLayer ( ) const

Get the last activated SVD layer index.

If there is no hit in the SVD pattern, -1 is returned.

Returns
Index of last layer.

Definition at line 112 of file HitPatternVXD.cc.

113{
114 for (auto rit = s_SVDLayerNumbers.rbegin(); rit != s_SVDLayerNumbers.rend(); ++rit) {
115 const auto layerId = *rit;
116 std::pair<const unsigned short, const unsigned short> hits(getSVDLayer(layerId));
117 if ((hits.first + hits.second) > 0) return layerId;
118 }
119 return -1;
120}

◆ getLayerMask()

std::bitset< 32 > getLayerMask ( const unsigned short  layerId) const
inlineprivate

Getter for the proper layer masks.

Makes index handling more easy.

Definition at line 236 of file HitPatternVXD.h.

236{ return HitPatternVXD::s_LayerMasks[layerId - 1]; }
static const std::bitset< 32 > s_LayerMasks[6]
Masks to zero out all bits from other layers.

◆ getNdf()

unsigned short getNdf ( ) const

Get degrees of freedom in PXD and SVD.

Nota Bene: Only for the outgoing arm.

Returns
Degrees of freedom.

Definition at line 41 of file HitPatternVXD.cc.

42{
43 return 2 * getNPXDHits() + getNSVDHits();
44}
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
unsigned short getNSVDHits() const
Get total number of hits in the SVD.

◆ getNPXDHits()

unsigned short getNPXDHits ( ) const

Get total number of hits in the PXD.

Returns
Total number of hits in the PXD.

Definition at line 147 of file HitPatternVXD.cc.

148{
149 unsigned short pxdHits = 0;
150 for (const auto layerId : s_PXDLayerNumbers) {
151 pxdHits += getPXDLayer(layerId, PXDMode::normal);
152 pxdHits += getPXDLayer(layerId, PXDMode::gated);
153 }
154 return pxdHits;
155}

◆ getNPXDLayers()

unsigned short getNPXDLayers ( const PXDMode mode = PXDMode::normal) const

Returns the total number of activated layers of the PXD.

Parameters
modenormal or gated
See also
HitPatternVXD::PXDMode
Returns
Total number of activated PXD layers.

Definition at line 157 of file HitPatternVXD.cc.

158{
159 unsigned short nPXD = 0;
160 for (const auto layerId : s_PXDLayerNumbers) {
161 if (getPXDLayer(layerId, mode) > 0) ++nPXD;
162 }
163 return nPXD;
164}

◆ getNSVDHits()

unsigned short getNSVDHits ( ) const

Get total number of hits in the SVD.

Returns
Total number of hits in the SVD.

Definition at line 83 of file HitPatternVXD.cc.

84{
85 unsigned short svdHits = 0;
86 for (const auto layerId : s_SVDLayerNumbers) {
87 std::pair<const unsigned short, const unsigned short> svdHitPair = getSVDLayer(layerId);
88 svdHits += svdHitPair.first + svdHitPair.second;
89 }
90 return svdHits;
91}

◆ getNSVDLayers()

unsigned short getNSVDLayers ( ) const

Returns the total number of activated layers of the SVD.

Returns
Number of activated SVD layers.

Definition at line 93 of file HitPatternVXD.cc.

94{
95 unsigned short nSVD = 0;
96 for (const auto layerId : s_SVDLayerNumbers) {
97 std::pair<const unsigned short, const unsigned short> hits(getSVDLayer(layerId));
98 if ((hits.first + hits.second) > 0) ++nSVD;
99 }
100 return nSVD;
101}

◆ getNVXDLayers()

unsigned short getNVXDLayers ( const PXDMode pxdmode = PXDMode::normal) const

Return the total number of activated layers in the VXD depending on the mode of the PXD.

Parameters
pxdmodenormal or gated
See also
HitPatternVXD::PXDMode
Returns
Number of activated layers.

Definition at line 46 of file HitPatternVXD.cc.

47{
48 return getNPXDLayers(pxdmode) + getNSVDLayers();
49}
unsigned short getNSVDLayers() const
Returns the total number of activated layers of the SVD.
unsigned short getNPXDLayers(const PXDMode &mode=PXDMode::normal) const
Returns the total number of activated layers of the PXD.

◆ getPXDLayer()

unsigned short getPXDLayer ( const unsigned short  layerId,
const PXDMode mode = PXDMode::normal 
) const

Get the number of hits in a specific layer of the PXD.

Parameters
layerIdPXD layer index.
modenormal or gated
See also
HitPatternVXD::PXDMode
Returns
Number of hits in the PXD layer.

Definition at line 133 of file HitPatternVXD.cc.

134{
135 B2ASSERT("PXD layer is out of range.", layerId == 1 or layerId == 2);
136 const unsigned short arrayId = layerId - 1;
137 std::bitset<32> hits(m_pattern & (getLayerMask(layerId) & s_PXDModeMasks[static_cast<unsigned short>(mode)]));
138 return (hits >> (4 * arrayId + 2 * static_cast<unsigned short>(mode))).to_ulong();
139}
static const std::bitset< 32 > s_PXDModeMasks[2]
Mask to zero out all bits from other layers.
std::bitset< 32 > getLayerMask(const unsigned short layerId) const
Getter for the proper layer masks.

◆ getSVDLayer()

std::pair< const unsigned short, const unsigned short > getSVDLayer ( const unsigned short  layerId) const

Get the number of hits in a specific layer of the SVD.

Parameters
layerIdSVD layer index.
Returns
Pair of (u, v) hits in the SVD layer.

Definition at line 65 of file HitPatternVXD.cc.

66{
67 B2ASSERT("SVD layer is out of range.", 3 <= layerId and layerId <= 6);
68 std::bitset<32> uHitsPattern(m_pattern & (getLayerMask(layerId) & s_SVDuvMasks[0]));
69 std::bitset<32> vHitsPattern(m_pattern & (getLayerMask(layerId) & s_SVDuvMasks[1]));
70 const unsigned short arrayId = layerId - 3;
71 const unsigned short uHits = (uHitsPattern >> (s_svdUshift + 4 * arrayId)).to_ulong();
72 const unsigned short vHits = (vHitsPattern >> (s_svdVshift + 4 * arrayId)).to_ulong();
73 return std::make_pair(uHits, vHits);
74}
static const std::bitset< 32 > s_SVDuvMasks[2]
Mask to zero out all bits from other layers.
static const unsigned int s_svdVshift
for internal shifting to the SVD bits.
static const unsigned int s_svdUshift
for internal shifting to the SVD bits.

◆ resetInnermostHitShareStatus()

void resetInnermostHitShareStatus ( )

Reset the innermost hit share flags for V0 daughters.

Definition at line 200 of file HitPatternVXD.cc.

201{
203}

◆ resetPXDLayer()

void resetPXDLayer ( const unsigned short  layerId,
const PXDMode mode = PXDMode::normal 
)

Reset the number of hits in a specific layer of the PXD.

Parameters
layerIdPXD layer index.
modenormal or gated
See also
HitPatternVXD::PXDMode

Definition at line 141 of file HitPatternVXD.cc.

142{
143 B2ASSERT("PXD layer is out of range.", layerId == 1 or layerId == 2);
144 m_pattern &= ~(getLayerMask(layerId) & s_PXDModeMasks[static_cast<unsigned short>(mode)]);
145}

◆ resetSVDLayer()

void resetSVDLayer ( const unsigned short  layerId)

Reset the number of hits in a specific layer of the SVD.

Parameters
layerIdSVD layer index.

Definition at line 76 of file HitPatternVXD.cc.

77{
78 B2ASSERT("SVD layer is out of range.", 3 <= layerId and layerId <= 6);
79 m_pattern &= ~getLayerMask(layerId);
80 return;
81}

◆ setInnermostHitShareStatus()

void setInnermostHitShareStatus ( const unsigned short  innermostHitShareStatus)

Set the innermost hit share flags for V0 daughters.

Parameters
innermostHitShareStatusInnermost hit share status flags.

Definition at line 183 of file HitPatternVXD.cc.

184{
185 B2ASSERT("Information is out of range. Information: " << innermostHitShareStatus << ", range: " << (s_V0DaughterMask >>
186 (4 * 6)).to_ulong(),
187 innermostHitShareStatus <= (s_V0DaughterMask >> (4 * 6)).to_ulong());
189 std::bitset<32> hits(innermostHitShareStatus);
190 hits <<= 4 * 6;
191 m_pattern |= hits;
192}
void resetInnermostHitShareStatus()
Reset the innermost hit share flags for V0 daughters.

◆ setPXDLayer()

void setPXDLayer ( const unsigned short  layerId,
unsigned short  nHits,
const PXDMode mode = PXDMode::normal 
)

Set the number of hits in a specific layer of the PXD.

Parameters
layerIdPXD layer index.
nHits0-3 hits possible
modenormal or gated
See also
HitPatternVXD::PXDMode

Definition at line 122 of file HitPatternVXD.cc.

123{
124 B2ASSERT("PXD layer is out of range.", layerId == 1 or layerId == 2);
125 resetPXDLayer(layerId, mode);
126 if (nHits > 3) nHits = 3; // A Maximum of 3 can be stored in 2 bits.
127 std::bitset<32> hits(nHits);
128 const unsigned short arrayId = layerId - 1;
129 hits <<= 4 * arrayId + 2 * static_cast<unsigned short>(mode);
130 m_pattern |= hits;
131}
void resetPXDLayer(const unsigned short layerId, const PXDMode &mode=PXDMode::normal)
Reset the number of hits in a specific layer of the PXD.

◆ setSVDLayer()

void setSVDLayer ( const unsigned short  layerId,
unsigned short  uHits,
unsigned short  vHits 
)

Set the number of hits in a specific layer of the SVD.

Parameters
layerIdSVD layer index.
uHits
vHits

Definition at line 51 of file HitPatternVXD.cc.

52{
53 B2ASSERT("SVD layer is out of range.", 3 <= layerId and layerId <= 6);
54 resetSVDLayer(layerId);
55 if (uHits > 3) uHits = 3;
56 if (vHits > 3) vHits = 3;
57 const unsigned short arrayId = layerId - 3;
58 std::bitset<32> uHitPattern(uHits);
59 uHitPattern <<= s_svdUshift + 4 * arrayId;
60 std::bitset<32> vHitPattern(vHits);
61 vHitPattern <<= s_svdVshift + 4 * arrayId;
62 m_pattern |= (uHitPattern | vHitPattern);
63}
void resetSVDLayer(const unsigned short layerId)
Reset the number of hits in a specific layer of the SVD.

Friends And Related Function Documentation

◆ HitPatternVXDTest_General_Test

friend class HitPatternVXDTest_General_Test
friend

Definition at line 38 of file HitPatternVXD.h.

◆ HitPatternVXDTest_NumberingScheme_Test

friend class HitPatternVXDTest_NumberingScheme_Test
friend

Definition at line 39 of file HitPatternVXD.h.

◆ HitPatternVXDTest_PXDSetterAndGetter_Test

friend class HitPatternVXDTest_PXDSetterAndGetter_Test
friend

Definition at line 41 of file HitPatternVXD.h.

◆ HitPatternVXDTest_SVDSetterAndGetter_Test

friend class HitPatternVXDTest_SVDSetterAndGetter_Test
friend

Definition at line 40 of file HitPatternVXD.h.

Member Data Documentation

◆ m_pattern

std::bitset<32> m_pattern
private

Storing of actual hit pattern.

PXD and SVD layer get 4 bits each. PXD has in each layer 4 bits where respectively two bits are used to store normal and gated mode hits separately. SVD has in each layer 4 bits where respectively two bits are used to store hits in u and v layer separately.

Definition at line 218 of file HitPatternVXD.h.

◆ s_infoLayerMask

const std::bitset< 32 > s_infoLayerMask
staticprivate

Mask to zero out all bits from other layers.

Definition at line 224 of file HitPatternVXD.h.

◆ s_LayerMasks

const std::bitset< 32 > s_LayerMasks
staticprivate
Initial value:
= {
std::bitset<32>(static_cast<std::string>("00000000000000000000000000001111")),
std::bitset<32>(static_cast<std::string>("00000000000000000000000011110000")),
std::bitset<32>(static_cast<std::string>("00000000000000000000111100000000")),
std::bitset<32>(static_cast<std::string>("00000000000000001111000000000000")),
std::bitset<32>(static_cast<std::string>("00000000000011110000000000000000")),
std::bitset<32>(static_cast<std::string>("00000000111100000000000000000000"))
}

Masks to zero out all bits from other layers.

Definition at line 220 of file HitPatternVXD.h.

◆ s_PXDLayerNumbers

const std::list< unsigned short > s_PXDLayerNumbers = {1, 2}
staticprivate

For iterating through layers.

Definition at line 226 of file HitPatternVXD.h.

◆ s_PXDModeMasks

const std::bitset< 32 > s_PXDModeMasks
staticprivate
Initial value:
= {
std::bitset<32>(static_cast<std::string>("00000000000000000000000000110011")),
std::bitset<32>(static_cast<std::string>("00000000000000000000000011001100"))
}

Mask to zero out all bits from other layers.

Definition at line 221 of file HitPatternVXD.h.

◆ s_SVDLayerNumbers

const std::list< unsigned short > s_SVDLayerNumbers = {3, 4, 5, 6}
staticprivate

For iterating through layers.

Definition at line 227 of file HitPatternVXD.h.

◆ s_svdUshift

const unsigned int s_svdUshift = 8
staticprivate

for internal shifting to the SVD bits.

Definition at line 229 of file HitPatternVXD.h.

◆ s_SVDuvMasks

const std::bitset< 32 > s_SVDuvMasks
staticprivate
Initial value:
= {
std::bitset<32>(static_cast<std::string>("00000000001100110011001100000000")),
std::bitset<32>(static_cast<std::string>("00000000110011001100110000000000"))
}

Mask to zero out all bits from other layers.

Definition at line 222 of file HitPatternVXD.h.

◆ s_svdVshift

const unsigned int s_svdVshift = 10
staticprivate

for internal shifting to the SVD bits.

Definition at line 230 of file HitPatternVXD.h.

◆ s_V0DaughterMask

const std::bitset< 32 > s_V0DaughterMask
staticprivate

Mask to zero out all bits from other layers.

Definition at line 223 of file HitPatternVXD.h.


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