CMS 3D CMS Logo

QIE11DataFrame.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
2 #define DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
3 
6 #include <ostream>
7 
12 public:
13 
14  static const int WORDS_PER_SAMPLE = 1;
15  static const int HEADER_WORDS = 1;
16  static const int FLAG_WORDS = 1;
17 
20 
21  class Sample {
22  public:
24  static const int MASK_ADC = 0xFF;
25  static const int MASK_TDC = 0x3F;
26  static const int OFFSET_TDC = 8; // 8 bits
27  static const int MASK_SOI = 0x4000;
28  static const int MASK_CAPID = 0x3;
29  static const int OFFSET_CAPID = 8;
30  constexpr int adc() const { return frame_[i_]&MASK_ADC; }
31  constexpr int tdc() const { return (frame_[i_]>>OFFSET_TDC)&MASK_TDC; }
32  constexpr bool soi() const { return frame_[i_]&MASK_SOI; }
33  constexpr int capid() const { return ((((frame_[0]>>OFFSET_CAPID)&MASK_CAPID)+i_-HEADER_WORDS)&MASK_CAPID); }
34  private:
37  };
38 
39  constexpr void copyContent(const QIE11DataFrame& digi) {
40  for (edm::DataFrame::size_type i=0; i<size() && i<digi.size();i++){
41  Sample sam = digi[i];
42  setSample(i,sam.adc(),sam.tdc(),sam.soi());
43  }
44  }
45 
47  constexpr DetId detid() const { return DetId(m_data.id()); }
57  constexpr int samples() const { return (size()-HEADER_WORDS-FLAG_WORDS)/WORDS_PER_SAMPLE; }
59  constexpr int presamples() const {
60  for (int i=0; i<samples(); i++) {
61  if ((*this)[i].soi()) return i;
62  }
63  return -1;
64  }
66  static const int OFFSET_FLAVOR = 12;
67  static const int MASK_FLAVOR = 0x7;
68  constexpr int flavor() const { return ((m_data[0]>>OFFSET_FLAVOR)&MASK_FLAVOR); }
70  static const int MASK_LINKERROR = 0x800;
71  constexpr bool linkError() const { return m_data[0]&MASK_LINKERROR; }
73  static const int MASK_CAPIDERROR = 0x400;
74  constexpr bool capidError() const { return m_data[0]&MASK_CAPIDERROR; }
76  constexpr bool zsMarkAndPass() const {return (flavor()==1); }
79  if(markAndPass) m_data[0] |= (markAndPass&MASK_FLAVOR)<<OFFSET_FLAVOR;
80  }
82  constexpr inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data,i+HEADER_WORDS); }
83  constexpr void setCapid0(int cap0) {
84  m_data[0]&=0xFCFF; // inversion of the capid0 mask
86  }
89  int tdc, bool soi=false) {
90  if (isample>=size()) return;
92  }
94  constexpr uint16_t flags() const { return m_data[size()-1]; }
96  constexpr void setFlags(uint16_t v) {
97  m_data[size()-1]=v;
98  }
99 
100  private:
102 
103 };
104 
105 std::ostream& operator<<(std::ostream&, const QIE11DataFrame&);
106 
107 #endif // DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
DetId detid() const
Get the detector id.
unsigned int id_type
Definition: DataFrame.h:19
void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false)
set the sample contents
static const int FLAG_WORDS
Sample(const edm::DataFrame &frame, edm::DataFrame::size_type i)
edm::DataFrame::size_type size() const
more accessors
static const int OFFSET_CAPID
QIE11DataFrame(edm::DataFrame const &df)
edm::DataFrame::const_iterator end() const
edm::DataFrame::size_type i_
constexpr iterator end()
Definition: DataFrame.h:51
void setCapid0(int cap0)
static const int MASK_CAPID
static const int HEADER_WORDS
int flavor() const
static const int MASK_ADC
static const int MASK_FLAVOR
void setFlags(uint16_t v)
set the flag word
uint16_t flags() const
get the flag word
static const int WORDS_PER_SAMPLE
static const int MASK_LINKERROR
was there a link error?
#define constexpr
static const int MASK_CAPIDERROR
was there a capid rotation error?
unsigned int size_type
Definition: DataFrame.h:18
constexpr id_type id() const
Definition: DataFrame.h:61
void setZSInfo(bool markAndPass)
set ZS params
static const int MASK_TDC
bool linkError() const
bool zsMarkAndPass() const
was this a mark-and-pass ZS event?
Sample operator[](edm::DataFrame::size_type i) const
get the sample
constexpr size_type size() const
Definition: DataFrame.h:64
edm::DataFrame::const_iterator begin() const
edm::DataFrame::id_type id() const
const edm::DataFrame & frame_
static const int OFFSET_FLAVOR
get the flavor of the frame
bool capidError() const
edm::DataFrame m_data
void copyContent(const QIE11DataFrame &digi)
Definition: DetId.h:18
static const int OFFSET_TDC
std::ostream & operator<<(std::ostream &, const QIE11DataFrame &)
constexpr iterator begin()
Definition: DataFrame.h:48
static const int MASK_SOI
int presamples() const
for backward compatibility
data_type * iterator
Definition: DataFrame.h:21
data_type const * const_iterator
Definition: DataFrame.h:22
edm::DataFrame::iterator begin()
iterators
edm::DataFrame::iterator end()
int samples() const
total number of samples in the digi