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 
32 class TotemFramePosition {
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;
80  }
81 
83 
84  unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
85 
86  void setSubSystemId(unsigned short v) {
87  v &= maskSubSystemId;
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;
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::maskSubSystemId
static const unsigned int maskSubSystemId
Definition: TotemFramePosition.h:44
TotemFramePosition::offsetFEDId
static const unsigned int offsetFEDId
Definition: TotemFramePosition.h:40
TotemFramePosition::offsetIdxInFiber
static const unsigned int offsetIdxInFiber
Definition: TotemFramePosition.h:38
TotemFramePosition::setXMLAttribute
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
Definition: TotemFramePosition.cc:29
TotemFramePosition::offsetOptoRxId
static const unsigned int offsetOptoRxId
Definition: TotemFramePosition.h:42
TotemFramePosition::offsetGOHId
static const unsigned int offsetGOHId
Definition: TotemFramePosition.h:39
TotemFramePosition::maskGOHId
static const unsigned int maskGOHId
Definition: TotemFramePosition.h:39
TotemFramePosition::rawPosition
unsigned int rawPosition
Definition: TotemFramePosition.h:136
TotemFramePosition::offsetSubSystemId
static const unsigned int offsetSubSystemId
Definition: TotemFramePosition.h:44
TotemFramePosition::setSubSystemId
void setSubSystemId(unsigned short v)
Definition: TotemFramePosition.h:90
TotemFramePosition::TotemFramePosition
TotemFramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
the preferred constructor
Definition: TotemFramePosition.h:47
pos
Definition: PixelAliasList.h:18
personalPlayback.fp
fp
Definition: personalPlayback.py:523
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TotemFramePosition::getTOTFEDId
unsigned short getTOTFEDId() const
Definition: TotemFramePosition.h:96
TotemFramePosition::maskOptoRxId
static const unsigned int maskOptoRxId
Definition: TotemFramePosition.h:42
TotemFramePosition::getOptoRxId
unsigned short getOptoRxId() const
Definition: TotemFramePosition.h:104
TotemFramePosition::maskFEDId
static const unsigned int maskFEDId
Definition: TotemFramePosition.h:40
TotemFramePosition::operator<<
friend std::ostream & operator<<(std::ostream &s, const TotemFramePosition &fp)
Definition: TotemFramePosition.cc:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TotemFramePosition::getSubSystemId
unsigned short getSubSystemId() const
the getters and setters below are deprecated
Definition: TotemFramePosition.h:88
TotemFramePosition::setTOTFEDId
void setTOTFEDId(unsigned short v)
Definition: TotemFramePosition.h:98
TotemFramePosition::getIdxInFiber
unsigned short getIdxInFiber() const
Definition: TotemFramePosition.h:78
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TotemFramePosition::maskTOTFEDId
static const unsigned int maskTOTFEDId
Definition: TotemFramePosition.h:43
TotemFramePosition::getGOHId
unsigned short getGOHId() const
Definition: TotemFramePosition.h:70
TotemFramePosition
Definition: TotemFramePosition.h:31
TotemFramePosition::operator==
bool operator==(const TotemFramePosition &pos) const
Definition: TotemFramePosition.h:117
TotemFramePosition::setIdxInFiber
void setIdxInFiber(unsigned short v)
Definition: TotemFramePosition.h:80
value
Definition: value.py:1
TotemFramePosition::setFEDId
void setFEDId(unsigned short v)
Definition: TotemFramePosition.h:64
TotemFramePosition::checkXMLAttributeFlag
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
Definition: TotemFramePosition.h:133
TotemFramePosition::operator<
bool operator<(const TotemFramePosition &pos) const
Definition: TotemFramePosition.h:115
TotemFramePosition::printXML
void printXML()
prints XML formatted DAQ channel to stdout
Definition: TotemFramePosition.cc:23
TotemFramePosition::getRawPosition
unsigned int getRawPosition() const
don't use this method unless you have a good reason
Definition: TotemFramePosition.h:113
TotemFramePosition::~TotemFramePosition
~TotemFramePosition()
Definition: TotemFramePosition.h:58
TotemFramePosition::setOptoRxId
void setOptoRxId(unsigned short v)
Definition: TotemFramePosition.h:106
TotemFramePosition::offsetTOTFEDId
static const unsigned int offsetTOTFEDId
Definition: TotemFramePosition.h:43
TotemFramePosition::maskIdxInFiber
static const unsigned int maskIdxInFiber
Definition: TotemFramePosition.h:38
TotemFramePosition::getFEDId
unsigned short getFEDId() const
recomended getters and setters
Definition: TotemFramePosition.h:62
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
TotemFramePosition::setGOHId
void setGOHId(unsigned short v)
Definition: TotemFramePosition.h:72