HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SKIROC2DataFrame.h
Go to the documentation of this file.
1 #ifndef SKIROC2DATAFRAME_H_INCLUDED
2 #define SKIROC2DATAFRAME_H_INCLUDED 1
3 
4 #include <stdint.h>
5 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
6 #include "DataFormats/Common/interface/DataFrame.h"
7 
9 {
10 public:
11 
12  static const int WORDS_PER_SAMPLE = 2;
13  static const int HEADER_WORDS = 1;
14  static const int FLAG_WORDS = 1;
15 
17  SKIROC2DataFrame(edm::DataFrame const & df) : m_data(df) { }
18 
19  class Sample
20  {
21  public:
22  Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame), i_(i) { }
23  static const int MASK_ADCTDC = 0x0FFF;
24  static const int MASK_HIT = 0x1000;
25  static const int MASK_GAIN = 0x2000;
26 
27  enum {
31  };
32 
33  int adcLow() const // adc values in 12 bits, so no reason to use unsigned types
34  {
35  return frame_[i_ + ADCLOW_SHIFT] & MASK_ADCTDC;
36  }
37  int adcHigh() const
38  {
39  return frame_[i_ + ADCHIGH_SHIFT] & MASK_ADCTDC;
40  }
41 
42  int tdc() const
43  {
44  return frame_[i_ + TDC_SHIFT] & MASK_ADCTDC;
45  }
46  private:
47  const edm::DataFrame& frame_;
48  edm::DataFrame::size_type i_;
49  };
50 
51  void copyContent(const SKIROC2DataFrame& src);
52 
53  /// Get the detector id
55  {
56  return HGCalTBDetId(m_data.id());
57  }
58 
59  edm::DataFrame::id_type id() const
60  {
61  return m_data.id();
62  }
63  /// more accessors
64  edm::DataFrame::size_type size() const
65  {
66  return m_data.size();
67  }
68  /// iterators
69  edm::DataFrame::iterator begin()
70  {
71  return m_data.begin();
72  }
73  edm::DataFrame::iterator end()
74  {
75  return m_data.end();
76  }
77  edm::DataFrame::const_iterator begin() const
78  {
79  return m_data.begin();
80  }
81  edm::DataFrame::const_iterator end() const
82  {
83  return m_data.end();
84  }
85 
86  /// total number of samples in the digi
87  int samples() const
88  {
90  }
91  /// get the sample
92  inline Sample operator[](edm::DataFrame::size_type i) const
93  {
94  return Sample(m_data, i * WORDS_PER_SAMPLE + HEADER_WORDS);
95  }
96  /// set the sample contents
97  void setSample(edm::DataFrame::size_type isample, int adcLow, int adcHigh, int tdc);
98  /// get the flag word
99  uint16_t flags() const
100  {
101  return m_data[size() - 1];
102  }
103  /// set the flag word
104  void setFlags(uint16_t v);
105 
106 private:
107  edm::DataFrame m_data;
108 };
109 
110 std::ostream& operator<<(std::ostream&, const SKIROC2DataFrame&);
111 
112 #endif // SKIROC2DATAFRAME_H_INCLUDED
static const int MASK_GAIN
void copyContent(const SKIROC2DataFrame &src)
HGCalTBDetId detid() const
Get the detector id.
Sample(const edm::DataFrame &frame, edm::DataFrame::size_type i)
static const int MASK_HIT
void setSample(edm::DataFrame::size_type isample, int adcLow, int adcHigh, int tdc)
set the sample contents
SKIROC2DataFrame(edm::DataFrame const &df)
edm::DataFrame::iterator begin()
iterators
Sample operator[](edm::DataFrame::size_type i) const
get the sample
edm::DataFrame::const_iterator end() const
void setFlags(uint16_t v)
set the flag word
uint16_t flags() const
get the flag word
static const int FLAG_WORDS
edm::DataFrame::const_iterator begin() const
std::ostream & operator<<(std::ostream &, const HGCalTBDetId &id)
Definition: HGCalTBDetId.cc:37
static const int MASK_ADCTDC
edm::DataFrame::size_type size() const
more accessors
static const int HEADER_WORDS
edm::DataFrame::iterator end()
static const int WORDS_PER_SAMPLE
edm::DataFrame::id_type id() const
int samples() const
total number of samples in the digi