CMS 3D CMS Logo

TotemFramePosition.h
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of the TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
9 #ifndef CondFormats_PPSObjects_TotemFramePosition
10 #define CondFormats_PPSObjects_TotemFramePosition
11 
13 #include <iostream>
14 #include <string>
15 
34 public:
35  static const unsigned int offsetIdxInFiber = 0, maskIdxInFiber = 0xF;
36  static const unsigned int offsetGOHId = 4, maskGOHId = 0xF;
37  static const unsigned int offsetFEDId = 8, maskFEDId = 0x3FF;
38 
39  static const unsigned int offsetOptoRxId = 8, maskOptoRxId = 0x3;
40  static const unsigned int offsetTOTFEDId = 10, maskTOTFEDId = 0x1F;
41  static const unsigned int offsetSubSystemId = 15, maskSubSystemId = 0x7;
42 
44  TotemFramePosition(unsigned short SubSystemId,
45  unsigned short TOTFEDId,
46  unsigned short OptoRxId,
47  unsigned short GOHId,
48  unsigned short IdxInFiber)
49  : rawPosition(IdxInFiber << offsetIdxInFiber | GOHId << offsetGOHId | OptoRxId << offsetOptoRxId |
50  TOTFEDId << offsetTOTFEDId | SubSystemId << offsetSubSystemId) {}
51 
53  TotemFramePosition(unsigned int pos = 0) : rawPosition(pos) {}
54 
56 
58 
59  unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
60 
61  void setFEDId(unsigned short v) {
62  v &= maskFEDId;
63  rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
64  rawPosition |= (v << offsetFEDId);
65  }
66 
67  unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
68 
69  void setGOHId(unsigned short v) {
70  v &= maskGOHId;
71  rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId);
72  rawPosition |= (v << offsetGOHId);
73  }
74 
75  unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
76 
77  void setIdxInFiber(unsigned short v) {
78  v &= maskIdxInFiber;
79  rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber);
81  }
82 
84 
85  unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
86 
87  void setSubSystemId(unsigned short v) {
88  v &= maskSubSystemId;
89  rawPosition &= 0xFFFFFFFF - (maskSubSystemId << offsetSubSystemId);
91  }
92 
93  unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId; }
94 
95  void setTOTFEDId(unsigned short v) {
96  v &= maskTOTFEDId;
97  rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId);
99  }
100 
101  unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
102 
103  void setOptoRxId(unsigned short v) {
104  v &= maskOptoRxId;
105  rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId);
106  rawPosition |= (v << offsetOptoRxId);
107  }
108 
110  unsigned int getRawPosition() const { return rawPosition; }
111 
112  bool operator<(const TotemFramePosition &pos) const { return (rawPosition < pos.rawPosition); }
113 
114  bool operator==(const TotemFramePosition &pos) const { return (rawPosition == pos.rawPosition); }
115 
119  friend std::ostream &operator<<(std::ostream &s, const TotemFramePosition &fp);
120 
122  void printXML();
123 
127  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
128 
130  static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0x1f); }
131 
132 protected:
133  unsigned int rawPosition;
134 
136 };
137 
138 #endif
TotemFramePosition(unsigned int pos=0)
don&#39;t use this constructor unless you have a good reason
void setIdxInFiber(unsigned short v)
bool operator<(const TotemFramePosition &pos) const
unsigned int getRawPosition() const
don&#39;t use this method unless you have a good reason
void setGOHId(unsigned short v)
void setOptoRxId(unsigned short v)
static const unsigned int offsetFEDId
static const unsigned int offsetSubSystemId
void setTOTFEDId(unsigned short v)
void printXML()
prints XML formatted DAQ channel to stdout
unsigned short getOptoRxId() const
friend std::ostream & operator<<(std::ostream &s, const TotemFramePosition &fp)
static const unsigned int offsetIdxInFiber
void setSubSystemId(unsigned short v)
unsigned short getSubSystemId() const
the getters and setters below are deprecated
unsigned short getTOTFEDId() const
unsigned short getGOHId() const
Definition: value.py:1
static const unsigned int offsetOptoRxId
static const unsigned int maskFEDId
static const unsigned int maskTOTFEDId
#define COND_SERIALIZABLE
Definition: Serializable.h:39
unsigned short getIdxInFiber() const
static const unsigned int maskGOHId
static const unsigned int offsetTOTFEDId
TotemFramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
the preferred constructor
static const unsigned int maskSubSystemId
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
unsigned short getFEDId() const
recomended getters and setters
void setFEDId(unsigned short v)
bool operator==(const TotemFramePosition &pos) const
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
static const unsigned int maskOptoRxId
static const unsigned int maskIdxInFiber
static const unsigned int offsetGOHId