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