CMS 3D CMS Logo

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

#include <CSCComparatorDigi.h>

Public Member Functions

 CSCComparatorDigi (int strip, int comparator, int timeBinWord)
 Construct from the strip number and the ADC readings. More...
 
 CSCComparatorDigi ()
 comparator here can be either 0 or 1 for left or right halfstrip of given strip More...
 
int getCFEB () const
 Get the CFEB number. Counts from 0. More...
 
int getComparator () const
 Get Comparator readings. Can be 0 or 1. More...
 
int getDiStrip () const
 Get the distrip number. Counts from 0. 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 16 of file CSCComparatorDigi.cc.

17  : 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 19 of file CSCComparatorDigi.cc.

Member Function Documentation

◆ getCFEB()

int CSCComparatorDigi::getCFEB ( ) const

Get the CFEB number. Counts from 0.

Definition at line 71 of file CSCComparatorDigi.cc.

References CSCConstants::NUM_STRIPS_PER_CFEB, and strip_.

Referenced by CSCComparatorData::add().

71 { return (strip_ - 1) / CSCConstants::NUM_STRIPS_PER_CFEB; }
static constexpr int NUM_STRIPS_PER_CFEB
Definition: CSCConstants.h:60

◆ getComparator()

int CSCComparatorDigi::getComparator ( ) const
inline

Get Comparator readings. Can be 0 or 1.

Definition at line 41 of file CSCComparatorDigi.h.

References comparator_.

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

41 { return comparator_; }

◆ getDiStrip()

int CSCComparatorDigi::getDiStrip ( ) const

Get the distrip number. Counts from 0.

Definition at line 67 of file CSCComparatorDigi.cc.

References CSCConstants::NUM_STRIPS_PER_CFEB, and strip_.

Referenced by CSCComparatorData::add().

67 { return ((strip_ - 1) % CSCConstants::NUM_STRIPS_PER_CFEB) / 2; }
static constexpr int NUM_STRIPS_PER_CFEB
Definition: CSCConstants.h:60

◆ getFractionalStrip()

float CSCComparatorDigi::getFractionalStrip ( ) const

Return the fractional half-strip. Counts from 0.25.

Definition at line 79 of file CSCComparatorDigi.cc.

References getComparator(), and getStrip().

79 { return getStrip() + getComparator() * 0.5f - 0.75f; }
int getComparator() const
Get Comparator readings. Can be 0 or 1.
int getStrip() const
Get the strip number. Counts from 1.

◆ getHalfStrip()

int CSCComparatorDigi::getHalfStrip ( ) const

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

Definition at line 76 of file CSCComparatorDigi.cc.

References getComparator(), and getStrip().

Referenced by CSCComparatorData::add().

76 { return (getStrip() - 1) * 2 + getComparator(); }
int getComparator() const
Get Comparator readings. Can be 0 or 1.
int getStrip() const
Get the strip number. Counts from 1.

◆ getStrip()

int CSCComparatorDigi::getStrip ( ) const
inline

Get the strip number. Counts from 1.

Definition at line 35 of file CSCComparatorDigi.h.

References strip_.

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

35 { return strip_; }

◆ getTimeBin()

int CSCComparatorDigi::getTimeBin ( ) const

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

Definition at line 51 of file CSCComparatorDigi.cc.

References mps_fire::i, and timeBinWord_.

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

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

◆ 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 81 of file CSCComparatorDigi.cc.

References mps_fire::i, and timeBinWord_.

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

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

◆ getTimeBinWord()

int CSCComparatorDigi::getTimeBinWord ( ) const
inline

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

Definition at line 44 of file CSCComparatorDigi.h.

References timeBinWord_.

Referenced by operator==().

44 { return timeBinWord_; }

◆ operator<()

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

sort by time first, then by strip

Definition at line 41 of file CSCComparatorDigi.cc.

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

41  {
42  bool result = false;
43  if (getTimeBin() == digi.getTimeBin()) {
44  result = (getStrip() < digi.getStrip());
45  }
46  return result;
47 }
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
int getStrip() const
Get the strip number. Counts from 1.

◆ 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 23 of file CSCComparatorDigi.cc.

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

23  {
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 }
int getComparator() const
Get Comparator readings. Can be 0 or 1.
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
int getStrip() const
Get the strip number. Counts from 1.

◆ print()

void CSCComparatorDigi::print ( void  ) const

Print content of digi.

Definition at line 103 of file CSCComparatorDigi.cc.

References filterCSVwithJSON::copy, getComparator(), getStrip(), getTimeBin(), and getTimeBinsOn().

103  {
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 }
Log< level::Info, true > LogVerbatim
int getComparator() const
Get Comparator readings. Can be 0 or 1.
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
std::vector< int > getTimeBinsOn() const
int getStrip() const
Get the strip number. Counts from 1.

◆ setComparator()

void CSCComparatorDigi::setComparator ( int  comparator)

Set Comparator data.

Definition at line 99 of file CSCComparatorDigi.cc.

References comparator_.

99 { comparator_ = comparator; }

◆ setStrip()

void CSCComparatorDigi::setStrip ( int  strip)

Set the strip number.

Definition at line 98 of file CSCComparatorDigi.cc.

References nano_mu_digi_cff::strip, and strip_.

Member Data Documentation

◆ comparator_

uint16_t CSCComparatorDigi::comparator_
private

Definition at line 71 of file CSCComparatorDigi.h.

Referenced by getComparator(), and setComparator().

◆ strip_

uint16_t CSCComparatorDigi::strip_
private

Definition at line 70 of file CSCComparatorDigi.h.

Referenced by getCFEB(), getDiStrip(), getStrip(), and setStrip().

◆ timeBinWord_

uint16_t CSCComparatorDigi::timeBinWord_
private

Definition at line 72 of file CSCComparatorDigi.h.

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