CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CTPPSPixelFramePosition.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  *
4  * Authors:
5  * F.Ferro ferro@ge.infn.it
6  *
7  ****************************************************************************/
8 
9 #ifndef CondFormats_PPSObjects_CTPPSPixelFramePosition
10 #define CondFormats_PPSObjects_CTPPSPixelFramePosition
11 
12 #include <iostream>
13 #include <string>
14 
16 
29 public:
30  static const unsigned int offsetROC = 0, maskROC = 0x3;
31  static const unsigned int offsetChannelIdx = 2, maskChannelIdx = 0x3F;
32  static const unsigned int offsetFMCId = 8, maskFMCId = 0x1;
33  static const unsigned int offsetFEDId = 9, maskFEDId = 0xFFF;
34 
36  CTPPSPixelFramePosition(unsigned short FEDId, unsigned short FMCId, unsigned short ChannelIdx, unsigned short ROC)
37  : rawPosition(ROC << offsetROC | ChannelIdx << offsetChannelIdx | FMCId << FMCId | FEDId << offsetFEDId) {}
38 
40  CTPPSPixelFramePosition(unsigned int pos = 0) : rawPosition(pos) {}
41 
43 
45 
46  unsigned short getFEDId() const { return (rawPosition >> offsetFEDId) & maskFEDId; }
47 
48  void setFEDId(unsigned short v) {
49  v &= maskFEDId;
50  rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId);
51  rawPosition |= (v << offsetFEDId);
52  }
53 
54  unsigned short getChannelIdx() const { return (rawPosition >> offsetChannelIdx) & maskChannelIdx; }
55 
56  void setChannelIdx(unsigned short v) {
57  v &= maskChannelIdx;
58  rawPosition &= 0xFFFFFFFF - (maskChannelIdx << offsetChannelIdx);
59  rawPosition |= (v << offsetChannelIdx);
60  }
61 
62  unsigned short getROC() const { return (rawPosition >> offsetROC) & maskROC; }
63 
64  void setROC(unsigned short v) {
65  v &= maskROC;
66  rawPosition &= 0xFFFFFFFF - (maskROC << offsetROC);
67  rawPosition |= (v << offsetROC);
68  }
69 
70  unsigned short getFMCId() const { return (rawPosition >> offsetFMCId) & maskFMCId; }
71 
72  void setFMCId(unsigned short v) {
73  v &= maskFMCId;
74  rawPosition &= 0xFFFFFFFF - (maskFMCId << offsetFMCId);
75  rawPosition |= (v << offsetFMCId);
76  }
77 
78  unsigned int getRawPosition() const { return rawPosition; }
79 
80  bool operator<(const CTPPSPixelFramePosition &pos) const { return (rawPosition < pos.rawPosition); }
81 
82  bool operator==(const CTPPSPixelFramePosition &pos) const { return (rawPosition == pos.rawPosition); }
83 
86  friend std::ostream &operator<<(std::ostream &s, const CTPPSPixelFramePosition &fp);
87 
89  void printXML();
90 
94  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
95 
97  static bool checkXMLAttributeFlag(unsigned char flag) { return (flag == 0xF); }
98 
99 protected:
100  unsigned int rawPosition;
101 
103 };
104 
105 #endif
CTPPSPixelFramePosition(unsigned short FEDId, unsigned short FMCId, unsigned short ChannelIdx, unsigned short ROC)
the preferred constructor
CTPPSPixelFramePosition(unsigned int pos=0)
don&#39;t use this constructor unless you have a good reason
bool operator<(const CTPPSPixelFramePosition &pos) const
void setChannelIdx(unsigned short v)
friend std::ostream & operator<<(std::ostream &s, const CTPPSPixelFramePosition &fp)
void printXML()
prints XML formatted DAQ channel to stdout
static const unsigned int offsetFMCId
static const unsigned int offsetROC
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
static const unsigned int maskFMCId
void setFMCId(unsigned short v)
static const unsigned int maskROC
static const unsigned int offsetFEDId
void setROC(unsigned short v)
unsigned short getFMCId() const
static const unsigned int maskFEDId
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
unsigned short getChannelIdx() const
unsigned short getROC() const
static const unsigned int maskChannelIdx
#define COND_SERIALIZABLE
Definition: Serializable.h:39
unsigned short getFEDId() const
recomended getters and setters
bool operator==(const CTPPSPixelFramePosition &pos) const
unsigned int getRawPosition() const
static const unsigned int offsetChannelIdx
void setFEDId(unsigned short v)