CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_TotemReadoutObjects_TotemFramePosition
10 #define CondFormats_TotemReadoutObjects_TotemFramePosition
11 
12 #include <iostream>
13 #include <string>
14 
28 {
29  public:
31  enum SubSystemType {ssNone=0, ssT1=1, ssT2=2, ssRP=3, ssTrigger=4, ssTTC=5, ssFEC=6};
32 
33  static const unsigned int offsetIdxInFiber = 0, maskIdxInFiber = 0xF;
34  static const unsigned int offsetGOHId = 4, maskGOHId = 0xF;
35  static const unsigned int offsetOptoRxId = 8, maskOptoRxId = 0x3;
36  static const unsigned int offsetTOTFEDId = 10, maskTOTFEDId = 0x1F;
37  static const unsigned int offsetSubSystemId = 15, maskSubSystemId = 0x7;
38 
40  TotemFramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber) :
41  rawPosition(IdxInFiber<<offsetIdxInFiber | GOHId<<offsetGOHId | OptoRxId<<offsetOptoRxId | TOTFEDId<<offsetTOTFEDId | SubSystemId<<offsetSubSystemId)
42  {
43  }
44 
46  TotemFramePosition(unsigned int pos = 0) : rawPosition(pos)
47  {
48  }
49 
51  {
52  }
53 
54  unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
55  unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId;}
56  unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
57  unsigned short getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }
58  unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }
59 
60  void setSubSystemId(unsigned short v)
62 
63  void setTOTFEDId(unsigned short v)
64  { v &= maskTOTFEDId; rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId); rawPosition |= (v << offsetTOTFEDId); }
65 
66  void setOptoRxId(unsigned short v)
67  { v &= maskOptoRxId; rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId); rawPosition |= (v << offsetOptoRxId); }
68 
69  void setGOHId(unsigned short v)
70  { v &= maskGOHId; rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId); rawPosition |= (v << offsetGOHId); }
71 
72  void setIdxInFiber(unsigned short v)
74 
75  void setAllIDs(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
76  {
77  rawPosition = (IdxInFiber<<offsetIdxInFiber | GOHId<<offsetGOHId | OptoRxId<<offsetOptoRxId
78  | TOTFEDId<<offsetTOTFEDId | SubSystemId<<offsetSubSystemId);
79  }
80 
82  unsigned int getRawPosition() const
83  {
84  return rawPosition;
85  }
86 
87  public:
88  bool operator < (const TotemFramePosition &pos) const
89  {
90  return (rawPosition < pos.rawPosition);
91  }
92 
93  bool operator == (const TotemFramePosition &pos) const
94  {
95  return (rawPosition == pos.rawPosition);
96  }
97 
101  friend std::ostream& operator << (std::ostream& s, const TotemFramePosition &fp);
102 
104  static const std::string tagSSNone;
105  static const std::string tagSSTrigger;
106  static const std::string tagSST1;
107  static const std::string tagSST2;
108  static const std::string tagSSRP;
109  static const std::string tagSSTTC;
110  static const std::string tagSSFEC;
111 
113  void printXML();
114 
118  unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);
119 
121  static bool checkXMLAttributeFlag(unsigned char flag)
122  {
123  return ((flag == 0x1f) | (flag == 0x20) | (flag == 0x40));
124  }
125 
126  unsigned short getFullOptoRxId() const
127  {
128  return (rawPosition >> 8) & 0xFFF;
129  }
130 
131  protected:
132  unsigned int rawPosition;
133 };
134 
135 #endif
static const std::string tagSSTrigger
TotemFramePosition(unsigned int pos=0)
don&#39;t use this constructor unless you have a good reason
void setIdxInFiber(unsigned short v)
unsigned short getIdxInFiber() const
static const std::string tagSST2
void setGOHId(unsigned short v)
unsigned short getTOTFEDId() const
void setOptoRxId(unsigned short v)
unsigned short getOptoRxId() const
static const unsigned int offsetSubSystemId
void setTOTFEDId(unsigned short v)
void printXML()
prints XML formatted DAQ channel to stdout
static const std::string tagSST1
friend std::ostream & operator<<(std::ostream &s, const TotemFramePosition &fp)
unsigned int getRawPosition() const
don&#39;t use this method unless you have a good reason
static const unsigned int offsetIdxInFiber
void setSubSystemId(unsigned short v)
unsigned short getSubSystemId() const
static const std::string tagSSRP
unsigned short getGOHId() const
static const unsigned int offsetOptoRxId
bool operator==(const TotemFramePosition &pos) const
static const unsigned int maskTOTFEDId
SubSystemType
the official enumeration of DAQ subsystems
bool operator<(const TotemFramePosition &pos) const
unsigned short getFullOptoRxId() const
static const unsigned int maskGOHId
static const unsigned int offsetTOTFEDId
static const std::string tagSSFEC
static const std::string tagSSNone
XML sub-system tags.
void setAllIDs(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
TotemFramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
the preferred constructor
static const unsigned int maskSubSystemId
static bool checkXMLAttributeFlag(unsigned char flag)
returns true if all attributes have been set
static const std::string tagSSTTC
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)
static const unsigned int maskOptoRxId
static const unsigned int maskIdxInFiber
static const unsigned int offsetGOHId