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 <stdint.h>
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  uint16_t packedPosition() const { return 0x7FFF & theChannel; }
34  // Access to digi information - strip sensors
35  unsigned int strip() const { return row(); }
36  unsigned int edge() const { return column(); } // CD: any better name for that?
37  // Access to the (raw) channel number
38  unsigned int channel() const { return theChannel; }
39  // Access Overthreshold bit
40  bool overThreshold() const { return (otBit(theChannel) ? true : false); }
41 
42  static std::pair<unsigned int,unsigned int> channelToPixel( unsigned int ch) {
43  return std::pair<unsigned int, unsigned int>(channelToRow(ch),channelToColumn(ch));
44  }
45 
46  static PackedDigiType pixelToChannel( unsigned int row, unsigned int col) {
47  assert(row<1016);
48  assert(col<32);
49  return row|(col<<10);
50  }
51 
52  private:
53  PackedDigiType theChannel;
54  static unsigned int channelToRow( unsigned int ch) { return ch & 0x03FF; }
55  static unsigned int channelToColumn( unsigned int ch) { return ((ch >> 10) & 0x1F); }
56  static unsigned int otBit( unsigned int ch) { return ((ch >> 15) & 0x1) ; }
57 };
58 
59 // Comparison operators
60 inline bool operator<( const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
61  return one.packedPosition() < other.packedPosition();
62 }
63 
64 // distance operators
65 inline int operator-( const Phase2TrackerDigi& one, const Phase2TrackerDigi& other) {
66  return int(one.packedPosition()) - int(other.packedPosition());
67 }
68 
69 
70 #include<iostream>
71 inline std::ostream & operator<<(std::ostream & o, const Phase2TrackerDigi& digi) {
72  return o << " " << digi.channel();
73 }
74 
75 #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
uint16_t packedPosition() 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:1008
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)