CMS 3D CMS Logo

HODataFrame.h
Go to the documentation of this file.
1 #ifndef DIGIHCAL_HODATAFRAME_H
2 #define DIGIHCAL_HODATAFRAME_H
3 
7 #include <ostream>
8 
9 
15 class HODataFrame {
16 public:
17  typedef HcalDetId key_type;
18 
20  : id_(0), size_(0), hcalPresamples_(0)
21  {}
22  explicit constexpr HODataFrame(const HcalDetId& id)
23  : id_(id), size_(0), hcalPresamples_(0)
24  {// TODO : test id for HcalOuter
25  }
26 
27  constexpr HcalDetId const& id() const { return id_; }
28  constexpr HcalElectronicsId const& elecId() const { return electronicsId_; }
29 
31  constexpr int size() const { return size_&0xF; }
33  constexpr int presamples() const { return hcalPresamples_&0xF; }
35  constexpr bool zsMarkAndPass() const { return (hcalPresamples_&0x10); }
37  constexpr bool zsUnsuppressed() const { return (hcalPresamples_&0x20); }
39  constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_&0x3FF000)>>12; }
40 
42  constexpr const HcalQIESample& operator[](int i) const { return data_[i]; }
44  constexpr const HcalQIESample& sample(int i) const { return data_[i]; }
45 
47  constexpr int fiberIdleOffset() const {
48  int val=(hcalPresamples_&0xF00)>>8;
49  return (val==0)?(-1000):(((val&0x8)==0)?(-(val&0x7)):(val&0x7));
50  }
51 
53  constexpr bool validate(int firstSample=0, int nSamples=100) const {
54  int capid=-1;
55  bool ok=true;
56  for (int i=0; ok && i<nSamples && i+firstSample<size_; i++) {
57  if (data_[i+firstSample].er() || !data_[i+firstSample].dv()) ok=false;
58  if (i==0) capid=data_[i+firstSample].capid();
59  if (capid!=data_[i+firstSample].capid()) ok=false;
60  capid=(capid+1)%4;
61  }
62  return ok;
63  }
64 
65  constexpr void setSize(int size) {
66  if (size>MAXSAMPLES) size_=MAXSAMPLES;
67  else if (size<=0) size_=0;
68  else size_=size;
69  }
70  constexpr void setPresamples(int ps) {
71  hcalPresamples_|=ps&0xF;
72  }
73  constexpr void setZSInfo(bool unsuppressed, bool markAndPass, 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_&=0xFFFF0FF;
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 HODataFrame&);
101 
102 
103 #endif
void setSize(int size)
Definition: HODataFrame.h:65
HcalElectronicsId electronicsId_
Definition: HODataFrame.h:94
HcalDetId const & id() const
Definition: HODataFrame.h:27
int fiberIdleOffset() const
offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7...
Definition: HODataFrame.h:47
bool zsUnsuppressed() const
was ZS unsuppressed?
Definition: HODataFrame.h:37
const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:44
#define constexpr
void setFiberIdleOffset(int offset)
Definition: HODataFrame.h:83
static const int MAXSAMPLES
Definition: HODataFrame.h:91
HcalElectronicsId const & elecId() const
Definition: HODataFrame.h:28
bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: HODataFrame.h:35
void setSample(int i, const HcalQIESample &sam)
Definition: HODataFrame.h:79
int size() const
total number of samples in the digi
Definition: HODataFrame.h:31
std::ostream & operator<<(std::ostream &, const HODataFrame &)
Definition: HODataFrame.cc:3
constexpr size_t nSamples
HcalQIESample data_[MAXSAMPLES]
Definition: HODataFrame.h:97
HcalDetId id_
Definition: HODataFrame.h:93
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: HODataFrame.h:53
void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0)
Definition: HODataFrame.h:73
int hcalPresamples_
Definition: HODataFrame.h:96
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:65
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HODataFrame.h:39
void setReadoutIds(const HcalElectronicsId &eid)
Definition: HODataFrame.h:80
HODataFrame(const HcalDetId &id)
Definition: HODataFrame.h:22
Readout chain identification for Hcal.
const HcalQIESample & operator[](int i) const
access a sample
Definition: HODataFrame.h:42
void setPresamples(int ps)
Definition: HODataFrame.h:70
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HODataFrame.h:33
HcalDetId key_type
For the sorted collection.
Definition: HODataFrame.h:17