test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TotemFramePosition.cc
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 
10 
11 #include <iomanip>
12 #include <cstdlib>
13 
14 using namespace std;
15 
16 const string TotemFramePosition::tagSSNone = "None";
17 const string TotemFramePosition::tagSST1 = "T1";
18 const string TotemFramePosition::tagSST2 = "T2";
19 const string TotemFramePosition::tagSSRP = "RP";
20 const string TotemFramePosition::tagSSTrigger = "Trigger";
21 const string TotemFramePosition::tagSSTTC = "TTC";
22 const string TotemFramePosition::tagSSFEC = "FEC";
23 
24 //----------------------------------------------------------------------------------------------------
25 
26 std::ostream& operator << (std::ostream& s, const TotemFramePosition &fp)
27 {
28  return s << std::hex
29  << fp.getSubSystemId() << ":"
30  << std::setw(2) << std::setfill('0')
31  << fp.getTOTFEDId() << ":"
32  << fp.getOptoRxId() << ":"
33  << fp.getGOHId() << ":"
34  << fp.getIdxInFiber()
35  << std::dec;
36 }
37 
38 //----------------------------------------------------------------------------------------------------
39 
41 {
42  cout << dec << "SubSystemId=\"";
43 
44  const unsigned char &ss = getSubSystemId();
45  switch (ss)
46  {
47  case ssT1: cout << "T1"; break;
48  case ssT2: cout << "T2"; break;
49  case ssRP: cout << "RP"; break;
50  case ssTrigger: cout << "Trigger"; break;
51  case ssTTC: cout << "TTC"; break;
52  case ssFEC: cout << "FEC"; break;
53  default: cout << "None";
54  }
55 
56  cout << "\" TOTFEDId=\"" << getTOTFEDId()
57  << "\" OptoRxId=\"" << getOptoRxId()
58  << "\" GOHId=\"" << getGOHId()
59  << "\" IdxInFiber=\"" << getIdxInFiber()
60  << "\"";
61 }
62 
63 //----------------------------------------------------------------------------------------------------
64 
65 unsigned char TotemFramePosition::setXMLAttribute(const std::string &attribute, const std::string &value,
66  unsigned char &flag)
67 {
68  if (attribute == "DAQPosition")
69  {
70  size_t dd1 = value.find(':', 0);
71  size_t dd2 = value.find(':', dd1+1);
72  size_t dd3 = value.find(':', dd2+1);
73  size_t dd4 = value.find(':', dd3+1);
74  size_t dd5 = value.find(':', dd4+1);
75 
76  if (dd1 == string::npos || dd2 == string::npos || dd3 == string::npos || dd4 == string::npos ||
77  dd5 != string::npos)
78  return 3;
79 
80  unsigned short ss = strtol(value.substr(0, dd1).c_str(), NULL, 16);
81  unsigned short ti = strtol(value.substr(dd1+1, dd2-dd1).c_str(), NULL, 16);
82  unsigned short oi = strtol(value.substr(dd2+1, dd3-dd2).c_str(), NULL, 16);
83  unsigned short gi = strtol(value.substr(dd3+1, dd4-dd3).c_str(), NULL, 16);
84  unsigned short fi = strtol(value.substr(dd4+1).c_str(), NULL, 16);
85 
86  setAllIDs(ss, ti, oi, gi, fi);
87  flag |= 0x40;
88  return 0;
89  }
90 
91  unsigned int v = atoi(value.c_str());
92 
93  if (attribute == "SubSystemId")
94  {
95  if (value == tagSSNone) setSubSystemId(ssNone);
96  else if (value == tagSST1) setSubSystemId(ssT1);
97  else if (value == tagSST2) setSubSystemId(ssT2);
98  else if (value == tagSSRP) setSubSystemId(ssRP);
99  else if (value == tagSSTrigger) setSubSystemId(ssTrigger);
100  else if (value == tagSSTTC) setSubSystemId(ssTTC);
101  else if (value == tagSSFEC) setSubSystemId(ssFEC);
102  else setSubSystemId(v);
103 
104  flag |= 0x10;
105  return 0;
106  }
107 
108  if (attribute == "TOTFEDId")
109  {
110  setTOTFEDId(v);
111  flag |= 0x8;
112  return 0;
113  }
114 
115  if (attribute == "OptoRxId")
116  {
117  setOptoRxId(v);
118  flag |= 0x4;
119  return 0;
120  }
121 
122  if (attribute == "GOHId")
123  {
124  setGOHId(v);
125  flag |= 0x2;
126  return 0;
127  }
128 
129  if (attribute == "IdxInFiber")
130  {
131  setIdxInFiber(v);
132  flag |= 0x1;
133  return 0;
134  }
135 
136  return 1;
137 }
static const std::string tagSSTrigger
unsigned short getIdxInFiber() const
static const std::string tagSST2
unsigned short getTOTFEDId() const
#define NULL
Definition: scimark2.h:8
ostream & operator<<(std::ostream &o, vector< std::string > const &iValue)
Definition: refresh.cc:45
unsigned short getOptoRxId() const
void printXML()
prints XML formatted DAQ channel to stdout
static const std::string tagSST1
unsigned short getSubSystemId() const
static const std::string tagSSRP
unsigned short getGOHId() const
static const std::string tagSSFEC
static const std::string tagSSNone
XML sub-system tags.
tuple cout
Definition: gather_cfg.py:145
static const std::string tagSSTTC
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag)