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