CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_CTPPSReadoutObjects_TotemFramePosition
10 #define CondFormats_CTPPSReadoutObjects_TotemFramePosition
11 
12 #include <iostream>
13 #include <string>
14 
33 {
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, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber) :
45  rawPosition(IdxInFiber<<offsetIdxInFiber | GOHId<<offsetGOHId | OptoRxId<<offsetOptoRxId | TOTFEDId<<offsetTOTFEDId | SubSystemId<<offsetSubSystemId)
46  {
47  }
48 
50  TotemFramePosition(unsigned int pos = 0) : rawPosition(pos)
51  {
52  }
53 
55  {
56  }
57 
59 
60  unsigned short getFEDId() const
61  {
62  return (rawPosition >> offsetFEDId) & maskFEDId;
63  }
64 
65  void setFEDId(unsigned short v)
66  { v &= maskFEDId; rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId); rawPosition |= (v << offsetFEDId); }
67 
68  unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
69 
70  void setGOHId(unsigned short v)
71  { v &= maskGOHId; rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId); rawPosition |= (v << offsetGOHId); }
72 
73  unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
74 
75  void setIdxInFiber(unsigned short v)
77 
78 
80 
81  unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
82 
83  void setSubSystemId(unsigned short v)
85 
86  unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId;}
87 
88  void setTOTFEDId(unsigned short v)
89  { v &= maskTOTFEDId; rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId); rawPosition |= (v << offsetTOTFEDId); }
90 
91  unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
92 
93  void setOptoRxId(unsigned short v)
94  { v &= maskOptoRxId; rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId); rawPosition |= (v << offsetOptoRxId); }
95 
97  unsigned int getRawPosition() const
98  {
99  return rawPosition;
100  }
101 
102  bool operator < (const TotemFramePosition &pos) const
103  {
104  return (rawPosition < pos.rawPosition);
105  }
106 
107  bool operator == (const TotemFramePosition &pos) const
108  {
109  return (rawPosition == pos.rawPosition);
110  }
111 
115  friend std::ostream& operator << (std::ostream& s, const TotemFramePosition &fp);
116 
118  void printXML();
119 
123  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
124 
126  static bool checkXMLAttributeFlag(unsigned char flag)
127  {
128  return (flag == 0x1f);
129  }
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)
unsigned short getFEDId() const
recomended getters and setters
unsigned short getIdxInFiber() const
void setGOHId(unsigned short v)
unsigned short getTOTFEDId() const
void setOptoRxId(unsigned short v)
static const unsigned int offsetFEDId
unsigned short getOptoRxId() const
static const unsigned int offsetSubSystemId
void setTOTFEDId(unsigned short v)
void printXML()
prints XML formatted DAQ channel to stdout
friend std::ostream & operator<<(std::ostream &s, const TotemFramePosition &fp)
unsigned int getRawPosition() const
don&#39;t use this method unless you have a good reason
static const unsigned int offsetIdxInFiber
void setSubSystemId(unsigned short v)
unsigned short getSubSystemId() const
the getters and setters below are deprecated
unsigned short getGOHId() const
static const unsigned int offsetOptoRxId
static const unsigned int maskFEDId
bool operator==(const TotemFramePosition &pos) const
static const unsigned int maskTOTFEDId
bool operator<(const TotemFramePosition &pos) 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
void setFEDId(unsigned short v)
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