CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
14 #include <boost/cstdint.hpp>
15 
16 
18 /*
19  A major problem is the numbering of the
20  RO componenets: do they all start from 0?
21  I think yes but mapping and coding (THIS class)
22  must be arranged accordingly.
23 
24  So far TDC channels and ID are bound to start from 0
25  whereas ROB, ROS and DDU are free to start from 0
26  or from 1. This has to be coded into the map
27 
28 */
29 
30 
32 
33 public:
34 
36 
38 
39  DTROChainCoding(const int & ddu, const int & ros,
40  const int & rob, const int & tdc, const int & channel) {
41  code =
42  ddu << DDU_SHIFT |
43  ros << ROS_SHIFT |
44  rob << ROB_SHIFT |
45  tdc << TDC_SHIFT |
46  channel << CHANNEL_SHIFT;
47  }
48 
49  DTROChainCoding(uint32_t code_): code(code_) {}
50 
52  virtual ~DTROChainCoding() {}
53 
55  inline void setCode(const uint32_t & code_) {code = code_;}
56  inline void setChain(const int & ddu, const int & ros,
57  const int & rob, const int & tdc, const int & channel) {
58 
59  code =
60  ddu << DDU_SHIFT |
61  ros << ROS_SHIFT |
62  rob << ROB_SHIFT |
63  tdc << TDC_SHIFT |
64  channel << CHANNEL_SHIFT;
65  }
66 
68  inline void setDDU(const int & ID) {
69  code = ( code & (~(DDU_MASK << DDU_SHIFT)) ) | (ID << DDU_SHIFT);
70  }
71  inline void setROS(const int & ID) {
72  code = ( code & (~(ROS_MASK << ROS_SHIFT)) ) | (ID << ROS_SHIFT);
73  }
74  inline void setROB(const int & ID) {
75  code = ( code & (~(ROB_MASK << ROB_SHIFT)) ) | (ID << ROB_SHIFT);
76  }
77  inline void setTDC(const int & ID) {
78  code = ( code & (~(TDC_MASK << TDC_SHIFT)) ) | (ID << TDC_SHIFT);
79  }
80  inline void setChannel(const int & ID) {
81  code = ( code & (~(CHANNEL_MASK << CHANNEL_SHIFT)) ) | (ID << CHANNEL_SHIFT);
82  }
83 
85  inline uint32_t getCode() const { return code; }
86  inline int getDDU() const { return (code >> DDU_SHIFT) & DDU_MASK; }
87  inline int getDDUID() const { return (code >> DDU_SHIFT) ; }
88  inline int getROS() const { return (code >> ROS_SHIFT) & ROS_MASK; }
89  inline int getROSID() const { return (code >> ROS_SHIFT) ; }
90  inline int getROB() const { return (code >> ROB_SHIFT) & ROB_MASK; }
91  inline int getROBID() const { return (code >> ROB_SHIFT) ; }
92  inline int getTDC() const { return (code >> TDC_SHIFT) & TDC_MASK; }
93  inline int getTDCID() const { return (code >> TDC_SHIFT) ; }
94  inline int getChannel() const { return (code >> CHANNEL_SHIFT) & CHANNEL_MASK; }
95  inline int getChannelID() const { return (code >> CHANNEL_SHIFT) ; }
96 
98  inline int getSC() const { return (code >> ROS_SHIFT) & ROS_MASK; }
99  inline int getSCID() const { return (code >> ROS_SHIFT) ; }
100 
101 
102 private:
103 
104  uint32_t code;
105 
106  // First shift the bits then apply the mask
107 
108  // ddu bit are the last ones. I DONT CARE if the ID is > than 730 (I always get the lsb)
109  static const int DDU_SHIFT = 16;
110  static const int DDU_MASK = 0x3FF;
111 
112  static const int ROS_SHIFT = 12;
113  static const int ROS_MASK = 0xF;
114 
115  static const int ROB_SHIFT = 7;
116  static const int ROB_MASK = 0x1F;
117 
118  static const int TDC_SHIFT = 5;
119  static const int TDC_MASK = 0x3;
120 
121  static const int CHANNEL_SHIFT = 0;
122  static const int CHANNEL_MASK = 0x1F;
123 
124 
125 };
126 
127 #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:26
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_)