CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalUpgradeDataFrame.cc
Go to the documentation of this file.
2 
3 
5  capId_(0),
6  size_(0),
7  presamples_(0)
8 {
9 }
10 
11 HcalUpgradeDataFrame::HcalUpgradeDataFrame(HcalDetId id, int capId, int samples, int presamples) : id_(id),
12  capId_(capId)
13 {
14  setSize(samples) ;
15  setPresamples(presamples) ;
16 }
17 
19  if (size>MAXSAMPLES) size_=MAXSAMPLES;
20  else if (size<=0) size_=0;
21  else size_=size;
22 }
23 
25  if (presamples>MAXSAMPLES) presamples_=MAXSAMPLES;
26  else if (presamples<=0) presamples_=0;
28 }
29 
30 void HcalUpgradeDataFrame::setSample(int relativeSample,
31  const uint16_t adc,
32  const uint8_t tdc,
33  const bool dv) {
34 
35  int linSample = presamples_ + relativeSample ;
36  if ( linSample < MAXSAMPLES && linSample>=0) {
37  adc_[linSample] = adc&0xFF ;
38  tdc_[linSample] = tdc&0x1F ;
39  dv_[linSample] = dv ;
40  }
41 }
42 
43 std::ostream& operator<<(std::ostream& s, const HcalUpgradeDataFrame& digi) {
44  s << digi.id() << " " << digi.size() << " samples " << digi.presamples() << " presamples ";
45  for (int i=0; i<digi.size(); i++) {
46  int relSample = i - digi.presamples() ;
47  if ( relSample < 0 ) s << " (PRE) " ;
48  else s << " " ;
49  s << int(digi.adc(relSample)) << " (adc) " ;
50  s << int(digi.tdc(relSample)) << " (tdc) " ;
51  if ( digi.valid(relSample) ) s << " (DV) " ;
52  s << std::endl ;
53  }
54  return s;
55 }
56 
57 
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const int MAXSAMPLES
uint8_t tdc(int iSample=0) const
void setPresamples(int presamples)
bool valid(int iSample=0) const
void setSample(int relSample, const uint16_t adc, const uint8_t tdc, const bool dv)
uint16_t adc_[MAXSAMPLES]
const HcalDetId & id() const
uint16_t adc(int iSample=0) const
size_(0)
Definition: OwnArray.h:181
uint8_t tdc_[MAXSAMPLES]
tuple size
Write out results.