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(const int &ddu, const int &ros, const int &rob, const int &tdc, const int &channel)
int getChannel() const
int getROBID() const
static const int ROS_MASK
static const int ROB_MASK
uint32_t ID
Definition: Definitions.h:24
int getChannelID() const
DTROChainCoding()
Constructors.
int getROS() const
void setTDC(const int &ID)
int getTDC() const
int getSC() const
SC getters: same as ROS getters (SC data goes in the corresponding ROS)
static const int ROB_SHIFT
int getSCID() const
uint32_t getCode() const
Getters ///////////////////////.
static const int ROS_SHIFT
void setChain(const int &ddu, const int &ros, const int &rob, const int &tdc, const int &channel)
static const int DDU_MASK
static const int TDC_MASK
void setChannel(const int &ID)
static const int CHANNEL_MASK
int getDDUID() const
static const int DDU_SHIFT
void setROB(const int &ID)
int getTDCID() const
void setROS(const int &ID)
int getDDU() const
int getROB() const
void setDDU(const int &ID)
need to reset the bits before setting
static const int CHANNEL_SHIFT
static const int TDC_SHIFT
virtual ~DTROChainCoding()
Destructor.
void setCode(const uint32_t &code_)
Setters ///////////////////////.
int getROSID() const
DTROChainCoding(uint32_t code_)