CMS 3D CMS Logo

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 CSCComparatorDigi::CSCComparatorDigi() : strip_(0), comparator_(0), timeBinWord_(0) {}
19 
20 // Comparison
21 
23  if (getStrip() != digi.getStrip())
24  return false;
25  if (getComparator() != digi.getComparator())
26  return false;
27  if (getTimeBinWord() != digi.getTimeBinWord())
28  return false;
29  return true;
30 }
31 
32 //@@ If one wanted to order comparator digis how would one want op< to behave?
33 // I don't know...
34 // I think LHS < RHS only makes sense if
35 // i) time(LHS) .eq. time(RHS)
36 // AND
37 // ii) strip(LHS) .lt. strip(RHS)
38 // But I don't see how this can be useful.
39 
41  bool result = false;
42  if (getTimeBin() == digi.getTimeBin()) {
43  result = (getStrip() < digi.getStrip());
44  }
45  return result;
46 }
47 
48 // Getters
49 
51  // Find first bin which fired, counting from 0
52  uint16_t tbit = 1;
53  int tbin = -1;
54  for (int i = 0; i < 16; ++i) {
55  if (tbit & timeBinWord_) {
56  tbin = i;
57  break;
58  }
59  tbit = tbit << 1;
60  }
61  return tbin;
62 }
63 
64 // This definition is consistent with the one used in
65 // the function CSCComparatorData::add() in EventFilter/CSCRawToDigi
66 // The halfstrip counts from 0!
67 int CSCComparatorDigi::getHalfStrip() const { return (getStrip() - 1) * 2 + getComparator(); }
68 
69 // Return the fractional half-strip
70 float CSCComparatorDigi::getFractionalStrip() const { return getStrip() + getComparator() * 0.5f - 0.75f; }
71 
72 std::vector<int> CSCComparatorDigi::getTimeBinsOn() const {
73  std::vector<int> tbins;
74  uint16_t tbit = timeBinWord_;
75  const uint16_t one = 1;
76  for (int i = 0; i < 16; ++i) {
77  if (tbit & one)
78  tbins.push_back(i);
79  tbit = tbit >> 1;
80  if (tbit == 0)
81  break; // end already if no more bits set
82  }
83  return tbins;
84 }
85 
86 // Setters
87 //@@ No way to set time word?
88 
90 void CSCComparatorDigi::setComparator(int comparator) { comparator_ = comparator; }
91 
92 // Output
93 
95  std::ostringstream ost;
96  ost << "CSCComparatorDigi | strip " << getStrip() << " | comparator " << getComparator() << " | first time bin "
97  << getTimeBin() << " | time bins on ";
98  std::vector<int> tbins = getTimeBinsOn();
99  for (unsigned int i = 0; i < tbins.size(); i++) {
100  ost << tbins[i] << " ";
101  }
102  edm::LogVerbatim("CSCDigi") << ost.str();
103 }
104 
105 //@@ Doesn't print all time bins
106 std::ostream& operator<<(std::ostream& o, const CSCComparatorDigi& digi) {
107  return o << " " << digi.getStrip() << " " << digi.getComparator() << " " << digi.getTimeBin();
108 }
CSCComparatorDigi::setComparator
void setComparator(int comparator)
Set Comparator data.
Definition: CSCComparatorDigi.cc:90
CSCComparatorDigi::print
void print() const
Print content of digi.
Definition: CSCComparatorDigi.cc:94
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
MessageLogger.h
CSCComparatorDigi::getFractionalStrip
float getFractionalStrip() const
Return the fractional half-strip. Counts from 0.25.
Definition: CSCComparatorDigi.cc:70
CSCComparatorDigi::operator==
bool operator==(const CSCComparatorDigi &digi) const
Digis are equal if they are on the same strip and have same Comparator data.
Definition: CSCComparatorDigi.cc:22
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
CSCComparatorDigi::setStrip
void setStrip(int strip)
Set the strip number.
Definition: CSCComparatorDigi.cc:89
CSCComparatorDigi::timeBinWord_
uint16_t timeBinWord_
Definition: CSCComparatorDigi.h:66
CSCComparatorDigi::getComparator
int getComparator() const
Get Comparator readings. Can be 0 or 1.
Definition: CSCComparatorDigi.h:35
CSCComparatorDigi::getTimeBin
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
Definition: CSCComparatorDigi.cc:50
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
CSCComparatorDigi.h
CSCComparatorDigi::CSCComparatorDigi
CSCComparatorDigi()
comparator here can be either 0 or 1 for left or right halfstrip of given strip
Definition: CSCComparatorDigi.cc:18
CSCComparatorDigi::comparator_
uint16_t comparator_
Definition: CSCComparatorDigi.h:65
CSCComparatorDigi
Definition: CSCComparatorDigi.h:16
CSCComparatorDigi::getTimeBinsOn
std::vector< int > getTimeBinsOn() const
Definition: CSCComparatorDigi.cc:72
CSCComparatorDigi::getTimeBinWord
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
Definition: CSCComparatorDigi.h:38
std
Definition: JetResolutionObject.h:76
CSCComparatorDigi::getHalfStrip
int getHalfStrip() const
Get the associated halfstrip number for this comparator digi. Counts from 0.
Definition: CSCComparatorDigi.cc:67
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CSCComparatorDigi::operator<
bool operator<(const CSCComparatorDigi &digi) const
sort by time first, then by strip
Definition: CSCComparatorDigi.cc:40
CSCComparatorDigi::getStrip
int getStrip() const
Get the strip number. Counts from 1.
Definition: CSCComparatorDigi.h:32
mps_fire.result
result
Definition: mps_fire.py:311
operator<<
std::ostream & operator<<(std::ostream &o, const CSCComparatorDigi &digi)
Output operator.
Definition: CSCComparatorDigi.cc:106
CSCComparatorDigi::strip_
uint16_t strip_
Definition: CSCComparatorDigi.h:64