File indexing completed on 2024-04-06 12:02:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef CondFormats_PPSObjects_TotemFramePosition
0010 #define CondFormats_PPSObjects_TotemFramePosition
0011
0012 #include "CondFormats/Serialization/interface/Serializable.h"
0013 #include <iostream>
0014 #include <string>
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 class TotemFramePosition {
0034 public:
0035 static const unsigned int offsetIdxInFiber = 0, maskIdxInFiber = 0xF;
0036 static const unsigned int offsetGOHId = 4, maskGOHId = 0xF;
0037 static const unsigned int offsetFEDId = 8, maskFEDId = 0x3FF;
0038
0039 static const unsigned int offsetOptoRxId = 8, maskOptoRxId = 0x3;
0040 static const unsigned int offsetTOTFEDId = 10, maskTOTFEDId = 0x1F;
0041 static const unsigned int offsetSubSystemId = 15, maskSubSystemId = 0x7;
0042
0043
0044 TotemFramePosition(unsigned short SubSystemId,
0045 unsigned short TOTFEDId,
0046 unsigned short OptoRxId,
0047 unsigned short GOHId,
0048 unsigned short IdxInFiber)
0049 : rawPosition(IdxInFiber << offsetIdxInFiber | GOHId << offsetGOHId | OptoRxId << offsetOptoRxId |
0050 TOTFEDId << offsetTOTFEDId | SubSystemId << offsetSubSystemId) {}
0051
0052
0053 TotemFramePosition(unsigned int pos = 0) : rawPosition(pos) {}
0054
0055 ~TotemFramePosition() {}
0056
0057
0058
0059 unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
0060
0061 void setFEDId(unsigned short v) {
0062 v &= maskFEDId;
0063 rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
0064 rawPosition |= (v << offsetFEDId);
0065 }
0066
0067 unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
0068
0069 void setGOHId(unsigned short v) {
0070 v &= maskGOHId;
0071 rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId);
0072 rawPosition |= (v << offsetGOHId);
0073 }
0074
0075 unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
0076
0077 void setIdxInFiber(unsigned short v) {
0078 v &= maskIdxInFiber;
0079 rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber);
0080 rawPosition |= (v << offsetIdxInFiber);
0081 }
0082
0083
0084
0085 unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
0086
0087 void setSubSystemId(unsigned short v) {
0088 v &= maskSubSystemId;
0089 rawPosition &= 0xFFFFFFFF - (maskSubSystemId << offsetSubSystemId);
0090 rawPosition |= (v << offsetSubSystemId);
0091 }
0092
0093 unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId; }
0094
0095 void setTOTFEDId(unsigned short v) {
0096 v &= maskTOTFEDId;
0097 rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId);
0098 rawPosition |= (v << offsetTOTFEDId);
0099 }
0100
0101 unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
0102
0103 void setOptoRxId(unsigned short v) {
0104 v &= maskOptoRxId;
0105 rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId);
0106 rawPosition |= (v << offsetOptoRxId);
0107 }
0108
0109
0110 unsigned int getRawPosition() const { return rawPosition; }
0111
0112 bool operator<(const TotemFramePosition &pos) const { return (rawPosition < pos.rawPosition); }
0113
0114 bool operator==(const TotemFramePosition &pos) const { return (rawPosition == pos.rawPosition); }
0115
0116
0117
0118
0119 friend std::ostream &operator<<(std::ostream &s, const TotemFramePosition &fp);
0120
0121
0122 void printXML();
0123
0124
0125
0126
0127 unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
0128
0129
0130 static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0x1f); }
0131
0132 protected:
0133 unsigned int rawPosition;
0134
0135 COND_SERIALIZABLE;
0136 };
0137
0138 #endif