62 void endJob()
override;
69 const std::vector<unsigned char>& lut,
74 std::ostream* openPerCrate(
int crate);
77 std::ostream* openChecksums();
103 snprintf(
fname, 1024,
"%s_checksums.xml", fileformat_.c_str());
104 std::ostream* os =
new std::ofstream(
fname);
105 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrick>\n";
111 snprintf(
fname, 1024,
"%s_%d.xml", fileformat_.c_str(), crate);
112 std::ostream* os =
new std::ofstream(
fname);
113 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrickSet>\n";
121 "%s_%d_%d%c_%d_%d_1.xml",
123 eid.readoutVMECrateId(),
125 ((
eid.htrTopBottom()) ? (
't') : (
'b')),
128 std::ostream* os =
new std::ofstream(
fname);
129 (*os) <<
"<?xml version=\"1.0\"?>\n";
137 "%s_%d_%d%c_%d_%d_2.xml",
139 eid.readoutVMECrateId(),
141 ((
eid.htrTopBottom()) ? (
't') : (
'b')),
143 eid.slbChannelIndex());
144 std::ostream* os =
new std::ofstream(
fname);
145 (*os) <<
"<?xml version=\"1.0\"?>\n";
151 const std::vector<unsigned short>& lut,
153 os <<
"<CFGBrick> " << std::endl;
154 os <<
" <Parameter name='IETA' type='int'>" <<
id.ieta() <<
"</Parameter>" << std::endl;
155 os <<
" <Parameter name='IPHI' type='int'>" <<
id.iphi() <<
"</Parameter>" << std::endl;
156 os <<
" <Parameter name='DEPTH' type='int'>" <<
id.depth() <<
"</Parameter>" << std::endl;
157 os <<
" <Parameter name='CRATE' type='int'>" <<
eid.readoutVMECrateId() <<
"</Parameter>" << std::endl;
158 os <<
" <Parameter name='SLOT' type='int'>" <<
eid.htrSlot() <<
"</Parameter>" << std::endl;
159 os <<
" <Parameter name='TOPBOTTOM' type='int'>" <<
eid.htrTopBottom() <<
"</Parameter>" << std::endl;
160 os <<
" <Parameter name='FIBER' type='int'>" <<
eid.fiberIndex() <<
"</Parameter>" << std::endl;
161 os <<
" <Parameter name='FIBERCHAN' type='int'>" <<
eid.fiberChanId() <<
"</Parameter>" << std::endl;
162 os <<
" <Parameter name='LUT_TYPE' type='int'>1</Parameter>" << std::endl;
163 os <<
" <Parameter name='CREATIONTAG' type='string'>" <<
creationtag_ <<
"</Parameter>" << std::endl;
164 os <<
" <Parameter name='CREATIONSTAMP' type='string'>" << creationstamp_ <<
"</Parameter>" << std::endl;
165 os <<
" <Parameter name='FORMATREVISION' type='string'>" <<
formatRevision_ <<
"</Parameter>" << std::endl;
166 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>" <<
targetfirmware_ <<
"</Parameter>" << std::endl;
167 int generalizedIndex =
id.ietaAbs() + 1000 *
id.depth() + 10000 *
id.iphi() + ((
id.ieta() < 0) ? (0) : (100)) +
168 ((
id.subdet() ==
HcalForward &&
id.ietaAbs() == 29) ? (4 * 10000) : (0));
170 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>" << generalizedIndex <<
"</Parameter>" << std::endl;
173 md5_byte_t digest[16];
174 unsigned char tool[2];
176 for (
int i = 0;
i < 128;
i++) {
177 tool[0] = lut[
i] & 0xFF;
178 tool[1] = (lut[
i] >> 8) & 0xFF;
179 md5_append(&md5er, tool, 2);
181 md5_finish(&md5er, digest);
182 os <<
" <Parameter name='CHECKSUM' type='string'>";
183 for (
int i = 0;
i < 16;
i++)
184 os << std::hex << (((
int)(digest[
i])) & 0xFF);
185 os <<
"</Parameter>\n";
187 *oc_ <<
" <Data crate='" <<
eid.readoutVMECrateId() <<
"' slot='" <<
eid.htrSlot() <<
"' fpga='"
188 <<
eid.htrTopBottom() <<
"' fiber='" <<
eid.fiberIndex() <<
"' fiberchan='" <<
eid.fiberChanId()
189 <<
"' luttype='1' elements='1' encoding='hex'>";
190 for (
int i = 0;
i < 16;
i++)
191 *oc_ << std::hex << (((
int)(digest[
i])) & 0xFF);
194 os <<
" <Data elements='128' encoding='hex'> " << std::endl;
196 for (
int initr2 = 0; initr2 < 128; initr2++) {
197 os << lut[initr2] <<
" ";
201 os <<
" </Data> " << std::endl;
202 os <<
"</CFGBrick> " << std::endl;
207 const std::vector<unsigned char>& lut,
209 os <<
"<CFGBrick> " << std::endl;
210 os <<
" <Parameter name='IETA' type='int'>" <<
id.ieta() <<
"</Parameter>" << std::endl;
211 os <<
" <Parameter name='IPHI' type='int'>" <<
id.iphi() <<
"</Parameter>" << std::endl;
212 os <<
" <Parameter name='CRATE' type='int'>" <<
eid.readoutVMECrateId() <<
"</Parameter>" << std::endl;
213 os <<
" <Parameter name='SLOT' type='int'>" <<
eid.htrSlot() <<
"</Parameter>" << std::endl;
214 os <<
" <Parameter name='TOPBOTTOM' type='int'>" <<
eid.htrTopBottom() <<
"</Parameter>" << std::endl;
215 os <<
" <Parameter name='SLB' type='int'>" <<
eid.slbSiteNumber() <<
"</Parameter>" << std::endl;
216 os <<
" <Parameter name='SLBCHAN' type='int'>" <<
eid.slbChannelIndex() <<
"</Parameter>" << std::endl;
217 os <<
" <Parameter name='LUT_TYPE' type='int'>2</Parameter>" << std::endl;
218 os <<
" <Parameter name='CREATIONTAG' type='string'>" <<
creationtag_ <<
"</Parameter>" << std::endl;
219 os <<
" <Parameter name='CREATIONSTAMP' type='string'>" << creationstamp_ <<
"</Parameter>" << std::endl;
220 os <<
" <Parameter name='FORMATREVISION' type='string'>" <<
formatRevision_ <<
"</Parameter>" << std::endl;
221 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>" <<
targetfirmware_ <<
"</Parameter>" << std::endl;
222 int generalizedIndex =
id.ietaAbs() + 10000 *
id.iphi() + ((
id.ieta() < 0) ? (0) : (100));
224 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>" << generalizedIndex <<
"</Parameter>" << std::endl;
228 md5_byte_t digest[16];
230 md5_append(&md5er, &(lut[0]), 1024);
231 md5_finish(&md5er, digest);
232 os <<
" <Parameter name='CHECKSUM' type='string'>";
233 for (
int i = 0;
i < 16;
i++)
234 os << std::hex << (((
int)(digest[
i])) & 0xFF);
235 os <<
"</Parameter>\n";
237 *oc_ <<
" <Data crate='" <<
eid.readoutVMECrateId() <<
"' slot='" <<
eid.htrSlot() <<
"' fpga='"
238 <<
eid.htrTopBottom() <<
"' slb='" <<
eid.slbSiteNumber() <<
"' slbchan='" <<
eid.slbChannelIndex()
239 <<
"' luttype='2' elements='1' encoding='hex'>";
240 for (
int i = 0;
i < 16;
i++)
241 *oc_ << std::hex << (((
int)(digest[
i])) & 0xFF);
244 os <<
" <Data elements='1024' encoding='hex'> " << std::endl;
246 for (
int initr2 = 0; initr2 < 1024; initr2++) {
247 os << (
int(lut[initr2]) & 0xFF) <<
" ";
251 os <<
" </Data> " << std::endl;
252 os <<
"</CFGBrick> " << std::endl;
256 std::vector<unsigned char> lut;
257 for (
int i = 0;
i < 1024;
i++) {
259 lut.push_back(
s.compressedEt());
269 edm::LogInfo(
"Hcal") <<
"Beginning dump of Hcal TPG LUTS (this may take a minute or two)";
282 std::vector<HcalElectronicsId>::iterator itreid;
284 std::ostream* pfile =
nullptr;
285 oc_ = openChecksums();
287 for (
int crate = 0; crate < 20; crate++) {
289 for (itreid = allEID.begin(); itreid != allEID.end(); ++itreid) {
290 if (itreid->readoutVMECrateId() != crate)
292 if (itreid->isTriggerChainId()) {
297 if (filePerCrate_ && pfile ==
nullptr)
298 pfile = openPerCrate(crate);
299 else if (pfile ==
nullptr)
300 pfile = openPerLut2(*itreid);
302 std::vector<unsigned char> lut = extractOutputLut(*outTranscoder, tid);
303 writeoutlut2(tid, *itreid, lut, *pfile);
304 if (!filePerCrate_) {
315 if (filePerCrate_ && pfile ==
nullptr)
316 pfile = openPerCrate(crate);
317 else if (pfile ==
nullptr)
318 pfile = openPerLut1(*itreid);
321 writeoutlut1(
HcalDetId(gid), *itreid, lut, *pfile);
322 if (!filePerCrate_) {
328 if (pfile !=
nullptr) {
330 *pfile <<
"</CFGBrickSet>\n";
335 *oc_ <<
"</CFGBrick>\n";
343 struct tm* tm = localtime(&
now);
344 strftime(
buffer, 120,
"%F %T", tm);