CMS 3D CMS Logo

HtrXmlPatternWriter.cc
Go to the documentation of this file.
1 #include "HtrXmlPatternWriter.h"
2 
3 static const char* tabbing(int level) {
4  static char tab[50];
5  for (int i = 0; i < level * 2; i++)
6  tab[i] = ' ';
7  tab[level * 2] = 0;
8  return tab;
9 }
10 
12  // set the timestamp!
13  time_t now1 = time(nullptr);
14  struct tm* now = localtime(&now1);
15 
16  char buffer[1024];
17  strftime(buffer, 1024, "%Y-%m-%d %H:%M:%S", now);
18 
19  m_stamp = buffer;
20 }
21 
22 void HtrXmlPatternWriter::writePattern(HalfHtrData* spigotData, int fiber, std::ostream& os, int level) {
23  os << tabbing(level) << "<CFGBrick>" << std::endl;
24  os << tabbing(level + 1) << "<Parameter name='DCC' type='int'>" << std::dec << spigotData->getDCC() << "</Parameter>"
25  << std::endl;
26  os << tabbing(level + 1) << "<Parameter name='SPIGOT' type='int'>" << std::dec << spigotData->getSpigot()
27  << "</Parameter>" << std::endl;
28  os << tabbing(level + 1) << "<Parameter name='CRATE' type='int'>" << std::dec << spigotData->getCrate()
29  << "</Parameter>" << std::endl;
30  os << tabbing(level + 1) << "<Parameter name='SLOT' type='int'>" << spigotData->getSlot() << "</Parameter>"
31  << std::endl;
32  os << tabbing(level + 1) << "<Parameter name='TOPBOTTOM' type='int'>" << spigotData->getTB() << "</Parameter>"
33  << std::endl;
34  os << tabbing(level + 1) << "<Parameter name='FIBER' type='int'>" << fiber << "</Parameter>" << std::endl;
35 
36  int genIndex = fiber + (spigotData->getTB() * 10) + (spigotData->getSlot() * 100) + (spigotData->getCrate() * 10000);
37  os << tabbing(level + 1) << "<Parameter name='GENERALIZEDINDEX' type='int'>" << std::dec << genIndex << "</Parameter>"
38  << std::endl;
39  os << tabbing(level + 1) << "<Parameter name='CREATIONTAG' type='string'>" << m_tagName << "</Parameter>"
40  << std::endl;
41  os << tabbing(level + 1) << "<Parameter name='CREATIONSTAMP' type='string'>" << m_stamp << "</Parameter>"
42  << std::endl;
43  os << tabbing(level + 1) << "<Parameter name='PATTERN_SPEC_NAME' type='string'>" << m_tagName << "</Parameter>"
44  << std::endl;
45 
46  // CREATIONTAG, CREATIONSTAMP, PATTERN_SPEC_NAME
47 
48  os << tabbing(level + 1) << "<Data elements='1024' encoding='hex'>" << std::endl;
49 
50  ChannelPattern* p1 = spigotData->getPattern((fiber - 1) * 3 + 1);
51  ChannelPattern* p2 = spigotData->getPattern((fiber - 1) * 3 + 2);
52  ChannelPattern* p3 = spigotData->getPattern((fiber - 1) * 3 + 3);
53 
54  unsigned int w1, w2;
55  for (int i = 0; i < 512; i++) {
56  packWordsStd(p1->getCoded(i), p2->getCoded(i), p3->getCoded(i), i % 4, w1, w2);
57  os << std::hex << w1 << ' ' << std::hex << w2 << ' ';
58  }
59 
60  os << std::endl << tabbing(level + 1) << "</Data>" << std::endl;
61 
62  os << tabbing(level) << "</CFGBrick>" << std::endl;
63 }
64 
65 void HtrXmlPatternWriter::packWordsStd(int adc0, int adc1, int adc2, int capid, unsigned int& w1, unsigned int& w2) {
66  w1 = 0x3;
67  w1 |= (capid & 0x3) << 3;
68  w1 |= (capid & 0x3) << 5;
69  w1 |= (capid & 0x3) << 7;
70  w1 |= adc2 << 9;
71  w1 |= 0x10000; // data valid
72  w2 = adc1 << 1;
73  w2 |= adc0 << 9;
74  w2 |= 0x10000; // data valid
75 }
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
static const char * tabbing(int level)
int getCrate() const
int getSpigot() const
int getSlot() const
void packWordsStd(int adc0, int adc1, int adc2, int capid, unsigned int &w1, unsigned int &w2)
ChannelPattern * getPattern(int chan)
int getTB() const
void writePattern(HalfHtrData *spigotData, int fiber, std::ostream &os, int level=0)
int getDCC() const