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 
19  : id_(0), size_(0), hcalPresamples_(0)
20  {}
21  constexpr explicit HBHEDataFrame(const HcalDetId& id) :
22  id_(id), size_(0), hcalPresamples_(0)
23  {
24  // TODO : test id for HcalBarrel or HcalEndcap
25  }
26 
27  constexpr const HcalDetId& id() const { return id_; }
28  constexpr const HcalElectronicsId& 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 HcalQIESample const& operator[](int i) const { return data_[i]; }
44  constexpr HcalQIESample const& 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,
74  uint32_t crossingMask=0) {
75  hcalPresamples_&=0x7FC00F0F; // preserve actual presamples and fiber idle offset
76  if (markAndPass) hcalPresamples_|=0x10;
77  if (unsuppressed) hcalPresamples_|=0x20;
78  hcalPresamples_|=(crossingMask&0x3FF)<<12;
79  }
80  constexpr void setSample(int i, const HcalQIESample& sam) { data_[i]=sam; }
83  }
85  hcalPresamples_&=0x7FFFF0FF;
86  if (offset>=7) hcalPresamples_|=0xF00;
87  else if (offset>=0) hcalPresamples_|=(0x800)|(offset<<8);
88  else if (offset>=-7) hcalPresamples_|=((-offset)<<8);
89  else hcalPresamples_|=0x700;
90  }
91 
92  static const int MAXSAMPLES = 10;
93 private:
96  int size_;
99 };
100 
101 std::ostream& operator<<(std::ostream&, const HBHEDataFrame&);
102 
103 
104 #endif
bool zsUnsuppressed() const
was ZS unsuppressed?
Definition: HBHEDataFrame.h:37
static const int MAXSAMPLES
Definition: HBHEDataFrame.h:92
bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: HBHEDataFrame.h:35
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:31
void setSize(int size)
Definition: HBHEDataFrame.h:65
HcalQIESample const & operator[](int i) const
access a sample
Definition: HBHEDataFrame.h:42
void setReadoutIds(const HcalElectronicsId &eid)
Definition: HBHEDataFrame.h:81
HBHEDataFrame(const HcalDetId &id)
Definition: HBHEDataFrame.h:21
void setPresamples(int ps)
Definition: HBHEDataFrame.h:70
void setSample(int i, const HcalQIESample &sam)
Definition: HBHEDataFrame.h:80
std::ostream & operator<<(std::ostream &, const HBHEDataFrame &)
Definition: HBHEDataFrame.cc:3
void setFiberIdleOffset(int offset)
Definition: HBHEDataFrame.h:84
HcalElectronicsId electronicsId_
Definition: HBHEDataFrame.h:95
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:53
HcalQIESample data_[MAXSAMPLES]
Definition: HBHEDataFrame.h:98
constexpr size_t nSamples
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HBHEDataFrame.h:33
int fiberIdleOffset() const
offset of bunch number for this channel relative to nominal set in the unpacker (range is +7->-7...
Definition: HBHEDataFrame.h:47
HcalQIESample const & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:44
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HBHEDataFrame.h:39
HcalDetId key_type
For the sorted collection.
Definition: HBHEDataFrame.h:16
const HcalElectronicsId & elecId() const
Definition: HBHEDataFrame.h:28
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:65
const HcalDetId & id() const
Definition: HBHEDataFrame.h:27
HcalDetId id_
Definition: HBHEDataFrame.h:94
void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0)
Definition: HBHEDataFrame.h:73
Readout chain identification for Hcal.
#define constexpr