CMS 3D CMS Logo

HFDataFrame.h
Go to the documentation of this file.
1 #ifndef DIGIHCAL_HFDATAFRAME_H
2 #define DIGIHCAL_HFDATAFRAME_H
3 
7 #include <ostream>
8 
14 class HFDataFrame {
15 public:
16  typedef HcalDetId key_type;
17 
19  : id_(0), size_(0), hcalPresamples_(0)
20  {}
21  constexpr explicit HFDataFrame(const HcalDetId& id) :
22  id_(id), size_(0), hcalPresamples_(0)
23  {// TODO : test id for HcalForward
24  }
25 
26  constexpr HcalDetId const& id() const { return id_; }
27  constexpr HcalElectronicsId const& elecId() const { return electronicsId_; }
28 
30  constexpr int size() const { return size_&0xF; }
32  constexpr int presamples() const { return hcalPresamples_&0xF; }
34  constexpr bool zsMarkAndPass() const { return (hcalPresamples_&0x10); }
36  constexpr bool zsUnsuppressed() const { return (hcalPresamples_&0x20); }
38  constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_&0x3FF000)>>12; }
39 
41  constexpr HcalQIESample const& operator[](int i) const { return data_[i]; }
43  constexpr HcalQIESample const& sample(int i) const { return data_[i]; }
44 
46  constexpr int fiberIdleOffset() const {
47  int val=(hcalPresamples_&0xF00)>>8;
48  return (val==0)?(-1000):(((val&0x8)==0)?(-(val&0x7)):(val&0x7));
49  }
50 
52  constexpr bool validate(int firstSample=0, int nSamples=100) const {
53  int capid=-1;
54  bool ok=true;
55  for (int i=0; ok && i<nSamples && i+firstSample<size_; i++) {
56  if (data_[i+firstSample].er() || !data_[i+firstSample].dv()) ok=false;
57  if (i==0) capid=data_[i+firstSample].capid();
58  if (capid!=data_[i+firstSample].capid()) ok=false;
59  capid=(capid+1)%4;
60  }
61  return ok;
62  }
63 
64  constexpr void setSize(int size) {
65  if (size>MAXSAMPLES) size_=MAXSAMPLES;
66  else if (size<=0) size_=0;
67  else size_=size;
68  }
69  constexpr void setPresamples(int ps) {
70  hcalPresamples_|=ps&0xF;
71  }
72  constexpr void setZSInfo(bool unsuppressed, bool markAndPass,
73  uint32_t crossingMask=0) {
74  hcalPresamples_&=0x7FC00F0F; // preserve actual presamples and fiber idle offset
75  if (markAndPass) hcalPresamples_|=0x10;
76  if (unsuppressed) hcalPresamples_|=0x20;
77  hcalPresamples_|=(crossingMask&0x3FF)<<12;
78  }
79  constexpr void setSample(int i, const HcalQIESample& sam) { data_[i]=sam; }
82  }
84  hcalPresamples_&=0x7FFFF0FF;
85  if (offset>=7) hcalPresamples_|=0xF00;
86  else if (offset>=0) hcalPresamples_|=(0x800)|(offset<<8);
87  else if (offset>=-7) hcalPresamples_|=((-offset)<<8);
88  else hcalPresamples_|=0x700;
89  }
90 
91  static const int MAXSAMPLES = 10;
92 private:
95  int size_;
98 };
99 
100 std::ostream& operator<<(std::ostream&, const HFDataFrame&);
101 
102 #endif
HcalDetId id_
Definition: HFDataFrame.h:93
HcalQIESample const & operator[](int i) const
access a sample
Definition: HFDataFrame.h:41
HcalDetId key_type
For the sorted collection.
Definition: HFDataFrame.h:16
int hcalPresamples_
Definition: HFDataFrame.h:96
bool zsUnsuppressed() const
was ZS unsuppressed?
Definition: HFDataFrame.h:36
bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: HFDataFrame.h:34
void setFiberIdleOffset(int offset)
Definition: HFDataFrame.h:83
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HFDataFrame.h:38
int fiberIdleOffset() const
offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7...
Definition: HFDataFrame.h:46
HcalQIESample const & sample(int i) const
access a sample
Definition: HFDataFrame.h:43
HcalElectronicsId const & elecId() const
Definition: HFDataFrame.h:27
std::ostream & operator<<(std::ostream &, const HFDataFrame &)
Definition: HFDataFrame.cc:3
HcalQIESample data_[MAXSAMPLES]
Definition: HFDataFrame.h:97
HFDataFrame(const HcalDetId &id)
Definition: HFDataFrame.h:21
HcalDetId const & id() const
Definition: HFDataFrame.h:26
void setReadoutIds(const HcalElectronicsId &eid)
Definition: HFDataFrame.h:80
bool validate(int firstSample=0, int nSamples=100) const
validate appropriate DV and ER bits as well as capid rotation for the specified samples (default is a...
Definition: HFDataFrame.h:52
void setPresamples(int ps)
Definition: HFDataFrame.h:69
constexpr size_t nSamples
void setSample(int i, const HcalQIESample &sam)
Definition: HFDataFrame.h:79
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:30
void setSize(int size)
Definition: HFDataFrame.h:64
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:65
HcalElectronicsId electronicsId_
Definition: HFDataFrame.h:94
static const int MAXSAMPLES
Definition: HFDataFrame.h:91
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HFDataFrame.h:32
Readout chain identification for Hcal.
#define constexpr
void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0)
Definition: HFDataFrame.h:72