CMS 3D CMS Logo

CSCComparatorDigi.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 #include <algorithm>
11 #include <iterator>
12 
13 using namespace std;
14 
15 // Constructors
16 CSCComparatorDigi::CSCComparatorDigi(int strip, int comparator, int timeBinWord)
17  : strip_(strip), comparator_(comparator), timeBinWord_(timeBinWord) {}
18 
19 CSCComparatorDigi::CSCComparatorDigi() : strip_(0), comparator_(0), timeBinWord_(0) {}
20 
21 // Comparison
22 
24  if (getStrip() != digi.getStrip())
25  return false;
26  if (getComparator() != digi.getComparator())
27  return false;
28  if (getTimeBinWord() != digi.getTimeBinWord())
29  return false;
30  return true;
31 }
32 
33 //@@ If one wanted to order comparator digis how would one want op< to behave?
34 // I don't know...
35 // I think LHS < RHS only makes sense if
36 // i) time(LHS) .eq. time(RHS)
37 // AND
38 // ii) strip(LHS) .lt. strip(RHS)
39 // But I don't see how this can be useful.
40 
42  bool result = false;
43  if (getTimeBin() == digi.getTimeBin()) {
44  result = (getStrip() < digi.getStrip());
45  }
46  return result;
47 }
48 
49 // Getters
50 
52  // Find first bin which fired, counting from 0
53  uint16_t tbit = 1;
54  int tbin = -1;
55  for (int i = 0; i < 16; ++i) {
56  if (tbit & timeBinWord_) {
57  tbin = i;
58  break;
59  }
60  tbit = tbit << 1;
61  }
62  return tbin;
63 }
64 
66 // originally defined in EventFilter/CSCRawToDigi/src/CSCComparatorData.cc
68 
70 // originally defined in EventFilter/CSCRawToDigi/src/CSCComparatorData.cc
72 
73 // This definition is consistent with the one used in
74 // the function CSCComparatorData::add() in EventFilter/CSCRawToDigi
75 // The halfstrip counts from 0!
76 int CSCComparatorDigi::getHalfStrip() const { return (getStrip() - 1) * 2 + getComparator(); }
77 
78 // Return the fractional half-strip
79 float CSCComparatorDigi::getFractionalStrip() const { return getStrip() + getComparator() * 0.5f - 0.75f; }
80 
81 std::vector<int> CSCComparatorDigi::getTimeBinsOn() const {
82  std::vector<int> tbins;
83  uint16_t tbit = timeBinWord_;
84  const uint16_t one = 1;
85  for (int i = 0; i < 16; ++i) {
86  if (tbit & one)
87  tbins.push_back(i);
88  tbit = tbit >> 1;
89  if (tbit == 0)
90  break; // end already if no more bits set
91  }
92  return tbins;
93 }
94 
95 // Setters
96 //@@ No way to set time word?
97 
99 void CSCComparatorDigi::setComparator(int comparator) { comparator_ = comparator; }
100 
101 // Output
102 
104  std::ostringstream ost;
105  ost << "CSCComparatorDigi | strip " << getStrip() << " | comparator " << getComparator() << " | first time bin "
106  << getTimeBin() << " | time bins on ";
107  std::vector<int> tbins = getTimeBinsOn();
108  std::copy(tbins.begin(), tbins.end(), std::ostream_iterator<int>(ost, " "));
109  edm::LogVerbatim("CSCDigi") << ost.str();
110 }
111 
112 std::ostream& operator<<(std::ostream& o, const CSCComparatorDigi& digi) {
113  o << "CSCComparatorDigi Strip:" << digi.getStrip() << ", Comparator: " << digi.getComparator()
114  << ", First Time Bin On: " << digi.getTimeBin() << ", Time Bins On: ";
115  std::vector<int> tbins = digi.getTimeBinsOn();
116  std::copy(tbins.begin(), tbins.end(), std::ostream_iterator<int>(o, " "));
117  return o;
118 }
CSCComparatorDigi::setComparator
void setComparator(int comparator)
Set Comparator data.
Definition: CSCComparatorDigi.cc:99
CSCComparatorDigi::print
void print() const
Print content of digi.
Definition: CSCComparatorDigi.cc:103
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
MessageLogger.h
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
CSCComparatorDigi::getFractionalStrip
float getFractionalStrip() const
Return the fractional half-strip. Counts from 0.25.
Definition: CSCComparatorDigi.cc:79
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:23
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
CSCComparatorDigi::setStrip
void setStrip(int strip)
Set the strip number.
Definition: CSCComparatorDigi.cc:98
CSCComparatorDigi::timeBinWord_
uint16_t timeBinWord_
Definition: CSCComparatorDigi.h:72
CSCComparatorDigi::getComparator
int getComparator() const
Get Comparator readings. Can be 0 or 1.
Definition: CSCComparatorDigi.h:41
CSCComparatorDigi::getTimeBin
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
Definition: CSCComparatorDigi.cc:51
CSCComparatorDigi::getCFEB
int getCFEB() const
Get the CFEB number. Counts from 0.
Definition: CSCComparatorDigi.cc:71
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
CSCConstants::NUM_STRIPS_PER_CFEB
Definition: CSCConstants.h:60
CSCComparatorDigi.h
CSCComparatorDigi::CSCComparatorDigi
CSCComparatorDigi()
comparator here can be either 0 or 1 for left or right halfstrip of given strip
Definition: CSCComparatorDigi.cc:19
CSCComparatorDigi::comparator_
uint16_t comparator_
Definition: CSCComparatorDigi.h:71
CSCConstants.h
CSCComparatorDigi
Definition: CSCComparatorDigi.h:16
CSCComparatorDigi::getTimeBinsOn
std::vector< int > getTimeBinsOn() const
Definition: CSCComparatorDigi.cc:81
CSCComparatorDigi::getTimeBinWord
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
Definition: CSCComparatorDigi.h:44
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:76
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:41
CSCComparatorDigi::getStrip
int getStrip() const
Get the strip number. Counts from 1.
Definition: CSCComparatorDigi.h:35
mps_fire.result
result
Definition: mps_fire.py:311
CSCComparatorDigi::getDiStrip
int getDiStrip() const
Get the distrip number. Counts from 0.
Definition: CSCComparatorDigi.cc:67
operator<<
std::ostream & operator<<(std::ostream &o, const CSCComparatorDigi &digi)
Output operator.
Definition: CSCComparatorDigi.cc:112
CSCComparatorDigi::strip_
uint16_t strip_
Definition: CSCComparatorDigi.h:70