CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCComparatorDigi.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <algorithm>
9 #include <iterator>
10 
11 using namespace std;
12 
13 // Constructors
14 CSCComparatorDigi::CSCComparatorDigi( int strip, int comparator, int timeBinWord )
15  : strip_( strip ), comparator_( comparator ), timeBinWord_( timeBinWord ) {
16 }
17 
18 
20  : strip_( 0 ), comparator_( 0 ), timeBinWord_( 0 ) {
21 }
22 
23 
24 // Comparison
25 
26 bool
28  if ( getStrip() != digi.getStrip() ) return false;
29  if ( getComparator() != digi.getComparator() ) return false;
30  if ( getTimeBinWord() != digi.getTimeBinWord() ) return false;
31  return true;
32 }
33 
34 
35 //@@ If one wanted to order comparator digis how would one want op< to behave?
36 // I don't know...
37 // I think LHS < RHS only makes sense if
38 // i) time(LHS) .eq. time(RHS)
39 // AND
40 // ii) strip(LHS) .lt. strip(RHS)
41 // But I don't see how this can be useful.
42 
43 bool
45  bool result = false;
46  if(getTimeBin() == digi.getTimeBin()) {
47  result = (getStrip() < digi.getStrip());
48  }
49  return result;
50 }
51 
52 
53 // Getters
54 
56  // Find first bin which fired, counting from 0
57  uint16_t tbit=1;
58  int tbin=-1;
59  for(int i=0;i<16;++i) {
60  if(tbit & timeBinWord_) {
61  tbin=i;
62  break;
63  }
64  tbit=tbit<<1;
65  }
66  return tbin;
67 }
68 
69 std::vector<int> CSCComparatorDigi::getTimeBinsOn() const {
70  std::vector<int> tbins;
71  uint16_t tbit = timeBinWord_;
72  const uint16_t one=1;
73  for(int i=0;i<16;++i) {
74  if(tbit & one) tbins.push_back(i);
75  tbit=tbit>>1;
76  if(tbit==0) break; // end already if no more bits set
77  }
78  return tbins;
79 }
80 
81 // Setters
82 //@@ No way to set time word?
83 
84 void CSCComparatorDigi::setStrip(int strip) {
85  strip_ = strip;
86 }
87 void CSCComparatorDigi::setComparator(int comparator) {
88  comparator_ = comparator;
89 }
90 
91 // Output
92 
93 void
95  std::cout << "CSCComparatorDigi strip: " << getStrip()
96  << " comparator: " << getComparator()
97  << " first time bin: "<< getTimeBin()
98  << " time bins on: ";
99  std::vector<int> tbins=getTimeBinsOn();
100  std::copy( tbins.begin(), tbins.end(),
101  std::ostream_iterator<int>( std::cout, " "));
102  std::cout << std::endl;
103 }
104 
105 //@@ Doesn't print all time bins
106 std::ostream & operator<<(std::ostream & o, const CSCComparatorDigi& digi) {
107  return o << " " << digi.getStrip()
108  << " " << digi.getComparator()
109  << " " << digi.getTimeBin();
110 }
111 
112 
int i
Definition: DBlmapReader.cc:9
int getStrip() const
Get the strip number.
void setComparator(int comparator)
Set Comparator data.
void print() const
Print content of digi.
void setStrip(int strip)
Set the strip number.
CSCComparatorDigi()
comparator here can be either 0 or 1 for left or right halfstrip of given strip
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
int getComparator() const
Get Comparator readings.
bool operator==(const CSCComparatorDigi &digi) const
Digis are equal if they are on the same strip and have same Comparator data.
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
bool operator<(const CSCComparatorDigi &digi) const
sort by time first, then by strip
tuple result
Definition: query.py:137
std::vector< int > getTimeBinsOn() const
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
tuple cout
Definition: gather_cfg.py:121