CMS 3D CMS Logo

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