ATLAS Offline Software
Loading...
Searching...
No Matches
Run2toRun3ConvertersL1.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
4
7
11#include "TrigConfData/L1Menu.h"
12#define BOOST_BIND_GLOBAL_PLACEHOLDERS // Needed to silence Boost pragma message
13#include <boost/property_tree/json_parser.hpp>
14#include <boost/tokenizer.hpp>
23
26
28
29#include <nlohmann/json.hpp>
30#include <vector>
31#include <numeric>
32#include <map>
33#include <unordered_set>
34#include <tuple>
35#include <stdexcept>
36#include <cctype> //std::isdigit
37#include <algorithm> //std::sort
38#include <fstream> //std::ofstream
39#include <sstream> //std::stringstream
40
41using json = nlohmann::json; // to be changed to ordered_json
42using ptree = boost::property_tree::ptree;
43
44namespace {
45 std::tuple<std::string, std::vector<std::string>>
46 decodeItemDefinition(const TrigConf::TriggerItem * item) {
47 std::string definition{""};
48 std::vector<std::string> bgps;
49 const TrigConf::TriggerItemNode * topNode = item->topNode();
50 std::vector<const TrigConf::TriggerItemNode*> nodes;
51 topNode->getAllFinalNodes(nodes);
52 std::map<unsigned int, const TrigConf::TriggerItemNode*> nodeMap;
53 for(auto * node : nodes) {
54 nodeMap[node->position()] = node;
55 }
56 // build tokens with separators ()&|! and <space>. Keeps all separators except <space> in the list of tokens
57 for ( auto & tok : boost::tokenizer<boost::char_separator<char> > (item->definition(), boost::char_separator<char>(" ", "()&|!")) ) {
58 if(std::isdigit(tok[0])) {
59 // replace by threshold
60 int idx = std::stoi(tok);
61 const TrigConf::TriggerItemNode* node = nodeMap[idx];
62 if(node->triggerThreshold()->type()=="BGRP") {
63 bgps.push_back(node->thresholdName());
64 if(definition.back()=='&') {
65 definition.pop_back();
66 }
67 } else {
68 definition += node->thresholdName() + "[x" + std::to_string(node->multiplicity()) + "]";
69 }
70 } else {
71 // keep token ()&|!
72 definition += tok;
73 }
74 }
75 // remove outer parentheses
76 if(definition.front()=='(' and definition.back()==')') {
77 definition = definition.substr(1,definition.size()-2);
78 }
79 return make_tuple(definition, bgps);
80 }
81}
82
83
87void
89 const std::string& filename, bool writeTmpFile)
90{
91
92 if( !ctpConfig ) {
93 std::cout << "No CTPConfig, no L1Menu file will be produced" << std::endl;
94 return;
95 }
96
97 unsigned int run = ctpConfig->ctpVersion() <=3 ? 1 : 2;
98
99 // items
100 json items = json::object_t{};
101 for( const TrigConf::TriggerItem * sourceItem: ctpConfig->menu().items() ) {
102 json item({});
103 item["name"] = sourceItem->name();
104 item["legacy"] = true;
105 item["ctpid"] = sourceItem->ctpId();
106 auto [definition, bunchgroups] = decodeItemDefinition(sourceItem);
107 item["definition"] = definition;
108 item["bunchgroups"] = bunchgroups;
109 item["triggerType"] = TrigConf::uint2bin(sourceItem->triggerType(),8);
110 item["partition"] = sourceItem->partition();
111 std::string smon("LF:");
112 smon += (sourceItem->monitor() & 0x04 ? '1' : '0');
113 smon += (sourceItem->monitor() & 0x02 ? '1' : '0');
114 smon += (sourceItem->monitor() & 0x01 ? '1' : '0');
115 smon += "|HF:";
116 smon += (sourceItem->monitor() & 0x20 ? '1' : '0');
117 smon += (sourceItem->monitor() & 0x10 ? '1' : '0');
118 smon += (sourceItem->monitor() & 0x08 ? '1' : '0');
119 item["monitor"] = smon;
120 items[sourceItem->name()] = item;
121 };
122
123 // thresholds
124 json thresholds = json::object_t{};
125 std::unordered_set<std::string> legacyThrTypes{"EM", "TAU", "JET", "JB", "JE", "JF", "XE", "XS", "TE", "ZB", "R2TOPO"};
126 for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) {
127 std::string thrType = sourceThr->type();
128 if(thrType=="BGRP" || thrType=="RNDM") {
129 continue;
130 }
131 if(thrType=="MUON") {
132 thrType = "MU";
133 }
134 else if(thrType=="TOPO") {
135 thrType = "R2TOPO";
136 }
137
138 bool isLegacyCalo = legacyThrTypes.count(thrType) > 0;
139 json &jThisType = isLegacyCalo ? thresholds["legacyCalo"][thrType] : thresholds[thrType];
140 bool firstOfItsType = jThisType.empty();
141 if (firstOfItsType)
142 {
143 jThisType["type"] = thrType;
144 }
145 json thr;
146 size_t mapping = sourceThr->mapping();
147 thr["mapping"] = mapping;
148 if(thrType=="MU") {
149 if (firstOfItsType)
150 {
151 jThisType["type"] = "MU";
152 jThisType["exclusionLists"] = json::object_t{};
153 jThisType["roads"]["rpc"] = json::object_t{};
154 jThisType["roads"]["tgc"] = json::object_t{};
155 }
156 int ptCut = sourceThr->triggerThresholdValue(0,0)->ptCutCount();
157 thr["baThr"] = ptCut;
158 thr["ecThr"] = ptCut;
159 thr["fwThr"] = ptCut;
160 thr["baIdx"] = mapping;
161 thr["ecIdx"] = mapping;
162 thr["fwIdx"] = mapping;
163 thr["tgcFlags"] = "";
164 thr["rpcFlags"] = "";
165 thr["region"] = "ALL";
166 jThisType["roads"]["rpc"][std::to_string(ptCut)] = mapping;
167 jThisType["roads"]["tgc"][std::to_string(ptCut)] = mapping;
168 }
169 else if (thrType == "EM")
170 {
171 thr["thrValues"] = json::array_t{};
172 for (const TrigConf::TriggerThresholdValue *tv : sourceThr->thresholdValueVector())
173 {
174 auto cl = dynamic_cast<const TrigConf::ClusterThresholdValue *>(tv);
175 if (not cl) continue;
176 json jtv;
177 jtv["value"] = static_cast<unsigned int>(tv->ptcut());
178 std::string isobits = "00000";
179 auto isomask = cl->isolationMask();
180 for (size_t b = 0; b < 5; ++b)
181 {
182 if (isomask & (1 << b))
183 {
184 isobits[4 - b] = '1';
185 }
186 }
187 jtv["isobits"] = isobits;
188 jtv["etamin"] = tv->etamin();
189 jtv["etamax"] = tv->etamax();
190 jtv["phimin"] = tv->phimin();
191 jtv["phimax"] = tv->phimax();
192 jtv["priority"] = static_cast<unsigned int>(tv->priority());
193 thr["thrValues"] += jtv;
194 }
195 }
196 else if (thrType == "TAU")
197 {
198 auto cl = dynamic_cast<const TrigConf::ClusterThresholdValue*>(sourceThr->triggerThresholdValue(0,0));
199 if (not cl) continue;
200 int ptCut = (int)cl->ptcut();
201 thr["value"] = ptCut;
202 std::string isobits = "00000";
203 auto isomask = cl->isolationMask();
204 for (size_t b = 0; b < 5; ++b)
205 {
206 if (isomask & (1 << b))
207 {
208 isobits[4 - b] = '1';
209 }
210 }
211 thr["isobits"] = isobits;
212 }
213 else if (thrType == "JET" || thrType == "JB" || thrType == "JF")
214 {
215 thr["thrValues"] = json::array_t{};
216 for (const TrigConf::TriggerThresholdValue *tv : sourceThr->thresholdValueVector())
217 {
218 auto jetThrVal = dynamic_cast<const TrigConf::JetThresholdValue *>(sourceThr->triggerThresholdValue(0, 0));
219 if (not jetThrVal) continue;
220 json jtv;
221 jtv["value"] = static_cast<unsigned int>(tv->ptcut());
222 jtv["etamin"] = tv->etamin();
223 jtv["etamax"] = tv->etamax();
224 jtv["phimin"] = tv->phimin();
225 jtv["phimax"] = tv->phimax();
226 jtv["window"] = jetThrVal->windowSize() == TrigConf::JetWindowSize::SMALL ? 4 : 8; // 4 and 8 are the two possible jet window sizes
227 jtv["priority"] = static_cast<unsigned int>(tv->priority());
228 thr["thrValues"] += jtv;
229 }
230 }
231 else if (thrType == "XE" || thrType == "TE" || thrType == "XS" || thrType == "JE")
232 {
233 thr["value"] = static_cast<unsigned int>(sourceThr->thresholdValueVector().at(0)->ptcut());
234 }
235 else if (thrType == "ZB")
236 {
237 thr["seed"] = sourceThr->zbSeedingThresholdName();
238 thr["seedMultiplicity"] = sourceThr->zbSeedingThresholdMulti();
239 thr["seedBcdelay"] = sourceThr->bcDelay();
240 }
241 jThisType["thresholds"][sourceThr->name()] = thr;
242 }
243
244 // extra info for thresholds
245 const TrigConf::CaloInfo& ci = ctpConfig->menu().caloInfo();
246 thresholds["legacyCalo"]["EM"]["ptMinToTopo"] = ci.minTobEM().ptmin;
247 thresholds["legacyCalo"]["EM"]["resolutionMeV"] = (int)(1000/ci.globalEmScale());
248 thresholds["legacyCalo"]["TAU"]["ptMinToTopo"] = ci.minTobTau().ptmin;
249 thresholds["legacyCalo"]["JET"]["ptMinToTopoSmallWindow"] = ci.minTobJetSmall().ptmin;
250 thresholds["legacyCalo"]["JET"]["ptMinToTopoLargeWindow"] = ci.minTobJetLarge().ptmin;
251 if(run==2) {
252 json isoHAforEM{ {"thrtype", "HAIsoForEMthr"}, {"Parametrization", json::array_t{}} };
253 json isoEMforEM{ {"thrtype", "EMIsoForEMthr"}, {"Parametrization", json::array_t{}} };
254 json isoEMforTAU{ {"thrtype", "EMIsoForTAUthr"}, {"Parametrization", json::array_t{}} };
255 for(const TrigConf::IsolationParam & iso : ci.isolationHAIsoForEMthr()) {
256 json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
257 {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
258 isoHAforEM["Parametrization"] += p;
259 }
260 for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForEMthr()) {
261 json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
262 {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
263 isoEMforEM["Parametrization"] += p;
264 }
265 for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForTAUthr()) {
266 json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
267 {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
268 isoEMforTAU["Parametrization"] += p;
269 }
270 thresholds["legacyCalo"]["EM"]["isolation"]["HAIsoForEMthr"] = std::move(isoHAforEM);
271 thresholds["legacyCalo"]["EM"]["isolation"]["EMIsoForEMthr"] = std::move(isoEMforEM);
272 thresholds["legacyCalo"]["TAU"]["isolation"]["EMIsoForTAUthr"] = std::move(isoEMforTAU);
273 }
274 const TrigConf::METSigParam &xs = ci.metSigParam();
275 thresholds["legacyCalo"]["XS"]["significance"] = json::object_t{
276 {"xsSigmaScale", xs.xsSigmaScale()}, {"xsSigmaOffset", xs.xsSigmaOffset()}, {"xeMin", xs.xeMin()}, {"xeMax", xs.xeMax()}, {"teSqrtMin", xs.teSqrtMin()}, {"teSqrtMax", xs.teSqrtMax()}};
277
278 // boards
279 json boards = json::object_t{};
280 boards["Ctpin7"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
281 {"connectors", std::vector<std::string>{"EM1", "EM2", "TAU1", "TAU2"}} };
282 boards["Ctpin8"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
283 {"connectors", std::vector<std::string>{"JET1", "JET2", "EN1", "EN2"}} };
284 boards["Ctpin9"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
285 {"connectors", std::vector<std::string>{"MUCTPI", "CTPCAL", "NIM1", "NIM2"}} };
286 boards["LegacyTopo0"] = json::object_t{ {"type", "TOPO"}, {"legacy", true},
287 {"connectors", std::vector<std::string>{"LegacyTopo0"}} };
288 boards["LegacyTopo1"] = json::object_t{ {"type", "TOPO"}, {"legacy", true},
289 {"connectors", std::vector<std::string>{"LegacyTopo1"}} };
290
291 // connectors
292 json connectors = json::object_t{};
293 std::map<std::string,std::vector<const TrigConf::TriggerThreshold*>> triggerlinesMap;
294 for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) {
295 if(sourceThr->isInternal()) {
296 continue;
297 }
298 std::string cableName = sourceThr->cableName();
299 if(cableName=="ALFA") {
300 cableName = "AlfaCtpin";
301 }
302 else if(cableName=="TOPO1") {
303 cableName = "LegacyTopo0";
304 }
305 else if(cableName=="TOPO2") {
306 cableName = "LegacyTopo1";
307 }
308 triggerlinesMap[cableName].push_back(sourceThr);
309 }
310 for( auto & [type, triggerlines] : triggerlinesMap) {
311 std::sort(std::begin(triggerlines), std::end(triggerlines),
312 [](const TrigConf::TriggerThreshold *a, const TrigConf::TriggerThreshold *b) { return a->cableStart() < b->cableStart(); });
313 for( const TrigConf::TriggerThreshold * thr : triggerlines) {
314 if(!connectors.contains(type)) {
315 if(thr->input()=="ctpcore") {
316 connectors[type]["type"] = "electrical";
317 if(type=="AlfaCtpin") {
318 connectors[type]["triggerlines"]["clock0"] = json::array_t{};
319 connectors[type]["triggerlines"]["clock1"] = json::array_t{};
320 } else {
321 connectors[type]["triggerlines"]["fpga0"]["clock0"] = json::array_t{};
322 connectors[type]["triggerlines"]["fpga0"]["clock1"] = json::array_t{};
323 connectors[type]["triggerlines"]["fpga1"]["clock0"] = json::array_t{};
324 connectors[type]["triggerlines"]["fpga1"]["clock1"] = json::array_t{};
325 }
326 } else if(thr->input()=="ctpin") {
327 connectors[type]["type"] = "ctpin";
328 connectors[type]["triggerlines"] = json::array_t{};
329 } else {
330 throw std::runtime_error("Unknown connector type" + thr->input());
331 }
332 connectors[type]["legacy"] = true;
333 }
334 size_t start = thr->cableStart();
335 size_t nbits = thr->cableEnd() - thr->cableStart() + 1;
336 if(thr->input()=="ctpcore") {
337 unsigned int clock = thr->clock();
338 if(type=="AlfaCtpin") {
339 json tl{{"name", thr->name()}, {"startbit", start}, {"nbits", nbits}};
340 connectors[type]["triggerlines"]["clock" + std::to_string(clock)] += tl;
341 } else {
342 size_t fpga = 0;
343 if(start>=16) {
344 start -= 16;
345 fpga++;
346 }
347 json tl{{"name", "R2TOPO_" + thr->name()}, {"startbit", start}, {"nbits", nbits}};
348 connectors[type]["triggerlines"]["fpga" + std::to_string(fpga)]["clock" + std::to_string(clock)] += tl;
349 }
350 } else {
351 json tl{{"name", thr->name()}, {"startbit", start}, {"nbits", nbits}};
352 connectors[type]["triggerlines"] += tl;
353 }
354 }
355 }
356
357 // algorithms
358 json::object_t decAlgos;
359 json::object_t sortAlgos;
360 for(const TXC::L1TopoConfigAlg & alg : topoMenu->getL1TopoConfigAlgs()) {
361 json jAlg;
362 jAlg["algId"] = alg.algoID();
363 jAlg["klass"] = alg.type();
364 jAlg["fixedParameters"]["generics"] = json::object_t{};
365 size_t pos{0};
366 for(const TXC::FixedParameter & fixP : alg.getFixedParameters()) {
367 try
368 {
369 auto vInt = std::stoi(fixP.value);
370 jAlg["fixedParameters"]["generics"][fixP.name] = json::object_t{{"value", vInt}, {"position", pos++}};
371 }
372 catch (std::invalid_argument &)
373 {
374 jAlg["fixedParameters"]["generics"][fixP.name] = json::object_t{{"value", fixP.value}, {"position", pos++}};
375 }
376 }
377 jAlg["variableParameters"] = json::array_t{};
378 for(const TXC::RegisterParameter & regP : alg.getParameters()) {
379 // Work around overflow in the database...
380 if (regP.name == "MaxMSqr") {
381 unsigned val = std::stoul(regP.value);
382 if (val >= 1u<<31) {
383 val = 999;
384 }
385 jAlg["variableParameters"] += json::object_t{{"name", regP.name}, {"selection", regP.selection}, {"value", val}};
386 }
387 else {
388 jAlg["variableParameters"] += json::object_t{{"name", regP.name}, {"selection", regP.selection}, {"value", std::stoi(regP.value)}};
389 }
390 }
391 if(alg.isSortAlg()) {
392 jAlg["input"] = alg.getInputNames()[0];
393 jAlg["output"] = alg.output();
394 sortAlgos[alg.name()] = std::move(jAlg);
395 } else if(alg.isDecAlg()) {
396 jAlg["input"] = alg.getInputNames();
397 jAlg["output"] = alg.getOutputNames();
398 decAlgos[alg.name()] = std::move(jAlg);
399 }
400 }
401 json topo = json::object_t{};
402 if(run==2) {
403 topo["R2TOPO"]["decisionAlgorithms"] = decAlgos;
404 topo["R2TOPO"]["sortingAlgorithms"] = sortAlgos;
405 }
406
407 // ctp
408 json ctp = json::object_t{};
409 ctp["inputs"]["ctpin"]["slot7"] = json::object_t{{"connector0", "EM1"}, {"connector1", "EM2"},
410 {"connector2", "TAU1"}, {"connector3", "TAU2"}};
411 ctp["inputs"]["ctpin"]["slot8"] = json::object_t{{"connector0", "JET1"}, {"connector1", "JET2"},
412 {"connector2", "EN1"}, {"connector3", "EN2"}};
413 ctp["inputs"]["ctpin"]["slot9"] = json::object_t{{"connector0", "MUCTPI"}, {"connector1", "CTPCAL"},
414 {"connector2", "NIM1"}, {"connector3", "NIM2"}};
415 if(run==2) {
416 ctp["inputs"]["electrical"] = json::object_t{{"connector0", "AlfaCtpin"}, {"connector1", "LegacyTopo0"}, {"connector2", "LegacyTopo1"}};
417 } else {
418 ctp["inputs"]["electrical"] = json::object_t{};
419 }
420 ctp["inputs"]["optical"] = json::object_t{};
421 ctp["monitoring"]["ctpmon"] = json::object_t{};
422
423 // putting the menu together
424 json menu = json::object_t{};
425 menu["filetype"] = "l1menu";
426 menu["run"] = run;
427 menu["name"] = ctpConfig->name();
428 menu["items"] = std::move(items);
429 menu["thresholds"] = std::move(thresholds);
430 menu["topoAlgorithms"] = std::move(topo);
431 menu["boards"] = std::move(boards);
432 menu["connectors"] = std::move(connectors);
433 menu["ctp"] = std::move(ctp);
434
435
436 if(writeTmpFile) {
437 std::ofstream outfile("tmp" + filename);
438 outfile << std::setw(4) << menu << std::endl;
439 std::cout << "Wrote tmp" << filename << std::endl;
440 }
441 std::stringstream ss;
442 ss << menu;
443 ptree top;
444 boost::property_tree::read_json(ss, top);
445 TrigConf::L1Menu l1menu(std::move(top));
447 writer.writeJsonFile(filename, l1menu);
448}
449
453std::vector<std::pair<int, int>>
454toRanges(const std::vector<int>& bunches) {
455 // converts sequence of bunches into the pairs of continous ranges
456 if ( bunches.empty() ) {
457 return {};
458 }
459 if (bunches.size() == 1) {
460 return { {bunches.front(), bunches.front()} };
461 }
462
463 // nontrival ranges
464 std::vector<std::pair<int, int>> ranges;
465 std::vector<int> sorted = bunches;
466 std::sort(sorted.begin(), sorted.end());
467
468 std::vector<int> differences;
469 std::adjacent_difference( sorted.begin(), sorted.end(), std::back_inserter(differences));
470
471 int start = sorted.front();
472
473 for (size_t i = 1; i < differences.size(); ++i) {
474 if (differences[i] == 1) continue;
475 ranges.emplace_back( std::pair(start, sorted[i-1]) );
476 start = sorted[i];
477 }
478 ranges.emplace_back( std::pair(start, sorted.back()) );
479 return ranges;
480}
481
482void
483convertRun2BunchGroupsToRun3(const TrigConf::CTPConfig* ctpConfig, const std::string& filename, bool writeTmpFile)
484{
485 const TrigConf::BunchGroupSet & bgs = ctpConfig->bunchGroupSet();
486 if(bgs.bunchGroups().size()==0) {
487 std::cout << "BunchgroupSet is empty, no file will be produced" << std::endl;
488 return;
489 }
490
491 json bgset;
492 bgset["filetype"] ="bunchgroupset";
493 bgset["name"] = bgs.name();
494
495 json jGroups;
496 const std::vector<TrigConf::BunchGroup>& bgVec = bgs.bunchGroups();
497 for (auto & group : bgVec) {
498 auto ranges = toRanges(group.bunches());
499 json jGroup;
500 jGroup["name"] =group.name();
501 jGroup["id"] =group.internalNumber();
502 jGroup["info"] = std::to_string(group.bunches().size()) + " bunches, " + std::to_string(ranges.size()) + " groups";
503
504 json jBCIDS = json::array_t{};
505 for ( auto [start, end] : ranges) {
506 jBCIDS += json{{"first", start}, {"length", 1+end-start}};
507 }
508 jGroup["bcids"] = std::move(jBCIDS);
509
510 jGroups[std::string("BGRP")+std::to_string(group.internalNumber())] = std::move(jGroup);
511 }
512 bgset["bunchGroups"] = std::move(jGroups);
513
514 if(writeTmpFile) {
515 std::ofstream outfile("tmp" + filename);
516 outfile << std::setw(4) << bgset << std::endl;
517 std::cout << "Wrote tmp" << filename << std::endl;
518 }
519 std::stringstream ss;
520 ss << bgset;
521 ptree top;
522 boost::property_tree::read_json(ss, top);
523 TrigConf::L1BunchGroupSet newbgs(std::move(top));
525 writer.writeJsonFile(filename, newbgs);
526}
527
531void
532convertRun2L1PrescalesToRun3(const TrigConf::CTPConfig* ctpConfig, const std::string& filename, bool writeTmpFile) {
533 const TrigConf::PrescaleSet & l1pss = ctpConfig->prescaleSet();
534 if(l1pss.isNull()) {
535 std::cout << "L1PrescaleSet is empty, no file will be produced" << std::endl;
536 return;
537 }
538
539 json psset;
540 psset["filetype"] = "l1prescale";
541 psset["name"] = l1pss.name();
542 json jCuts;
543 for (size_t id = 0; id < l1pss.prescales_float().size(); ++id) {
544 json jCut;
545 auto itemPtr = ctpConfig->menu().item(id);
546 if ( itemPtr != nullptr ) {
547 int32_t cut = l1pss.cuts().at(id);
548 jCut["cut"] = abs(cut);
549 jCut["enabled"] = cut > 0;
550 double ps = static_cast<double>(0xFFFFFF) / ( 0x1000000 - cut );
551 jCut["info"] = "prescale: "+std::to_string(ps);
552 jCuts[itemPtr->name()] = std::move(jCut);
553 }
554 }
555 psset["cutValues"] = std::move(jCuts);
556
557 if(writeTmpFile) {
558 std::ofstream outfile("tmp" + filename);
559 outfile << std::setw(4) << psset << std::endl;
560 std::cout << "Wrote tmp" << filename << std::endl;
561 }
562 std::stringstream ss;
563 ss << psset;
564 ptree top;
565 boost::property_tree::read_json(ss, top);
566 TrigConf::L1PrescalesSet ps(std::move(top));
568 writer.writeJsonFile(filename, ps);
569}
std::shared_ptr< HepMC3::Writer > writer
nlohmann::json json
boost::property_tree::ptree ptree
static Double_t a
static Double_t ss
void convertRun2L1MenuToRun3(const TrigConf::CTPConfig *ctpConfig, const TXC::L1TopoMenu *topoMenu, const std::string &filename, bool writeTmpFile)
Conversion of L1 menu.
void convertRun2L1PrescalesToRun3(const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
Conversion of L1 prescales set.
std::vector< std::pair< int, int > > toRanges(const std::vector< int > &bunches)
Conversion of bunchgroup set.
void convertRun2BunchGroupsToRun3(const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
Run 2 to Run 3 bunchgroup converter.
@ top
const std::vector< TXC::L1TopoConfigAlg > & getL1TopoConfigAlgs() const
Definition L1TopoMenu.h:53
const std::vector< BunchGroup > & bunchGroups() const
unsigned int ctpVersion() const
Definition CTPConfig.h:34
const BunchGroupSet & bunchGroupSet() const
Definition CTPConfig.h:41
const Menu & menu() const
Definition CTPConfig.h:39
const PrescaleSet & prescaleSet(unsigned int partition=0) const
Definition CTPConfig.h:40
const MinTOBPt & minTobEM() const
Definition CaloInfo.h:60
const MinTOBPt & minTobJetSmall() const
Definition CaloInfo.h:62
float globalEmScale() const
Definition CaloInfo.h:43
const MinTOBPt & minTobTau() const
Definition CaloInfo.h:61
const std::vector< IsolationParam > & isolationEMIsoForTAUthr() const
Definition CaloInfo.h:55
METSigParam & metSigParam()
Definition CaloInfo.h:50
const std::vector< IsolationParam > & isolationEMIsoForEMthr() const
Definition CaloInfo.h:54
const std::vector< IsolationParam > & isolationHAIsoForEMthr() const
Definition CaloInfo.h:53
const MinTOBPt & minTobJetLarge() const
Definition CaloInfo.h:63
Loader of trigger configurations from Json files.
L1 board configuration.
L1 menu configuration.
Definition L1Menu.h:28
L1 menu configuration.
int xsSigmaOffset() const
Definition METSigParam.h:31
int teSqrtMax() const
Definition METSigParam.h:35
int xsSigmaScale() const
Definition METSigParam.h:30
int teSqrtMin() const
Definition METSigParam.h:34
TriggerItem * item(int ctpid) const
Definition Menu.cxx:84
const std::vector< TriggerThreshold * > & thresholdVector() const
Definition Menu.cxx:123
const CaloInfo & caloInfo() const
Definition Menu.h:74
const ItemContainer & items() const
Definition Menu.h:140
bool isNull() const
Definition PrescaleSet.h:37
const std::vector< float > & prescales_float() const
Definition PrescaleSet.h:43
const std::vector< int32_t > & cuts() const
Definition PrescaleSet.h:44
const std::string & name() const
void getAllFinalNodes(std::vector< const TriggerItemNode * > &) const
const TriggerItemNode * topNode() const
Definition TriggerItem.h:37
const std::string & definition() const
Definition TriggerItem.h:33
make the sidebar many part of the config
Definition hcg.cxx:552
Definition node.h:24
void type(TYPE t)
Definition node.h:51
std::string uint2bin(uint32_t uinteger, uint16_t width)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
unsigned int ptmin
Definition CaloInfo.h:28
int run(int argc, char *argv[])