10 #include <nlohmann/json.hpp>
27 jItem[
"name"] =
item.name();
28 jItem[
"ctpid"] =
item.ctpId();
29 jItem[
"definition"] =
item.definition();
30 jItem[
"monitor"] =
item.monitor();
31 jItem[
"partition"] =
item.partition();
32 jItem[
"triggerType"] =
item.triggerType();
33 jItem[
"bunchgroups"] =
json(
item.bunchgroups());
34 if(
auto legacy =
item.legacy() )
35 jItem[
"legacy"] = *legacy;
39 json thresholds = json::object_t{};
40 for(
const std::string & thrType :
l1menu.thresholdTypes()) {
41 json jThresholsByType({});
43 for(
auto & thr :
l1menu.thresholds(thrType)) {
45 jThr[
"mapping"] = thr->mapping();
47 if(thr->hasChild(
"sectors")) {
48 std::vector<std::string> sectors;
49 for(
auto &
s : thr->getList(
"sectors")) {
50 sectors.push_back(
s.getValue());
52 jThr[
"sectors"] = sectors;
54 if(thr->hasAttribute(
"voltage")) {
55 jThr[
"voltage"] = thr->getAttribute<
float>(
"voltage");
60 if(thr->hasAttribute(
"value")) {
62 jThr[
"value"] =
int(caloThr.thrValue());
64 }
catch(std::bad_cast&) {};
70 jThr[
"ecThr"] = muThr.ptEndcap();
71 jThr[
"fwThr"] = muThr.ptForward();
72 jThr[
"baIdx"] = muThr.idxBarrel();
73 jThr[
"ecIdx"] = muThr.idxEndcap();
74 jThr[
"fwIdx"] = muThr.idxForward();
75 jThr[
"region"] = muThr.region();
76 jThr[
"tgcFlags"] = muThr.tgcFlags();
77 jThr[
"rpcFlags"] = muThr.rpcFlags();
78 if(
const std::string & roiExcl = muThr.rpcExclROIList(); !roiExcl.empty()) {
79 jThr[
"rpcExclROIList"] = roiExcl;
81 }
catch(std::bad_cast&) {};
86 std::string isobits =
"00000";
88 for(
size_t b=0;
b<5; ++
b) {
89 if(isomask & (1<<
b)) { isobits[4-
b] =
'1'; }
91 jThr[
"isobits"] = isobits;
92 jThr[
"thrValues"] = json::array_t({});
93 for(
auto &
rv : tauThr.thrValues()) {
95 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
96 jRV[
"etamin"] =
rv.etaMin();
97 jRV[
"etamax"] =
rv.etaMax();
100 jRV[
"priority"] =
rv.priority();
101 jThr[
"thrValues"] += jRV;
103 }
catch(std::bad_cast&) {};
108 jThr[
"thrValues"] = json::array_t({});
109 for(
auto &
rv : EMThr.thrValues()) {
111 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
112 jRV[
"etamin"] =
rv.etaMin();
113 jRV[
"etamax"] =
rv.etaMax();
116 std::string isobits =
"00000";
117 auto isomask = EMThr.isolationMask(
rv.etaMin());
118 for(
size_t b=0;
b<5; ++
b) {
119 if(isomask & (1<<
b)) { isobits[4-
b] =
'1'; }
121 jRV[
"isobits"] = isobits;
122 jRV[
"priority"] =
rv.priority();
123 jThr[
"thrValues"] += jRV;
125 }
catch(std::bad_cast&) {};
130 jThr[
"thrValues"] = json::array_t({});
131 for(
auto &
rv : JThr.thrValues()) {
133 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
134 jRV[
"etamin"] =
rv.etaMin();
135 jRV[
"etamax"] =
rv.etaMax();
138 jRV[
"window"] = JThr.window(0);
139 jRV[
"priority"] =
rv.priority();
140 jThr[
"thrValues"] += jRV;
142 }
catch(std::bad_cast&) {};
148 for(
auto &
rv : teThr.thrValues()) {
150 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
151 jRV[
"etamin"] =
rv.etaMin();
152 jRV[
"etamax"] =
rv.etaMax();
153 jRV[
"priority"] =
rv.priority();
154 jThr[
"thrValues"] += jRV;
156 }
catch(std::bad_cast&) {};
161 jThr[
"seed"] = zbThr.
seed();
162 jThr[
"seedBcdelay"] = zbThr.seedBcdelay();
163 jThr[
"seedMultiplicity"] = zbThr.seedMultiplicity();
164 }
catch(std::bad_cast&) {};
169 jThr[
"mask0"] = zbTopoThr.
mask0();
170 jThr[
"mask0"] = zbTopoThr.mask0();
171 jThr[
"mask0"] = zbTopoThr.mask0();
172 jThr[
"mask0"] = zbTopoThr.mask0();
173 jThr[
"mask0"] = zbTopoThr.mask0();
174 jThr[
"mask0"] = zbTopoThr.mask0();
175 jThr[
"seedBcdelay"] = zbTopoThr.seedBcdelay();
177 }
catch(std::bad_cast&) {};
186 for(
auto &
rv : eEMThr.thrValues()) {
188 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
189 jRV[
"etamin"] =
rv.etaMin();
190 jRV[
"etamax"] =
rv.etaMax();
191 jRV[
"priority"] =
rv.priority();
192 jThr[
"thrValues"] += jRV;
194 }
catch(std::bad_cast&) {};
203 for(
auto &
rv : jEMThr.thrValues()) {
205 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
206 jRV[
"etamin"] =
rv.etaMin();
207 jRV[
"etamax"] =
rv.etaMax();
208 jRV[
"priority"] =
rv.priority();
209 jThr[
"thrValues"] += jRV;
211 }
catch(std::bad_cast&) {};
218 jThr[
"thrValues"] = json::array_t({});
219 for(
auto &
rv : eTAUThr.thrValues()) {
221 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
222 jRV[
"etamin"] =
rv.etaMin();
223 jRV[
"etamax"] =
rv.etaMax();
226 jRV[
"priority"] =
rv.priority();
227 jThr[
"thrValues"] += jRV;
229 }
catch(std::bad_cast&) {};
235 jThr[
"thrValues"] = json::array_t({});
236 for(
auto &
rv : jTAUThr.thrValues()) {
238 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
239 jRV[
"etamin"] =
rv.etaMin();
240 jRV[
"etamax"] =
rv.etaMax();
243 jRV[
"priority"] =
rv.priority();
244 jThr[
"thrValues"] += jRV;
246 }
catch(std::bad_cast&) {};
252 jThr[
"thrValues"] = json::array_t({});
253 for(
auto &
rv : cTAUThr.thrValues()) {
255 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
256 jRV[
"etamin"] =
rv.etaMin();
257 jRV[
"etamax"] =
rv.etaMax();
260 jRV[
"priority"] =
rv.priority();
261 jThr[
"thrValues"] += jRV;
263 }
catch(std::bad_cast&) {};
268 jThr[
"thrValues"] = json::array_t({});
269 for(
auto &
rv : jJThr.thrValues()) {
271 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
272 jRV[
"etamin"] =
rv.etaMin();
273 jRV[
"etamax"] =
rv.etaMax();
274 jRV[
"priority"] =
rv.priority();
275 jThr[
"thrValues"] += jRV;
277 }
catch(std::bad_cast&) {};
282 jThr[
"thrValues"] = json::array_t({});
283 for(
auto &
rv : jLJThr.thrValues()) {
285 jRV[
"value"] =
static_cast<unsigned int>(
rv.value());
286 jRV[
"etamin"] =
rv.etaMin();
287 jRV[
"etamax"] =
rv.etaMax();
288 jRV[
"priority"] =
rv.priority();
289 jThr[
"thrValues"] += jRV;
291 }
catch(std::bad_cast&) {};
296 jThr[
"value"] =
int(gJThr.thrValue());
297 }
catch(std::bad_cast&) {};
302 jThr[
"value"] =
int(gLJThr.thrValue());
303 }
catch(std::bad_cast&) {};
308 jThr[
"value"] =
int(jXEThr.thrValue());
309 }
catch(std::bad_cast&) {};
314 jThr[
"value"] =
int(jTEThr.thrValue());
315 }
catch(std::bad_cast&) {};
320 jThr[
"value"] =
int(gXEThr.thrValue());
321 }
catch(std::bad_cast&) {};
326 jThr[
"value"] =
int(gTEThr.thrValue());
327 }
catch(std::bad_cast&) {};
329 jThresholsByType[thr->name()] = jThr;
332 if(thrType !=
"internal") {
333 jThrType[
"thresholds"] = jThresholsByType;
335 jThrType[
"type"] = thrType;
338 auto & extraInfo =
l1menu.thrExtraInfo().thrExtraInfo(thrType);
339 if(extraInfo.hasAttribute(
"ptMinToTopo")) {
340 jThrType[
"ptMinToTopo"] = extraInfo.getAttribute<
unsigned int>(
"ptMinToTopo");
342 if(extraInfo.hasAttribute(
"resolutionMeV")) {
343 jThrType[
"resolutionMeV"] = extraInfo.getAttribute<
unsigned int>(
"resolutionMeV");
347 if(thrType ==
"internal") {
348 jThrType[
"names"] = json::array_t({});
349 for(
auto & thr :
l1menu.thresholds(thrType)) {
350 jThrType[
"names"] += thr->name();
352 auto & extInfo =
l1menu.thrExtraInfo().thrExtraInfo(
"internal");
353 if(
auto randoms = extInfo.getExtraInfo(
"randoms")) {
354 for(
size_t rc=0; rc<4; ++rc) {
356 randoms->get().getAttribute<
unsigned int>(
"RNDM" +
std::to_string(rc)+
".cut");
361 if(thrType ==
"MU") {
362 auto & muinfo =
l1menu.thrExtraInfo().MU();
364 for(
auto & listName : muinfo.exclusionListNames()) {
365 jThrType[
"exclusionLists"][listName] = json::array_t({});
366 for(
auto &
x : muinfo.exclusionList(listName)) {
367 jThrType[
"exclusionLists"][listName] +=
json({ {
"sectorName",
x.first}, {
"rois",
x.second}});
370 for(
auto & rpcPt : muinfo.knownRpcPtValues()) {
371 jThrType[
"roads"][
"rpc"][
std::to_string(rpcPt)] = muinfo.rpcIdxForPt(rpcPt);
373 for(
auto &
tgcPt : muinfo.knownTgcPtValues()) {
378 if(thrType ==
"EM" &&
l1menu.run()>1) {
379 auto & eminfo =
l1menu.thrExtraInfo().EM();
380 for(
const std::string isoSet : {
"EMIsoForEMthr",
"HAIsoForEMthr" }) {
381 jThrType[
"isolation"][isoSet][
"thrtype"] = isoSet;
382 jThrType[
"isolation"][isoSet][
"Parametrization"] = json::array_t({});
383 for(
size_t bit = 1; bit<=5; ++bit) {
384 auto & iso = eminfo.isolation(isoSet,bit);
386 jIso[
"etamax"] = iso.etamax();
387 jIso[
"etamin"] = iso.etamin();
388 jIso[
"isobit"] = iso.isobit();
389 jIso[
"mincut"] = iso.mincut();
390 jIso[
"offset"] = iso.offset();
391 jIso[
"priority"] = iso.priority();
392 jIso[
"slope"] = iso.slope();
393 jIso[
"upperlimit"] = iso.upperlimit();
394 jThrType[
"isolation"][isoSet][
"Parametrization"] += jIso;
399 if(thrType ==
"TAU" &&
l1menu.run()>1) {
400 auto & tauinfo =
l1menu.thrExtraInfo().TAU();
401 const std::string isoSet{
"EMIsoForTAUthr" };
402 jThrType[
"isolation"][isoSet][
"thrtype"] = isoSet;
403 jThrType[
"isolation"][isoSet][
"Parametrization"] = json::array_t({});
404 for(
size_t bit = 1; bit<=5; ++bit) {
405 auto & iso = tauinfo.isolation(isoSet,bit);
407 jIso[
"etamax"] = iso.etamax();
408 jIso[
"etamin"] = iso.etamin();
409 jIso[
"isobit"] = iso.isobit();
410 jIso[
"mincut"] = iso.mincut();
411 jIso[
"offset"] = iso.offset();
412 jIso[
"priority"] = iso.priority();
413 jIso[
"slope"] = iso.slope();
414 jIso[
"upperlimit"] = iso.upperlimit();
415 jThrType[
"isolation"][isoSet][
"Parametrization"] += jIso;
419 if(thrType ==
"JET") {
420 auto & jetinfo =
l1menu.thrExtraInfo().JET();
421 jThrType[
"ptMinToTopoSmallWindow"] = (
int)jetinfo.ptMinToTopoSmallWindow();
422 jThrType[
"ptMinToTopoLargeWindow"] = (
int)jetinfo.ptMinToTopoLargeWindow();
425 if(thrType ==
"XS") {
426 auto & xsinfo =
l1menu.thrExtraInfo().XS();
427 jThrType[
"significance"][
"xeMin"] = xsinfo.xeMin();
428 jThrType[
"significance"][
"xeMax"] = xsinfo.xeMax();
429 jThrType[
"significance"][
"teSqrtMin"] = xsinfo.teSqrtMin();
430 jThrType[
"significance"][
"teSqrtMax"] = xsinfo.teSqrtMax();
431 jThrType[
"significance"][
"xsSigmaScale"] = xsinfo.xsSigmaScale();
432 jThrType[
"significance"][
"xsSigmaOffset"] = xsinfo.xsSigmaOffset();
435 if(thrType ==
"eEM") {
436 auto & eeminfo =
l1menu.thrExtraInfo().eEM();
437 jThrType[
"maxEt"] = (
int)eeminfo.maxEt();
440 jThrType[
"workingPoints"][wpstr] = json::array_t({});
441 for(
auto & iso : eeminfo.isolation(
wp)) {
444 stream << std::fixed << std::setprecision(3) << iso.value().reta_d();
445 jWPIso[
"reta"] = std::stod(
stream.str());
446 jWPIso[
"reta_fw"] = iso.value().reta_fw();
449 stream << std::fixed << std::setprecision(3) << iso.value().rhad_d();
450 jWPIso[
"rhad"] = std::stod(
stream.str());
451 jWPIso[
"rhad_fw"] = iso.value().rhad_fw();
454 stream << std::fixed << std::setprecision(3) << iso.value().wstot_d();
455 jWPIso[
"wstot"] = std::stod(
stream.str());
456 jWPIso[
"wstot_fw"] = iso.value().wstot_fw();
457 jWPIso[
"etamin"] = iso.etaMin();
458 jWPIso[
"etamax"] = iso.etaMax();
459 jWPIso[
"priority"] = iso.priority();
460 jThrType[
"workingPoints"][wpstr] += jWPIso;
465 if(thrType ==
"jEM") {
466 auto & jeminfo =
l1menu.thrExtraInfo().jEM();
467 jThrType[
"maxEt"] = (
int)jeminfo.maxEt();
468 jThrType[
"ptMinToTopo1"] = (
int)jeminfo.ptMinToTopo(
"1A");
469 jThrType[
"ptMinToTopo2"] = (
int)jeminfo.ptMinToTopo(
"2A");
470 jThrType[
"ptMinToTopo3"] = (
int)jeminfo.ptMinToTopo(
"3A");
471 jThrType[
"ptMinxTOB1"] = (
int)jeminfo.ptMinxTOB(
"1A");
472 jThrType[
"ptMinxTOB2"] = (
int)jeminfo.ptMinxTOB(
"2A");
473 jThrType[
"ptMinxTOB3"] = (
int)jeminfo.ptMinxTOB(
"3A");
476 jThrType[
"workingPoints"][wpstr] = json::array_t({});
477 for(
auto & iso : jeminfo.isolation(
wp)) {
480 stream << std::fixed << std::setprecision(3) << iso.value().iso_d();
481 jWPIso[
"iso"] = std::stod(
stream.str());
482 jWPIso[
"iso_fw"] = iso.value().iso_fw();
485 stream << std::fixed << std::setprecision(3) << iso.value().frac_d();
486 jWPIso[
"frac"] = std::stod(
stream.str());
487 jWPIso[
"frac_fw"] = iso.value().frac_fw();
490 stream << std::fixed << std::setprecision(3) << iso.value().frac2_d();
491 jWPIso[
"frac2"] = std::stod(
stream.str());
492 jWPIso[
"frac2_fw"] = iso.value().frac2_fw();
493 jWPIso[
"etamin"] = iso.etaMin();
494 jWPIso[
"etamax"] = iso.etaMax();
495 jWPIso[
"priority"] = iso.priority();
496 jThrType[
"workingPoints"][wpstr] += jWPIso;
501 if(thrType ==
"eTAU") {
502 auto & eeminfo =
l1menu.thrExtraInfo().eTAU();
503 jThrType[
"minIsoEt"] = (
int)eeminfo.minIsoEt();
504 jThrType[
"maxEt"] = (
int)eeminfo.maxEt();
505 jThrType[
"algoVersion"] = (
int)eeminfo.algoVersion();
509 jThrType[
"workingPoints"][wpstr] = json::array_t({});
510 for(
auto & iso : eeminfo.isolation(
wp)) {
513 stream << std::fixed << std::setprecision(3) << iso.value().rCore_d();
514 jWPIso[
"rCore"] = std::stod(
stream.str());
515 jWPIso[
"rCore_fw"] = iso.value().rCore_fw();
518 stream << std::fixed << std::setprecision(3) << iso.value().rHad_d();
519 jWPIso[
"rHad"] = std::stod(
stream.str());
520 jWPIso[
"rHad_fw"] = iso.value().rHad_fw();
521 jThrType[
"workingPoints"][wpstr] += jWPIso;
526 if(thrType ==
"jTAU") {
527 auto & jtauinfo =
l1menu.thrExtraInfo().jTAU();
528 jThrType[
"maxEt"] = (
int)jtauinfo.maxEt();
529 jThrType[
"ptMinToTopo1"] = (
int)jtauinfo.ptMinToTopo(
"1A");
530 jThrType[
"ptMinToTopo2"] = (
int)jtauinfo.ptMinToTopo(
"2A");
531 jThrType[
"ptMinToTopo3"] = (
int)jtauinfo.ptMinToTopo(
"3A");
532 jThrType[
"ptMinxTOB1"] = (
int)jtauinfo.ptMinxTOB(
"1A");
533 jThrType[
"ptMinxTOB2"] = (
int)jtauinfo.ptMinxTOB(
"2A");
534 jThrType[
"ptMinxTOB3"] = (
int)jtauinfo.ptMinxTOB(
"3A");
537 jThrType[
"workingPoints"][wpstr] = json::array_t({});
538 for(
auto & iso : jtauinfo.isolation(
wp)) {
541 stream << std::fixed << std::setprecision(3) << iso.value().isolation_d();
542 jWPIso[
"isolation"] = std::stod(
stream.str());
543 jWPIso[
"isolation_fw"] = iso.value().isolation_fw();
544 jThrType[
"workingPoints"][wpstr] += jWPIso;
549 if(thrType ==
"cTAU") {
550 auto & eeminfo =
l1menu.thrExtraInfo().cTAU();
553 jThrType[
"workingPoints"][wpstr] = json::array_t({});
554 for(
auto & iso : eeminfo.isolation(
wp)) {
557 stream << std::fixed << std::setprecision(3) << iso.value().isolation_d();
558 jWPIso[
"isolation"] = std::stod(
stream.str());
559 jWPIso[
"isolation_fw"] = iso.value().isolation_fw();
561 stream << std::fixed << std::setprecision(3) << iso.value().isolation_jTAUCoreScale_d();
562 jWPIso[
"isolation_jTAUCoreScale"] = std::stod(
stream.str());
563 jWPIso[
"isolation_jTAUCoreScale_fw"] = iso.value().isolation_jTAUCoreScale_fw();
565 stream << std::fixed << std::setprecision(3) << iso.value().eTAU_rCoreMin_WP_d();
566 jWPIso[
"eTAU_rCoreMin"] = std::stod(
stream.str());
567 jWPIso[
"eTAU_rCoreMin_WP_fw"] = iso.value().eTAU_rCoreMin_WP_fw();
569 stream << std::fixed << std::setprecision(3) << iso.value().eTAU_rHadMin_WP_d();
570 jWPIso[
"eTAU_rHadMin"] = std::stod(
stream.str());
571 jWPIso[
"eTAU_rHadMin_WP_fw"] = iso.value().eTAU_rHadMin_WP_fw();
572 jThrType[
"workingPoints"][wpstr] += jWPIso;
577 if(thrType ==
"jJ") {
578 auto & jjinfo =
l1menu.thrExtraInfo().jJ();
579 jThrType[
"ptMinToTopo1"] = (
int)jjinfo.ptMinToTopo(
"1A");
580 jThrType[
"ptMinToTopo2"] = (
int)jjinfo.ptMinToTopo(
"2A");
581 jThrType[
"ptMinToTopo3"] = (
int)jjinfo.ptMinToTopo(
"3A");
582 jThrType[
"ptMinxTOB1"] = (
int)jjinfo.ptMinxTOB(
"1A");
583 jThrType[
"ptMinxTOB2"] = (
int)jjinfo.ptMinxTOB(
"2A");
584 jThrType[
"ptMinxTOB3"] = (
int)jjinfo.ptMinxTOB(
"3A");
587 if(thrType ==
"jLJ") {
588 auto & jljinfo =
l1menu.thrExtraInfo().jLJ();
589 jThrType[
"ptMinToTopo1"] = (
int)jljinfo.ptMinToTopo(
"1A");
590 jThrType[
"ptMinToTopo2"] = (
int)jljinfo.ptMinToTopo(
"2A");
591 jThrType[
"ptMinToTopo3"] = (
int)jljinfo.ptMinToTopo(
"3A");
592 jThrType[
"ptMinxTOB1"] = (
int)jljinfo.ptMinxTOB(
"1A");
593 jThrType[
"ptMinxTOB2"] = (
int)jljinfo.ptMinxTOB(
"2A");
594 jThrType[
"ptMinxTOB3"] = (
int)jljinfo.ptMinxTOB(
"3A");
597 if(thrType ==
"gJ") {
598 auto & gjinfo =
l1menu.thrExtraInfo().gJ();
599 jThrType[
"ptMinToTopo1"] = (
int)gjinfo.ptMinToTopo(1);
600 jThrType[
"ptMinToTopo2"] = (
int)gjinfo.ptMinToTopo(2);
603 if(thrType ==
"gLJ") {
604 auto & gljinfo =
l1menu.thrExtraInfo().gLJ();
605 jThrType[
"ptMinToTopo1"] = (
int)gljinfo.ptMinToTopo(1);
606 jThrType[
"ptMinToTopo2"] = (
int)gljinfo.ptMinToTopo(2);
607 jThrType[
"seedThrA"] = (
int)gljinfo.seedThr(
'A');
608 jThrType[
"seedThrB"] = (
int)gljinfo.seedThr(
'B');
609 jThrType[
"seedThrC"] = (
int)gljinfo.seedThr(
'C');
611 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMin(
'A');
612 jThrType[
"rhoTowerMinA"] = std::stod(
stream.str());
615 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMin(
'B');
616 jThrType[
"rhoTowerMinB"] = std::stod(
stream.str());
619 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMin(
'C');
620 jThrType[
"rhoTowerMinC"] = std::stod(
stream.str());
623 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMax(
'A');
624 jThrType[
"rhoTowerMaxA"] = std::stod(
stream.str());
627 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMax(
'B');
628 jThrType[
"rhoTowerMaxB"] = std::stod(
stream.str());
631 stream << std::fixed << std::setprecision(3) << gljinfo.rhoTowerMax(
'C');
632 jThrType[
"rhoTowerMaxC"] = std::stod(
stream.str());
635 if(thrType ==
"jXE") {
639 if(thrType ==
"jTE") {
640 auto & ei =
l1menu.thrExtraInfo().jTE();
641 jThrType[
"etaBoundary1"] = ei.etaBoundary(
"1A");
642 jThrType[
"etaBoundary1_fw"] = ei.etaBoundary_fw(
"1A");
643 jThrType[
"etaBoundary2"] = ei.etaBoundary(
"2A");
644 jThrType[
"etaBoundary2_fw"] = ei.etaBoundary_fw(
"2A");
645 jThrType[
"etaBoundary3"] = ei.etaBoundary(
"3A");
646 jThrType[
"etaBoundary3_fw"] = ei.etaBoundary_fw(
"3A");
649 if(thrType ==
"gXE") {
650 auto & ei =
l1menu.thrExtraInfo().gXE();
651 jThrType[
"seedThrA"] = (
int)ei.seedThr(
'A');
652 jThrType[
"seedThrB"] = (
int)ei.seedThr(
'B');
653 jThrType[
"seedThrC"] = (
int)ei.seedThr(
'C');
654 jThrType[
"XERHO_sigmaPosA"] = ei.XERHO_param(
'A',
true);
655 jThrType[
"XERHO_sigmaPosB"] = ei.XERHO_param(
'B',
true);
656 jThrType[
"XERHO_sigmaPosC"] = ei.XERHO_param(
'C',
true);
657 jThrType[
"XERHO_sigmaNegA"] = ei.XERHO_param(
'A',
false);
658 jThrType[
"XERHO_sigmaNegB"] = ei.XERHO_param(
'B',
false);
659 jThrType[
"XERHO_sigmaNegC"] = ei.XERHO_param(
'C',
false);
660 jThrType[
"XEJWOJ_a_A"] = ei.JWOJ_param(
'A',
'a');
661 jThrType[
"XEJWOJ_a_B"] = ei.JWOJ_param(
'B',
'a');
662 jThrType[
"XEJWOJ_a_C"] = ei.JWOJ_param(
'C',
'a');
663 jThrType[
"XEJWOJ_b_A"] = ei.JWOJ_param(
'A',
'b');
664 jThrType[
"XEJWOJ_b_B"] = ei.JWOJ_param(
'B',
'b');
665 jThrType[
"XEJWOJ_b_C"] = ei.JWOJ_param(
'C',
'b');
666 jThrType[
"XEJWOJ_c_A"] = ei.JWOJ_param(
'A',
'c');
667 jThrType[
"XEJWOJ_c_B"] = ei.JWOJ_param(
'B',
'c');
668 jThrType[
"XEJWOJ_c_C"] = ei.JWOJ_param(
'C',
'c');
671 if(thrType ==
"gTE") {
675 std::vector<std::string> legacyCalo = {
"EM",
"JET",
"TAU",
"XE",
"TE",
"XS",
"ZB",
"JB",
"JF",
"JE",
"R2TOPO"};
676 if( std::any_of(
begin(legacyCalo),
end(legacyCalo), [&thrType](
const std::string &
c) {
return c==thrType; }) ) {
677 thresholds[
"legacyCalo"][thrType] = jThrType;
679 thresholds[thrType] = jThrType;
683 json boards = json::object_t{};
684 for(
auto & bname :
l1menu.boardNames() ) {
685 auto & bdef =
l1menu.board(bname);
686 boards[bname] =
json{ {
"connectors", bdef.connectorNames()}, {
"type", bdef.type()} };
688 boards[bname][
"legacy"] =
true;
691 json connectors = json::object_t{};
692 for(
auto & cname :
l1menu.connectorNames() ) {
694 auto & cdef =
l1menu.connector(cname);
695 jConn[
"type"] = cdef.type();
697 jConn[
"legacy"] =
true;
698 jConn[
"triggerlines"] = json::array_t();
699 if(cdef.maxClock() == 2){
700 if(cdef.maxFpga() == 2){
702 for(
size_t fpga = 0; fpga<cdef.maxFpga(); ++fpga) {
703 for(
size_t clock = 0; clock<cdef.maxClock(); ++clock) {
704 for(
auto &
tl : cdef.triggerLines(fpga, clock)) {
705 jConn[
"triggerlines"] +=
json({ {
"name",
tl.name()}, {
"nbits",
tl.nbits()}, {
"startbit",
tl.startbit()}, {
"flatindex",
tl.flatindex()}, {
"fpga",
tl.fpga()}, {
"clock",
tl.clock()}, });
711 for(
size_t fpga = 0; fpga<cdef.maxFpga(); ++fpga) {
712 for(
size_t clock = 0; clock<cdef.maxClock(); ++clock) {
713 for(
auto &
tl : cdef.triggerLines(fpga, clock)) {
714 jConn[
"triggerlines"] +=
json({ {
"name",
tl.name()}, {
"nbits",
tl.nbits()}, {
"startbit",
tl.startbit()}, {
"flatindex",
tl.flatindex()}, {
"clock",
tl.clock()}, });
720 for(
auto &
tl : cdef.triggerLines()) {
721 jConn[
"triggerlines"] +=
json({ {
"name",
tl.name()}, {
"nbits",
tl.nbits()}, {
"startbit",
tl.startbit()}, {
"flatindex",
tl.flatindex()} });
724 connectors[cname] = jConn;
729 for(
size_t slot=7; slot<=9; ++slot) {
731 ctp[
"inputs"][
"ctpin"][sName] =
json({});
736 ctp[
"inputs"][
"electrical"] = json::object_t{};
742 ctp[
"inputs"][
"optical"] = json::object_t{};
748 json ctpmon = json::object_t{};
749 for(
auto &
mon :
l1menu.ctp().ctpMon()) {
750 ctpmon[
mon.first] =
json({{
"multiplicity",
mon.second.first},{
"thr",
mon.second.second}});
752 json ctpin = json::object_t{};
753 for(
auto &
mon :
l1menu.ctp().ctpinMon()) {
754 ctpin[
mon.first] =
json({{
"multiplicity",
mon.second.first},{
"thr",
mon.second.second}});
756 ctp[
"monitoring"] =
json({{
"ctpmon", ctpmon}, {
"ctpin", ctpin}});
759 json jtopo = json::object_t{};
761 std::map<L1TopoAlgorithm::AlgorithmType,std::string> algTypeNames = {
766 auto topoCategories =
l1menu.isRun2() ? std::vector<std::string> {
"R2TOPO"} : std::vector<std::string> {
"TOPO",
"MUTOPO",
"MULTTOPO",
"R2TOPO"};
767 for(
const std::string& topoCat : topoCategories ) {
769 json jalg = json::object_t({});
771 jalg[
"klass"] =
alg.klass();
774 if(
alg.inputs().size()>0) {
775 jalg[
"input"] =
alg.inputs()[0];
777 jalg[
"input"] =
nullptr;
780 jalg[
"input"] =
alg.inputs()[0];
782 jalg[
"input"] =
alg.inputs();
786 jalg[
"output"] =
alg.outputs();
788 jalg[
"output"] =
alg.outputs()[0];
791 if(topoCat ==
"MULTTOPO") {
792 jalg[
"nbits"] =
alg.getAttribute<
unsigned int>(
"nbits");
793 jalg[
"threshold"] =
alg.getAttribute(
"threshold");
794 if(
alg.klass()==
"EnergyThreshold"){
800 const auto &
ds =
alg.generics();
801 for(
const auto & gpname :
ds.getKeys()) {
802 auto gp =
ds.getObject(gpname);
804 if(gp.hasAttribute(
"position")) {
805 jalg[
"fixedParameters"][
"generics"][gpname][
"position"] = gp.getAttribute<
unsigned int>(
"position");
807 std::string pval =
alg.genericParameter(gpname);
809 int pvali = std::stoi(pval);
810 jalg[
"fixedParameters"][
"generics"][gpname][
"value"] = pvali;
811 }
catch(std::invalid_argument &) {
812 jalg[
"fixedParameters"][
"generics"][gpname][
"value"] = pval;
818 if(topoCat !=
"MULTTOPO") {
819 jalg[
"variableParameters"] = json::array_t({});
822 jVPar[
"name"] = vpar.name();
823 jVPar[
"value"] = vpar.value();
824 if(
auto sel = vpar.selection_optional()) { jVPar[
"selection"] = *
sel; }
825 jalg[
"variableParameters"] += jVPar;
828 jtopo[topoCat][algTypeNames[
alg.type()]][
algName] = jalg;
833 json j = json::object_t{};
834 j[
"filetype"] =
"l1menu";
836 j[
"name"] =
l1menu.name();
838 j[
"thresholds"] = thresholds;
839 j[
"topoAlgorithms"] = jtopo;
840 j[
"boards"] = boards;
841 j[
"connectors"] = connectors;
845 outfile << std::setw(4) << j << std::endl;
856 j[
"filetype"] =
"bunchgroupset";
857 j[
"name"] = l1bgs.
name();
860 for (
size_t i = 0 ;
i< l1bgs.
size(); ++
i) {
863 jgroup[
"name"] =
group->name();
864 jgroup[
"id"] =
group->id();
869 train[
"first"] =
first;
870 train[
"length"] = len;
871 trains.push_back(train);
873 jgroup[
"bcids"] = trains;
876 j[
"bunchGroups"] =
groups;
878 outfile << std::setw(4) << j << std::endl;
885 j[
"filetype"] =
"l1prescale";
886 j[
"name"] = l1ps.
name();
888 for (
const auto & [itemName, ps]: l1ps.
prescales()){
891 cut[
"enabled"] = ps.enabled;
895 j[
"cutValues"] =
cuts;
897 outfile << std::setw(4) << j << std::endl;