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 getComparator () const
 Get Comparator readings. Can be 0 or 1. 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::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 ) {
17 }
CSCComparatorDigi::CSCComparatorDigi ( )

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

Default construction.

Definition at line 20 of file CSCComparatorDigi.cc.

21  : strip_( 0 ), comparator_( 0 ), timeBinWord_( 0 ) {
22 }

Member Function Documentation

int CSCComparatorDigi::getComparator ( ) const
inline

Get Comparator readings. Can be 0 or 1.

Definition at line 38 of file CSCComparatorDigi.h.

References comparator_.

Referenced by CSCCLCTData::add(), CSCDigiToRaw::add(), getHalfStrip(), operator<<(), operator==(), print(), and CSCCathodeLCTProcessor::readComparatorDigis().

38 { return comparator_; }
int CSCComparatorDigi::getHalfStrip ( ) const

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

Definition at line 73 of file CSCComparatorDigi.cc.

References getComparator(), and getStrip().

Referenced by getTimeBinWord().

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

Get the strip number. Counts from 1.

Definition at line 35 of file CSCComparatorDigi.h.

References strip_.

Referenced by CSCCLCTData::add(), CSCDigiToRaw::add(), getHalfStrip(), operator<(), operator<<(), operator==(), print(), and CSCCathodeLCTProcessor::readComparatorDigis().

35 { return strip_; }
int CSCComparatorDigi::getTimeBin ( ) const

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

Definition at line 56 of file CSCComparatorDigi.cc.

References mps_fire::i, and timeBinWord_.

Referenced by getTimeBinWord(), operator<(), operator<<(), print(), and CSCCathodeLCTProcessor::readComparatorDigis().

56  {
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 }
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 77 of file CSCComparatorDigi.cc.

References mps_fire::i, and timeBinWord_.

Referenced by CSCCLCTData::add(), getTimeBinWord(), and print().

77  {
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 }
int CSCComparatorDigi::getTimeBinWord ( ) const
inline

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

Definition at line 41 of file CSCComparatorDigi.h.

References getHalfStrip(), getTimeBin(), getTimeBinsOn(), print(), setComparator(), setStrip(), and timeBinWord_.

Referenced by CSCDigiToRaw::add(), and operator==().

41 { return timeBinWord_; }
bool CSCComparatorDigi::operator< ( const CSCComparatorDigi digi) const

sort by time first, then by strip

Definition at line 45 of file CSCComparatorDigi.cc.

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

45  {
46  bool result = false;
47  if(getTimeBin() == digi.getTimeBin()) {
48  result = (getStrip() < digi.getStrip());
49  }
50  return result;
51 }
int getStrip() const
Get the strip number. Counts from 1.
int getTimeBin() const
Return bin number of first time bin which is ON. Counts from 0.
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 28 of file CSCComparatorDigi.cc.

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

28  {
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 }
int getStrip() const
Get the strip number. Counts from 1.
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.
void CSCComparatorDigi::print ( void  ) const

Print content of digi.

Definition at line 102 of file CSCComparatorDigi.cc.

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

Referenced by getTimeBinWord().

102  {
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 }
int getStrip() const
Get the strip number. Counts from 1.
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
void CSCComparatorDigi::setComparator ( int  comparator)

Set Comparator data.

Definition at line 95 of file CSCComparatorDigi.cc.

References comparator_.

Referenced by getTimeBinWord().

95  {
96  comparator_ = comparator;
97 }
void CSCComparatorDigi::setStrip ( int  strip)

Set the strip number.

Definition at line 92 of file CSCComparatorDigi.cc.

References digi_MixPreMix_cfi::strip, and strip_.

Referenced by getTimeBinWord().

Member Data Documentation

uint16_t CSCComparatorDigi::comparator_
private

Definition at line 67 of file CSCComparatorDigi.h.

Referenced by getComparator(), and setComparator().

uint16_t CSCComparatorDigi::strip_
private

Definition at line 66 of file CSCComparatorDigi.h.

Referenced by getStrip(), and setStrip().

uint16_t CSCComparatorDigi::timeBinWord_
private

Definition at line 68 of file CSCComparatorDigi.h.

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