CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QIE10DataFrame.cc
Go to the documentation of this file.
1 #include <type_traits>
2 
5 
6 void QIE10DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi, bool ok) {
7  if (isample>=size()) return;
9  m_data[isample*WORDS_PER_SAMPLE+HEADER_WORDS+1]=(le_tdc&Sample::MASK_LE_TDC)|((te_tdc&Sample::MASK_TE_TDC)<<Sample::OFFSET_TE_TDC)|((capid&Sample::MASK_CAPID)<<Sample::OFFSET_CAPID)|0x4000; // 0x4000 marks this as second word of a pair
10 }
11 
12 void QIE10DataFrame::setFlags(uint16_t v) {
13  m_data[size()-1]=v;
14 }
15 
17  for (edm::DataFrame::size_type i=0; i<size() && i<digi.size();i++){
18  Sample sam = digi[i];
19  setSample(i, sam.adc(), sam.le_tdc(), sam.te_tdc(), sam.capid(), sam.soi(), sam.ok());
20  }
21 }
22 
24  for (int i=0; i<samples(); i++) {
25  if ((*this)[i].soi()) return i;
26  }
27  return -1;
28 }
29 
30 void QIE10DataFrame::setZSInfo(bool markAndPass) {
31  if(markAndPass) m_data[0] |= MASK_MARKPASS;
32 }
33 
35  static_assert(sizeof(wide) == 2*sizeof(word1_),
36  "The wide input type must be able to contain two words");
37  const edm::DataFrame::data_type* ptr =
38  reinterpret_cast<const edm::DataFrame::data_type*>(&wide);
39  word1_ = ptr[0];
40  word2_ = ptr[1];
41 }
42 
44  static_assert(sizeof(QIE10DataFrame::Sample::wide_type) == 2*sizeof(word1_),
45  "The wide result type must be able to contain two words");
48  reinterpret_cast<edm::DataFrame::data_type*>(&result);
49  ptr[0] = word1_;
50  ptr[1] = word2_;
51  return result;
52 }
53 
54 std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) {
55  if (digi.detid().det()==DetId::Hcal) {
56  s << HcalGenericDetId(digi.detid());
57  } else {
58  s << "DetId(" << digi.detid().rawId() << ")";
59  }
60  s << " " << digi.samples() << " samples";
61  if (digi.linkError()) s << " LinkError ";
62  if (digi.zsMarkAndPass()) s << " MaP ";
63  s << std::endl;
64  for (int i=0; i<digi.samples(); i++) {
65  QIE10DataFrame::Sample sam = digi[i];
66  s << " ADC=" << sam.adc() << " TDC(LE)=" << sam.le_tdc() << " TDC(TE)=" << sam.te_tdc() << " CAPID=" << sam.capid();
67  if (sam.soi()) s << " SOI ";
68  if (!sam.ok()) s << " !OK ";
69  s << std::endl;
70  }
71  return s;
72 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int samples() const
total number of samples in the digi
static const int MASK_OK
int i
Definition: DBlmapReader.cc:9
static const int MASK_SOI
void setFlags(uint16_t v)
set the flag word
static const int MASK_CAPID
static const int MASK_LE_TDC
int presamples() const
for backward compatibility
unsigned short data_type
Definition: DataFrame.h:20
bool linkError() const
edm::DataFrame m_data
void copyContent(const QIE10DataFrame &src)
static const int WORDS_PER_SAMPLE
edm::DataFrame::size_type size() const
more accessors
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
void setZSInfo(bool markAndPass)
set ZS params
static const int MASK_ADC
unsigned int size_type
Definition: DataFrame.h:18
tuple result
Definition: mps_fire.py:84
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
Sample(const edm::DataFrame &frame, edm::DataFrame::size_type i)
static const int MASK_MARKPASS
was this a mark-and-pass ZS event?
bool zsMarkAndPass() const
DetId detid() const
Get the detector id.
static const int OFFSET_TE_TDC
wide_type wideRaw() const
edm::DataFrame::data_type word1_
edm::DataFrame::data_type word2_
static const int HEADER_WORDS
static const int MASK_TE_TDC
void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi=false, bool ok=true)
set the sample contents
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
static const int OFFSET_CAPID