CMS 3D CMS Logo

ZDCDataFrame.cc
Go to the documentation of this file.
2 
3 ZDCDataFrame::ZDCDataFrame() : id_(0), size_(0), hcalPresamples_(0) {}
4 
5 ZDCDataFrame::ZDCDataFrame(const HcalZDCDetId& id) : id_(id), size_(0), hcalPresamples_(0) {
6  // TODO : test id for ZDC
7 }
8 
10  if (size > MAXSAMPLES)
11  size_ = MAXSAMPLES;
12  else if (size <= 0)
13  size_ = 0;
14  else
15  size_ = size;
16 }
17 void ZDCDataFrame::setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; }
19 
21  int capid = -1;
22  bool ok = true;
23  for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) {
24  if (data_[i + firstSample].er() || !data_[i + firstSample].dv())
25  ok = false;
26  if (i == 0)
27  capid = data_[i + firstSample].capid();
28  if (capid != data_[i + firstSample].capid())
29  ok = false;
30  capid = (capid + 1) % 4;
31  }
32  return ok;
33 }
34 
35 void ZDCDataFrame::setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask) {
36  hcalPresamples_ &= 0x7FC00F0F; // preserve actual presamples and fiber idle offset
37  if (markAndPass)
38  hcalPresamples_ |= 0x10;
39  if (unsuppressed)
40  hcalPresamples_ |= 0x20;
41  hcalPresamples_ |= (crossingMask & 0x3FF) << 12;
42 }
43 
45  int val = (hcalPresamples_ & 0xF00) >> 8;
46  return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7));
47 }
48 
50  hcalPresamples_ &= 0x7FFFF0FF;
51  if (offset >= 7)
52  hcalPresamples_ |= 0xF00;
53  else if (offset >= 0)
54  hcalPresamples_ |= (0x800) | (offset << 8);
55  else if (offset >= -7)
56  hcalPresamples_ |= ((-offset) << 8);
57  else
58  hcalPresamples_ |= 0x700;
59 }
60 
61 std::ostream& operator<<(std::ostream& s, const ZDCDataFrame& digi) {
62  s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples ";
63  if (digi.zsUnsuppressed())
64  s << " zsUS ";
65  if (digi.zsMarkAndPass())
66  s << " zsM&P ";
67  if (digi.fiberIdleOffset() != 0) {
68  if (digi.fiberIdleOffset() == -1000)
69  s << " nofiberOffset";
70  else
71  s << " fiberOffset=" << digi.fiberIdleOffset();
72  }
73  s << std::endl;
74  for (int i = 0; i < digi.size(); i++)
75  s << " " << digi.sample(i) << std::endl;
76  return s;
77 }
size
Write out results.
const HcalQIESample & sample(int i) const
access a sample
Definition: ZDCDataFrame.h:39
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: ZDCDataFrame.h:28
bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: ZDCDataFrame.h:30
void setPresamples(int ps)
Definition: ZDCDataFrame.cc:17
int fiberIdleOffset() const
offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7...
Definition: ZDCDataFrame.cc:44
std::ostream & operator<<(std::ostream &s, const ZDCDataFrame &digi)
Definition: ZDCDataFrame.cc:61
int hcalPresamples_
Definition: ZDCDataFrame.h:60
static const int MAXSAMPLES
Definition: ZDCDataFrame.h:54
void setFiberIdleOffset(int offset)
Definition: ZDCDataFrame.cc:49
const HcalZDCDetId & id() const
Definition: ZDCDataFrame.h:22
bool zsUnsuppressed() const
was ZS unsuppressed?
Definition: ZDCDataFrame.h:32
void setReadoutIds(const HcalElectronicsId &eid)
Definition: ZDCDataFrame.cc:18
int size() const
total number of samples in the digi
Definition: ZDCDataFrame.h:26
void setSize(int size)
Definition: ZDCDataFrame.cc:9
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: ZDCDataFrame.cc:20
void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0)
Definition: ZDCDataFrame.cc:35
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
HcalQIESample data_[MAXSAMPLES]
Definition: ZDCDataFrame.h:61
HcalElectronicsId electronicsId_
Definition: ZDCDataFrame.h:58
Readout chain identification for Hcal.