ATLAS Offline Software
Macros | Typedefs | Functions
Run2toRun3ConvertersL1.cxx File Reference
#include "Run2toRun3ConvertersL1.h"
#include <numeric>
#include <unordered_set>
#include <boost/tokenizer.hpp>
#include <tuple>
#include <stdexcept>
#include "TrigConfData/L1BunchGroupSet.h"
#include "TrigConfData/DataStructure.h"
#include "TrigConfData/L1PrescalesSet.h"
#include <boost/property_tree/json_parser.hpp>
#include "TrigConfL1Data/CTPConfig.h"
#include "TrigConfL1Data/TriggerThreshold.h"
#include "TrigConfL1Data/TriggerItem.h"
#include "TrigConfL1Data/TriggerItemNode.h"
#include "TrigConfL1Data/ClusterThresholdValue.h"
#include "TrigConfL1Data/JetThresholdValue.h"
#include "TrigConfL1Data/HelperFunctions.h"
#include "TrigConfL1Data/CaloInfo.h"
#include "TrigConfL1Data/BunchGroupSet.h"
#include "TrigConfL1Data/BunchGroup.h"
#include "TrigConfIO/JsonFileWriterL1.h"
#include <nlohmann/json.hpp>

Go to the source code of this file.

Macros

#define BOOST_BIND_GLOBAL_PLACEHOLDERS
 

Typedefs

using json = nlohmann::json
 
using ptree = boost::property_tree::ptree
 

Functions

void convertRun2L1MenuToRun3 (const TrigConf::CTPConfig *ctpConfig, const TXC::L1TopoMenu *topoMenu, const std::string &filename, bool writeTmpFile)
 Conversion of L1 menu. More...
 
std::vector< std::pair< int, int > > toRanges (const std::vector< int > &bunches)
 Conversion of bunchgroup set. More...
 
void convertRun2BunchGroupsToRun3 (const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
 Run 2 to Run 3 bunchgroup converter. More...
 
void convertRun2L1PrescalesToRun3 (const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
 Conversion of L1 prescales set. More...
 

Macro Definition Documentation

◆ BOOST_BIND_GLOBAL_PLACEHOLDERS

#define BOOST_BIND_GLOBAL_PLACEHOLDERS

Definition at line 14 of file Run2toRun3ConvertersL1.cxx.

Typedef Documentation

◆ json

using json = nlohmann::json

Definition at line 31 of file Run2toRun3ConvertersL1.cxx.

◆ ptree

using ptree = boost::property_tree::ptree

Definition at line 32 of file Run2toRun3ConvertersL1.cxx.

Function Documentation

◆ convertRun2BunchGroupsToRun3()

void convertRun2BunchGroupsToRun3 ( const TrigConf::CTPConfig ctpConfig,
const std::string &  filename,
bool  writeTmpFile = false 
)

Run 2 to Run 3 bunchgroup converter.

Parameters
ctpConfigpointer to L1 menu (which contains the bunchgroups)
filenamename of the output json file

Definition at line 470 of file Run2toRun3ConvertersL1.cxx.

471 {
472  const TrigConf::BunchGroupSet & bgs = ctpConfig->bunchGroupSet();
473  if(bgs.bunchGroups().size()==0) {
474  std::cout << "BunchgroupSet is empty, no file will be produced" << std::endl;
475  return;
476  }
477 
478  json bgset;
479  bgset["filetype"] ="bunchgroupset";
480  bgset["name"] = bgs.name();
481 
482  json jGroups;
483  const std::vector<TrigConf::BunchGroup>& bgVec = bgs.bunchGroups();
484  for (auto & group : bgVec) {
485  auto ranges = toRanges(group.bunches());
486  json jGroup;
487  jGroup["name"] =group.name();
488  jGroup["id"] =group.internalNumber();
489  jGroup["info"] = std::to_string(group.bunches().size()) + " bunches, " + std::to_string(ranges.size()) + " groups";
490 
491  json jBCIDS = json::array_t{};
492  for ( auto [start, end] : ranges) {
493  jBCIDS += json{{"first", start}, {"length", 1+end-start}};
494  }
495  jGroup["bcids"] = jBCIDS;
496 
497  jGroups[std::string("BGRP")+std::to_string(group.internalNumber())] = jGroup;
498  }
499  bgset["bunchGroups"] = jGroups;
500 
501  if(writeTmpFile) {
502  std::ofstream outfile("tmp" + filename);
503  outfile << std::setw(4) << bgset << std::endl;
504  std::cout << "Wrote tmp" << filename << std::endl;
505  }
506  std::stringstream ss;
507  ss << bgset;
508  ptree top;
509  boost::property_tree::read_json(ss, top);
510  TrigConf::L1BunchGroupSet newbgs(std::move(top));
512  writer.writeJsonFile(filename, newbgs);
513 }

◆ convertRun2L1MenuToRun3()

void convertRun2L1MenuToRun3 ( const TrigConf::CTPConfig ctpConfig,
const TXC::L1TopoMenu topoMenu,
const std::string &  filename,
bool  writeTmpFile 
)

Conversion of L1 menu.

Run 2 to Run 3 L1 menu converter Converts Run 2 L1 menu and L1Topo menu into run 3 format and writes out a json file.

Definition at line 78 of file Run2toRun3ConvertersL1.cxx.

80 {
81 
82  if( !ctpConfig ) {
83  std::cout << "No CTPConfig, no L1Menu file will be produced" << std::endl;
84  return;
85  }
86 
87  unsigned int run = ctpConfig->ctpVersion() <=3 ? 1 : 2;
88 
89  // items
90  json items = json::object_t{};
91  for( const TrigConf::TriggerItem * sourceItem: ctpConfig->menu().items() ) {
92  json item({});
93  item["name"] = sourceItem->name();
94  item["legacy"] = true;
95  item["ctpid"] = sourceItem->ctpId();
96  auto [definition, bunchgroups] = decodeItemDefinition(sourceItem);
97  item["definition"] = definition;
98  item["bunchgroups"] = bunchgroups;
99  item["triggerType"] = TrigConf::uint2bin(sourceItem->triggerType(),8);
100  item["partition"] = sourceItem->partition();
101  std::string smon("LF:");
102  smon += (sourceItem->monitor() & 0x04 ? '1' : '0');
103  smon += (sourceItem->monitor() & 0x02 ? '1' : '0');
104  smon += (sourceItem->monitor() & 0x01 ? '1' : '0');
105  smon += "|HF:";
106  smon += (sourceItem->monitor() & 0x20 ? '1' : '0');
107  smon += (sourceItem->monitor() & 0x10 ? '1' : '0');
108  smon += (sourceItem->monitor() & 0x08 ? '1' : '0');
109  item["monitor"] = smon;
110  items[sourceItem->name()] = item;
111  };
112 
113  // thresholds
114  json thresholds = json::object_t{};
115  std::unordered_set<std::string> legacyThrTypes{"EM", "TAU", "JET", "JB", "JE", "JF", "XE", "XS", "TE", "ZB", "R2TOPO"};
116  for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) {
117  std::string thrType = sourceThr->type();
118  if(thrType=="BGRP" || thrType=="RNDM") {
119  continue;
120  }
121  if(thrType=="MUON") {
122  thrType = "MU";
123  }
124  else if(thrType=="TOPO") {
125  thrType = "R2TOPO";
126  }
127 
128  bool isLegacyCalo = legacyThrTypes.count(thrType) > 0;
129  json &jThisType = isLegacyCalo ? thresholds["legacyCalo"][thrType] : thresholds[thrType];
130  bool firstOfItsType = jThisType.empty();
131  if (firstOfItsType)
132  {
133  jThisType["type"] = thrType;
134  }
135  json thr;
136  size_t mapping = sourceThr->mapping();
137  thr["mapping"] = mapping;
138  if(thrType=="MU") {
139  if (firstOfItsType)
140  {
141  jThisType["type"] = "MU";
142  jThisType["exclusionLists"] = json::object_t{};
143  jThisType["roads"]["rpc"] = json::object_t{};
144  jThisType["roads"]["tgc"] = json::object_t{};
145  }
146  int ptCut = sourceThr->triggerThresholdValue(0,0)->ptCutCount();
147  thr["baThr"] = ptCut;
148  thr["ecThr"] = ptCut;
149  thr["fwThr"] = ptCut;
150  thr["baIdx"] = mapping;
151  thr["ecIdx"] = mapping;
152  thr["fwIdx"] = mapping;
153  thr["tgcFlags"] = "";
154  thr["rpcFlags"] = "";
155  thr["region"] = "ALL";
156  jThisType["roads"]["rpc"][std::to_string(ptCut)] = mapping;
157  jThisType["roads"]["tgc"][std::to_string(ptCut)] = mapping;
158  }
159  else if (thrType == "EM")
160  {
161  thr["thrValues"] = json::array_t{};
162  for (const TrigConf::TriggerThresholdValue *tv : sourceThr->thresholdValueVector())
163  {
164  auto cl = dynamic_cast<const TrigConf::ClusterThresholdValue *>(tv);
165  json jtv;
166  jtv["value"] = static_cast<unsigned int>(tv->ptcut());
167  std::string isobits = "00000";
168  auto isomask = cl->isolationMask();
169  for (size_t b = 0; b < 5; ++b)
170  {
171  if (isomask & (1 << b))
172  {
173  isobits[4 - b] = '1';
174  }
175  }
176  jtv["isobits"] = isobits;
177  jtv["etamin"] = tv->etamin();
178  jtv["etamax"] = tv->etamax();
179  jtv["phimin"] = tv->phimin();
180  jtv["phimax"] = tv->phimax();
181  jtv["priority"] = static_cast<unsigned int>(tv->priority());
182  thr["thrValues"] += jtv;
183  }
184  }
185  else if (thrType == "TAU")
186  {
187  auto cl = dynamic_cast<const TrigConf::ClusterThresholdValue*>(sourceThr->triggerThresholdValue(0,0));
188  int ptCut = (int)cl->ptcut();
189  thr["value"] = ptCut;
190  std::string isobits = "00000";
191  auto isomask = cl->isolationMask();
192  for (size_t b = 0; b < 5; ++b)
193  {
194  if (isomask & (1 << b))
195  {
196  isobits[4 - b] = '1';
197  }
198  }
199  thr["isobits"] = isobits;
200  }
201  else if (thrType == "JET" || thrType == "JB" || thrType == "JF")
202  {
203  thr["thrValues"] = json::array_t{};
204  for (const TrigConf::TriggerThresholdValue *tv : sourceThr->thresholdValueVector())
205  {
206  auto jetThrVal = dynamic_cast<const TrigConf::JetThresholdValue *>(sourceThr->triggerThresholdValue(0, 0));
207  json jtv;
208  jtv["value"] = static_cast<unsigned int>(tv->ptcut());
209  jtv["etamin"] = tv->etamin();
210  jtv["etamax"] = tv->etamax();
211  jtv["phimin"] = tv->phimin();
212  jtv["phimax"] = tv->phimax();
213  jtv["window"] = jetThrVal->windowSize() == TrigConf::JetWindowSize::SMALL ? 4 : 8; // 4 and 8 are the two possible jet window sizes
214  jtv["priority"] = static_cast<unsigned int>(tv->priority());
215  thr["thrValues"] += jtv;
216  }
217  }
218  else if (thrType == "XE" || thrType == "TE" || thrType == "XS" || thrType == "JE")
219  {
220  thr["value"] = static_cast<unsigned int>(sourceThr->thresholdValueVector().at(0)->ptcut());
221  }
222  else if (thrType == "ZB")
223  {
224  thr["seed"] = sourceThr->zbSeedingThresholdName();
225  thr["seedMultiplicity"] = sourceThr->zbSeedingThresholdMulti();
226  thr["seedBcdelay"] = sourceThr->bcDelay();
227  }
228  jThisType["thresholds"][sourceThr->name()] = thr;
229  }
230 
231  // extra info for thresholds
232  const TrigConf::CaloInfo& ci = ctpConfig->menu().caloInfo();
233  thresholds["legacyCalo"]["EM"]["ptMinToTopo"] = ci.minTobEM().ptmin;
234  thresholds["legacyCalo"]["EM"]["resolutionMeV"] = (int)(1000/ci.globalEmScale());
235  thresholds["legacyCalo"]["TAU"]["ptMinToTopo"] = ci.minTobTau().ptmin;
236  thresholds["legacyCalo"]["JET"]["ptMinToTopoSmallWindow"] = ci.minTobJetSmall().ptmin;
237  thresholds["legacyCalo"]["JET"]["ptMinToTopoLargeWindow"] = ci.minTobJetLarge().ptmin;
238  if(run==2) {
239  json isoHAforEM{ {"thrtype", "HAIsoForEMthr"}, {"Parametrization", json::array_t{}} };
240  json isoEMforEM{ {"thrtype", "EMIsoForEMthr"}, {"Parametrization", json::array_t{}} };
241  json isoEMforTAU{ {"thrtype", "EMIsoForTAUthr"}, {"Parametrization", json::array_t{}} };
242  for(const TrigConf::IsolationParam & iso : ci.isolationHAIsoForEMthr()) {
243  json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
244  {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
245  isoHAforEM["Parametrization"] += p;
246  }
247  for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForEMthr()) {
248  json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
249  {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
250  isoEMforEM["Parametrization"] += p;
251  }
252  for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForTAUthr()) {
253  json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()},
254  {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} };
255  isoEMforTAU["Parametrization"] += p;
256  }
257  thresholds["legacyCalo"]["EM"]["isolation"]["HAIsoForEMthr"] = isoHAforEM;
258  thresholds["legacyCalo"]["EM"]["isolation"]["EMIsoForEMthr"] = isoEMforEM;
259  thresholds["legacyCalo"]["TAU"]["isolation"]["EMIsoForTAUthr"] = isoEMforTAU;
260  }
261  const TrigConf::METSigParam &xs = ci.metSigParam();
262  thresholds["legacyCalo"]["XS"]["significance"] = json::object_t{
263  {"xsSigmaScale", xs.xsSigmaScale()}, {"xsSigmaOffset", xs.xsSigmaOffset()}, {"xeMin", xs.xeMin()}, {"xeMax", xs.xeMax()}, {"teSqrtMin", xs.teSqrtMin()}, {"teSqrtMax", xs.teSqrtMax()}};
264 
265  // boards
266  json boards = json::object_t{};
267  boards["Ctpin7"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
268  {"connectors", std::vector<std::string>{"EM1", "EM2", "TAU1", "TAU2"}} };
269  boards["Ctpin8"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
270  {"connectors", std::vector<std::string>{"JET1", "JET2", "EN1", "EN2"}} };
271  boards["Ctpin9"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true},
272  {"connectors", std::vector<std::string>{"MUCTPI", "CTPCAL", "NIM1", "NIM2"}} };
273  boards["LegacyTopo0"] = json::object_t{ {"type", "TOPO"}, {"legacy", true},
274  {"connectors", std::vector<std::string>{"LegacyTopo0"}} };
275  boards["LegacyTopo1"] = json::object_t{ {"type", "TOPO"}, {"legacy", true},
276  {"connectors", std::vector<std::string>{"LegacyTopo1"}} };
277 
278  // connectors
279  json connectors = json::object_t{};
280  std::map<std::string,std::vector<const TrigConf::TriggerThreshold*>> triggerlinesMap;
281  for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) {
282  if(sourceThr->isInternal()) {
283  continue;
284  }
285  std::string cableName = sourceThr->cableName();
286  if(cableName=="ALFA") {
287  cableName = "AlfaCtpin";
288  }
289  else if(cableName=="TOPO1") {
290  cableName = "LegacyTopo0";
291  }
292  else if(cableName=="TOPO2") {
293  cableName = "LegacyTopo1";
294  }
295  triggerlinesMap[cableName].push_back(sourceThr);
296  }
297  for( auto & [type, triggerlines] : triggerlinesMap) {
298  std::sort(std::begin(triggerlines), std::end(triggerlines),
299  [](const TrigConf::TriggerThreshold *a, const TrigConf::TriggerThreshold *b) { return a->cableStart() < b->cableStart(); });
300  for( const TrigConf::TriggerThreshold * thr : triggerlines) {
301  if(!connectors.contains(type)) {
302  if(thr->input()=="ctpcore") {
303  connectors[type]["type"] = "electrical";
304  if(type=="AlfaCtpin") {
305  connectors[type]["triggerlines"]["clock0"] = json::array_t{};
306  connectors[type]["triggerlines"]["clock1"] = json::array_t{};
307  } else {
308  connectors[type]["triggerlines"]["fpga0"]["clock0"] = json::array_t{};
309  connectors[type]["triggerlines"]["fpga0"]["clock1"] = json::array_t{};
310  connectors[type]["triggerlines"]["fpga1"]["clock0"] = json::array_t{};
311  connectors[type]["triggerlines"]["fpga1"]["clock1"] = json::array_t{};
312  }
313  } else if(thr->input()=="ctpin") {
314  connectors[type]["type"] = "ctpin";
315  connectors[type]["triggerlines"] = json::array_t{};
316  } else {
317  throw std::runtime_error("Unknown connector type" + thr->input());
318  }
319  connectors[type]["legacy"] = true;
320  }
321  size_t start = thr->cableStart();
322  size_t nbits = thr->cableEnd() - thr->cableStart() + 1;
323  if(thr->input()=="ctpcore") {
324  unsigned int clock = thr->clock();
325  if(type=="AlfaCtpin") {
326  json tl{{"name", thr->name()}, {"startbit", start}, {"nbits", nbits}};
327  connectors[type]["triggerlines"]["clock" + std::to_string(clock)] += tl;
328  } else {
329  size_t fpga = 0;
330  if(start>=16) {
331  start -= 16;
332  fpga++;
333  }
334  json tl{{"name", "R2TOPO_" + thr->name()}, {"startbit", start}, {"nbits", nbits}};
335  connectors[type]["triggerlines"]["fpga" + std::to_string(fpga)]["clock" + std::to_string(clock)] += tl;
336  }
337  } else {
338  json tl{{"name", thr->name()}, {"startbit", start}, {"nbits", nbits}};
339  connectors[type]["triggerlines"] += tl;
340  }
341  }
342  }
343 
344  // algorithms
345  json::object_t decAlgos;
346  json::object_t sortAlgos;
347  for(const TXC::L1TopoConfigAlg & alg : topoMenu->getL1TopoConfigAlgs()) {
348  json jAlg;
349  jAlg["algId"] = alg.algoID();
350  jAlg["klass"] = alg.type();
351  jAlg["fixedParameters"]["generics"] = json::object_t{};
352  size_t pos{0};
353  for(const TXC::FixedParameter & fixP : alg.getFixedParameters()) {
354  try
355  {
356  auto vInt = std::stoi(fixP.value);
357  jAlg["fixedParameters"]["generics"][fixP.name] = json::object_t{{"value", vInt}, {"position", pos++}};
358  }
359  catch (std::invalid_argument &)
360  {
361  jAlg["fixedParameters"]["generics"][fixP.name] = json::object_t{{"value", fixP.value}, {"position", pos++}};
362  }
363  }
364  jAlg["variableParameters"] = json::array_t{};
365  for(const TXC::RegisterParameter & regP : alg.getParameters()) {
366  // Work around overflow in the database...
367  if (regP.name == "MaxMSqr") {
368  unsigned val = std::stoul(regP.value);
369  if (val >= 1u<<31) {
370  val = 999;
371  }
372  jAlg["variableParameters"] += json::object_t{{"name", regP.name}, {"selection", regP.selection}, {"value", val}};
373  }
374  else {
375  jAlg["variableParameters"] += json::object_t{{"name", regP.name}, {"selection", regP.selection}, {"value", std::stoi(regP.value)}};
376  }
377  }
378  if(alg.isSortAlg()) {
379  jAlg["input"] = alg.getInputNames()[0];
380  jAlg["output"] = alg.output();
381  sortAlgos[alg.name()] = jAlg;
382  } else if(alg.isDecAlg()) {
383  jAlg["input"] = alg.getInputNames();
384  jAlg["output"] = alg.getOutputNames();
385  decAlgos[alg.name()] = jAlg;
386  }
387  }
388  json topo = json::object_t{};
389  if(run==2) {
390  topo["R2TOPO"]["decisionAlgorithms"] = decAlgos;
391  topo["R2TOPO"]["sortingAlgorithms"] = sortAlgos;
392  }
393 
394  // ctp
395  json ctp = json::object_t{};
396  ctp["inputs"]["ctpin"]["slot7"] = json::object_t{{"connector0", "EM1"}, {"connector1", "EM2"},
397  {"connector2", "TAU1"}, {"connector3", "TAU2"}};
398  ctp["inputs"]["ctpin"]["slot8"] = json::object_t{{"connector0", "JET1"}, {"connector1", "JET2"},
399  {"connector2", "EN1"}, {"connector3", "EN2"}};
400  ctp["inputs"]["ctpin"]["slot9"] = json::object_t{{"connector0", "MUCTPI"}, {"connector1", "CTPCAL"},
401  {"connector2", "NIM1"}, {"connector3", "NIM2"}};
402  if(run==2) {
403  ctp["inputs"]["electrical"] = json::object_t{{"connector0", "AlfaCtpin"}, {"connector1", "LegacyTopo0"}, {"connector2", "LegacyTopo1"}};
404  } else {
405  ctp["inputs"]["electrical"] = json::object_t{};
406  }
407  ctp["inputs"]["optical"] = json::object_t{};
408  ctp["monitoring"]["ctpmon"] = json::object_t{};
409 
410  // putting the menu together
411  json menu = json::object_t{};
412  menu["filetype"] = "l1menu";
413  menu["run"] = run;
414  menu["name"] = ctpConfig->name();
415  menu["items"] = items;
416  menu["thresholds"] = thresholds;
417  menu["topoAlgorithms"] = topo;
418  menu["boards"] = boards;
419  menu["connectors"] = connectors;
420  menu["ctp"] = ctp;
421 
422 
423  if(writeTmpFile) {
424  std::ofstream outfile("tmp" + filename);
425  outfile << std::setw(4) << menu << std::endl;
426  std::cout << "Wrote tmp" << filename << std::endl;
427  }
428  std::stringstream ss;
429  ss << menu;
430  ptree top;
431  boost::property_tree::read_json(ss, top);
432  TrigConf::L1Menu l1menu(std::move(top));
434  writer.writeJsonFile(filename, l1menu);
435 }

◆ convertRun2L1PrescalesToRun3()

void convertRun2L1PrescalesToRun3 ( const TrigConf::CTPConfig ctpConfig,
const std::string &  filename,
bool  writeTmpFile 
)

Conversion of L1 prescales set.

Run 2 to Run 3 L1 prescale converter.

Definition at line 519 of file Run2toRun3ConvertersL1.cxx.

519  {
520  const TrigConf::PrescaleSet & l1pss = ctpConfig->prescaleSet();
521  if(l1pss.isNull()) {
522  std::cout << "L1PrescaleSet is empty, no file will be produced" << std::endl;
523  return;
524  }
525 
526  json psset;
527  psset["filetype"] = "l1prescale";
528  psset["name"] = l1pss.name();
529  json jCuts;
530  for (size_t id = 0; id < l1pss.prescales_float().size(); ++id) {
531  json jCut;
532  auto itemPtr = ctpConfig->menu().item(id);
533  if ( itemPtr != nullptr ) {
534  int32_t cut = l1pss.cuts().at(id);
535  jCut["cut"] = abs(cut);
536  jCut["enabled"] = cut > 0;
537  double ps = static_cast<double>(0xFFFFFF) / ( 0x1000000 - cut );
538  jCut["info"] = "prescale: "+std::to_string(ps);
539  jCuts[itemPtr->name()] = jCut;
540  }
541  }
542  psset["cutValues"] = jCuts;
543 
544  if(writeTmpFile) {
545  std::ofstream outfile("tmp" + filename);
546  outfile << std::setw(4) << psset << std::endl;
547  std::cout << "Wrote tmp" << filename << std::endl;
548  }
549  std::stringstream ss;
550  ss << psset;
551  ptree top;
552  boost::property_tree::read_json(ss, top);
553  TrigConf::L1PrescalesSet ps(std::move(top));
555  writer.writeJsonFile(filename, ps);
556 }

◆ toRanges()

std::vector<std::pair<int, int> > toRanges ( const std::vector< int > &  bunches)

Conversion of bunchgroup set.

Definition at line 441 of file Run2toRun3ConvertersL1.cxx.

441  {
442  // converts sequence of bunches into the pairs of continous ranges
443  if ( bunches.empty() ) {
444  return {};
445  }
446  if (bunches.size() == 1) {
447  return { {bunches.front(), bunches.front()} };
448  }
449 
450  // nontrival ranges
451  std::vector<std::pair<int, int>> ranges;
452  std::vector<int> sorted = bunches;
453  std::sort(sorted.begin(), sorted.end());
454 
455  std::vector<int> differences;
456  std::adjacent_difference( sorted.begin(), sorted.end(), std::back_inserter(differences));
457 
458  int start = sorted.front();
459 
460  for (size_t i = 1; i < differences.size(); ++i) {
461  if (differences[i] == 1) continue;
462  ranges.emplace_back( std::pair(start, sorted[i-1]) );
463  start = sorted[i];
464  }
465  ranges.emplace_back( std::pair(start, sorted.back()) );
466  return ranges;
467 }
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
TrigConf::BunchGroupSet
Definition: BunchGroupSet.h:19
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
TrigConf::TrigConfData::name
const std::string & name() const
Definition: TrigConfData.h:22
SGout2dot.alg
alg
Definition: SGout2dot.py:243
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrigConf::PrescaleSet
Definition: PrescaleSet.h:22
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TrigConf::METSigParam
Definition: METSigParam.h:12
TrigConf::CaloInfo::minTobJetLarge
const MinTOBPt & minTobJetLarge() const
Definition: CaloInfo.h:63
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
json
nlohmann::json json
Definition: HistogramDef.cxx:9
TrigConf::MinTOBPt::ptmin
unsigned int ptmin
Definition: CaloInfo.h:28
TrigConf::Menu::caloInfo
const CaloInfo & caloInfo() const
Definition: Menu.h:74
TrigConf::CTPConfig::ctpVersion
unsigned int ctpVersion() const
Definition: CTPConfig.h:33
TrigConf::CaloInfo::minTobJetSmall
const MinTOBPt & minTobJetSmall() const
Definition: CaloInfo.h:62
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
python.TriggerConfig.menu
menu
Definition: TriggerConfig.py:836
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TrigConf::CTPConfig::bunchGroupSet
const BunchGroupSet & bunchGroupSet() const
Definition: CTPConfig.h:40
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
TrigConf::CaloInfo::metSigParam
METSigParam & metSigParam()
Definition: CaloInfo.h:50
TrigConf::Menu::item
TriggerItem * item(int ctpid) const
Definition: Menu.cxx:84
TrigConf::CaloInfo::isolationEMIsoForEMthr
const std::vector< IsolationParam > & isolationEMIsoForEMthr() const
Definition: CaloInfo.h:54
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
TrigConf::Menu::thresholdVector
const std::vector< TriggerThreshold * > & thresholdVector() const
Definition: Menu.cxx:123
find_tgc_unfilled_channelids.mapping
mapping
Definition: find_tgc_unfilled_channelids.py:17
TrigConf::ClusterThresholdValue
Definition: ClusterThresholdValue.h:13
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
TrigConf::METSigParam::teSqrtMax
int teSqrtMax() const
Definition: METSigParam.h:35
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrigConf::PrescaleSet::prescales_float
const std::vector< float > & prescales_float() const
Definition: PrescaleSet.h:43
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
TrigConf::METSigParam::xeMin
int xeMin() const
Definition: METSigParam.h:32
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigConf::CaloInfo
Definition: CaloInfo.h:35
TrigConf::METSigParam::teSqrtMin
int teSqrtMin() const
Definition: METSigParam.h:34
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
TrigConf::PrescaleSet::cuts
const std::vector< int32_t > & cuts() const
Definition: PrescaleSet.h:44
TrigConf::CTPConfig::prescaleSet
const PrescaleSet & prescaleSet(unsigned int partition=0) const
Definition: CTPConfig.h:39
run
Definition: run.py:1
toRanges
std::vector< std::pair< int, int > > toRanges(const std::vector< int > &bunches)
Conversion of bunchgroup set.
Definition: Run2toRun3ConvertersL1.cxx:441
TrigConf::L1BunchGroupSet
L1 board configuration.
Definition: L1BunchGroupSet.h:71
TrigConf::IsolationParam
Definition: IsolationParam.h:16
TrigConf::uint2bin
std::string uint2bin(uint32_t uinteger, uint16_t width)
Definition: Trigger/TrigConfiguration/TrigConfL1Data/Root/HelperFunctions.cxx:332
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
TrigConf::L1PrescalesSet
L1 menu configuration.
Definition: L1PrescalesSet.h:19
TrigConf::BunchGroupSet::bunchGroups
const std::vector< BunchGroup > & bunchGroups() const
Definition: BunchGroupSet.h:27
TrigConf::JetWindowSize::SMALL
@ SMALL
Definition: TriggerThresholdValue.h:17
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::TriggerThresholdValue::etamin
int etamin() const
Definition: TriggerThresholdValue.h:53
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TXC::RegisterParameter
Definition: L1TopoConfigAlg.h:45
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
TrigConf::CaloInfo::isolationEMIsoForTAUthr
const std::vector< IsolationParam > & isolationEMIsoForTAUthr() const
Definition: CaloInfo.h:55
TriggerTest.ctp
ctp
Retrieve trigger EDM objects.
Definition: TriggerTest.py:14
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TrigConf::JsonFileWriterL1
Loader of trigger configurations from Json files.
Definition: JsonFileWriterL1.h:23
TXC::L1TopoConfigAlg
Definition: L1TopoConfigAlg.h:56
TrigConf::METSigParam::xeMax
int xeMax() const
Definition: METSigParam.h:33
TXC::L1TopoMenu::getL1TopoConfigAlgs
const std::vector< TXC::L1TopoConfigAlg > & getL1TopoConfigAlgs() const
Definition: L1TopoMenu.h:53
TrigConf::METSigParam::xsSigmaOffset
int xsSigmaOffset() const
Definition: METSigParam.h:31
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
TrigConf::CaloInfo::isolationHAIsoForEMthr
const std::vector< IsolationParam > & isolationHAIsoForEMthr() const
Definition: CaloInfo.h:53
TrigConf::JetThresholdValue
Definition: JetThresholdValue.h:12
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
TrigConf::CTPConfig::menu
const Menu & menu() const
Definition: CTPConfig.h:38
TrigConf::Menu::items
const ItemContainer & items() const
Definition: Menu.h:140
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TXC::FixedParameter
Definition: L1TopoConfigAlg.h:38
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
top
@ top
Definition: TruthClasses.h:64
dqt_zlumi_alleff_HIST.tl
tl
Definition: dqt_zlumi_alleff_HIST.py:73
TrigConf::CaloInfo::globalEmScale
float globalEmScale() const
Definition: CaloInfo.h:43
example.writer
writer
show summary of content
Definition: example.py:36
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
TrigConf::CaloInfo::minTobTau
const MinTOBPt & minTobTau() const
Definition: CaloInfo.h:61
TrigConf::METSigParam::xsSigmaScale
int xsSigmaScale() const
Definition: METSigParam.h:30
TrigConf::TriggerItem
Definition: TriggerItem.h:25
TrigConf::PrescaleSet::isNull
bool isNull() const
Definition: PrescaleSet.h:37
TrigConf::CaloInfo::minTobEM
const MinTOBPt & minTobEM() const
Definition: CaloInfo.h:60