CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalUHTRData.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef HcalUHTRData_H
3 #define HcalUHTRData_H
4 
5 #include <stdint.h>
6 
16 class HcalUHTRData {
17  public:
18  static const int FIBERS_PER_UHTR = 24;
19  static const int CHANNELS_PER_FIBER_HF = 4;
20  static const int CHANNELS_PER_FIBER_HBHE = 6;
21  static const int CHANNELS_PER_FIBER_MAX = 8;
22 
23  HcalUHTRData();
24  ~HcalUHTRData() { if (m_ownData!=0) delete [] m_ownData; }
25  HcalUHTRData(int version_to_create);
26  HcalUHTRData(const uint64_t* data, int length_words);
27  HcalUHTRData(const HcalUHTRData&);
28 
30 
32  inline int getFormatVersion() const { return m_formatVersion; }
33 
35  inline const unsigned short* getRawData16() const { return m_raw16; }
36 
38  inline const int getRawLengthBytes() const { return m_rawLength64*sizeof(uint64_t); }
39 
41  public:
42  const_iterator(const uint16_t* ptr, const uint16_t* limit=0);
43 
44  bool isHeader() const { return ((*m_ptr)&0x8000)!=0; }
45  int flavor() const { return ((*m_ptr)>>12)&0x7; }
46  int errFlags() const { return ((*m_ptr)>>10)&0x3; }
47  int capid0() const { return ((*m_ptr)>>8)&0x3; }
48  int channelid() const { return ((*m_ptr))&0xFF; }
49 
50  uint16_t value() const { return *m_ptr; }
51 
52  uint8_t adc() const;
53  uint8_t le_tdc() const;
54  uint8_t te_tdc() const;
55  bool soi() const;
56  uint8_t capid() const;
57  bool ok() const;
58 
59  uint16_t operator*() const { return *m_ptr; }
60 
63 
64  bool operator==(const const_iterator& i) { return m_ptr==i.m_ptr; }
65  bool operator!=(const const_iterator& i) { return m_ptr!=i.m_ptr; }
66  const uint16_t* raw() const { return m_ptr; }
67 
68  private:
69  void determineMode();
70  const uint16_t* m_ptr, *m_limit;
71  const uint16_t* m_header_ptr, *m_0th_data_ptr;
74  int m_flavor;
75  };
76 
77  const_iterator begin() const;
78  const_iterator end() const;
79 
80  class packer {
81  public:
82  packer(uint16_t* baseptr);
83  void addHeader(int flavor, int errf, int cap0, int channelid);
84  void addSample(int adc, bool soi=false, int retdc=0, int fetdc=0, int tdcstat=0);
85  void addTP(int tpword, bool soi=false);
86  private:
87  uint16_t* m_baseptr;
88  int m_ptr;
89  int m_flavor;
91  };
92 
93  packer pack();
94 
95 
97  void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int
98  orbitn, int pipeline, int ndd, int nps, int firmwareRev=0);
99 
101  void packUnsuppressed(const bool* mp);
102 
104  inline uint32_t l1ANumber() const { return uint32_t(m_raw64[0]>>32)&0xFFFFFF; }
106  inline uint32_t bunchNumber() const { return uint32_t(m_raw64[0]>>20)&0xFFF; }
108  inline uint32_t orbitNumber() const { return uint32_t(m_raw64[1]>>16)&0xFFFF; }
110  inline uint32_t boardId() const { return uint32_t(m_raw64[1])&0xFFFF; }
112  inline uint32_t crateId() const { return uint32_t(m_raw64[1])&0xFF; }
114  inline uint32_t slot() const { return uint32_t(m_raw64[1]>>8)&0xF; }
115 
117  bool wasMarkAndPassZS(int fiber, int fiberchan) const;
119  bool wasMarkAndPassZSTP(int slb, int slbchan) const;
120 
122  unsigned int getFirmwareRevision() const { return uint32_t(m_raw64[1]>>48)&0xFFFF; }
124  int getFirmwareFlavor() const { return uint32_t(m_raw64[1]>>32)&0xFF; }
125 
126 
127 protected:
131  const uint16_t* m_raw16;
133 };
134 
135 #endif
136 
int adc(sample_type sample)
get the ADC sample (12 bits)
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalUHTRData.h:124
bool operator!=(const const_iterator &i)
Definition: HcalUHTRData.h:65
void addTP(int tpword, bool soi=false)
int i
Definition: DBlmapReader.cc:9
const uint16_t * m_limit
Definition: HcalUHTRData.h:70
static int slb(const HcalTriggerPrimitiveSample &theSample)
const unsigned short * getRawData16() const
Get a pointer to the raw data.
Definition: HcalUHTRData.h:35
uint16_t value() const
Definition: HcalUHTRData.h:50
static const int CHANNELS_PER_FIBER_MAX
Definition: HcalUHTRData.h:21
const uint16_t * m_0th_data_ptr
Definition: HcalUHTRData.h:71
uint32_t crateId() const
Get the board crate.
Definition: HcalUHTRData.h:112
int getFormatVersion() const
Get the version number of this event.
Definition: HcalUHTRData.h:32
void addHeader(int flavor, int errf, int cap0, int channelid)
Definition: HcalUHTRData.cc:88
packer(uint16_t *baseptr)
Definition: HcalUHTRData.cc:85
const_iterator & operator++()
Definition: HcalUHTRData.cc:10
static const int CHANNELS_PER_FIBER_HF
Definition: HcalUHTRData.h:19
uint32_t bunchNumber() const
Get the HTR bunch number.
Definition: HcalUHTRData.h:106
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
void addSample(int adc, bool soi=false, int retdc=0, int fetdc=0, int tdcstat=0)
Definition: HcalUHTRData.cc:99
static const int CHANNELS_PER_FIBER_HBHE
Definition: HcalUHTRData.h:20
const_iterator begin() const
Definition: HcalUHTRData.cc:77
const uint16_t * m_raw16
Definition: HcalUHTRData.h:131
uint32_t orbitNumber() const
Get the HTR orbit number.
Definition: HcalUHTRData.h:108
static const int FIBERS_PER_UHTR
Definition: HcalUHTRData.h:18
const_iterator(const uint16_t *ptr, const uint16_t *limit=0)
Definition: HcalUHTRData.cc:6
uint32_t slot() const
Get the board slot.
Definition: HcalUHTRData.h:114
void packUnsuppressed(const bool *mp)
pack trailer with Mark and Pass bits
HcalUHTRData & operator=(const HcalUHTRData &)
unsigned long long uint64_t
Definition: Time.h:15
bool operator==(const const_iterator &i)
Definition: HcalUHTRData.h:64
uint32_t l1ANumber() const
Get the HTR event number.
Definition: HcalUHTRData.h:104
uint16_t operator*() const
Definition: HcalUHTRData.h:59
const int getRawLengthBytes() const
Get the length of the raw data.
Definition: HcalUHTRData.h:38
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&amp;Pass ZS?
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
packer pack()
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalUHTRData.h:122
const uint16_t * m_header_ptr
Definition: HcalUHTRData.h:71
const uint64_t * m_raw64
Definition: HcalUHTRData.h:130
const_iterator end() const
Definition: HcalUHTRData.cc:81
uint64_t * m_ownData
Definition: HcalUHTRData.h:132
uint32_t boardId() const
Get the raw board id.
Definition: HcalUHTRData.h:110
uint16_t * m_baseptr
Definition: HcalUHTRData.h:87
const uint16_t * raw() const
Definition: HcalUHTRData.h:66
void packHeaderTrailer(int L1Anumber, int bcn, int submodule, int orbitn, int pipeline, int ndd, int nps, int firmwareRev=0)
pack header and trailer (call after pack)