HgcrocBoe.hh 1.43 KB
Newer Older
dauncey's avatar
dauncey committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef HgcrocBoe_HH
#define HgcrocBoe_HH

#include <iostream>
#include <iomanip>
#include <cassert>

class HgcrocBoe {
public:
  HgcrocBoe() {
    fWord=0x00ff0000; // Non-existant HGCROC value
  }

  HgcrocBoe(uint32_t w) {
    fWord=w;
  }

dauncey's avatar
dauncey committed
18
  HgcrocBoe(uint8_t e, uint8_t h, uint8_t b, uint8_t l, uint8_t n, bool s=true) {
dauncey's avatar
dauncey committed
19 20
    assert(n<64);
    fWord=(b<<24)+((18*e+h)<<16)+(l<<8)+(n&0x3f)+(s?0x40:0);
dauncey's avatar
dauncey committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  }

  uint8_t bx() const {
    return fWord>>24;
  }
  
  uint8_t econ() const {
    return ((fWord>>16)&0xff)/18;
  }
  
  uint8_t hgcroc() const {
    return ((fWord>>16)&0xff)%18;
  }
  
  uint8_t l1a() const {
    return (fWord>>8)&0xff;
  }
dauncey's avatar
dauncey committed
38 39 40

  bool startOfEvent() const {
    return (fWord&0x40)!=0;
dauncey's avatar
dauncey committed
41 42
  }
  
dauncey's avatar
dauncey committed
43 44 45 46
  uint8_t numberOfWords() const {
    return fWord&0x3f;
  }

dauncey's avatar
dauncey committed
47 48 49 50 51 52 53 54 55 56 57 58 59
  uint32_t word() const {
    return fWord;
  }

  void word(uint32_t w) {
    fWord=w;
  }

  void print() const {
    std::cout << "HgcrocBoe::print() Value = 0x" << std::hex << std::setw(8) << std::setfill('0') << fWord << std::dec << std::endl;
    std::cout << " BX = " << unsigned(bx()) << std::endl;
    std::cout << " ECON, HGCROC = " << unsigned(econ()) << ", " << unsigned(hgcroc()) << std::endl;
    std::cout << " L1Accept = " << unsigned(l1a()) << std::endl;
dauncey's avatar
dauncey committed
60
    std::cout << " Start of event = " << (startOfEvent()?"true":"false") << std::endl;
dauncey's avatar
dauncey committed
61 62 63 64 65 66 67 68
    std::cout << " Number of words = " << unsigned(numberOfWords()) << std::endl;
  }
  
private:
  uint32_t fWord;
};

#endif