diff --git a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Menu.h b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Menu.h index 828074586595b515f4575f72a8e3a3bb68a67eba..a150568d0191a12cfcf848c8c1467cbae9806f90 100644 --- a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Menu.h +++ b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Menu.h @@ -147,7 +147,9 @@ namespace TrigConf { /** print overview of L1 Menu */ void printMenu(bool full = false) const; - bool isRun2() const { return m_run<3; } + bool isRun2() const { return m_run == 2; } + + unsigned int run() const { return m_run; } /** Clearing the configuration data */ virtual void clear() override; diff --git a/Trigger/TrigConfiguration/TrigConfData/src/L1Menu.cxx b/Trigger/TrigConfiguration/TrigConfData/src/L1Menu.cxx index 9b83d9f14706860ffc27294970dc4d15cf6c029d..19cce74c5399a1dc5be7a19aa142513bd361e00e 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/L1Menu.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/L1Menu.cxx @@ -98,41 +98,43 @@ TrigConf::L1Menu::load() } // algorithms - try { - auto topoCategories = isRun2() ? std::vector<std::string> {"R2TOPO"} : std::vector<std::string> {"TOPO", "MUTOPO", "MULTTOPO", "R2TOPO"}; - for( const std::string& algoCategory : topoCategories ) { - auto & v = m_algorithmsByCategory[algoCategory] = std::vector<TrigConf::L1TopoAlgorithm>(); - if(algoCategory == "MULTTOPO") { - for( auto & alg : data().get_child( "topoAlgorithms." + algoCategory + ".multiplicityAlgorithms" ) ) { - v.emplace_back( alg.first, L1TopoAlgorithm::AlgorithmType::MULTIPLICITY, algoCategory, alg.second ); - } - } else { - for( L1TopoAlgorithm::AlgorithmType algoType : { L1TopoAlgorithm::AlgorithmType::DECISION, L1TopoAlgorithm::AlgorithmType::SORTING } ) { - std::string subpath = "topoAlgorithms." + algoCategory + (algoType==L1TopoAlgorithm::AlgorithmType::DECISION ? ".decisionAlgorithms" : ".sortingAlgorithms" ); - for( auto & algorithm : data().get_child( subpath ) ) { - v.emplace_back( algorithm.first, algoType, algoCategory, algorithm.second ); + if(m_run>1) { + try { + auto topoCategories = isRun2() ? std::vector<std::string> {"R2TOPO"} : std::vector<std::string> {"TOPO", "MUTOPO", "MULTTOPO", "R2TOPO"}; + for( const std::string& algoCategory : topoCategories ) { + auto & v = m_algorithmsByCategory[algoCategory] = std::vector<TrigConf::L1TopoAlgorithm>(); + if(algoCategory == "MULTTOPO") { + for( auto & alg : data().get_child( "topoAlgorithms." + algoCategory + ".multiplicityAlgorithms" ) ) { + v.emplace_back( alg.first, L1TopoAlgorithm::AlgorithmType::MULTIPLICITY, algoCategory, alg.second ); + } + } else { + for( L1TopoAlgorithm::AlgorithmType algoType : { L1TopoAlgorithm::AlgorithmType::DECISION, L1TopoAlgorithm::AlgorithmType::SORTING } ) { + std::string subpath = "topoAlgorithms." + algoCategory + (algoType==L1TopoAlgorithm::AlgorithmType::DECISION ? ".decisionAlgorithms" : ".sortingAlgorithms" ); + for( auto & algorithm : data().get_child( subpath ) ) { + v.emplace_back( algorithm.first, algoType, algoCategory, algorithm.second ); + } } } - } - for( auto & algo : v ) { - if( m_algorithmsByName[algoCategory].count(algo.name()) > 0 ) { - std::cerr << "ERROR : Topo algorithm with name " << algo.name() << " and of type " << algoCategory << " already exists" << std::endl; - throw std::runtime_error("Found duplicate topo algorithm name " + algo.name() + " of type " + algoCategory); - } - m_algorithmsByName[ algoCategory ][ algo.name() ] = & algo; - for( const std::string & output : algo.outputs() ) { - if( m_algorithmsByOutput[algoCategory].count(output) > 0 ) { - std::cerr << "ERROR : Topo algorithm output " << output << " already exists" << std::endl; - throw std::runtime_error("Found duplicate topo algorithm output " + output + " of type " + algoCategory); + for( auto & algo : v ) { + if( m_algorithmsByName[algoCategory].count(algo.name()) > 0 ) { + std::cerr << "ERROR : Topo algorithm with name " << algo.name() << " and of type " << algoCategory << " already exists" << std::endl; + throw std::runtime_error("Found duplicate topo algorithm name " + algo.name() + " of type " + algoCategory); + } + m_algorithmsByName[ algoCategory ][ algo.name() ] = & algo; + for( const std::string & output : algo.outputs() ) { + if( m_algorithmsByOutput[algoCategory].count(output) > 0 ) { + std::cerr << "ERROR : Topo algorithm output " << output << " already exists" << std::endl; + throw std::runtime_error("Found duplicate topo algorithm output " + output + " of type " + algoCategory); + } + m_algorithmsByOutput[algoCategory][output] = & algo; } - m_algorithmsByOutput[algoCategory][output] = & algo; } } } - } - catch(std::exception & ex) { - std::cerr << "ERROR: problem when building L1 menu structure (algorithms). " << ex.what() << std::endl; - throw; + catch(std::exception & ex) { + std::cerr << "ERROR: problem when building L1 menu structure (algorithms). " << ex.what() << std::endl; + throw; + } } // CTP @@ -472,11 +474,13 @@ TrigConf::L1Menu::printMenu(bool full) const } } } - cout << "Topo algorithms: " << endl; - cout << " new : " << data().get_child("topoAlgorithms.TOPO.decisionAlgorithms").size() << endl; - cout << " muon : " << data().get_child("topoAlgorithms.MUTOPO.decisionAlgorithms").size() << endl; - cout << " mult : " << data().get_child("topoAlgorithms.MULTTOPO.multiplicityAlgorithms").size() << endl; - cout << " legacy: " << data().get_child("topoAlgorithms.R2TOPO.decisionAlgorithms").size() << endl; + if(m_run>1) { + cout << "Topo algorithms: " << endl; + cout << " new : " << data().get_child("topoAlgorithms.TOPO.decisionAlgorithms").size() << endl; + cout << " muon : " << data().get_child("topoAlgorithms.MUTOPO.decisionAlgorithms").size() << endl; + cout << " mult : " << data().get_child("topoAlgorithms.MULTTOPO.multiplicityAlgorithms").size() << endl; + cout << " legacy: " << data().get_child("topoAlgorithms.R2TOPO.decisionAlgorithms").size() << endl; + } cout << "Boards: " << data().get_child("boards").size() << endl; cout << "Connectors: " << data().get_child("connectors").size() << endl; unsigned int ctpinputs = data().get_child("ctp.inputs.optical").size(); diff --git a/Trigger/TrigConfiguration/TrigConfData/src/L1ThrExtraInfo.cxx b/Trigger/TrigConfiguration/TrigConfData/src/L1ThrExtraInfo.cxx index c32a1180b936fd57e5ecd5967943e0137d0c4273..7c7b2e99159a0673b3ea58886670ef82360cd0cb 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/L1ThrExtraInfo.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/L1ThrExtraInfo.cxx @@ -145,7 +145,7 @@ TrigConf::L1ThrExtraInfo_EMTAULegacy::isolation(const std::string & thrType, siz return m_isolation.at(thrType)[bit-1]; } catch(std::exception & ex) { - std::cerr << "Threshold type EM does not have isolation parameters for type " << thrType << endl; + std::cerr << "Threshold type " << name() << " does not have isolation parameters for type " << thrType << endl; throw; } } @@ -158,8 +158,7 @@ TrigConf::L1ThrExtraInfo_EMTAULegacy::load() m_ptMinToTopoMeV = std::lround( 1000 * x.second.getValue<float>() ); } else if( x.first == "isolation" ) { for( auto & y : x.second.data() ) { - auto & isoV = m_isolation[y.first] = std::vector<IsolationLegacy>(); - isoV.resize(5); + auto & isoV = m_isolation[y.first] = std::vector<IsolationLegacy>(5); for(auto & c : y.second.get_child("Parametrization") ) { auto iso = IsolationLegacy(c.second); isoV[iso.isobit()-1] = iso; diff --git a/Trigger/TrigConfiguration/TrigConfData/src/L1ThresholdBase.cxx b/Trigger/TrigConfiguration/TrigConfData/src/L1ThresholdBase.cxx index d88335f97986db6f0d46c8a78eee2ddf79b375c2..ef4069646dda0cb68664eab0290d642ee1f6d7bf 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/L1ThresholdBase.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/L1ThresholdBase.cxx @@ -28,22 +28,22 @@ std::shared_ptr<TrigConf::L1Threshold> TrigConf::L1Threshold::createThreshold( const std::string & name, const std::string & type, std::weak_ptr<L1ThrExtraInfoBase> extraInfo, const ptree & data ) { - if( type == "EM" ) + if( type == "EM" ) return std::make_shared<L1Threshold_EM>( name, type, extraInfo, data ); - + if( type == "TAU" ) return std::make_shared<L1Threshold_TAU>( name, type, extraInfo, data ); if( type == "XE" ) return std::make_shared<L1Threshold_XE>( name, type, extraInfo, data ); - if( type == "JET" ) + if( type == "JET" || type == "JB" || type == "JF" ) // JB and JF are Run 1 thresholds return std::make_shared<L1Threshold_JET>( name, type, extraInfo, data ); if( type == "XS" ) return std::make_shared<L1Threshold_XS>( name, type, extraInfo, data ); - if( type == "TE" ) + if( type == "TE" || type == "JE" ) // JE is a Run 1 threshold return std::make_shared<L1Threshold_TE>( name, type, extraInfo, data ); if( type == "eEM" ) @@ -62,8 +62,7 @@ TrigConf::L1Threshold::createThreshold( const std::string & name, const std::str return std::make_shared<L1Threshold_ZB>( name, type, extraInfo, data ); static const std::string NIMtypes[] = { "BCM", "BCMCMB", "LUCID", "ZDC", "BPTX", "CALREQ", "MBTS", "MBTSSI", "NIM" }; - bool isNIMtype = std::find(std::begin(NIMtypes), std::end(NIMtypes), type) != - std::end(NIMtypes); + bool isNIMtype = std::find(std::begin(NIMtypes), std::end(NIMtypes), type) != std::end(NIMtypes); if( isNIMtype ) return std::make_shared<L1Threshold_NIM>( name, type, extraInfo, data ); @@ -72,21 +71,19 @@ TrigConf::L1Threshold::createThreshold( const std::string & name, const std::str return std::make_shared<L1Threshold_internal>( name, type, extraInfo, data ); static const std::string caloBaseImp[] = { "gXE", "jXE" }; - bool useCaloBaseClass = std::find(std::begin(caloBaseImp), std::end(caloBaseImp),type) != - std::end(caloBaseImp); + bool useCaloBaseClass = std::find(std::begin(caloBaseImp), std::end(caloBaseImp),type) != std::end(caloBaseImp); if( useCaloBaseClass ) return std::make_shared<L1Threshold_Calo>( name, type, extraInfo, data ); - static const std::string noSpecialImp[] = { "JET", "XS", "TOPO", "MULTTOPO", "MUTOPO", "R2TOPO", "ALFA" }; - bool useBaseClass = std::find(std::begin(noSpecialImp), std::end(noSpecialImp),type) != - std::end(noSpecialImp); + static const std::string noSpecialImp[] = { "JET", "XS", "TOPO", "MULTTOPO", "MUTOPO", "R2TOPO", "ALFA"}; + bool useBaseClass = std::find(std::begin(noSpecialImp), std::end(noSpecialImp),type) != std::end(noSpecialImp); if( useBaseClass ) return std::make_shared<L1Threshold>( name, type, extraInfo, data ); - + throw std::runtime_error("Threshold " + name + " is not of a valid L1 threshold type: " + type); - + } TrigConf::L1Threshold::L1Threshold( const std::string & name, const std::string & type, diff --git a/Trigger/TrigConfiguration/TrigConfIO/src/JsonFileWriterL1.cxx b/Trigger/TrigConfiguration/TrigConfIO/src/JsonFileWriterL1.cxx index e62715f3d729047efd9d1e4e4dd0c1e4d6a957c4..d65c15eb0c52061bdf5f1d09ef99eaa758a9b252 100644 --- a/Trigger/TrigConfiguration/TrigConfIO/src/JsonFileWriterL1.cxx +++ b/Trigger/TrigConfiguration/TrigConfIO/src/JsonFileWriterL1.cxx @@ -20,7 +20,7 @@ bool TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1Menu & l1menu) const { - json items({}); + json items = json::object_t{}; for( auto & item : l1menu ) { json jItem({}); jItem["name"] = item.name(); @@ -35,7 +35,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 items[item.name()] = jItem; }; - json thresholds({}); + json thresholds = json::object_t{}; for(const std::string & thrType : l1menu.thresholdTypes()) { json jThresholsByType({}); // first the thresholds of this type @@ -54,6 +54,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 jThr["voltage"] = thr->getAttribute<float>("voltage"); } + // value try { if(thr->hasAttribute("value")) { auto & caloThr = dynamic_cast<const TrigConf::L1Threshold_Calo &>(*thr); // for MBTSII @@ -61,6 +62,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // MU try { auto muThr = dynamic_cast<const TrigConf::L1Threshold_MU &>(*thr); jThr["baThr"] = muThr.ptBarrel(); @@ -76,6 +78,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // TAU try { auto tauThr = dynamic_cast<const TrigConf::L1Threshold_TAU &>(*thr); std::string isobits = "00000"; @@ -86,6 +89,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 jThr["isobits"] = isobits; } catch(std::bad_cast&) {}; + // EM try { auto EMThr = dynamic_cast<const TrigConf::L1Threshold_EM &>(*thr); jThr["thrValues"] = json::array_t({}); @@ -107,6 +111,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // JET try { auto JThr = dynamic_cast<const TrigConf::L1Threshold_JET &>(*thr); jThr["thrValues"] = json::array_t({}); @@ -123,6 +128,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // TE try { auto teThr = dynamic_cast<const TrigConf::L1Threshold_TE &>(*thr); //jThr["thrValues"] = json::array_t({}); @@ -136,6 +142,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // ZB try { auto zbThr = dynamic_cast<const TrigConf::L1Threshold_ZB &>(*thr); jThr["seed"] = zbThr.seed(); @@ -143,7 +150,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 jThr["seedMultiplicity"] = zbThr.seedMultiplicity(); } catch(std::bad_cast&) {}; - + // eEM try { auto eEMThr = dynamic_cast<const TrigConf::L1Threshold_eEM &>(*thr); jThr["reta"] = TrigConf::Selection::wpToString(eEMThr.reta()); @@ -160,6 +167,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } catch(std::bad_cast&) {}; + // jJ try { auto jJThr = dynamic_cast<const TrigConf::L1Threshold_jJ &>(*thr); jThr["ranges"] = json::array_t({}); @@ -221,7 +229,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } - if(thrType == "EM") { + if(thrType == "EM" && l1menu.run()>1) { auto & eminfo = l1menu.thrExtraInfo().EM(); for(const std::string isoSet : { "EMIsoForEMthr", "HAIsoForEMthr" }) { jThrType["isolation"][isoSet]["thrtype"] = isoSet; @@ -242,7 +250,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } - if(thrType == "TAU") { + if(thrType == "TAU" && l1menu.run()>1) { auto & tauinfo = l1menu.thrExtraInfo().TAU(); const std::string isoSet{ "EMIsoForTAUthr" }; jThrType["isolation"][isoSet]["thrtype"] = isoSet; @@ -321,7 +329,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } - std::vector<std::string> legacyCalo = {"EM", "JET", "TAU", "XE", "TE", "XS", "ZB", "R2TOPO"}; + std::vector<std::string> legacyCalo = {"EM", "JET", "TAU", "XE", "TE", "XS", "ZB", "JB", "JF", "JE", "R2TOPO"}; if( std::any_of(begin(legacyCalo), end(legacyCalo), [&thrType](const std::string &c) { return c==thrType; }) ) { thresholds["legacyCalo"][thrType] = jThrType; } else { @@ -329,8 +337,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } }; - - json boards; + json boards = json::object_t{}; for( auto & bname : l1menu.boardNames() ) { auto & bdef = l1menu.board(bname); boards[bname] = json{ {"connectors", bdef.connectorNames()}, {"type", bdef.type()} }; @@ -338,8 +345,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 boards[bname]["legacy"] = true; }; - - json connectors; + json connectors = json::object_t{}; for( auto & cname : l1menu.connectorNames() ) { auto jConn = json{}; auto & cdef = l1menu.connector(cname); @@ -377,7 +383,7 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 connectors[cname] = jConn; } - json ctp; + json ctp = json::object_t{}; { for(size_t slot=7; slot<=9; ++slot) { std::string sName = "slot" + std::to_string(slot); @@ -386,11 +392,13 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 ctp["inputs"]["ctpin"][sName]["connector" + std::to_string(conn)] = l1menu.ctp().ctpin(slot,conn); } } + ctp["inputs"]["electrical"] = json::object_t{}; for(size_t conn=0; conn<3; ++conn) { if(l1menu.ctp().electrical(conn)=="") continue; ctp["inputs"]["electrical"]["connector" + std::to_string(conn)] = l1menu.ctp().electrical(conn); } + ctp["inputs"]["optical"] = json::object_t{}; for(size_t conn=0; conn<12; ++conn) { if(l1menu.ctp().optical(conn)=="") continue; @@ -403,8 +411,8 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 ctp["monitoring"] = json({{"ctpmon",ctpmon}}); } - json jtopo; - { + json jtopo = json::object_t{}; + if(l1menu.run()>1) { std::map<L1TopoAlgorithm::AlgorithmType,std::string> algTypeNames = { {L1TopoAlgorithm::AlgorithmType::SORTING, "sortingAlgorithms"}, {L1TopoAlgorithm::AlgorithmType::DECISION, "decisionAlgorithms"}, @@ -473,11 +481,9 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 } } - json j; + json j = json::object_t{}; j["filetype"] = "l1menu"; - if(l1menu.isRun2()) { - j["run"] = 2; - } + j["run"] = l1menu.run(); j["name"] = l1menu.name(); j["items"] = items; j["thresholds"] = thresholds; @@ -486,7 +492,6 @@ TrigConf::JsonFileWriterL1::writeJsonFile(const std::string & filename, const L1 j["connectors"] = connectors; j["ctp"] = ctp; - std::ofstream outfile(filename); outfile << std::setw(4) << j << std::endl; diff --git a/Trigger/TrigConfiguration/TrigConfL1Data/TrigConfL1Data/CaloInfo.h b/Trigger/TrigConfiguration/TrigConfL1Data/TrigConfL1Data/CaloInfo.h index fb885680fcc440f7b5106db90de463a1532a8879..583d143094c578a83067513bd1b3e6cd562bcfa1 100644 --- a/Trigger/TrigConfiguration/TrigConfL1Data/TrigConfL1Data/CaloInfo.h +++ b/Trigger/TrigConfiguration/TrigConfL1Data/TrigConfL1Data/CaloInfo.h @@ -50,8 +50,8 @@ namespace TrigConf { METSigParam& metSigParam() { return m_METSigParam; } const METSigParam& metSigParam() const { return m_METSigParam; } - const std::vector<IsolationParam>& isolationHAIsoForEMthr() const { return m_IsolationHAIsoForEMthr;; } - const std::vector<IsolationParam>& isolationEMIsoForEMthr() const { return m_IsolationEMIsoForEMthr;; } + const std::vector<IsolationParam>& isolationHAIsoForEMthr() const { return m_IsolationHAIsoForEMthr; } + const std::vector<IsolationParam>& isolationEMIsoForEMthr() const { return m_IsolationEMIsoForEMthr; } const std::vector<IsolationParam>& isolationEMIsoForTAUthr() const { return m_IsolationEMIsoForTAUthr; } unsigned int jetWindowSizeSmall() const { return m_JetWindowSizeSmall; } diff --git a/Trigger/TrigConfiguration/TrigConfStorage/src/test/Run2toRun3ConvertersL1.cxx b/Trigger/TrigConfiguration/TrigConfStorage/src/test/Run2toRun3ConvertersL1.cxx index 344f93b37f1024acf11060f070cdb9e5078a04a9..862df2b7e214d2b202bd7433a97df453f061d8e7 100644 --- a/Trigger/TrigConfiguration/TrigConfStorage/src/test/Run2toRun3ConvertersL1.cxx +++ b/Trigger/TrigConfiguration/TrigConfStorage/src/test/Run2toRun3ConvertersL1.cxx @@ -84,8 +84,10 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM return; } + unsigned int run = ctpConfig->ctpVersion() <=3 ? 1 : 2; + // items - json items; + json items = json::object_t{}; for( const TrigConf::TriggerItem * sourceItem: ctpConfig->menu().items() ) { json item({}); item["name"] = sourceItem->name(); @@ -109,8 +111,8 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM }; // thresholds - json thresholds; - std::unordered_set<std::string> legacyThrTypes{"EM", "TAU", "JET", "XE", "XS", "TE", "ZB", "R2TOPO"}; + json thresholds = json::object_t{}; + std::unordered_set<std::string> legacyThrTypes{"EM", "TAU", "JET", "JB", "JE", "JF", "XE", "XS", "TE", "ZB", "R2TOPO"}; for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) { std::string thrType = sourceThr->type(); if(thrType=="BGRP" || thrType=="RNDM") { @@ -195,7 +197,7 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM } thr["isobits"] = isobits; } - else if (thrType == "JET") + else if (thrType == "JET" || thrType == "JB" || thrType == "JF") { thr["thrValues"] = json::array_t{}; for (const TrigConf::TriggerThresholdValue *tv : sourceThr->thresholdValueVector()) @@ -212,6 +214,10 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM thr["thrValues"] += jtv; } } + else if (thrType == "XE" || thrType == "TE" || thrType == "XS" || thrType == "JE") + { + thr["value"] = static_cast<unsigned int>(sourceThr->thresholdValueVector().at(0)->ptcut()); + } else if (thrType == "ZB") { thr["seed"] = sourceThr->zbSeedingThresholdName(); @@ -221,40 +227,42 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM jThisType["thresholds"][sourceThr->name()] = thr; } - // exra info for thresholds + // extra info for thresholds const TrigConf::CaloInfo& ci = ctpConfig->menu().caloInfo(); thresholds["legacyCalo"]["EM"]["ptMinToTopo"] = ci.minTobEM().ptmin; thresholds["legacyCalo"]["EM"]["resolutionMeV"] = (int)(1000/ci.globalEmScale()); thresholds["legacyCalo"]["TAU"]["ptMinToTopo"] = ci.minTobTau().ptmin; thresholds["legacyCalo"]["JET"]["ptMinToTopoSmallWindow"] = ci.minTobJetSmall().ptmin; thresholds["legacyCalo"]["JET"]["ptMinToTopoLargeWindow"] = ci.minTobJetLarge().ptmin; - json isoHAforEM{ {"thrtype", "HAIsoForEMthr"}, {"Parametrization", json::array_t{}} }; - json isoEMforEM{ {"thrtype", "EMIsoForEMthr"}, {"Parametrization", json::array_t{}} }; - json isoEMforTAU{ {"thrtype", "EMIsoForTAUthr"}, {"Parametrization", json::array_t{}} }; - for(const TrigConf::IsolationParam & iso : ci.isolationHAIsoForEMthr()) { - json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, - {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; - isoHAforEM["Parametrization"] += p; - } - for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForEMthr()) { - json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, - {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; - isoEMforEM["Parametrization"] += p; - } - for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForTAUthr()) { - json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, - {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; - isoEMforTAU["Parametrization"] += p; + if(run==2) { + json isoHAforEM{ {"thrtype", "HAIsoForEMthr"}, {"Parametrization", json::array_t{}} }; + json isoEMforEM{ {"thrtype", "EMIsoForEMthr"}, {"Parametrization", json::array_t{}} }; + json isoEMforTAU{ {"thrtype", "EMIsoForTAUthr"}, {"Parametrization", json::array_t{}} }; + for(const TrigConf::IsolationParam & iso : ci.isolationHAIsoForEMthr()) { + json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, + {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; + isoHAforEM["Parametrization"] += p; + } + for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForEMthr()) { + json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, + {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; + isoEMforEM["Parametrization"] += p; + } + for(const TrigConf::IsolationParam & iso : ci.isolationEMIsoForTAUthr()) { + json p{ {"etamax", iso.etamax()}, {"etamin", iso.etamin()}, {"isobit", iso.isobit()}, {"mincut", iso.mincut()}, + {"offset", iso.offset()}, {"priority", iso.priority()}, {"slope", iso.slope()}, {"upperlimit", iso.upperlimit()} }; + isoEMforTAU["Parametrization"] += p; + } + thresholds["legacyCalo"]["EM"]["isolation"]["HAIsoForEMthr"] = isoHAforEM; + thresholds["legacyCalo"]["EM"]["isolation"]["EMIsoForEMthr"] = isoEMforEM; + thresholds["legacyCalo"]["TAU"]["isolation"]["EMIsoForTAUthr"] = isoEMforTAU; } - thresholds["legacyCalo"]["EM"]["isolation"]["HAIsoForEMthr"] = isoHAforEM; - thresholds["legacyCalo"]["EM"]["isolation"]["EMIsoForEMthr"] = isoEMforEM; - thresholds["legacyCalo"]["TAU"]["isolation"]["EMIsoForTAUthr"] = isoEMforTAU; const TrigConf::METSigParam &xs = ci.metSigParam(); thresholds["legacyCalo"]["XS"]["significance"] = json::object_t{ {"xsSigmaScale", xs.xsSigmaScale()}, {"xsSigmaOffset", xs.xsSigmaOffset()}, {"xeMin", xs.xeMin()}, {"xeMax", xs.xeMax()}, {"teSqrtMin", xs.teSqrtMin()}, {"teSqrtMax", xs.teSqrtMax()}}; // boards - json boards; + json boards = json::object_t{}; boards["Ctpin7"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true}, {"connectors", std::vector<std::string>{"EM1", "EM2", "TAU1", "TAU2"}} }; boards["Ctpin8"] = json::object_t{ {"type", "CTPIN"}, {"legacy", true}, @@ -267,7 +275,7 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM {"connectors", std::vector<std::string>{"LegacyTopo1"}} }; // connectors - json connectors; + json connectors = json::object_t{}; std::map<std::string,std::vector<const TrigConf::TriggerThreshold*>> triggerlinesMap; for( const TrigConf::TriggerThreshold * sourceThr : ctpConfig->menu().thresholdVector()) { if(sourceThr->isInternal()) { @@ -333,8 +341,8 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM } // algorithms - json decAlgos; - json sortAlgos; + json::object_t decAlgos; + json::object_t sortAlgos; for(const TXC::L1TopoConfigAlg & alg : topoMenu->getL1TopoConfigAlgs()) { json jAlg; jAlg["algId"] = alg.algoID(); @@ -376,25 +384,32 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM decAlgos[alg.name()] = jAlg; } } - json topo; - topo["R2TOPO"]["decisionAlgorithms"] = decAlgos; - topo["R2TOPO"]["sortingAlgorithms"] = sortAlgos; + json topo = json::object_t{}; + if(run==2) { + topo["R2TOPO"]["decisionAlgorithms"] = decAlgos; + topo["R2TOPO"]["sortingAlgorithms"] = sortAlgos; + } // ctp - json ctp; + json ctp = json::object_t{}; ctp["inputs"]["ctpin"]["slot7"] = json::object_t{{"connector0", "EM1"}, {"connector1", "EM2"}, {"connector2", "TAU1"}, {"connector3", "TAU2"}}; ctp["inputs"]["ctpin"]["slot8"] = json::object_t{{"connector0", "JET1"}, {"connector1", "JET2"}, {"connector2", "EN1"}, {"connector3", "EN2"}}; ctp["inputs"]["ctpin"]["slot9"] = json::object_t{{"connector0", "MUCTPI"}, {"connector1", "CTPCAL"}, {"connector2", "NIM1"}, {"connector3", "NIM2"}}; - ctp["inputs"]["electrical"] = json::object_t{{"connector0", "AlfaCtpin"}, {"connector1", "LegacyTopo0"}, {"connector2", "LegacyTopo1"}}; + if(run==2) { + ctp["inputs"]["electrical"] = json::object_t{{"connector0", "AlfaCtpin"}, {"connector1", "LegacyTopo0"}, {"connector2", "LegacyTopo1"}}; + } else { + ctp["inputs"]["electrical"] = json::object_t{}; + } + ctp["inputs"]["optical"] = json::object_t{}; ctp["monitoring"]["ctpmon"] = json::object_t{}; // putting the menu together - json menu({}); + json menu = json::object_t{}; menu["filetype"] = "l1menu"; - menu["run"] = 2; + menu["run"] = run; menu["name"] = ctpConfig->name(); menu["items"] = items; menu["thresholds"] = thresholds; @@ -403,6 +418,7 @@ convertRun2L1MenuToRun3(const TrigConf::CTPConfig* ctpConfig, const TXC::L1TopoM menu["connectors"] = connectors; menu["ctp"] = ctp; + if(writeTmpFile) { std::ofstream outfile("tmp" + filename); outfile << std::setw(4) << menu << std::endl; diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigGetter.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigGetter.py index fb5793aad61fdae1a9be4fc99afa57a8c263772a..321fa437403565c0c6db24294060ede3b53fa9e9 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigGetter.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigGetter.py @@ -532,7 +532,10 @@ def fetchRun3ConfigFiles(isMC, run, lb): triggerDBKeys = getTrigConfFromCool(run, lb) triggerDBKeys['DB'] = 'TRIGGERDB' if run > 230000 else 'TRIGGERDB_RUN1' - filesFetchStatus = subprocess.run("TrigConfReadWrite -i {DB} {SMK},{L1PSK},{HLTPSK},{BGSK} -o r3json > Run3ConfigFetchJSONFiles.log".format(**triggerDBKeys), shell=True) + cmd = "TrigConfReadWrite -i {DB} {SMK},{L1PSK},{HLTPSK},{BGSK} -o r3json > Run3ConfigFetchJSONFiles.log".format(**triggerDBKeys) + log = logging.getLogger( "TriggerConfigGetter.py" ) + log.info("Running command '%s'", cmd) + filesFetchStatus = subprocess.run(cmd, shell=True) assert filesFetchStatus.returncode == 0, "TrigConfReadWrite failed to fetch JSON files" return triggerDBKeys @@ -542,4 +545,4 @@ if __name__ == "__main__": keys = fetchRun3ConfigFiles(isMC=False, run=360026, lb=151) for k,v in {"SMK" : 2749, "L1PSK" : 23557, "HLTPSK" : 17824, "BGSK" : 2181}.items(): assert k in keys, "Missing key {}".format(k) - assert v == keys[k], "Wrong value {}".format(v) \ No newline at end of file + assert v == keys[k], "Wrong value {}".format(v) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Base/L1Menu2JSON.py b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Base/L1Menu2JSON.py index a4a8582f82f089d0d65b044eb114831be90fa050..b91694082b6dd905fe6adfdfaacce930c4ab19dd 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Base/L1Menu2JSON.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Base/L1Menu2JSON.py @@ -46,6 +46,8 @@ class L1MenuJSONConverter(object): confObj["name"] = self.menu.menuName + confObj["run"] = 3 # will be useful for later (we also record this for Run 1 and 2) + # items confObj["items"] = self.menu.items.json()