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