CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCStripDigi.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <stdint.h>
9 
10 // Constructors
11 CSCStripDigi::CSCStripDigi (const int & istrip, const std::vector<int> & vADCCounts, const std::vector<uint16_t> & vADCOverflow, const std::vector<uint16_t> & vOverlap, const std::vector<uint16_t> & vErrorstat ):
12  strip(istrip),
13  ADCCounts(vADCCounts),
14  ADCOverflow(vADCOverflow),
15  OverlappedSample(vOverlap),
16  Errorstat(vErrorstat)
17 {
18 }
19 
20 CSCStripDigi::CSCStripDigi (const int & istrip, const std::vector<int> & vADCCounts):
21  strip(istrip),
22  ADCCounts(vADCCounts),
23  ADCOverflow(8,0),
24  OverlappedSample(8,0),
25  Errorstat(8,0)
26 {
27 }
28 
29 
31  strip(0),
32  ADCCounts(8,0),
33  ADCOverflow(8,0),
34  OverlappedSample(8,0),
35  Errorstat(8,0)
36 {
37 }
38 
39 std::vector<int> CSCStripDigi::getADCCounts() const { return ADCCounts; }
40 
41 
43 std::vector<int> CSCStripDigi::getL1APhase() const {
44  std::vector<int> L1APhaseResult;
45  for (int i=0; i<(int)getOverlappedSample().size(); i++) {
46  L1APhaseResult.push_back((getOverlappedSample()[i]>>8) & 0x1);}
47  return L1APhaseResult;
48 }
49 
50 // Comparison
51 bool
53  if ( getStrip() != digi.getStrip() ) return false;
54  if ( getADCCounts().size() != digi.getADCCounts().size() ) return false;
55  if ( getADCCounts() != digi.getADCCounts() ) return false;
56  return true;
57 }
58 
59 // Getters
60 //int CSCStripDigi::getStrip() const { return strip; }
61 //std::vector<int> CSCStripDigi::getADCCounts() const { return ADCCounts; }
62 
63 
64 // Setters
65 //void CSCStripDigi::setStrip(int istrip) {
66 // strip = istrip;
67 //}
68 
69 
70 void CSCStripDigi::setADCCounts(const std::vector<int>&vADCCounts) {
71  bool badVal = false;
72  for (int i=0; i<(int)vADCCounts.size(); i++) {
73  if (vADCCounts[i] < 1) badVal = true;
74  }
75  if ( !badVal ) {
76  ADCCounts = vADCCounts;
77  } else {
78  std::vector<int> ZeroCounts(8,0);
79  ADCCounts = ZeroCounts;
80  }
81 }
82 
83 // Debug
84 void
86  std::cout << "CSC Strip: " << getStrip() << " ADC Counts: ";
87  for (int i=0; i<(int)getADCCounts().size(); i++) {std::cout << getADCCounts()[i] << " ";}
88  std::cout << "\n";
89  std::cout << " " << " ADCOverflow: ";
90  for (int i=0; i<(int)getADCOverflow().size(); i++) {std::cout << getADCOverflow()[i] << " ";}
91  std::cout << "\n";
92  std::cout << " " << " OverflappedSample: ";
93  for (int i=0; i<(int)getOverlappedSample().size(); i++) {
94  //if(getOverlappedSample()[i]!=1)
95  std::cout << getOverlappedSample()[i] << " ";}
96  std::cout << "\n";
97  std::cout << " " << " L1APhases: ";
98  for(int i=0; i<(int)getL1APhase().size(); i++){
99  std::cout << getL1APhase()[i] << " ";
100  }
101  std::cout << "\n";
102 }
103 
104 std::ostream & operator<<(std::ostream & o, const CSCStripDigi& digi) {
105  o << " " << digi.getStrip();
106  for (size_t i = 0; i<digi.getADCCounts().size(); ++i ){
107  o <<" " <<(digi.getADCCounts())[i]; }
108  return o;
109 
110 }
111 
112 
113 
int i
Definition: DBlmapReader.cc:9
std::vector< int > getADCCounts() const
Get ADC readings.
Definition: CSCStripDigi.cc:39
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
std::vector< int > ADCCounts
Definition: CSCStripDigi.h:66
void setADCCounts(const std::vector< int > &ADCCounts)
Definition: CSCStripDigi.cc:70
int getStrip() const
Definition: CSCStripDigi.h:37
std::vector< int > getL1APhase() const
Get L1APhase from OverlappedSample (9th bit)
Definition: CSCStripDigi.cc:43
std::vector< uint16_t > getADCOverflow() const
Other getters.
Definition: CSCStripDigi.h:46
void print() const
Definition: CSCStripDigi.cc:85
bool operator==(const CSCStripDigi &digi) const
Definition: CSCStripDigi.cc:52
std::vector< uint16_t > getOverlappedSample() const
Definition: CSCStripDigi.h:47
tuple cout
Definition: gather_cfg.py:121