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...
 
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::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
float CSCComparatorDigi::getFractionalStrip ( ) const

Return the fractional half-strip. Counts from 0.25.

Definition at line 78 of file CSCComparatorDigi.cc.

References getComparator(), and getStrip().

Referenced by getTimeBinWord().

78  {
79  return getStrip() + getComparator() * 0.5f - 0.75f;
80 }
int getStrip() const
Get the strip number. Counts from 1.
int getComparator() const
Get Comparator readings. Can be 0 or 1.
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(), getFractionalStrip(), 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 82 of file CSCComparatorDigi.cc.

References mps_fire::i, and timeBinWord_.

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

82  {
83  std::vector<int> tbins;
84  uint16_t tbit = timeBinWord_;
85  const uint16_t one=1;
86  for(int i=0;i<16;++i) {
87  if(tbit & one) tbins.push_back(i);
88  tbit=tbit>>1;
89  if(tbit==0) break; // end already if no more bits set
90  }
91  return tbins;
92 }
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 getFractionalStrip(), 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 107 of file CSCComparatorDigi.cc.

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

Referenced by getTimeBinWord().

107  {
108  std::ostringstream ost;
109  ost << "CSCComparatorDigi | strip " << getStrip()
110  << " | comparator " << getComparator()
111  << " | first time bin " << getTimeBin() << " | time bins on ";
112  std::vector<int> tbins=getTimeBinsOn();
113  for(unsigned int i=0; i<tbins.size();i++) {ost << tbins[i] << " ";}
114  edm::LogVerbatim("CSCDigi") << ost.str();
115 }
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 100 of file CSCComparatorDigi.cc.

References comparator_.

Referenced by getTimeBinWord().

100  {
101  comparator_ = comparator;
102 }
void CSCComparatorDigi::setStrip ( int  strip)

Set the strip number.

Definition at line 97 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 70 of file CSCComparatorDigi.h.

Referenced by getComparator(), and setComparator().

uint16_t CSCComparatorDigi::strip_
private

Definition at line 69 of file CSCComparatorDigi.h.

Referenced by getStrip(), and setStrip().

uint16_t CSCComparatorDigi::timeBinWord_
private

Definition at line 71 of file CSCComparatorDigi.h.

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