CMS 3D CMS Logo

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_CTPPSReadoutObjects_CTPPSPixelFramePosition
10 #define CondFormats_CTPPSReadoutObjects_CTPPSPixelFramePosition
11 
12 #include <iostream>
13 #include <string>
14 
16 
29 {
30 public:
31  static const unsigned int offsetROC = 0, maskROC = 0x3;
32  static const unsigned int offsetChannelIdx = 2, maskChannelIdx = 0x3F;
33  static const unsigned int offsetFMCId = 8, maskFMCId = 0x1;
34  static const unsigned int offsetFEDId = 9, maskFEDId = 0xFFF;
35 
36 
38 CTPPSPixelFramePosition( unsigned short FEDId, unsigned short FMCId, unsigned short ChannelIdx, unsigned short ROC) :
39  rawPosition(ROC<<offsetROC | ChannelIdx<<offsetChannelIdx | FMCId<<FMCId | FEDId<<offsetFEDId )
40  {
41  }
42 
45  {
46  }
47 
49  {
50  }
51 
53 
54  unsigned short getFEDId() const
55  {
56  return (rawPosition >> offsetFEDId) & maskFEDId;
57  }
58 
59  void setFEDId(unsigned short v)
60  { v &= maskFEDId; rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId); rawPosition |= (v << offsetFEDId); }
61 
62  unsigned short getChannelIdx() const { return (rawPosition >> offsetChannelIdx) & maskChannelIdx; }
63 
64  void setChannelIdx(unsigned short v)
66 
67  unsigned short getROC() const { return (rawPosition >> offsetROC) & maskROC; }
68 
69  void setROC(unsigned short v)
70  { v &= maskROC; rawPosition &= 0xFFFFFFFF - (maskROC << offsetROC); rawPosition |= (v << offsetROC); }
71 
72  unsigned short getFMCId() const { return (rawPosition >> offsetFMCId) & maskFMCId; }
73 
74  void setFMCId(unsigned short v)
75  { v &= maskFMCId; rawPosition &= 0xFFFFFFFF - (maskFMCId << offsetFMCId); rawPosition |= (v << offsetFMCId); }
76 
77 
78  unsigned int getRawPosition() const
79  {
80  return rawPosition;
81  }
82 
84  {
85  return (rawPosition < pos.rawPosition);
86  }
87 
89  {
90  return (rawPosition == pos.rawPosition);
91  }
92 
95  friend std::ostream& operator << (std::ostream& s, const CTPPSPixelFramePosition &fp);
96 
98  void printXML();
99 
103  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
104 
106  static bool checkXMLAttributeFlag(unsigned char flag)
107  {
108  return (flag == 0xF);
109  }
110 
111 protected:
112  unsigned int rawPosition;
113 
115 
116 };
117 
118 #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
Definition: value.py:1
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:38
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)