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 }
personalPlayback.level
level
Definition: personalPlayback.py:22
HalfHtrData::getDCC
int getDCC() const
Definition: HtrXmlPatternSet.h:52
w2
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
mps_fire.i
i
Definition: mps_fire.py:428
ChannelPattern
Definition: HtrXmlPatternSet.h:8
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
HtrXmlPatternWriter::packWordsStd
void packWordsStd(int adc0, int adc1, int adc2, int capid, unsigned int &w1, unsigned int &w2)
Definition: HtrXmlPatternWriter.cc:65
HalfHtrData
Definition: HtrXmlPatternSet.h:44
HalfHtrData::getSlot
int getSlot() const
Definition: HtrXmlPatternSet.h:49
protons_cff.time
time
Definition: protons_cff.py:39
tabbing
static const char * tabbing(int level)
Definition: HtrXmlPatternWriter.cc:3
HalfHtrData::getCrate
int getCrate() const
Definition: HtrXmlPatternSet.h:48
HalfHtrData::getPattern
ChannelPattern * getPattern(int chan)
Definition: HtrXmlPatternSet.h:47
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
HalfHtrData::getSpigot
int getSpigot() const
Definition: HtrXmlPatternSet.h:51
p2
double p2[4]
Definition: TauolaWrapper.h:90
HtrXmlPatternWriter::m_tagName
std::string m_tagName
Definition: HtrXmlPatternWriter.h:15
p1
double p1[4]
Definition: TauolaWrapper.h:89
HtrXmlPatternWriter.h
HtrXmlPatternWriter::m_stamp
std::string m_stamp
Definition: HtrXmlPatternWriter.h:15
HalfHtrData::getTB
int getTB() const
Definition: HtrXmlPatternSet.h:50
p3
double p3[4]
Definition: TauolaWrapper.h:91
HtrXmlPatternWriter::HtrXmlPatternWriter
HtrXmlPatternWriter()
Definition: HtrXmlPatternWriter.cc:11
HtrXmlPatternWriter::writePattern
void writePattern(HalfHtrData *spigotData, int fiber, std::ostream &os, int level=0)
Definition: HtrXmlPatternWriter.cc:22
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143