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 
12 #include <iostream>
13 #include <string>
14 
33 public:
34  static const unsigned int offsetIdxInFiber = 0, maskIdxInFiber = 0xF;
35  static const unsigned int offsetGOHId = 4, maskGOHId = 0xF;
36  static const unsigned int offsetFEDId = 8, maskFEDId = 0x3FF;
37 
38  static const unsigned int offsetOptoRxId = 8, maskOptoRxId = 0x3;
39  static const unsigned int offsetTOTFEDId = 10, maskTOTFEDId = 0x1F;
40  static const unsigned int offsetSubSystemId = 15, maskSubSystemId = 0x7;
41 
43  TotemFramePosition(unsigned short SubSystemId,
44  unsigned short TOTFEDId,
45  unsigned short OptoRxId,
46  unsigned short GOHId,
47  unsigned short IdxInFiber)
48  : rawPosition(IdxInFiber << offsetIdxInFiber | GOHId << offsetGOHId | OptoRxId << offsetOptoRxId |
49  TOTFEDId << offsetTOTFEDId | SubSystemId << offsetSubSystemId) {}
50 
52  TotemFramePosition(unsigned int pos = 0) : rawPosition(pos) {}
53 
55 
57 
58  unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
59 
60  void setFEDId(unsigned short v) {
61  v &= maskFEDId;
62  rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
63  rawPosition |= (v << offsetFEDId);
64  }
65 
66  unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
67 
68  void setGOHId(unsigned short v) {
69  v &= maskGOHId;
70  rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId);
71  rawPosition |= (v << offsetGOHId);
72  }
73 
74  unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
75 
76  void setIdxInFiber(unsigned short v) {
77  v &= maskIdxInFiber;
78  rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber);
80  }
81 
83 
84  unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
85 
86  void setSubSystemId(unsigned short v) {
87  v &= maskSubSystemId;
88  rawPosition &= 0xFFFFFFFF - (maskSubSystemId << offsetSubSystemId);
90  }
91 
92  unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId; }
93 
94  void setTOTFEDId(unsigned short v) {
95  v &= maskTOTFEDId;
96  rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId);
98  }
99 
100  unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
101 
102  void setOptoRxId(unsigned short v) {
103  v &= maskOptoRxId;
104  rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId);
105  rawPosition |= (v << offsetOptoRxId);
106  }
107 
109  unsigned int getRawPosition() const { return rawPosition; }
110 
111  bool operator<(const TotemFramePosition &pos) const { return (rawPosition < pos.rawPosition); }
112 
113  bool operator==(const TotemFramePosition &pos) const { return (rawPosition == pos.rawPosition); }
114 
118  friend std::ostream &operator<<(std::ostream &s, const TotemFramePosition &fp);
119 
121  void printXML();
122 
126  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
127 
129  static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0x1f); }
130 
131 protected:
132  unsigned int rawPosition;
133 };
134 
135 #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
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