CMS 3D CMS Logo

HBHEDataFrame.h
Go to the documentation of this file.
1 #ifndef DIGIHCAL_HBHEDATAFRAME_H
2 #define DIGIHCAL_HBHEDATAFRAME_H
3 
7 #include <ostream>
8 
15 public:
16  typedef HcalDetId key_type;
17 
18  constexpr HBHEDataFrame() : id_(0), size_(0), hcalPresamples_(0) {}
19  constexpr explicit HBHEDataFrame(const HcalDetId& id) : id_(id), size_(0), hcalPresamples_(0) {
20  // TODO : test id for HcalBarrel or HcalEndcap
21  }
22 
23  constexpr const HcalDetId& id() const { return id_; }
24  constexpr const HcalElectronicsId& elecId() const { return electronicsId_; }
25 
27  constexpr int size() const { return size_ & 0xF; }
29  constexpr int presamples() const { return hcalPresamples_ & 0xF; }
31  constexpr bool zsMarkAndPass() const { return (hcalPresamples_ & 0x10); }
33  constexpr bool zsUnsuppressed() const { return (hcalPresamples_ & 0x20); }
35  constexpr uint32_t zsCrossingMask() const { return (hcalPresamples_ & 0x3FF000) >> 12; }
36 
38  constexpr HcalQIESample const& operator[](int i) const { return data_[i]; }
40  constexpr HcalQIESample const& sample(int i) const { return data_[i]; }
41 
43  constexpr int fiberIdleOffset() const {
44  int val = (hcalPresamples_ & 0xF00) >> 8;
45  return (val == 0) ? (-1000) : (((val & 0x8) == 0) ? (-(val & 0x7)) : (val & 0x7));
46  }
47 
49  constexpr bool validate(int firstSample = 0, int nSamples = 100) const {
50  int capid = -1;
51  bool ok = true;
52  for (int i = 0; ok && i < nSamples && i + firstSample < size_; i++) {
53  if (data_[i + firstSample].er() || !data_[i + firstSample].dv())
54  ok = false;
55  if (i == 0)
56  capid = data_[i + firstSample].capid();
57  if (capid != data_[i + firstSample].capid())
58  ok = false;
59  capid = (capid + 1) % 4;
60  }
61  return ok;
62  }
63 
64  constexpr void setSize(int size) {
65  if (size > MAXSAMPLES)
66  size_ = MAXSAMPLES;
67  else if (size <= 0)
68  size_ = 0;
69  else
70  size_ = size;
71  }
72  constexpr void setPresamples(int ps) { hcalPresamples_ |= ps & 0xF; }
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)
76  hcalPresamples_ |= 0x10;
77  if (unsuppressed)
78  hcalPresamples_ |= 0x20;
79  hcalPresamples_ |= (crossingMask & 0x3FF) << 12;
80  }
81  constexpr void setSample(int i, const HcalQIESample& sam) { data_[i] = sam; }
82  constexpr void setReadoutIds(const HcalElectronicsId& eid) { electronicsId_ = eid; }
83  constexpr void setFiberIdleOffset(int offset) {
84  hcalPresamples_ &= 0x7FFFF0FF;
85  if (offset >= 7)
86  hcalPresamples_ |= 0xF00;
87  else if (offset >= 0)
88  hcalPresamples_ |= (0x800) | (offset << 8);
89  else if (offset >= -7)
90  hcalPresamples_ |= ((-offset) << 8);
91  else
92  hcalPresamples_ |= 0x700;
93  }
94 
95  static const int MAXSAMPLES = 10;
96 
97 private:
100  int size_;
103 };
104 
105 std::ostream& operator<<(std::ostream&, const HBHEDataFrame&);
106 
107 #endif
HBHEDataFrame::MAXSAMPLES
static const int MAXSAMPLES
Definition: HBHEDataFrame.h:95
mps_fire.i
i
Definition: mps_fire.py:355
HBHEDataFrame::sample
constexpr HcalQIESample const & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:40
HBHEDataFrame::HBHEDataFrame
constexpr HBHEDataFrame(const HcalDetId &id)
Definition: HBHEDataFrame.h:19
HBHEDataFrame::setSample
constexpr void setSample(int i, const HcalQIESample &sam)
Definition: HBHEDataFrame.h:81
HBHEDataFrame::setReadoutIds
constexpr void setReadoutIds(const HcalElectronicsId &eid)
Definition: HBHEDataFrame.h:82
HBHEDataFrame::operator[]
constexpr HcalQIESample const & operator[](int i) const
access a sample
Definition: HBHEDataFrame.h:38
HBHEDataFrame::electronicsId_
HcalElectronicsId electronicsId_
Definition: HBHEDataFrame.h:99
HBHEDataFrame::key_type
HcalDetId key_type
For the sorted collection.
Definition: HBHEDataFrame.h:16
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
HcalQIESample
Definition: HcalQIESample.h:32
HBHEDataFrame::elecId
constexpr const HcalElectronicsId & elecId() const
Definition: HBHEDataFrame.h:24
HBHEDataFrame::id_
HcalDetId id_
Definition: HBHEDataFrame.h:98
HBHEDataFrame::zsUnsuppressed
constexpr bool zsUnsuppressed() const
was ZS unsuppressed?
Definition: HBHEDataFrame.h:33
operator<<
std::ostream & operator<<(std::ostream &, const HBHEDataFrame &)
Definition: HBHEDataFrame.cc:3
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
DigiNZS_cff.markAndPass
markAndPass
Definition: DigiNZS_cff.py:6
HBHEDataFrame
Definition: HBHEDataFrame.h:14
HBHEDataFrame::HBHEDataFrame
constexpr HBHEDataFrame()
Definition: HBHEDataFrame.h:18
castor_dqm_sourceclient-live_cfg.firstSample
firstSample
Definition: castor_dqm_sourceclient-live_cfg.py:58
HBHEDataFrame::setZSInfo
constexpr void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0)
Definition: HBHEDataFrame.h:73
HcalQIESample.h
HcalDetId.h
HBHEDataFrame::data_
HcalQIESample data_[MAXSAMPLES]
Definition: HBHEDataFrame.h:102
HcalDetId
Definition: HcalDetId.h:12
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
HcalQIESample::capid
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
HBHEDataFrame::setPresamples
constexpr void setPresamples(int ps)
Definition: HBHEDataFrame.h:72
HcalElectronicsId.h
HBHEDataFrame::zsCrossingMask
constexpr uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HBHEDataFrame.h:35
HBHEDataFrame::setSize
constexpr void setSize(int size)
Definition: HBHEDataFrame.h:64
HBHEDataFrame::id
constexpr const HcalDetId & id() const
Definition: HBHEDataFrame.h:23
heppy_batch.val
val
Definition: heppy_batch.py:351
HBHEDataFrame::size
constexpr int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:27
HBHEDataFrame::validate
constexpr 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: HBHEDataFrame.h:49
HBHEDataFrame::zsMarkAndPass
constexpr bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: HBHEDataFrame.h:31
HBHEDataFrame::hcalPresamples_
int hcalPresamples_
Definition: HBHEDataFrame.h:101
HBHEDataFrame::setFiberIdleOffset
constexpr void setFiberIdleOffset(int offset)
Definition: HBHEDataFrame.h:83
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
HBHEDataFrame::presamples
constexpr int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware)
Definition: HBHEDataFrame.h:29
HBHEDataFrame::size_
int size_
Definition: HBHEDataFrame.h:100
HBHEDataFrame::fiberIdleOffset
constexpr int fiberIdleOffset() const
offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7....
Definition: HBHEDataFrame.h:43