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
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
uint32_t algoDepend_[8]
Definition: HcalTTPDigi.h:51
int size() const
Definition: HcalTTPDigi.h:34
unsigned int pipelineLength() const
Definition: HcalTTPDigi.h:38
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:35
int presamples_
Definition: HcalTTPDigi.h:45
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:37
std::vector< bool > inputPattern(int relativeSample=0) const
Definition: HcalTTPDigi.cc:42
tuple out
Definition: dbtoconf.py:99
uint8_t triggerOutput_[8]
Definition: HcalTTPDigi.h:52
int algorithm() const
Definition: HcalTTPDigi.h:36
uint16_t triggerInputs_[5 *8]
Definition: HcalTTPDigi.h:50
int id() const
Definition: HcalTTPDigi.h:33