CMS 3D CMS Logo

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 
15  typedef uint16_t PackedDigiType;
16 
17  Phase2TrackerDigi( unsigned int packed_channel) : theChannel(packed_channel) {}
18 
19  Phase2TrackerDigi( unsigned int row, unsigned int col) {
20  theChannel = pixelToChannel(row,col);
21  }
22 
23  Phase2TrackerDigi( unsigned int row, unsigned int col, bool ot_flag) {
24  theChannel = pixelToChannel(row,col);
25  if (ot_flag) theChannel |= (1<< 15);
26  }
27 
29 
30  // Access to digi information - pixel sensors
31  unsigned int row() const { return channelToRow(theChannel); }
32  unsigned int column() const { return channelToColumn(theChannel); }
33  // Access to digi information - strip sensors
34  unsigned int strip() const { return row(); }
35  unsigned int edge() const { return column(); } // CD: any better name for that?
36  // Access to the (raw) channel number
37  unsigned int channel() const { return 0x7FFF & theChannel; }
38  // Access Overthreshold bit
39  bool overThreshold() const { return (otBit(theChannel) ? true : false); }
40 
41  static std::pair<unsigned int,unsigned int> channelToPixel( unsigned int ch) {
42  return std::pair<unsigned int, unsigned int>(channelToRow(ch),channelToColumn(ch));
43  }
44 
45  static PackedDigiType pixelToChannel( unsigned int row, unsigned int col) {
46  assert(row<1016);
47  assert(col<32);
48  return row|(col<<10);
49  }
50 
51  private:
52  PackedDigiType theChannel;
53  static unsigned int channelToRow( unsigned int ch) { return ch & 0x03FF; }
54  static unsigned int channelToColumn( unsigned int ch) { return ((ch >> 10) & 0x1F); }
55  static unsigned int otBit( unsigned int ch) { return ((ch >> 15) & 0x1) ; }
56 };
57 
58 // Comparison operators
59 inline bool operator<( const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
60  return one.channel() < other.channel();
61 }
62 
63 // distance operators
64 inline int operator-( const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
65  return int(one.channel()) - int(other.channel());
66 }
67 
68 
69 #include<iostream>
70 inline std::ostream & operator<<(std::ostream & o, const Phase2TrackerDigi& digi) {
71  return o << " " << digi.channel();
72 }
73 
74 #endif // DataFormats_Phase2TrackerDigi_Phase2TrackerDigi_H
unsigned int column() const
bool overThreshold() const
unsigned int row() const
bool operator<(const Phase2TrackerDigi &one, const Phase2TrackerDigi &other)
Phase2TrackerDigi(unsigned int packed_channel)
Phase2TrackerDigi(unsigned int row, unsigned int col, bool ot_flag)
int operator-(const Phase2TrackerDigi &one, const Phase2TrackerDigi &other)
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
unsigned int channel() const
std::ostream & operator<<(std::ostream &o, const Phase2TrackerDigi &digi)
static unsigned int otBit(unsigned int ch)
static unsigned int channelToRow(unsigned int ch)
unsigned int edge() const
col
Definition: cuy.py:1009
PackedDigiType theChannel
unsigned int strip() const
Phase2TrackerDigi(unsigned int row, unsigned int col)
static std::pair< unsigned int, unsigned int > channelToPixel(unsigned int ch)
static unsigned int channelToColumn(unsigned int ch)