CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalTTPDigi.cc
Go to the documentation of this file.
2 
3 HcalTTPDigi::HcalTTPDigi() : identifier_(0), samples_(0), presamples_(0), fwVersion_(0), algorithm_(0), lPipe_(0) {
4  for (int i = 0; i < 8; i++) {
5  algoDepend_[i] = 0;
6  triggerOutput_[i] = 0;
7  for (int j = 0; j < 5; j++)
8  triggerInputs_[j * 8 + i] = 0;
9  }
10 }
11 
13  int identifier, int samples, int presamples, unsigned int fwVersion, int algorithm, unsigned int lPipe)
14  : identifier_(identifier),
15  samples_(samples),
16  presamples_(presamples),
17  fwVersion_(fwVersion),
18  algorithm_(algorithm),
19  lPipe_(lPipe) {
20  for (int i = 0; i < 8; i++) {
21  algoDepend_[i] = 0x0;
22  triggerOutput_[i] = 0x0;
23  for (int j = 0; j < 5; j++)
24  triggerInputs_[i * 5 + j] = 0x0;
25  }
26 }
27 
28 void HcalTTPDigi::setSample(int relativeSample,
29  const uint16_t* triggerInputs,
30  const uint32_t algodep,
31  const uint8_t outputTrigger) {
32  int linSample = presamples_ + relativeSample;
33  if (linSample >= 0 && linSample < samples_) {
34  // Trigger input: 72 bits
35  for (int i = 0; i < 4; i++)
36  triggerInputs_[5 * linSample + i] = triggerInputs[i];
37  triggerInputs_[5 * linSample + 4] = triggerInputs[4] & 0xFF;
38  // Algo dependency: 20 bits
39  algoDepend_[linSample] = algodep & 0xFFFFF;
40  // Trigger output: 4 bits
41  triggerOutput_[linSample] = outputTrigger & 0xF;
42  }
43 }
44 
45 std::vector<bool> HcalTTPDigi::inputPattern(int relativeSample) const {
46  std::vector<bool> retval;
47  int linSample = presamples_ + relativeSample;
48  if (linSample >= 0 && linSample < samples_) {
49  for (int i = 0; i < 72; i++) {
50  int ioff = i / 16;
51  retval.push_back(triggerInputs_[linSample * 5 + ioff] & (1 << (i % 16)));
52  }
53  }
54  return retval;
55 }
56 
57 uint8_t HcalTTPDigi::triggerOutput(int relativeSample) const {
58  int linSample = presamples_ + relativeSample;
59  if (linSample >= 0 && linSample < samples_)
60  return triggerOutput_[linSample];
61  else
62  return 0;
63 }
64 
65 uint32_t HcalTTPDigi::algorithmWord(int relativeSample) const {
66  int linSample = presamples_ + relativeSample;
67  if (linSample >= 0 && linSample < samples_)
68  return algoDepend_[linSample];
69  else
70  return 0;
71 }
72 
73 bool HcalTTPDigi::operator==(const HcalTTPDigi& digi) const {
74  if (samples_ != digi.size() || presamples_ != digi.presamples())
75  return false;
76  int relativeSize = digi.size() - digi.presamples();
77  for (int i = -this->presamples(); i < relativeSize; i++) {
78  if (this->inputPattern(i) != digi.inputPattern(i))
79  return false;
80  if (this->algorithmWord(i) != digi.algorithmWord(i))
81  return false;
82  if (this->triggerOutput(i) != digi.triggerOutput(i))
83  return false;
84  }
85  return true;
86 }
87 
88 std::ostream& operator<<(std::ostream& out, const HcalTTPDigi& digi) {
89  out << "HcalTTPDigi " << digi.id() << " with " << digi.size() << " samples, " << digi.presamples() << " presamples. "
90  << std::endl;
91  out << "Firmware version " << digi.fwVersion() << " and flavor/algo " << digi.algorithm();
92  out << "; pipeline length " << digi.pipelineLength() << std::endl;
93  int relativeSize = digi.size() - digi.presamples();
94  for (int i = -digi.presamples(); i < relativeSize; i++) {
95  for (unsigned int j = digi.inputPattern(i).size(); j > 0; j--) {
96  if (!(j % 16))
97  out << " ";
98  out << digi.inputPattern(i).at(j - 1);
99  }
100  if (i < 0)
101  out << " (PRE)"; // Indicates presamples
102  out << std::endl;
103  out << "ALGO: ";
104  for (int j = 19; j >= 0; j--)
105  out << bool((digi.algorithmWord(i)) & (1 << j));
106 
107  out << " TRIG: ";
108  for (int j = 3; j >= 0; j--)
109  out << bool((digi.triggerOutput(i)) & (1 << j));
110  out << std::endl;
111  }
112 
113  return out;
114 }
uint32_t algoDepend_[8]
Definition: HcalTTPDigi.h:49
int size() const
Definition: HcalTTPDigi.h:32
unsigned int pipelineLength() const
Definition: HcalTTPDigi.h:36
uint32_t algorithmWord(int relativeSample=0) const
Definition: HcalTTPDigi.cc:65
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
int presamples() const
Definition: HcalTTPDigi.h:33
int presamples_
Definition: HcalTTPDigi.h:43
bool operator==(const HcalTTPDigi &digi) const
Definition: HcalTTPDigi.cc:73
uint8_t triggerOutput(int relativeSample=0) const
Definition: HcalTTPDigi.cc:57
void setSample(int relativeSample, const uint16_t *triggerInputs, const uint32_t algodep, const uint8_t outputTrigger)
Definition: HcalTTPDigi.cc:28
unsigned int fwVersion() const
Definition: HcalTTPDigi.h:35
std::vector< bool > inputPattern(int relativeSample=0) const
Definition: HcalTTPDigi.cc:45
uint8_t triggerOutput_[8]
Definition: HcalTTPDigi.h:50
int algorithm() const
Definition: HcalTTPDigi.h:34
uint16_t triggerInputs_[5 *8]
Definition: HcalTTPDigi.h:48
int id() const
Definition: HcalTTPDigi.h:31