CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CSCComparatorDigi Class Reference

#include <CSCComparatorDigi.h>

Public Member Functions

 CSCComparatorDigi ()
 comparator here can be either 0 or 1 for left or right halfstrip of given strip More...
 
 CSCComparatorDigi (int strip, int comparator, int timeBinWord)
 Construct from the strip number and the ADC readings. More...
 
int getComparator () const
 Get Comparator readings. Can be 0 or 1. More...
 
float getFractionalStrip () const
 Return the fractional half-strip. Counts from 0.25. More...
 
int getHalfStrip () const
 Get the associated halfstrip number for this comparator digi. Counts from 0. More...
 
int getStrip () const
 Get the strip number. Counts from 1. More...
 
int getTimeBin () const
 Return bin number of first time bin which is ON. Counts from 0. More...
 
std::vector< int > getTimeBinsOn () const
 
int getTimeBinWord () const
 Return the word with each bit corresponding to a time bin. More...
 
bool operator< (const CSCComparatorDigi &digi) const
 sort by time first, then by strip More...
 
bool operator== (const CSCComparatorDigi &digi) const
 Digis are equal if they are on the same strip and have same Comparator data. More...
 
void print () const
 Print content of digi. More...
 
void setComparator (int comparator)
 Set Comparator data. More...
 
void setStrip (int strip)
 Set the strip number. More...
 

Private Attributes

uint16_t comparator_
 
uint16_t strip_
 
uint16_t timeBinWord_
 

Detailed Description

Digi for CSC Comparators.

Author
M. Schmitt, Northwestern

Definition at line 16 of file CSCComparatorDigi.h.

Constructor & Destructor Documentation

◆ CSCComparatorDigi() [1/2]

CSCComparatorDigi::CSCComparatorDigi ( int  strip,
int  comparator,
int  timeBinWord 
)

Construct from the strip number and the ADC readings.

Definition at line 15 of file CSCComparatorDigi.cc.

16  : strip_(strip), comparator_(comparator), timeBinWord_(timeBinWord) {}

◆ CSCComparatorDigi() [2/2]

CSCComparatorDigi::CSCComparatorDigi ( )

comparator here can be either 0 or 1 for left or right halfstrip of given strip

Default construction.

Definition at line 18 of file CSCComparatorDigi.cc.

18 : strip_(0), comparator_(0), timeBinWord_(0) {}

Member Function Documentation

◆ getComparator()

int CSCComparatorDigi::getComparator ( ) const
inline

Get Comparator readings. Can be 0 or 1.

Definition at line 35 of file CSCComparatorDigi.h.

35 { return comparator_; }

References comparator_.

Referenced by CSCComparatorData::add(), getFractionalStrip(), getHalfStrip(), operator<<(), operator==(), and print().

◆ getFractionalStrip()

float CSCComparatorDigi::getFractionalStrip ( ) const

Return the fractional half-strip. Counts from 0.25.

Definition at line 70 of file CSCComparatorDigi.cc.

70 { return getStrip() + getComparator() * 0.5f - 0.75f; }

References getComparator(), and getStrip().

◆ getHalfStrip()

int CSCComparatorDigi::getHalfStrip ( ) const

Get the associated halfstrip number for this comparator digi. Counts from 0.

Definition at line 67 of file CSCComparatorDigi.cc.

67 { return (getStrip() - 1) * 2 + getComparator(); }

References getComparator(), and getStrip().

◆ getStrip()

int CSCComparatorDigi::getStrip ( ) const
inline

Get the strip number. Counts from 1.

Definition at line 32 of file CSCComparatorDigi.h.

32 { return strip_; }

References strip_.

Referenced by CSCComparatorData::add(), getFractionalStrip(), getHalfStrip(), operator<(), operator<<(), operator==(), and print().

◆ getTimeBin()

int CSCComparatorDigi::getTimeBin ( ) const

Return bin number of first time bin which is ON. Counts from 0.

Definition at line 50 of file CSCComparatorDigi.cc.

50  {
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 }

References mps_fire::i, and timeBinWord_.

Referenced by operator<(), operator<<(), and print().

◆ getTimeBinsOn()

std::vector< int > CSCComparatorDigi::getTimeBinsOn ( ) const

Return vector of the bin numbers for which time bins are ON. e.g. if bits 0 and 13 fired, then this vector will contain the values 0 and 13

Definition at line 72 of file CSCComparatorDigi.cc.

72  {
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 }

References mps_fire::i, SiPixelPI::one, and timeBinWord_.

Referenced by CSCComparatorData::add(), and print().

◆ getTimeBinWord()

int CSCComparatorDigi::getTimeBinWord ( ) const
inline

Return the word with each bit corresponding to a time bin.

Definition at line 38 of file CSCComparatorDigi.h.

38 { return timeBinWord_; }

References timeBinWord_.

Referenced by operator==().

◆ operator<()

bool CSCComparatorDigi::operator< ( const CSCComparatorDigi digi) const

sort by time first, then by strip

Definition at line 40 of file CSCComparatorDigi.cc.

40  {
41  bool result = false;
42  if (getTimeBin() == digi.getTimeBin()) {
43  result = (getStrip() < digi.getStrip());
44  }
45  return result;
46 }

References getStrip(), getTimeBin(), and mps_fire::result.

◆ operator==()

bool CSCComparatorDigi::operator== ( const CSCComparatorDigi digi) const

Digis are equal if they are on the same strip and have same Comparator data.

Definition at line 22 of file CSCComparatorDigi.cc.

22  {
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 }

References getComparator(), getStrip(), and getTimeBinWord().

◆ print()

void CSCComparatorDigi::print ( void  ) const

Print content of digi.

Definition at line 94 of file CSCComparatorDigi.cc.

94  {
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 }

References getComparator(), getStrip(), getTimeBin(), getTimeBinsOn(), and mps_fire::i.

◆ setComparator()

void CSCComparatorDigi::setComparator ( int  comparator)

Set Comparator data.

Definition at line 90 of file CSCComparatorDigi.cc.

90 { comparator_ = comparator; }

References comparator_.

◆ setStrip()

void CSCComparatorDigi::setStrip ( int  strip)

Set the strip number.

Definition at line 89 of file CSCComparatorDigi.cc.

89 { strip_ = strip; }

References digitizers_cfi::strip, and strip_.

Member Data Documentation

◆ comparator_

uint16_t CSCComparatorDigi::comparator_
private

Definition at line 65 of file CSCComparatorDigi.h.

Referenced by getComparator(), and setComparator().

◆ strip_

uint16_t CSCComparatorDigi::strip_
private

Definition at line 64 of file CSCComparatorDigi.h.

Referenced by getStrip(), and setStrip().

◆ timeBinWord_

uint16_t CSCComparatorDigi::timeBinWord_
private

Definition at line 66 of file CSCComparatorDigi.h.

Referenced by getTimeBin(), getTimeBinsOn(), and getTimeBinWord().

mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
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
CSCComparatorDigi::comparator_
uint16_t comparator_
Definition: CSCComparatorDigi.h:65
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
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
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
CSCComparatorDigi::strip_
uint16_t strip_
Definition: CSCComparatorDigi.h:64