test
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 
8 #include <iostream>
9 #include <algorithm>
10 #include <iterator>
11 
12 using namespace std;
13 
14 // Constructors
15 CSCComparatorDigi::CSCComparatorDigi( int strip, int comparator, int timeBinWord )
16  : strip_( strip ), comparator_( comparator ), timeBinWord_( timeBinWord ) {
17 }
18 
19 
21  : strip_( 0 ), comparator_( 0 ), timeBinWord_( 0 ) {
22 }
23 
24 
25 // Comparison
26 
27 bool
29  if ( getStrip() != digi.getStrip() ) return false;
30  if ( getComparator() != digi.getComparator() ) return false;
31  if ( getTimeBinWord() != digi.getTimeBinWord() ) return false;
32  return true;
33 }
34 
35 
36 //@@ If one wanted to order comparator digis how would one want op< to behave?
37 // I don't know...
38 // I think LHS < RHS only makes sense if
39 // i) time(LHS) .eq. time(RHS)
40 // AND
41 // ii) strip(LHS) .lt. strip(RHS)
42 // But I don't see how this can be useful.
43 
44 bool
46  bool result = false;
47  if(getTimeBin() == digi.getTimeBin()) {
48  result = (getStrip() < digi.getStrip());
49  }
50  return result;
51 }
52 
53 
54 // Getters
55 
57  // Find first bin which fired, counting from 0
58  uint16_t tbit=1;
59  int tbin=-1;
60  for(int i=0;i<16;++i) {
61  if(tbit & timeBinWord_) {
62  tbin=i;
63  break;
64  }
65  tbit=tbit<<1;
66  }
67  return tbin;
68 }
69 
70 // This definition is consistent with the one used in
71 // the function CSCCLCTData::add() in EventFilter/CSCRawToDigi
72 // The halfstrip counts from 0!
74  return (getStrip() - 1) * 2 + getComparator();
75 }
76 
77 std::vector<int> CSCComparatorDigi::getTimeBinsOn() const {
78  std::vector<int> tbins;
79  uint16_t tbit = timeBinWord_;
80  const uint16_t one=1;
81  for(int i=0;i<16;++i) {
82  if(tbit & one) tbins.push_back(i);
83  tbit=tbit>>1;
84  if(tbit==0) break; // end already if no more bits set
85  }
86  return tbins;
87 }
88 
89 // Setters
90 //@@ No way to set time word?
91 
92 void CSCComparatorDigi::setStrip(int strip) {
93  strip_ = strip;
94 }
95 void CSCComparatorDigi::setComparator(int comparator) {
96  comparator_ = comparator;
97 }
98 
99 // Output
100 
101 void
103  std::ostringstream ost;
104  ost << "CSCComparatorDigi | strip " << getStrip()
105  << " | comparator " << getComparator()
106  << " | first time bin " << getTimeBin() << " | time bins on ";
107  std::vector<int> tbins=getTimeBinsOn();
108  for(unsigned int i=0; i<tbins.size();i++) {ost << tbins[i] << " ";}
109  edm::LogVerbatim("CSCDigi") << ost.str();
110 }
111 
112 //@@ Doesn't print all time bins
113 std::ostream & operator<<(std::ostream & o, const CSCComparatorDigi& digi) {
114  return o << " " << digi.getStrip()
115  << " " << digi.getComparator()
116  << " " << digi.getTimeBin();
117 }
118 
119 
int i
Definition: DBlmapReader.cc:9
int getHalfStrip() const
Get the associated halfstrip number for this comparator digi. Counts from 0.
int getStrip() const
Get the strip number. Counts from 1.
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:188
int getComparator() const
Get Comparator readings. Can be 0 or 1.
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.
tuple result
Definition: mps_fire.py:84
bool operator<(const CSCComparatorDigi &digi) const
sort by time first, then by strip
std::vector< int > getTimeBinsOn() const
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.