CMS 3D CMS Logo

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