CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Phase2TrackerDigi.h
Go to the documentation of this file.
1 #ifndef DataFormats_Phase2TrackerDigi_Phase2TrackerDigi_H
2 #define DataFormats_Phase2TrackerDigi_Phase2TrackerDigi_H
3 
4 #include <cstdint>
5 #include <utility>
6 #include <cassert>
7 
13 public:
14  typedef uint16_t PackedDigiType;
15 
16  Phase2TrackerDigi(unsigned int packed_channel) : theChannel(packed_channel) {}
17 
18  Phase2TrackerDigi(unsigned int row, unsigned int col) { theChannel = pixelToChannel(row, col); }
19 
20  Phase2TrackerDigi(unsigned int row, unsigned int col, bool ot_flag) {
21  theChannel = pixelToChannel(row, col);
22  if (ot_flag)
23  theChannel |= (1 << 15);
24  }
25 
27 
28  // Access to digi information - pixel sensors
29  unsigned int row() const { return channelToRow(theChannel); }
30  unsigned int column() const { return channelToColumn(theChannel); }
31  // Access to digi information - strip sensors
32  unsigned int strip() const { return row(); }
33  unsigned int edge() const { return column(); } // CD: any better name for that?
34  // Access to the (raw) channel number
35  unsigned int channel() const { return 0x7FFF & theChannel; }
36  // Access Overthreshold bit
37  bool overThreshold() const { return (otBit(theChannel) ? true : false); }
38 
39  static std::pair<unsigned int, unsigned int> channelToPixel(unsigned int ch) {
40  return std::pair<unsigned int, unsigned int>(channelToRow(ch), channelToColumn(ch));
41  }
42 
43  static PackedDigiType pixelToChannel(unsigned int row, unsigned int col) {
44  assert(row < 1016);
45  assert(col < 32);
46  return row | (col << 10);
47  }
48 
49 private:
51  static unsigned int channelToRow(unsigned int ch) { return ch & 0x03FF; }
52  static unsigned int channelToColumn(unsigned int ch) { return ((ch >> 10) & 0x1F); }
53  static unsigned int otBit(unsigned int ch) { return ((ch >> 15) & 0x1); }
54 };
55 
56 // Comparison operators
57 inline bool operator<(const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
58  return one.channel() < other.channel();
59 }
60 
61 // distance operators
62 inline int operator-(const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
63  return int(one.channel()) - int(other.channel());
64 }
65 
66 #include <iostream>
67 inline std::ostream& operator<<(std::ostream& o, const Phase2TrackerDigi& digi) { return o << " " << digi.channel(); }
68 
69 #endif // DataFormats_Phase2TrackerDigi_Phase2TrackerDigi_H
unsigned int column() const
bool overThreshold() const
unsigned int row() const
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Phase2TrackerDigi(unsigned int packed_channel)
Phase2TrackerDigi(unsigned int row, unsigned int col, bool ot_flag)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
assert(be >=bs)
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
unsigned int channel() const
static unsigned int otBit(unsigned int ch)
static unsigned int channelToRow(unsigned int ch)
unsigned int edge() const
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:70
static std::pair< unsigned int, unsigned int > channelToPixel(unsigned int ch)
PackedDigiType theChannel
int col
Definition: cuy.py:1009
unsigned int strip() const
Phase2TrackerDigi(unsigned int row, unsigned int col)
static unsigned int channelToColumn(unsigned int ch)