File indexing completed on 2024-04-06 12:02:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef CondFormats_PPSObjects_CTPPSPixelFramePosition
0010 #define CondFormats_PPSObjects_CTPPSPixelFramePosition
0011
0012 #include <iostream>
0013 #include <string>
0014
0015 #include "CondFormats/Serialization/interface/Serializable.h"
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 class CTPPSPixelFramePosition {
0029 public:
0030 static const unsigned int offsetROC = 0, maskROC = 0x3;
0031 static const unsigned int offsetChannelIdx = 2, maskChannelIdx = 0x3F;
0032 static const unsigned int offsetFMCId = 8, maskFMCId = 0x1;
0033 static const unsigned int offsetFEDId = 9, maskFEDId = 0xFFF;
0034
0035
0036 CTPPSPixelFramePosition(unsigned short FEDId, unsigned short FMCId, unsigned short ChannelIdx, unsigned short ROC)
0037 : rawPosition(ROC << offsetROC | ChannelIdx << offsetChannelIdx | FMCId << FMCId | FEDId << offsetFEDId) {}
0038
0039
0040 CTPPSPixelFramePosition(unsigned int pos = 0) : rawPosition(pos) {}
0041
0042 ~CTPPSPixelFramePosition() {}
0043
0044
0045
0046 unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
0047
0048 void setFEDId(unsigned short v) {
0049 v &= maskFEDId;
0050 rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
0051 rawPosition |= (v << offsetFEDId);
0052 }
0053
0054 unsigned short getChannelIdx() const { return (rawPosition >> offsetChannelIdx) & maskChannelIdx; }
0055
0056 void setChannelIdx(unsigned short v) {
0057 v &= maskChannelIdx;
0058 rawPosition &= 0xFFFFFFFF - (maskChannelIdx << offsetChannelIdx);
0059 rawPosition |= (v << offsetChannelIdx);
0060 }
0061
0062 unsigned short getROC() const { return (rawPosition >> offsetROC) & maskROC; }
0063
0064 void setROC(unsigned short v) {
0065 v &= maskROC;
0066 rawPosition &= 0xFFFFFFFF - (maskROC << offsetROC);
0067 rawPosition |= (v << offsetROC);
0068 }
0069
0070 unsigned short getFMCId() const { return (rawPosition >> offsetFMCId) & maskFMCId; }
0071
0072 void setFMCId(unsigned short v) {
0073 v &= maskFMCId;
0074 rawPosition &= 0xFFFFFFFF - (maskFMCId << offsetFMCId);
0075 rawPosition |= (v << offsetFMCId);
0076 }
0077
0078 unsigned int getRawPosition() const { return rawPosition; }
0079
0080 bool operator<(const CTPPSPixelFramePosition &pos) const { return (rawPosition < pos.rawPosition); }
0081
0082 bool operator==(const CTPPSPixelFramePosition &pos) const { return (rawPosition == pos.rawPosition); }
0083
0084
0085
0086 friend std::ostream &operator<<(std::ostream &s, const CTPPSPixelFramePosition &fp);
0087
0088
0089 void printXML();
0090
0091
0092
0093
0094 unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
0095
0096
0097 static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0xF); }
0098
0099 protected:
0100 unsigned int rawPosition;
0101
0102 COND_SERIALIZABLE;
0103 };
0104
0105 #endif