CMS 3D CMS Logo

DTROChainCoding.h
Go to the documentation of this file.
1 #ifndef DTRawToDigi_DTROChainCoding_h
2 #define DTRawToDigi_DTROChainCoding_h
3 
11 
12 #include <vector>
13 #include <cstdint>
14 
16 /*
17  A major problem is the numbering of the
18  RO componenets: do they all start from 0?
19  I think yes but mapping and coding (THIS class)
20  must be arranged accordingly.
21 
22  So far TDC channels and ID are bound to start from 0
23  whereas ROB, ROS and DDU are free to start from 0
24  or from 1. This has to be coded into the map
25 
26 */
27 
29 public:
31 
33 
34  DTROChainCoding(const int& ddu, const int& ros, const int& rob, const int& tdc, const int& channel) {
35  code = ddu << DDU_SHIFT | ros << ROS_SHIFT | rob << ROB_SHIFT | tdc << TDC_SHIFT | channel << CHANNEL_SHIFT;
36  }
37 
38  DTROChainCoding(uint32_t code_) : code(code_) {}
39 
41  virtual ~DTROChainCoding() {}
42 
44  inline void setCode(const uint32_t& code_) { code = code_; }
45  inline void setChain(const int& ddu, const int& ros, const int& rob, const int& tdc, const int& channel) {
46  code = ddu << DDU_SHIFT | ros << ROS_SHIFT | rob << ROB_SHIFT | tdc << TDC_SHIFT | channel << CHANNEL_SHIFT;
47  }
48 
50  inline void setDDU(const int& ID) { code = (code & (~(DDU_MASK << DDU_SHIFT))) | (ID << DDU_SHIFT); }
51  inline void setROS(const int& ID) { code = (code & (~(ROS_MASK << ROS_SHIFT))) | (ID << ROS_SHIFT); }
52  inline void setROB(const int& ID) { code = (code & (~(ROB_MASK << ROB_SHIFT))) | (ID << ROB_SHIFT); }
53  inline void setTDC(const int& ID) { code = (code & (~(TDC_MASK << TDC_SHIFT))) | (ID << TDC_SHIFT); }
54  inline void setChannel(const int& ID) { code = (code & (~(CHANNEL_MASK << CHANNEL_SHIFT))) | (ID << CHANNEL_SHIFT); }
55 
57  inline uint32_t getCode() const { return code; }
58  inline int getDDU() const { return (code >> DDU_SHIFT) & DDU_MASK; }
59  inline int getDDUID() const { return (code >> DDU_SHIFT); }
60  inline int getROS() const { return (code >> ROS_SHIFT) & ROS_MASK; }
61  inline int getROSID() const { return (code >> ROS_SHIFT); }
62  inline int getROB() const { return (code >> ROB_SHIFT) & ROB_MASK; }
63  inline int getROBID() const { return (code >> ROB_SHIFT); }
64  inline int getTDC() const { return (code >> TDC_SHIFT) & TDC_MASK; }
65  inline int getTDCID() const { return (code >> TDC_SHIFT); }
66  inline int getChannel() const { return (code >> CHANNEL_SHIFT) & CHANNEL_MASK; }
67  inline int getChannelID() const { return (code >> CHANNEL_SHIFT); }
68 
70  inline int getSC() const { return (code >> ROS_SHIFT) & ROS_MASK; }
71  inline int getSCID() const { return (code >> ROS_SHIFT); }
72 
73 private:
74  uint32_t code;
75 
76  // First shift the bits then apply the mask
77 
78  // ddu bit are the last ones. I DONT CARE if the ID is > than 730 (I always get the lsb)
79  static const int DDU_SHIFT = 16;
80  static const int DDU_MASK = 0x3FF;
81 
82  static const int ROS_SHIFT = 12;
83  static const int ROS_MASK = 0xF;
84 
85  static const int ROB_SHIFT = 7;
86  static const int ROB_MASK = 0x1F;
87 
88  static const int TDC_SHIFT = 5;
89  static const int TDC_MASK = 0x3;
90 
91  static const int CHANNEL_SHIFT = 0;
92  static const int CHANNEL_MASK = 0x1F;
93 };
94 
95 #endif
DTROChainCoding::getROSID
int getROSID() const
Definition: DTROChainCoding.h:61
DTROChainCoding::getTDCID
int getTDCID() const
Definition: DTROChainCoding.h:65
DTROChainCoding::DTROChainCoding
DTROChainCoding()
Constructors.
Definition: DTROChainCoding.h:32
DTROChainCoding::DDU_MASK
static const int DDU_MASK
Definition: DTROChainCoding.h:80
DTROChainCoding::TDC_MASK
static const int TDC_MASK
Definition: DTROChainCoding.h:89
DTDDUWords.h
DTROChainCoding::ROB_MASK
static const int ROB_MASK
Definition: DTROChainCoding.h:86
DTROChainCoding::~DTROChainCoding
virtual ~DTROChainCoding()
Destructor.
Definition: DTROChainCoding.h:41
DTROChainCoding::ROS_SHIFT
static const int ROS_SHIFT
Definition: DTROChainCoding.h:82
DTROChainCoding::setDDU
void setDDU(const int &ID)
need to reset the bits before setting
Definition: DTROChainCoding.h:50
DTROChainCoding::setCode
void setCode(const uint32_t &code_)
Setters ///////////////////////.
Definition: DTROChainCoding.h:44
DTROChainCoding::DTROChainCoding
DTROChainCoding(uint32_t code_)
Definition: DTROChainCoding.h:38
DTROChainCoding::getCode
uint32_t getCode() const
Getters ///////////////////////.
Definition: DTROChainCoding.h:57
DTROChainCoding::getROBID
int getROBID() const
Definition: DTROChainCoding.h:63
DTROChainCoding::getChannelID
int getChannelID() const
Definition: DTROChainCoding.h:67
DTROChainCoding::ROB_SHIFT
static const int ROB_SHIFT
Definition: DTROChainCoding.h:85
DTROChainCoding::getROB
int getROB() const
Definition: DTROChainCoding.h:62
DTROChainCoding::code
uint32_t code
Definition: DTROChainCoding.h:74
DTROChainCoding::setChannel
void setChannel(const int &ID)
Definition: DTROChainCoding.h:54
align::ID
uint32_t ID
Definition: Definitions.h:24
DTROChainCoding::DDU_SHIFT
static const int DDU_SHIFT
Definition: DTROChainCoding.h:79
DTROChainCoding::setROB
void setROB(const int &ID)
Definition: DTROChainCoding.h:52
DTROChainCoding::getSC
int getSC() const
SC getters: same as ROS getters (SC data goes in the corresponding ROS)
Definition: DTROChainCoding.h:70
DTROChainCoding::getDDU
int getDDU() const
Definition: DTROChainCoding.h:58
DTROChainCoding::DTROChainCoding
DTROChainCoding(const int &ddu, const int &ros, const int &rob, const int &tdc, const int &channel)
Definition: DTROChainCoding.h:34
DTROChainCoding::getROS
int getROS() const
Definition: DTROChainCoding.h:60
DTROChainCoding::setChain
void setChain(const int &ddu, const int &ros, const int &rob, const int &tdc, const int &channel)
Definition: DTROChainCoding.h:45
DTROChainCoding::setROS
void setROS(const int &ID)
Definition: DTROChainCoding.h:51
DTROChainCoding::setTDC
void setTDC(const int &ID)
Definition: DTROChainCoding.h:53
DTROChainCoding
FIXEME:
Definition: DTROChainCoding.h:28
DTROChainCoding::getSCID
int getSCID() const
Definition: DTROChainCoding.h:71
DTROChainCoding::getTDC
int getTDC() const
Definition: DTROChainCoding.h:64
DTROChainCoding::TDC_SHIFT
static const int TDC_SHIFT
Definition: DTROChainCoding.h:88
DTROChainCoding::CHANNEL_SHIFT
static const int CHANNEL_SHIFT
Definition: DTROChainCoding.h:91
DTROChainCoding::ROS_MASK
static const int ROS_MASK
Definition: DTROChainCoding.h:83
DTROChainCoding::getChannel
int getChannel() const
Definition: DTROChainCoding.h:66
DTROChainCoding::getDDUID
int getDDUID() const
Definition: DTROChainCoding.h:59
DTROChainCoding::CHANNEL_MASK
static const int CHANNEL_MASK
Definition: DTROChainCoding.h:92