31 if (nbits <= 0) nbits = 8;
32 fNbytes = ((nbits-1)/8) + 1;
33 fAllBits =
new UChar_t[fNbytes];
35 memset(fAllBits,0,fNbytes);
42 fNbytes(original.fNbytes)
96 needed > 0 &&
fAllBits[needed]==0; ) { needed--; };
101 fAllBits =
new UChar_t[needed];
103 memcpy(fAllBits,old_location,needed);
104 delete [] old_location;
116 static const Int_t nbits[256] = {
117 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
118 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
119 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
120 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
121 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
122 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
123 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
124 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
125 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
126 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
127 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
128 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
129 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
130 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
131 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
132 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};
141 if (startBit >=
fNbits)
return count;
142 UInt_t startByte = startBit/8;
145 for (i=ibit;i<8;i++) {
146 if (
fAllBits[startByte] & (1<<ibit)) count++;
150 for(i=startByte; i<
fNbytes; i++) {
164 for(
UInt_t i=0; i<min; ++i) {
180 for(
UInt_t i=0; i<min; ++i) {
193 for(
UInt_t i=0; i<min; ++i) {
214 if (shift==0)
return;
215 const UInt_t wordshift = shift / 8;
216 const UInt_t offset = shift % 8;
222 const UInt_t sub_offset = 8 - offset;
225 (
fAllBits[
n - wordshift - 1] >> sub_offset);
237 if (shift==0)
return;
238 const UInt_t wordshift = shift / 8;
239 const UInt_t offset = shift % 8;
247 const UInt_t sub_offset = 8 - offset;
250 (
fAllBits[
n + wordshift + 1] << sub_offset);
262 static const Int_t fbits[256] = {
263 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
264 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
265 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
266 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
267 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
268 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
269 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
270 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,
271 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
272 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
273 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
274 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
275 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
276 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
277 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
278 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8};
288 UInt_t startByte = startBit/8;
291 for (i=ibit;i<8;i++) {
292 if ((
fAllBits[startByte] & (1<<i)) == 0)
return 8*startByte+i;
296 for(i=startByte; i<
fNbytes; i++) {
307 static const Int_t fbits[256] = {
308 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
309 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
310 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
311 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
312 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
313 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
314 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
315 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
316 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
317 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
318 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
319 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
320 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
321 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
322 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
323 3,3,3,3,3,3,3,3,2,2,2,2,1,1,0,8};
327 UInt_t startByte = startBit/8;
330 for (i=ibit+1;i>0;i--) {
331 if ((
fAllBits[startByte] & (1<<(i-1))) == 0)
return 8*startByte+i-1;
335 for(i=startByte+1; i>0; i--) {
346 static const Int_t fbits[256] = {
347 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
348 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
349 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
350 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
351 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
352 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
353 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
354 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
355 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
356 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
357 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
358 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
359 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
360 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
361 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
362 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
372 UInt_t startByte = startBit/8;
375 for (i=ibit;i<8;i++) {
376 if ((
fAllBits[startByte] & (1<<i)) != 0)
return 8*startByte+i;
380 for(i=startByte; i<
fNbytes; i++) {
391 static const Int_t fbits[256] = {
392 8,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
393 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
394 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
395 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
396 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
397 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
398 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
399 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
400 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
401 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
402 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
403 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
404 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
405 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
406 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
407 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
411 UInt_t startByte = startBit/8;
414 for (i=ibit+1;i>0;i--) {
415 if ((
fAllBits[startByte] & (1<<(i-1))) != 0)
return 8*startByte+i-1;
419 for(i=startByte+1; i>0; i--) {
432 for (
UInt_t j=0; j<8; ++j) {
455 for (
UInt_t j=0; j<8; ++j) {
456 if (val & 1)
printf(
" bit:%4d = 1\n",count);
490 UInt_t nbytes=(nbits+7)>>3;
565 UInt_t nbytes = ((nbits+15)>>3)&~1;
572 for (
UInt_t i=0; i<nbytes; i+=2) {
581 UInt_t nbytes = ((nbits+31)>>3)&~3;
588 for (
UInt_t i=0; i<nbytes; i+=4) {
599 UInt_t nbytes = ((nbits+63)>>3)&~7;
606 for (
UInt_t i=0; i<nbytes; i+=8) {
623 UInt_t nSafeBytes = nBytes&~1;
626 for (
UInt_t i=0; i<nSafeBytes; i+=2) {
631 if (nBytes>nSafeBytes) {
632 cArray[nSafeBytes+1] =
fAllBits[nSafeBytes];
641 UInt_t nSafeBytes = nBytes&~3;
645 for (i=0; i<nSafeBytes; i+=4) {
652 for (i=0; i<nBytes-nSafeBytes; ++i) {
653 cArray[nSafeBytes + (3 - i)] =
fAllBits[nSafeBytes + i];
662 UInt_t nSafeBytes = nBytes&~7;
666 for (i=0; i<nSafeBytes; i+=8) {
677 for (i=0; i<nBytes-nSafeBytes; ++i) {
678 cArray[nSafeBytes + (7 - i)] =
fAllBits[nSafeBytes + i];
ClassImp(TBits) TBits
TBits constructor. All bits set to 0.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
void Clear(Option_t *option="")
Clear the value.
void Set(UInt_t nbits, const Char_t *array)
Set all the bytes.
void DoAndEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
UInt_t FirstSetBit(UInt_t startBit=0) const
Return position of first non null bit (starting from position 0 and up)
void Print(Option_t *option="") const
Print the list of active bits.
UInt_t FirstNullBit(UInt_t startBit=0) const
Return position of first null bit (starting from position 0 and up)
void DoRightShift(UInt_t shift)
Execute the left shift operation.
void ResetAllBits(Bool_t value=kFALSE)
Reset all bits to 0 (false).
Bool_t operator==(const TBits &other) const
TBits & operator=(const TBits &)
TBits assignment operator.
virtual ~TBits()
TBits destructor.
UInt_t LastNullBit(UInt_t startBit=999999999) const
Return position of first null bit (starting from position 0 and up)
void DoOrEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
TObject & operator=(const TObject &rhs)
TObject assignment operator.
UInt_t CountBits(UInt_t startBit=0) const
Return number of bits set to 1 starting at bit startBit.
void Compact()
Reduce the storage used by the object to a minimun.
void Output(std::ostream &) const
Print the value to the std::ostream.
void DoLeftShift(UInt_t shift)
Execute the left shift operation.
void DoXorEqual(const TBits &rhs)
Execute (*this) ^= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void Get(Char_t *array) const
Copy all the byes.
Mother of all ROOT objects.
void Paint(Option_t *option="")
Once implemented, it will draw the bit field as an histogram.
void DoFlip()
Execute ~(*this)
UInt_t LastSetBit(UInt_t startBit=999999999) const
Return position of first non null bit (starting from position 0 and up)
void ReserveBytes(UInt_t nbytes)
Reverse each bytes.