CMS 3D CMS Logo

TotemT2FramePosition.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_TotemT2FramePosition
10 #define CondFormats_PPSObjects_TotemT2FramePosition
12 
13 #include <iostream>
14 #include <string>
15 
28 public:
29  static const unsigned int offsetPayload = 18, maskPayload = 0x3;
30 
32  TotemT2FramePosition(unsigned short SubSystemId,
33  unsigned short TOTFEDId,
34  unsigned short OptoRxId,
35  unsigned short GOHId,
36  unsigned short IdxInFiber,
37  unsigned short payload)
38  : rawPosition(IdxInFiber << offsetIdxInFiber | GOHId << offsetGOHId | OptoRxId << offsetOptoRxId |
39  TOTFEDId << offsetTOTFEDId | SubSystemId << offsetSubSystemId | (payload + 1) << offsetPayload) {}
40 
42  TotemT2FramePosition(unsigned int pos = 0) : rawPosition(pos) {}
43 
45 
47 
48  unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
49  unsigned short getPayload() const { return (((rawPosition >> offsetPayload) & maskPayload) - 1); }
50 
51  void setFEDId(unsigned short v) {
52  v &= maskFEDId;
53  rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
54  rawPosition |= (v << offsetFEDId);
55  }
56  void setPayload(unsigned short v) {
57  unsigned short av = (v + 1) & maskPayload;
58  rawPosition &= 0xFFFFFFFF - (maskPayload << offsetPayload);
59  rawPosition |= (av << offsetPayload);
60  }
61 
62  unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
63 
64  void setGOHId(unsigned short v) {
65  v &= maskGOHId;
66  rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId);
67  rawPosition |= (v << offsetGOHId);
68  }
69 
70  unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
71 
72  void setIdxInFiber(unsigned short v) {
73  v &= maskIdxInFiber;
74  rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber);
76  }
77 
79 
81  unsigned int getRawPosition() const { return rawPosition; }
82 
83  bool operator<(const TotemT2FramePosition &pos) const { return (rawPosition < pos.rawPosition); }
84  bool operator<(const TotemFramePosition &pos) const { return (rawPosition < pos.getRawPosition()); }
85 
86  bool operator==(const TotemT2FramePosition &pos) const { return (rawPosition == pos.rawPosition); }
87  bool operator==(const TotemFramePosition &pos) const { return (rawPosition == pos.getRawPosition()); }
88 
92  friend std::ostream &operator<<(std::ostream &s, const TotemT2FramePosition &fp);
93 
95  void printXML();
96 
100  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
101 
103  static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0x3f); }
104 
105 protected:
106  unsigned int rawPosition;
107 };
108 
109 #endif
friend std::ostream & operator<<(std::ostream &s, const TotemT2FramePosition &fp)
static const unsigned int maskPayload
void printXML()
prints XML formatted DAQ channel to stdout
bool operator<(const TotemT2FramePosition &pos) const
static const unsigned int offsetPayload
void setGOHId(unsigned short v)
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
unsigned short getGOHId() const
static const unsigned int offsetFEDId
TotemT2FramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber, unsigned short payload)
the preferred constructor
static const unsigned int offsetSubSystemId
TotemT2FramePosition(unsigned int pos=0)
don&#39;t use this constructor unless you have a good reason
bool operator<(const TotemFramePosition &pos) const
static const unsigned int offsetIdxInFiber
unsigned short getIdxInFiber() const
unsigned short getFEDId() const
recomended getters and setters
bool operator==(const TotemFramePosition &pos) const
Definition: value.py:1
static const unsigned int offsetOptoRxId
static const unsigned int maskFEDId
bool operator==(const TotemT2FramePosition &pos) const
void setPayload(unsigned short v)
unsigned int getRawPosition() const
the getters and setters below are deprecated
unsigned short getPayload() const
static const unsigned int maskGOHId
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
static const unsigned int offsetTOTFEDId
void setIdxInFiber(unsigned short v)
void setFEDId(unsigned short v)
static const unsigned int maskIdxInFiber
static const unsigned int offsetGOHId