FairRoot/PandaRoot
Functions | Variables
mrftools Namespace Reference

Helper functions for single bit manipulations. More...

Functions

bool getIntBit (const UInt_t &position, const UInt_t &value)
 Retrieves a single bit from an integer value. More...
 
void setIntBit (const UInt_t &position, UInt_t &value, const bool &state)
 Sets a single bit in an integer value. More...
 
UInt_t shiftBy (const int &positions, const UInt_t &value)
 Shifts the bits in an integer value. More...
 
unsigned int getIteratorItemCount (const std::map< std::string, TConfItem >::const_iterator &start, const std::map< std::string, TConfItem >::const_iterator &stop)
 
unsigned int getIteratorItemCount (const std::map< std::string, std::map< std::string, TConfItem > >::const_iterator &start, const std::map< std::string, std::map< std::string, TConfItem > >::const_iterator &stop)
 
UInt_t grayToBin (UInt_t gray)
 Converts gray encoded values to bianry values. More...
 

Variables

static const UInt_t UInt_t_bitlength = sizeof(UInt_t) * CHAR_BIT
 
static const UInt_t UInt_t_bitlength = sizeof(UInt_t) * CHAR_BIT
 

Detailed Description

Helper functions for single bit manipulations.

Function Documentation

bool mrftools::getIntBit ( const UInt_t &  position,
const UInt_t &  value 
)

Retrieves a single bit from an integer value.

Parameters
positionPosition of bit to investigate.
valueValue whose bits are to be investigated.
Returns
True if the bit is set, False if the bit is not set.

Definition at line 15 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

References UInt_t_bitlength.

Referenced by TMrfData_8b::resample().

16 {
17  if (position < UInt_t_bitlength) {
18  return (value & (1 << position));
19  }
20  else {
21  return false;
22  }
23 }
static const UInt_t UInt_t_bitlength
unsigned int mrftools::getIteratorItemCount ( const std::map< std::string, TConfItem >::const_iterator &  start,
const std::map< std::string, TConfItem >::const_iterator &  stop 
)

Definition at line 50 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

References count.

51 {
52  std::map<std::string, TConfItem>::const_iterator iter;
53  unsigned int count = 0;
54  for (iter = start; iter != stop; ++iter) {
55  ++count;
56  }
57  return count;
58 }
int count
unsigned int mrftools::getIteratorItemCount ( const std::map< std::string, std::map< std::string, TConfItem > >::const_iterator &  start,
const std::map< std::string, std::map< std::string, TConfItem > >::const_iterator &  stop 
)

Definition at line 60 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

References count.

61 {
62  unsigned int count = 0;
63  std::map<std::string, std::map<std::string, TConfItem> >::const_iterator iter;
64  std::map<std::string,TConfItem>::const_iterator iter2;
65  for (iter=start; iter!=stop; ++iter) {
66  for (iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) {
67  ++count;
68  }
69  }
70  return count;
71 }
int count
UInt_t mrftools::grayToBin ( UInt_t  gray)

Converts gray encoded values to bianry values.

Parameters
grayGray encoded value.
Returns
The correponding binary value.

Definition at line 73 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

Referenced by PndMvdPasta::AnalyzeThresholdWordFull(), PndTopix4::BitAnalyzePixelData(), and PndMvdReadInTBData::BitAnalyzePixelData().

74 {
75  //UInt_t result = 0;
76  //setIntBit(31, result, getIntBit(31, gray));
77  //for (unsigned int i = 30; i > 0; --i) {
78  // setIntBit(i, result, (getIntBit(i+1, result) && !(getIntBit(i, gray))) || (!(getIntBit(i+1, result)) && getIntBit(i, gray)));
79  //}
80  //setIntBit(0, result, (getIntBit(1, result) && !(getIntBit(0, gray))) || (!(getIntBit(1, result)) && getIntBit(0, gray)));
81 
82  //return result;
83 
84  for (UInt_t bit = 1U << 31; bit > 1; bit >>= 1)
85  {
86  if (gray & bit) gray ^= bit >> 1;
87  }
88  return gray;
89 }
void mrftools::setIntBit ( const UInt_t &  position,
UInt_t &  value,
const bool &  state 
)

Sets a single bit in an integer value.

Parameters
positionThe positional index of the bit to be manipulated, 0 referring to the least significant bit.
valueThe integer value whose bits are to be manipulated.
stateTrue sets the bit, False resets the bit.

Definition at line 25 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

References UInt_t_bitlength.

Referenced by TMrfData_8b::getBitBlock(), and TMrfData_8b::setBit().

26 {
27  if (position < UInt_t_bitlength) {
28  if (state) {
29  value |= (1 << position);
30  }
31  else {
32  value &= (~(1 << position));
33  }
34  }
35 }
static const UInt_t UInt_t_bitlength
UInt_t mrftools::shiftBy ( const int &  positions,
const UInt_t &  value 
)

Shifts the bits in an integer value.

Parameters
positionsNumber of positions to be shifted. A positive value means shift to the MSB (left), negative means shift to the LSB (right).
valueThe integer value whose bits are to be shifted.
Returns
The original value shifted by the given number of positions.

Definition at line 37 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

38 {
39  if (positions < 0) {
40  return (value >> (-positions));
41  }
42  else if (positions > 0) {
43  return (value << positions);
44  }
45  else {
46  return value;
47  }
48 }

Variable Documentation

const UInt_t mrftools::UInt_t_bitlength = sizeof(UInt_t) * CHAR_BIT
static

Definition at line 13 of file MvdOfflineTBAnalysis_Topix4/mrftools.cxx.

Referenced by getIntBit(), and setIntBit().

const UInt_t mrftools::UInt_t_bitlength = sizeof(UInt_t) * CHAR_BIT
static

Definition at line 13 of file MvdTestBeam/Tools/mrftools.cxx.