From 9706aa0782a31cfbe6fd6fb8d4b2278b4d676b74 Mon Sep 17 00:00:00 2001 From: William Panduro Vazquez <j.panduro.vazquez@cern.ch> Date: Mon, 30 Nov 2020 16:06:53 +0000 Subject: [PATCH] Revert "Merge branch 'master-checkL1TopoSeq' into 'master'" This reverts merge request !38137 --- .../share/TrigL1TopoWriteValData.py | 8 +- .../TrigConfData/TrigConfData/L1Connector.h | 6 +- .../TrigConfData/src/L1Connector.cxx | 10 +- .../python/TrigConfigSvcConfig.py | 20 +- .../L1Topo/L1TopoCoreSim/CMakeLists.txt | 6 +- .../L1TopoCoreSim/DecisionConnector.h | 9 +- .../L1TopoCoreSim/GlobalDecision.h | 33 +- .../L1TopoCoreSim/TopoCoreSimResult.h | 4 +- .../L1TopoCoreSim/TopoSteering.h | 20 +- .../L1TopoCoreSim/TopoSteeringStructure.h | 5 +- .../L1TopoCoreSim/Root/DecisionConnector.cxx | 8 +- .../L1TopoCoreSim/Root/GlobalDecision.cxx | 109 ++--- .../L1TopoCoreSim/Root/TopoCoreSimResult.cxx | 28 +- .../L1TopoCoreSim/Root/TopoSteering.cxx | 91 ++-- .../Root/TopoSteeringStructure.cxx | 422 ++++++------------ .../L1TopoCoreSim/src/test/TopoStandAlone.cxx | 34 +- .../src/test/TopoTestSteeringConfig.cxx | 19 +- .../L1Topo/L1TopoSimulation/CMakeLists.txt | 2 +- .../python/L1TopoSimulationConfig.py | 7 +- .../share/L1TopoSimulationTest.py | 11 +- .../L1TopoSimulation/src/L1TopoSimulation.cxx | 163 ++++--- .../L1TopoSimulation/src/L1TopoSimulation.h | 103 +++-- .../src/test/L1TopoSimulationTest.cxx | 45 +- .../src/test/L1TopoSimulationTest.h | 2 - .../TrigT1/TrigT1CTP/src/CTPSimulation.cxx | 189 +++----- Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.h | 2 +- .../TrigT1/TrigT1CTP/src/CTPTriggerItem.cxx | 14 +- .../TrigT1/TrigT1CTP/src/ResultBuilder.cxx | 5 +- Trigger/TrigT1/TrigT1CTP/src/ThresholdMap.cxx | 7 +- .../python/Lvl1SimulationConfig.py | 2 +- .../TriggerMenuMT/python/L1/Config/ItemDef.py | 13 +- .../python/L1/Menu/MenuMapping.py | 1 - 32 files changed, 566 insertions(+), 832 deletions(-) diff --git a/HLT/Trigger/TrigMonitoring/TrigOnlineMonitor/share/TrigL1TopoWriteValData.py b/HLT/Trigger/TrigMonitoring/TrigOnlineMonitor/share/TrigL1TopoWriteValData.py index 8388b47ca14..cbf3c84a238 100755 --- a/HLT/Trigger/TrigMonitoring/TrigOnlineMonitor/share/TrigL1TopoWriteValData.py +++ b/HLT/Trigger/TrigMonitoring/TrigOnlineMonitor/share/TrigL1TopoWriteValData.py @@ -55,10 +55,10 @@ else: # Add an instance of TrigL1TopoWriteValData to the sequence -#from AthenaCommon import CfgMgr -#l1topoWriteValData = CfgMgr.TrigL1TopoWriteValData("l1topoWriteValData") -#topSequence += l1topoWriteValData -#log.debug("added l1topoWriteValData to topSequence") +from AthenaCommon import CfgMgr +l1topoWriteValData = CfgMgr.TrigL1TopoWriteValData("l1topoWriteValData") +topSequence += l1topoWriteValData +log.debug("added l1topoWriteValData to topSequence") #l1topoWriteValData.OutputLevel=1 #-------------------------------------------------------------- diff --git a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Connector.h b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Connector.h index 5b85a067afa..69cd439b7ec 100644 --- a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Connector.h +++ b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/L1Connector.h @@ -20,8 +20,8 @@ namespace TrigConf { */ class TriggerLine { public: - TriggerLine(const std::string & name, unsigned int startbit, unsigned int nbits, unsigned int fpga=0, unsigned int clock=0, const std::string & connName="") : - m_name(name), m_startbit(startbit), m_nbits(nbits), m_fpga(fpga), m_clock(clock), m_connName(connName) + TriggerLine(const std::string & name, unsigned int startbit, unsigned int nbits, unsigned int fpga=0, unsigned int clock=0) : + m_name(name), m_startbit(startbit), m_nbits(nbits), m_fpga(fpga), m_clock(clock) {} const std::string & name() const { return m_name; } unsigned int startbit() const { return m_startbit; } @@ -29,14 +29,12 @@ namespace TrigConf { unsigned int nbits() const { return m_nbits; } unsigned int fpga() const { return m_fpga; } unsigned int clock() const { return m_clock; } - const std::string & connName() const { return m_connName; } private: std::string m_name{""}; // the name of the threshold whose multiplicity is transmitted unsigned int m_startbit{0}; // the location on the cable - first bit unsigned int m_nbits{0}; // the location on the cable - number of bits used to encode the multiplicity unsigned int m_fpga{0}; // for electrical signals from L1Topo boards only: the fpga the signal is coming from unsigned int m_clock{0}; // for electrical signals from L1Topo boards only: the clock of the signal - std::string m_connName{""}; // the name of the connector where the triggerline is allocated }; /** @brief L1 connectors configuration */ diff --git a/Trigger/TrigConfiguration/TrigConfData/src/L1Connector.cxx b/Trigger/TrigConfiguration/TrigConfData/src/L1Connector.cxx index 7a08959afc2..3d7de39fe71 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/L1Connector.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/L1Connector.cxx @@ -52,10 +52,10 @@ TrigConf::L1Connector::update() for( size_t clock = 0; clock < m_maxClock; ++clock ) { std::string path = "triggerlines"; if( m_type == ConnectorType::ELECTRICAL ) { - if(hasMultipleFPGAs) { - path += ".fpga"; - path += std::to_string(fpga); - } + if(hasMultipleFPGAs) { + path += ".fpga"; + path += std::to_string(fpga); + } path += ".clock"; path += std::to_string(clock); } @@ -66,7 +66,7 @@ TrigConf::L1Connector::update() m_triggerLines[fpga][clock].emplace_back( name, tl.second.get_child("startbit").get_value<unsigned int>(), tl.second.get_child("nbits").get_value<unsigned int>(), - fpga, clock, m_name); + fpga, clock); m_lineByName[name] = & m_triggerLines[fpga][clock].back(); } } diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py index fbf5759f4bd..59b620da651 100755 --- a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py +++ b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py @@ -364,27 +364,9 @@ class SetupTrigConfigSvc(object): self.mlog.info( "Will not setup HLTConfigSvc, since TriggerFlags doLVL2(), doEF(), and doHLT() are all False" ) self.states[self.states.index("xml")] = "xmll1" - # generating a json L1 menu for Physics_pp_v7_primaries - # is needed for a transition period where we still have jobs - # running on this old menu, but the software expects a - # json-style L1 menu - menuName = TriggerFlags.triggerMenuSetup() - doGenerateJsonMenuForRun2Menu = (menuName == "Physics_pp_v7_primaries") - if doGenerateJsonMenuForRun2Menu: - self.mlog.info("Generating L1 menu %s", menuName) - from TriggerMenuMT.L1.L1MenuConfig import L1MenuConfig - l1cfg = L1MenuConfig(menuName = menuName) # create menu - fileName = 'L1Menu_' + menuName + '.json' - l1JsonFileName = l1cfg.writeJSON(outputFile = fileName) # write menu - self.mlog.info("setup LVL1 ConfigSvc and add instance to ServiceMgr") - self.mlog.info("xml file = %s", self.l1XmlFile) - if doGenerateJsonMenuForRun2Menu: - self.mlog.info("json file= %s", l1JsonFileName) + self.mlog.info( "setup LVL1ConfigSvc and add instance to ServiceMgr (xml file="+self.l1XmlFile+")" ) l1 = LVL1ConfigSvc("LVL1ConfigSvc") l1.XMLMenuFile = self.l1XmlFile - if doGenerateJsonMenuForRun2Menu: - l1.JsonFileName = l1JsonFileName - ServiceMgr += l1 self.mlog.info( "setup L1TopoConfigSvc and add instance to ServiceMgr (xml file="+self.l1topoXmlFile+")" ) diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/CMakeLists.txt b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/CMakeLists.txt index 39c5b7d102e..dd086bcc87c 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/CMakeLists.txt +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/CMakeLists.txt @@ -13,13 +13,13 @@ atlas_add_library( L1TopoCoreSim Root/*.cxx PUBLIC_HEADERS L1TopoCoreSim PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} L1TopoCommon L1TopoConfig L1TopoEvent L1TopoInterfaces TrigConfBase TrigConfData + LINK_LIBRARIES ${ROOT_LIBRARIES} L1TopoCommon L1TopoConfig L1TopoEvent L1TopoInterfaces TrigConfBase PRIVATE_LINK_LIBRARIES L1TopoHardware L1TopoAlgorithms ) atlas_add_executable( TrigConfTopoStandAlone src/test/TopoStandAlone.cxx - LINK_LIBRARIES L1TopoCoreSim TrigConfBase TrigConfIO TrigConfData) + LINK_LIBRARIES L1TopoCoreSim TrigConfBase ) atlas_add_executable( TrigConfTopoTestSteeringConfig src/test/TopoTestSteeringConfig.cxx - LINK_LIBRARIES L1TopoCoreSim TrigConfBase TrigConfIO TrigConfData) + LINK_LIBRARIES L1TopoCoreSim ) diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/DecisionConnector.h b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/DecisionConnector.h index f66de22f6e4..cf6143617d6 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/DecisionConnector.h +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/DecisionConnector.h @@ -1,6 +1,4 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #ifndef L1TopoCoreSim_DecisionConnector #define L1TopoCoreSim_DecisionConnector @@ -9,7 +7,6 @@ #include "L1TopoInterfaces/Decision.h" #include "L1TopoConfig/L1TopoConfigOutputList.h" -#include "TrigConfData/L1Connector.h" #include <vector> #include <string> @@ -40,7 +37,7 @@ namespace TCS { bool decision(const std::string & trigger) const; - const std::vector<TrigConf::TriggerLine> & triggers() const { return m_triggers; } + const std::vector<TXC::TriggerLine> & triggers() const { return m_triggers; } // output data void attachOutputData(const std::vector<TOBArray *>&); @@ -65,7 +62,7 @@ namespace TCS { TCS::DecisionAlg* m_decisionAlgorithm; - std::vector<TrigConf::TriggerLine> m_triggers; + std::vector<TXC::TriggerLine> m_triggers; // attached output data std::vector<TOBArray const *> m_outputData; diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/GlobalDecision.h b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/GlobalDecision.h index b50a84421f5..31903997479 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/GlobalDecision.h +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/GlobalDecision.h @@ -1,7 +1,4 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #ifndef L1TopoCoreSim_GlobalDecision #define L1TopoCoreSim_GlobalDecision @@ -11,8 +8,6 @@ #include "L1TopoCommon/StatusCode.h" #include "L1TopoConfig/L1TopoConfigOutputList.h" -#include "TrigConfData/L1Connector.h" - #include <iostream> #include <vector> #include <set> @@ -34,22 +29,22 @@ namespace TCS { class GlobalDecision : public TrigConf::TrigConfMessaging { public: - GlobalDecision(const std::string & name = "L1TopoGlobalDecision"); + GlobalDecision(); - uint64_t decision_field(const std::string & connName) const { return m_decision.find(connName)->second; } + uint64_t decision(unsigned int module) const { return m_decision[module]; } - uint32_t decision_field(std::string connName, unsigned int clock) const; + uint32_t decision(unsigned int module, unsigned int clock) const; - bool passed(std::string connName, unsigned int bit) const { return ( ( (uint64_t)0x1 << bit) & m_decision.find(connName)->second) != 0; } - uint64_t overflow_field(std::string connName) const { return m_overflow.find(connName)->second; } - uint32_t overflow_field(std::string connName, unsigned int clock) const; - bool overflowed(std::string connName, unsigned int bit) const { return ( ( (uint64_t)0x1 << bit) & m_overflow.find(connName)->second) != 0; } + bool passed(unsigned int module, unsigned int bit) const { return ( ( (uint64_t)0x1 << bit) & m_decision[module]) != 0; } + uint64_t overflow(unsigned int module) const { return m_overflow[module]; } + uint32_t overflow(unsigned int module, unsigned int clock) const; + bool overflowed(unsigned int module, unsigned int bit) const { return ( ( (uint64_t)0x1 << bit) & m_overflow[module]) != 0; } const Decision & decision(const std::string & algName) const; bool isValid() const { return m_valid; } - void setTriggerLines(const std::vector<TrigConf::TriggerLine> & triggers); + void setTriggerLines(const std::vector<TXC::TriggerLine> & triggers) { m_triggers = triggers; } StatusCode collectDecision(const std::set<DecisionConnector*> & outconn); @@ -59,16 +54,16 @@ namespace TCS { private: friend std::ostream& operator<<(std::ostream&, const TCS::GlobalDecision &); - // 64 bit decision bit field - map connector name-decision field - std::map<std::string,uint64_t> m_decision; - // 64 bit overflow bit field - map connector name-overflow field - std::map<std::string,uint64_t> m_overflow; + // 64 bit decision bit field + uint64_t m_decision[3] {0,0,0}; + // 64 bit overflow bit field + uint64_t m_overflow[3] {0,0,0}; // flags if the decision field is up to date // set by @collectDecision(), unset by @resetDecision() bool m_valid {false}; // trigger lines - std::vector<TrigConf::TriggerLine> m_triggers; + std::vector<TXC::TriggerLine> m_triggers; }; } diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoCoreSimResult.h b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoCoreSimResult.h index de178edb679..88aecb9e2eb 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoCoreSimResult.h +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoCoreSimResult.h @@ -10,8 +10,6 @@ #include "TrigConfBase/TrigConfMessaging.h" -#include "TrigConfData/L1Menu.h" - #include <iostream> #include "L1TopoCommon/StatusCode.h" #include "L1TopoCoreSim/GlobalDecision.h" @@ -45,7 +43,7 @@ namespace TCS { const std::vector<const TCS::TOBArray*> & output(const std::string & connName) const; - StatusCode setupFromMenu(const std::map<std::string, TCS::DecisionConnector*>& outputConnectorMap); + StatusCode setupFromMenu(const TXC::L1TopoMenu & menu, const std::map<std::string, TCS::DecisionConnector*>& outputConnectorMap); StatusCode collectResult(TCS::DecisionConnector* outputConn = nullptr ); diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteering.h b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteering.h index 0f035f6597e..042c4e20b00 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteering.h +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteering.h @@ -1,6 +1,4 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #ifndef L1TopoCoreSim_TopoSteering #define L1TopoCoreSim_TopoSteering @@ -19,9 +17,6 @@ #include "L1TopoCoreSim/TopoCoreSimResult.h" #include "L1TopoCoreSim/TopoSteeringStructure.h" -// Menu related dependencies -#include "TrigConfData/L1Menu.h" - namespace TXC { class L1TopoMenu; } @@ -53,20 +48,16 @@ namespace TCS { const TopoCoreSimResult & simulationResult() const { return m_simulationResult; } - // @brief: build the execution structure and parameterspace from // the configuration StatusCode setupFromConfiguration(const TXC::L1TopoMenu& menu); - - StatusCode setupFromConfiguration(const TrigConf::L1Menu& l1menu); - + void setUseBitwise(bool useBitwise) { m_useBitwise = useBitwise; } // @brief: call the initialize function of the algorithms // will be called after the parameters are set and before the event loop starts StatusCode initializeAlgorithms(); - // run the topo simulation StatusCode executeEvent(); @@ -158,9 +149,8 @@ namespace TCS { std::bitset<numberOfL1TopoBits> m_triggerHdwBits; std::bitset<numberOfL1TopoBits> m_ovrflowHdwBits; - }; - -} + }; +} -#endif +#endif diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteeringStructure.h b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteeringStructure.h index 8aac19c35c5..119c899410a 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteeringStructure.h +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/L1TopoCoreSim/TopoSteeringStructure.h @@ -3,9 +3,6 @@ */ #include "L1TopoCommon/StatusCode.h" -#include "TrigConfData/L1Menu.h" -#include "TrigConfData/L1TopoAlgorithm.h" - #include <vector> #include <map> #include <string> @@ -31,7 +28,7 @@ namespace TCS { ~TopoSteeringStructure(); - StatusCode setupFromMenu(const TrigConf::L1Menu& l1menu, bool debug = false, bool legacy = false); + StatusCode setupFromMenu(const TXC::L1TopoMenu& menu, bool debug = false); // accessors bool isConfigured() const { return m_isConfigured; } diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/DecisionConnector.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/DecisionConnector.cxx index ee648be0973..1dba9be38b4 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/DecisionConnector.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/DecisionConnector.cxx @@ -1,6 +1,4 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #include "L1TopoCoreSim/DecisionConnector.h" @@ -26,7 +24,7 @@ DecisionConnector::~DecisionConnector() { bool TCS::DecisionConnector::decision(const std::string & trigger) const { unsigned int index(0); - for(const TrigConf::TriggerLine & tl : m_triggers) { + for(const TXC::TriggerLine & tl : m_triggers) { if(tl.name() == trigger) return m_decision.bit(index); ++index; @@ -39,7 +37,7 @@ TCS::DecisionConnector::decision(const std::string & trigger) const { TCS::TOBArray const * TCS::DecisionConnector::output(const std::string & trigger) const { unsigned int index(0); - for(const TrigConf::TriggerLine & tl : m_triggers) { + for(const TXC::TriggerLine & tl : m_triggers) { if(tl.name() == trigger) return m_outputData[index]; ++index; diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/GlobalDecision.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/GlobalDecision.cxx index e6068f8b508..5c59db40692 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/GlobalDecision.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/GlobalDecision.cxx @@ -1,6 +1,4 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #include <iomanip> @@ -12,53 +10,33 @@ using namespace std; using namespace TCS; -void -GlobalDecision::setTriggerLines(const vector<TrigConf::TriggerLine> & triggers) { - - m_triggers = triggers; - vector<string> connNames = {}; - for (const TrigConf::TriggerLine & trigger : triggers){ - auto it = find(connNames.begin(), connNames.end(), trigger.connName()); - if (it == connNames.end()){ - connNames.push_back(trigger.connName()); - m_decision[trigger.connName()] = 0; - } - } -} - uint32_t -GlobalDecision::decision_field(string connName, unsigned int clock) const { - try { - if(clock==0) { - // lower 32 bit - return (uint32_t) (m_decision.at(connName) & 0xffffffff); - } else { - // upper 32 bit - uint64_t clock1 = m_decision.at(connName) & 0xffffffff00000000; - return (uint32_t) (clock1 >> 32); - } - } - catch(std::exception &) { - TRG_MSG_ERROR("Connector name " << connName << " unknown"); - throw; +GlobalDecision::decision(unsigned int module, unsigned int clock) const { + if(clock==0) { + // lower 32 bit + return (uint32_t) (m_decision[module] & 0xffffffff); + } else { + // upper 32 bit + uint64_t clock1 = m_decision[module] & 0xffffffff00000000; + return (uint32_t) (clock1 >> 32); } } uint32_t -GlobalDecision::overflow_field(string connName, unsigned int clock) const { +GlobalDecision::overflow(unsigned int module, unsigned int clock) const { if(clock==0) { // lower 32 bit - return (uint32_t) (m_overflow.find(connName)->second & 0xffffffff); + return (uint32_t) (m_overflow[module] & 0xffffffff); } else { // upper 32 bit - uint64_t clock1 = m_overflow.find(connName)->second & 0xffffffff00000000; + uint64_t clock1 = m_overflow[module] & 0xffffffff00000000; return (uint32_t) (clock1 >> 32); } } -GlobalDecision::GlobalDecision(const std::string &name) : - TrigConfMessaging(name) +GlobalDecision::GlobalDecision() : + TrigConfMessaging("L1TopoGlobalDecision") {} /**************************************************************** @@ -69,7 +47,7 @@ GlobalDecision::GlobalDecision(const std::string &name) : * ****************************************************************/ -TCS::StatusCode +StatusCode GlobalDecision::collectDecision(const set<DecisionConnector*> & outconn) { resetDecision(); @@ -78,34 +56,34 @@ GlobalDecision::collectDecision(const set<DecisionConnector*> & outconn) { const Decision& dec = conn->decision(); unsigned int pos = 0; // for multi-output algorithms pos is the output index - for(const TrigConf::TriggerLine & trigger : conn->triggers() ) { - - unsigned int position = trigger.startbit() + 32*trigger.fpga() + 16*trigger.clock(); + for(const TXC::TriggerLine & trigger : conn->triggers() ) { - uint64_t & connectorDec = m_decision[trigger.connName()]; - uint64_t & connectorOvf = m_overflow[trigger.connName()]; + unsigned int bit = trigger.counter() % 64; // trigger bit in module + + uint64_t & moduleDec = m_decision[trigger.module()]; + uint64_t & moduleOvf = m_overflow[trigger.module()]; uint64_t mask(0x1); + //std::cout << "JOERG GlobalDecision::collectDecision: trigger line " << trigger.name() << " [counter="<<trigger.counter()<<"] on module " << trigger.module() << " and bit [0-63] " << bit << " -> dec " << dec << std::endl; + if( dec.bit(pos++) ) // bit set? - connectorDec |= (mask << position); + moduleDec |= (mask << bit); if( dec.overflow()) - connectorOvf |= (mask << position); + moduleOvf |= (mask << bit); } } m_valid = true; - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -TCS::StatusCode +StatusCode GlobalDecision::resetDecision() { - for(auto const& dec : m_decision) - m_decision[dec.first] = 0; - for(auto const& ovf : m_overflow) - m_overflow[ovf.first] = 0; + m_decision[0] = m_decision[1] = m_decision[2] = 0; + m_overflow[0] = m_overflow[1] = m_overflow[2] = 0; m_valid = false; - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -118,17 +96,18 @@ operator<<(std::ostream& o, const TCS::GlobalDecision & dec) { if(!dec.isValid()) o << "Note that the overall decision has not been calculated" << endl; - for(auto const& itdec : dec.m_decision) - o << "Overall decision for connector " << itdec.first << ": 0x" << right << hex << setfill('0') << setw(16) << dec.decision_field(itdec.first) << std::dec << setfill(' ') << endl; + for(unsigned int module = 0; module<3; ++module) + o << "Overall decision module " << module << ": 0x" << right << hex << setfill('0') << setw(16) << dec.decision(module) << std::dec << setfill(' ') << endl; + if(dec.isValid()) { - for(const TrigConf::TriggerLine & trigger : dec.m_triggers){ - unsigned int position = trigger.startbit() + 32*trigger.fpga() + 16*trigger.clock(); - o << " " << setw(30) << left << trigger.name() << " " << (dec.passed(trigger.connName(), position) ? "pass" : "fail") << endl;} + for(const TXC::TriggerLine & trigger : dec.m_triggers) + o << " " << setw(30) << left << trigger.name() << " " << (dec.passed(trigger.module(), trigger.counter() % 64) ? "pass" : "fail") << endl; } else { - for(const TrigConf::TriggerLine & trigger : dec.m_triggers) - o << " " << setw(30) << left << trigger.name() << " unset" << endl; + for(const TXC::TriggerLine & trigger : dec.m_triggers) + o << " " << setw(30) << left << trigger.name() << " unset" << endl; } + return o; } //---------------------------------------------------------- @@ -138,17 +117,17 @@ GlobalDecision::print() const { if(!isValid()) TRG_MSG_INFO("Note that the overall decision has not been calculated"); - for(auto const& dec : m_decision) - TRG_MSG_INFO("Overall decision from connector " << dec.first << ": 0x" << right << hex << setfill('0') << setw(16) << decision_field(dec.first) << std::dec << setfill(' ')); + for(unsigned int module = 0; module<3; ++module) + TRG_MSG_INFO("Overall decision module " << module << ": 0x" << right << hex << setfill('0') << setw(16) << decision(module) << std::dec << setfill(' ')); + if(isValid()) { - for(const TrigConf::TriggerLine & trigger : m_triggers){ - unsigned int position = trigger.startbit() + 32*trigger.fpga() + 16*trigger.clock(); - TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " " << (passed(trigger.connName(), position) ? "pass" : "fail") );} + for(const TXC::TriggerLine & trigger : m_triggers) + TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " " << (passed(trigger.module(), trigger.counter() % 64) ? "pass" : "fail") ); } else { - for(const TrigConf::TriggerLine & trigger : m_triggers) + for(const TXC::TriggerLine & trigger : m_triggers) TRG_MSG_INFO(" " << setw(30) << left << trigger.name() << " unset" ); } + } - } diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoCoreSimResult.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoCoreSimResult.cxx index fe17f5cfeaf..f1dcd5ee539 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoCoreSimResult.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoCoreSimResult.cxx @@ -15,8 +15,6 @@ #include "L1TopoCommon/Exception.h" -#include "TrigConfData/L1Menu.h" - #include <algorithm> using namespace std; @@ -48,9 +46,9 @@ TopoCoreSimResult::triggerOutput(const std::string & triggerName) const { -TCS::StatusCode +StatusCode TopoCoreSimResult::collectResult(TCS::DecisionConnector* outputConn) { - TCS::StatusCode sc = TCS::StatusCode::SUCCESS; + StatusCode sc = StatusCode::SUCCESS; if (outputConn == nullptr ) { sc = m_globalDecision.collectDecision(m_outputConnectors); } else { @@ -61,33 +59,31 @@ TopoCoreSimResult::collectResult(TCS::DecisionConnector* outputConn) { } -TCS::StatusCode +StatusCode TopoCoreSimResult::reset() { return m_globalDecision.resetDecision(); } -TCS::StatusCode -TopoCoreSimResult::setupFromMenu(const std::map<std::string, TCS::DecisionConnector*>& outputConnectorMap) { +StatusCode +TopoCoreSimResult::setupFromMenu(const TXC::L1TopoMenu & menu, + const std::map<std::string, TCS::DecisionConnector*>& outputConnectorMap) { m_outputConnectorMap = outputConnectorMap; - vector<TrigConf::TriggerLine> triggerLines; - for(auto & x : m_outputConnectorMap) { // fill the set m_outputConnectors.insert(x.second); // fill the trigger line map (trigger name --> (TCS::DecisionConnector*,unsigned int index) ) - for( const TrigConf::TriggerLine & trigger : x.second->triggers() ) { + for( const TXC::TriggerLine & trigger : x.second->triggers() ) { m_triggerLocation[trigger.name()] = x.second; - triggerLines.push_back(trigger); } } - m_globalDecision.setTriggerLines(triggerLines); + m_globalDecision.setTriggerLines(menu.getL1TopoConfigOutputList().getTriggerLines()); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -116,9 +112,9 @@ operator<<(std::ostream& o, const TCS::TopoCoreSimResult & simRes) { for( const DecisionConnector * conn : simRes.m_outputConnectors ) { o << conn->name() << endl; - // for(const TrigConf::TriggerLine & trigger : conn->triggers()) { - // o << " " << trigger << endl; - // } + for(const TXC::TriggerLine & trigger : conn->triggers()) { + o << " " << trigger << endl; + } for(const TCS::TOBArray* output : conn->outputData()) o << " output " << output << endl; } diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteering.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteering.cxx index a7e609b804d..007bfc2f624 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteering.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteering.cxx @@ -1,11 +1,8 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ +// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #include "L1TopoInterfaces/AlgFactory.h" #include "L1TopoInterfaces/IL1TopoHistSvc.h" - #include "L1TopoInterfaces/ConfigurableAlg.h" #include "L1TopoInterfaces/ParameterSpace.h" #include "L1TopoInterfaces/SortingAlg.h" @@ -44,31 +41,22 @@ TopoSteering::~TopoSteering() { AlgFactory::destroy_instance(); } -TCS::StatusCode -TopoSteering::setupFromConfiguration(const TXC::L1TopoMenu&){ - - // Keep this method to avoid crashes. TO-DO: Switch menu loading in L1TopoSimulation.cxx - TRG_MSG_WARNING("Cannot configure simulation from XML. Use JSON format"); - - return TCS::StatusCode::SUCCESS; - -} - - -TCS::StatusCode -TopoSteering::setupFromConfiguration(const TrigConf::L1Menu& l1menu){ +StatusCode +TopoSteering::setupFromConfiguration(const TXC::L1TopoMenu& menu) { + + if(m_useBitwise){ TRG_MSG_INFO("Will be using bitwise implementation of algorithms");} + else{TRG_MSG_INFO("Will NOT be using bitwise implementation of algorithms");} - TCS::StatusCode sc = m_structure.setupFromMenu( l1menu ); - - // configure layout of the simulation result - sc &= m_simulationResult.setupFromMenu( m_structure.outputConnectors() ); + StatusCode sc = m_structure.setupFromMenu( menu ); - return sc; + // configure layout of the simulation result + sc &= m_simulationResult.setupFromMenu( menu, m_structure.outputConnectors() ); + return sc; } -TCS::StatusCode +StatusCode TopoSteering::reset() { ClusterTOB::clearHeap(); @@ -86,11 +74,11 @@ TopoSteering::reset() { m_simulationResult.reset(); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -TCS::StatusCode +StatusCode TopoSteering::initializeAlgorithms() { TRG_MSG_INFO("initializing algorithms"); if( ! structure().isConfigured() ) { @@ -113,7 +101,7 @@ TopoSteering::initializeAlgorithms() { } -TCS::StatusCode +StatusCode TopoSteering::setHistSvc(std::shared_ptr<IL1TopoHistSvc> histSvc) { TRG_MSG_INFO("setting L1TopoHistSvc "); m_histSvc = histSvc; @@ -121,7 +109,7 @@ TopoSteering::setHistSvc(std::shared_ptr<IL1TopoHistSvc> histSvc) { } -TCS::StatusCode +StatusCode TopoSteering::saveHist() { if(m_histSvc) { m_histSvc->save(); @@ -132,7 +120,7 @@ TopoSteering::saveHist() { } -TCS::StatusCode +StatusCode TopoSteering::executeEvent() { @@ -147,7 +135,7 @@ TopoSteering::executeEvent() { inputEvent().print(); // execute all connectors - TCS::StatusCode sc = TCS::StatusCode::SUCCESS; + StatusCode sc = StatusCode::SUCCESS; TRG_MSG_INFO("Going to execute " << m_structure.outputConnectors().size() << " connectors"); for(auto outConn: m_structure.outputConnectors()) { TRG_MSG_INFO("executing trigger line " << outConn.first); @@ -160,19 +148,19 @@ TopoSteering::executeEvent() { m_simulationResult.globalDecision().print(); TRG_MSG_INFO("finished executing event " << m_evtCounter++); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -TCS::StatusCode +StatusCode TopoSteering::executeTrigger(const std::string & TrigName) { if( ! structure().isConfigured() ) TCS_EXCEPTION("TopoSteering has not been configured, can't run"); DecisionConnector * outConn = m_structure.outputConnector(TrigName); - TCS::StatusCode sc = executeConnector(outConn); + StatusCode sc = executeConnector(outConn); m_simulationResult.collectResult(outConn); @@ -180,22 +168,18 @@ TopoSteering::executeTrigger(const std::string & TrigName) { } - - - - -TCS::StatusCode +StatusCode TopoSteering::executeConnector(TCS::Connector *conn) { if (conn == NULL) { - return TCS::StatusCode::FAILURE; + return StatusCode::FAILURE; } // caching if(conn->isExecuted()) return conn->executionStatusCode(); - TCS::StatusCode sc(TCS::StatusCode::SUCCESS); + StatusCode sc(StatusCode::SUCCESS); if(conn->isInputConnector()) { //TRG_MSG_DEBUG(" ... executing input connector '" << conn->name() << "'"); @@ -216,14 +200,14 @@ TopoSteering::executeConnector(TCS::Connector *conn) { -TCS::StatusCode +StatusCode TopoSteering::executeInputConnector(TCS::InputConnector *conn) { if (conn == NULL) { - return TCS::StatusCode::FAILURE; + return StatusCode::FAILURE; } - TCS::StatusCode sc(TCS::StatusCode::SUCCESS); + StatusCode sc(StatusCode::SUCCESS); // attaching data from inputEvent to input connector, depending on the configured input type @@ -239,14 +223,14 @@ TopoSteering::executeInputConnector(TCS::InputConnector *conn) { -TCS::StatusCode +StatusCode TopoSteering::executeSortingConnector(TCS::SortingConnector *conn) { if (conn == NULL) { return StatusCode::FAILURE; } - TCS::StatusCode sc = TCS::StatusCode::SUCCESS; + StatusCode sc = StatusCode::SUCCESS; // execute all the prior connectors for( TCS::Connector* inputConn: conn->inputConnectors() ){ @@ -269,14 +253,14 @@ TopoSteering::executeSortingConnector(TCS::SortingConnector *conn) { -TCS::StatusCode +StatusCode TopoSteering::executeDecisionConnector(TCS::DecisionConnector *conn) { if (conn == NULL) { - return TCS::StatusCode::FAILURE; + return StatusCode::FAILURE; } - TCS::StatusCode sc = TCS::StatusCode::SUCCESS; + StatusCode sc = StatusCode::SUCCESS; // execute all the prior connectors for( TCS::Connector* inputConn: conn->inputConnectors() ){ @@ -321,7 +305,7 @@ TopoSteering::executeDecisionConnector(TCS::DecisionConnector *conn) { -TCS::StatusCode +StatusCode TopoSteering::executeSortingAlgorithm(TCS::SortingAlg *alg, TCS::InputConnector* inputConnector, TCS::TOBArray * & sortedOutput) { @@ -334,12 +318,12 @@ TopoSteering::executeSortingAlgorithm(TCS::SortingAlg *alg, if(m_useBitwise) alg->sortBitCorrect(*input, *sortedOutput); else alg->sort(*input, *sortedOutput); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } -TCS::StatusCode +StatusCode TopoSteering::executeDecisionAlgorithm(TCS::DecisionAlg *alg, const std::vector<Connector*> & inputConnectors, const std::vector<TCS::TOBArray *> & output, @@ -373,11 +357,10 @@ TopoSteering::executeDecisionAlgorithm(TCS::DecisionAlg *alg, else alg->process( input, output, decision ); //TRG_MSG_ALWAYS("[XS1234sz]L1Topo Steering alg " << alg->name() << " has decision " << decision.decision()); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } - void TopoSteering::printDebugInfo() { TRG_MSG_INFO("Number of ClusterTOB : " << ClusterTOB::heap().size()); @@ -439,8 +422,8 @@ void TopoSteering::propagateHardwareBitsToAlgos() TCS::DecisionConnector *outCon = connector.second; outCon->decisionAlgorithm()->resetHardwareBits(); unsigned int pos = 0; // for multi-output algorithms pos is the output index - for(const TrigConf::TriggerLine &trigger : outCon->triggers()){ - unsigned int bitNumber = trigger.startbit() + 32*trigger.fpga() + 16*clock(); + for(const TXC::TriggerLine &trigger : outCon->triggers()){ + unsigned int bitNumber = trigger.counter(); outCon->decisionAlgorithm()->setHardwareBits(pos, m_triggerHdwBits[bitNumber], m_ovrflowHdwBits[bitNumber]); diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteeringStructure.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteeringStructure.cxx index e0623628224..e7b1fd48d0e 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteeringStructure.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/Root/TopoSteeringStructure.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "L1TopoCoreSim/TopoSteeringStructure.h" @@ -20,8 +20,6 @@ #include "L1TopoHardware/L1TopoHardware.h" -#include "TrigConfData/L1Menu.h" - #include <set> #include <iomanip> #include <boost/lexical_cast.hpp> @@ -74,11 +72,11 @@ TopoSteeringStructure::~TopoSteeringStructure() { } -TCS::StatusCode +StatusCode TopoSteeringStructure::reset() { for(Connector* conn: m_connectors) conn->reset(); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -119,319 +117,189 @@ TCS::TopoSteeringStructure::printParameters(std::ostream & o) const { } + + TCS::StatusCode -TCS::TopoSteeringStructure::setupFromMenu(const TrigConf::L1Menu& l1menu, bool debug, bool legacy) { +TCS::TopoSteeringStructure::setupFromMenu(const TXC::L1TopoMenu& menu, bool debug) { if(debug) cout << "/***************************************************************************/" << endl << " L1Topo steering structure: configuring from L1 Topo Menu " << endl << "/***************************************************************************/" << endl; - // set<TCS::inputTOBType_t> neededInputs; // Stores inputs for DecisionConnectors - vector<string> storedConn; // Stores decision connectors in order to avoid double counting - vector<vector<string>> confAlgorithms; // Stores algorithm name/category that have been configured in L1Menu to be used for setting the parameters - // Loop over boards in L1Menu and skip the ones that are not TOPO. Use Run-2 boards if legacy flag is on - for (const string & boardName : l1menu.boardNames() ){ - - auto & l1board = l1menu.board(boardName); - - if (l1board.type() != "TOPO") continue; - if (l1board.legacy() != legacy) continue; - - // Access the connectors in the boards - - for (const string & connName : l1board.connectorNames() ){ - - auto & l1conn = l1menu.connector(connName); - - // All topo decision algorithms are configured in boards with electrical connection to CTP - Add optical connectors when adding multiplicity algorithms - // Look at all Topo algorithms in each connector, and get inputs from each algorithm to configure SortingConnectors - if ( ! (l1conn.connectorType() == TrigConf::L1Connector::ConnectorType::ELECTRICAL ) ) continue; - - for( size_t fpga : { 0, 1} ) { - for( size_t clock : { 0, 1} ) { - for( auto & tl : l1conn.triggerLines(fpga, clock) ) { - - const string & tlName = tl.name(); - auto & algo = l1menu.algorithmFromTriggerline(tlName); - - // One algorithm can have multiple trigger lines. Check the connector/algorithm has not been stored already - auto it = find(storedConn.begin(), storedConn.end(), algo.name()); - if (it == storedConn.end()) { // Algorithm/Connector does not exist: create and store it - - storedConn.push_back(algo.name()); - vector<string> inputNames; - for( auto & input : algo.inputs() ) { - if( sortingConnector(input) == 0 ) { // if connector does not exist, create it - if(debug) - cout << "L1TopoSteering: Decision algo( " << algo.name() << " ) input is not defined: " << input << ". Creating sortingConnector" << endl; - - auto & sortAlgo = l1menu.algorithm(input, algo.category()); - if(!(sortAlgo.type() == TrigConf::L1TopoAlgorithm::AlgorithmType::SORTING ) ) - TCS_EXCEPTION("L1TopoSteering: Decision algo " << algo.name() << ") has as input " << input << " which is not associated to a sorting algorithm"); - - // TCS::inputTOBType_t en = inputType(sortAlgo.inputs().at(0)); - // neededInputs.insert(en); - - // Create connector - SortingConnector * sortConn = new SortingConnector(sortAlgo.inputs().at(0), sortAlgo.klass()+"/"+input, sortAlgo.outputs().at(0)); - if(debug) - cout << "Adding sorting connector " << "[" << *sortConn << "]" << endl; - addSortingConnector( sortConn ); - confAlgorithms.push_back({sortAlgo.name(), sortAlgo.category()}); - - } // if connector does not exist - - inputNames.push_back(input); - - } // loop over inputs - - DecisionConnector * conn = new DecisionConnector(algo.name(), inputNames, algo.klass()+"/"+algo.name(), algo.outputs()); - conn->m_decision.setNBits( algo.outputs().size() ); - - if(tl.name() != "UNDEF") - conn->m_triggers.push_back(tl); - - if(debug) - cout << "Adding decision connector " << "[" << *conn << "]" << endl; - addDecisionConnector( conn ); - confAlgorithms.push_back({algo.name(), algo.category()}); - - } else { // Connector already exists: look for it and add the trigger line - for(auto out : algo.outputs()){ - auto c = m_outputLookup.find(out); - if (c != m_outputLookup.end()){ - auto conn = c->second; - if(tl.name() != "UNDEF") - conn->m_triggers.push_back(tl); - break; - } - } - } - - } // Trigger Line - - } // Clock - - } // FPGA - - } // Connector in l1board + set<TCS::inputTOBType_t> neededInputs; + if(debug) + cout << "... building sorting connectors" << endl; + + for( const TXC::L1TopoConfigAlg & configalgo: menu.getL1TopoConfigAlgs() ) { + + if(!configalgo.isSortAlg()) continue; + + // Input + for(string & algoInput : configalgo.getInputNames()) { + TCS::inputTOBType_t en = inputType(algoInput); + neededInputs.insert(en); + } + + // create connector + SortingConnector * conn = new SortingConnector(configalgo.getInputNames()[0], configalgo.fullname(), configalgo.output()); + if(debug) + cout << "Adding sorting connector " << "[" << *conn << "]" << endl; + addSortingConnector( conn ); + } + + - } // Board in l1menu - /* if(debug) - cout << "... building sorting connectors" << endl; + cout << "... building output connectors" << endl; + for( const TXC::L1TopoConfigAlg & configalgo: menu.getL1TopoConfigAlgs() ) { - std::string categories[] = { "TOPO" }; + if(!configalgo.isDecAlg()) continue; - for( auto & category : categories ){ - - for( auto & name : l1menu.topoAlgorithmNames(category)) { - - auto & algo = l1menu.algorithm(name, category); - - if(!(algo.type() == TrigConf::L1TopoAlgorithm::AlgorithmType::SORTING ) ) continue; - - TCS::inputTOBType_t en = inputType(algo.inputs().at(0)); - neededInputs.insert(en); - - // create connector - SortingConnector * conn = new SortingConnector(algo.inputs().at(0), algo.klass()+"/"+name, algo.outputs().at(0)); - if(debug) - cout << "Adding sorting connector " << "[" << *conn << "]" << endl; - addSortingConnector( conn ); - } + for( const TXC::InputElement & input : configalgo.getInputs() ) { + if( sortingConnector(input.value) == 0 ) { + TCS_EXCEPTION("L1TopoSteering: Decision algo ( " << configalgo.fullname() << " ) input is not defined: " << input.value); + } + } + + DecisionConnector * conn = new DecisionConnector(configalgo.name(), configalgo.getInputNames(), configalgo.fullname(), configalgo.getOutputNames()); + conn->m_decision.setNBits( configalgo.getOutputs().size() ); + + for(const std::string & output: conn->outputNames()) { + const TXC::TriggerLine & trigger = menu.getL1TopoConfigOutputList().getTrigger(output); + if(trigger.name()!="UNDEF") + conn->m_triggers.push_back(trigger); + } + if(debug) + cout << "Adding decision connector " << "[" << *conn << "]" << endl; + addDecisionConnector( conn ); } - - - if(debug) - cout << "... building output connectors" << endl; - - // All topo decision algorithms are configured in boards with electrical connection to CTP - // Create all DecisionConnectors from L1Connectors of type ELECTRICAL - std::vector<std::string> storedConn; - for ( const string & connName : l1menu.connectorNames() ){ - - auto & l1conn = l1menu.connector(connName); - - if ( ! (l1conn.type() == TrigConf::L1Connector::ConnectorType::ELECTRICAL ) ) continue; - if ( l1conn.isLegacy() ) continue; - - for( size_t fpga : { 0 ,1 } ) { - for( size_t clock : { 0 ,1 } ) { - for( auto & tl : l1conn.triggerLines(fpga, clock) ) { - - const string & tlName = tl.name(); - auto & algo = l1menu.algorithmFromTriggerline(tlName); - - // One algorithm can have multiple trigger lines. Check the connector/algorithm has not been stored already - auto it = std::find(storedConn.begin(), storedConn.end(), algo.name()); - if (it == storedConn.end()) { // Algorithm/Connector do not exist: create and store it - - storedConn.push_back(algo.name()); - - std::vector<std::string> inputNames; - for( auto & input : algo.inputs() ) { - if( sortingConnector(input) == 0 ) { - TCS_EXCEPTION("L1TopoSteering: Decision algo ( " << algo.name() << " ) input is not defined: " << input); - } - inputNames.push_back(input); - } - - DecisionConnector * conn = new DecisionConnector(algo.name(), inputNames, algo.klass()+"/"+algo.name(), algo.outputs()); - conn->m_decision.setNBits( algo.outputs().size() ); - - if(tl.name() != "UNDEF") - conn->m_triggers.push_back(tl); - - if(debug) - cout << "Adding decision connector " << "[" << *conn << "]" << endl; - addDecisionConnector( conn ); - - } else { // Connector already exists: look for it and add the trigger line - for(auto out : algo.outputs()){ - auto c = m_outputLookup.find(out); - if (c != m_outputLookup.end()){ - auto conn = c->second; - if(tl.name() != "UNDEF") - conn->m_triggers.push_back(tl); - break; - } - } - } - } // Trigger Line - } // Clock - } // FPGA - } // L1Connectors - - */ if(debug) - cout << "... building input connectors" << endl; + cout << "... building input connectors" << endl; for(auto sortConn : m_sortedLookup) { - const string & in = sortConn.second->inputNames()[0]; // name of input - - if( m_inputLookup.count(in) > 0 ) continue; // InputConnector already exists - - InputConnector * conn = new InputConnector(in); - m_connectors.push_back(conn); - m_inputLookup[in] = conn; - if(debug) - cout << "Adding input connector " << "[" << *conn << "]" << endl; + const string & in = sortConn.second->inputNames()[0]; // name of input + + if( m_inputLookup.count(in) > 0 ) continue; // InputConnector already exists + + InputConnector * conn = new InputConnector(in); + m_connectors.push_back(conn); + m_inputLookup[in] = conn; + if(debug) + cout << "Adding input connector " << "[" << *conn << "]" << endl; } + // link the connector objects together - TCS::StatusCode sc = linkConnectors(); - + StatusCode sc = linkConnectors(); + // instantiate the algorithms from the algorithm names in the connectors if(debug) - cout << "... instantiating algorithms" << endl; + cout << "... instantiating algorithms" << endl; sc &= instantiateAlgorithms(debug); + - + // iterate through OutputList elements + if(debug) { + cout << "... checking output list" << endl; + cout << menu.getL1TopoConfigOutputList().getOutputList().size() << " output algorithms for " + << menu.getL1TopoConfigOutputList().getTriggerLines().size() << " trigger lines." << endl; + } + // set algorithm parameters if(debug) - cout << "... setting algorithm parameters" << endl; + cout << "... setting algorithm parameters" << endl; + + for( const TXC::L1TopoConfigAlg & configalgo: menu.getL1TopoConfigAlgs() ) { - for ( auto & confAlgo : confAlgorithms ) { - - auto & l1algo = l1menu.algorithm(confAlgo.at(0), confAlgo.at(1)); - - ConfigurableAlg * alg = AlgFactory::instance().algorithm(l1algo.name()); - alg->setAlgoId( l1algo.algId() ); - - if(debug) - cout << "Algorithm " << alg->name() << " has algoId " << alg->algoId() << endl << " (reading parameters)" << endl; - - if(alg->isDecisionAlg()) - ((DecisionAlg *) alg)->setNumberOutputBits(l1algo.outputs().size()); - - // create ParameterSpace for this algorithm - ParameterSpace * ps = new ParameterSpace(alg->name()); - - for(auto & pe : l1algo.parameters()) { - - auto & pname = pe.name(); - uint32_t val = pe.value(); - uint32_t sel = pe.selection(); - - if(debug) - cout << " parameter " << ": " << setw(20) << left << pname << " value = " << setw(3) << left << val << " (selection " << sel << ")" << endl; - ps->addParameter( pname, val, sel); - - } - - for(auto & gen : l1algo.generics().getKeys()) { - - auto pe = l1algo.generics().getObject(gen); - string pname = gen; - uint32_t val = interpretGenericParam(pe.getAttribute("value")); - if (pname == "NumResultBits"){ - if(val != l1algo.outputs().size()) { - TCS_EXCEPTION("Algorithm " << pname << " parameter OutputBits (" << val << ") is different from output size (" << l1algo.outputs().size() << ")"); - } - continue; // ignore this, because it is defined through the output list - } - if(debug) - cout << " fixed parameter : " << setw(20) << left << pname << " value = " << setw(3) << left << val << endl; - ps->addParameter( pname, val ); - - } - - - if(debug) - cout << " (setting parameters)"; - alg->setParameters( *ps ); - - if(debug) - cout << " --> (parameters set)"; - - if( alg->isDecisionAlg() ) { - if( m_parameters[alg->algoId()] != nullptr ) { - // TCS_EXCEPTION("Decision algorithm " << alg->name() << " has algoId " << alg->algoId() << " which is already used"); - } - m_parameters[alg->algoId()] = ps; - } else if (alg->isSortingAlg() ) { - if( m_parameters[alg->algoId() + LayoutConstraints::maxComponents()] != nullptr ) { - // TCS_EXCEPTION("Sorting algorithm " << alg->name() << " has algoId " << alg->algoId() << " which is already used"); - } - m_parameters[alg->algoId() + LayoutConstraints::maxComponents()] = ps; - } else { - // newed parameters usued so delete to avoid memory leak - delete ps; - ps=0; - } - - if(debug) - cout << " --> (parameters stored)" << endl; + ConfigurableAlg * alg = AlgFactory::instance().algorithm(configalgo.name()); + + alg->setAlgoId( configalgo.algoID() ); + + if(debug) + cout << "Algorithm " << alg->name() << endl << " (reading parameters)" << endl; + + if(alg->isDecisionAlg()) + ((DecisionAlg *) alg)->setNumberOutputBits(configalgo.getOutputs().size()); + + // create ParameterSpace for this algorithm + ParameterSpace * ps = new ParameterSpace(alg->name()); + + for(TXC::RegisterParameter pe: configalgo.getParameters()) { + + string name = pe.name; + uint32_t val = lexical_cast<uint32_t, string>(pe.value); + uint32_t pos = pe.position; + uint32_t sel = pe.selection; + + if(debug) + cout << " parameter " << pos << ": " << setw(20) << left << name << " value = " << setw(3) << left << val << " (selection " << sel << ")" << endl; + ps->addParameter( name, val, sel); + } + + + for(TXC::FixedParameter pe: configalgo.getFixedParameters()) { + + string name = pe.name; + uint32_t val = interpretGenericParam(pe.value); + if(name=="NumResultBits") { + if(val != configalgo.getOutputs().size()) { + TCS_EXCEPTION("Algorithm " << name << " parameter OutputBits (" << val << ") is different from output size (" << configalgo.getOutputs().size() << ")"); + } + continue; // ignore this, because it is defined through the output list + } + if(debug) + cout << " fixed parameter : " << setw(20) << left << name << " value = " << setw(3) << left << val << endl; + ps->addParameter( name, val); + } + + + if(debug) + cout << " (setting parameters)" << endl; + alg->setParameters( *ps ); + + if( alg->isDecisionAlg() ) { + if( m_parameters[alg->algoId()] != nullptr ) { + TCS_EXCEPTION("Decision algorithm " << alg->name() << " has algoId " << alg->algoId() << " which is already used"); + } + m_parameters[alg->algoId()] = ps; + } else if( alg->isSortingAlg() ) { + if( m_parameters[alg->algoId() + LayoutConstraints::maxComponents()] != nullptr ) { + TCS_EXCEPTION("Sorting algorithm " << alg->name() << " has algoId " << alg->algoId() << " which is already used"); + } + m_parameters[alg->algoId() + LayoutConstraints::maxComponents()] = ps; + } else { + // newed parameters unused so delete to avoid memory leak + delete ps; + ps=0; + } } - + m_isConfigured = true; - + if(debug) - cout << "... L1TopoSteering successfully configured" << endl; + cout << "... L1TopoSteering successfully configured" << endl; return sc; } - TCS::StatusCode TopoSteeringStructure::addSortingConnector(SortingConnector * conn) { m_connectors.push_back(conn); for( const string & output : conn->outputNames() ) m_sortedLookup[output] = conn; - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } TCS::StatusCode TopoSteeringStructure::addDecisionConnector(DecisionConnector * conn) { - m_connectors.push_back(conn); + m_connectors.push_back(conn); for( const string & output : conn->outputNames() ) - m_outputLookup[output] = conn; - return TCS::StatusCode::SUCCESS; + m_outputLookup[output] = conn; + return StatusCode::SUCCESS; } @@ -442,7 +310,7 @@ TopoSteeringStructure::linkConnectors() { for(const std::string & inconn: conn->inputNames()) conn->inputConnectors().push_back( connector(inconn) ); - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -472,7 +340,7 @@ TCS::TopoSteeringStructure::instantiateAlgorithms(bool debug) { } conn->setAlgorithm(algInstance); } - return TCS::StatusCode::SUCCESS; + return StatusCode::SUCCESS; } @@ -498,7 +366,9 @@ TopoSteeringStructure::sortingConnector(const std::string & connectorName) const } } } - + if(sc==nullptr) { + TCS_EXCEPTION("TopoSteeringStructure: can not find SortingConnector of name " << connectorName << ". Need to abort!"); + } return sc; } diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoStandAlone.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoStandAlone.cxx index bb8081cf368..64eb5b92b03 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoStandAlone.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoStandAlone.cxx @@ -7,8 +7,6 @@ #include <stdint.h> #include "TrigConfBase/TrigConfMessaging.h" -#include "TrigConfIO/JsonFileLoader.h" -#include "TrigConfData/L1Menu.h" #include "L1TopoConfig/L1TopoXMLParser.h" #include "L1TopoCoreSim/TopoSteering.h" @@ -29,7 +27,7 @@ using namespace std; int printHelp(const char * exeName) { cout << "Please specify menu and data file and optionally the message levels for the framework and the algorithms:" << endl << endl; - cout << exeName << " <menu.json> <data.txt> [INFO|DEBUG|WARNING] [INFO|DEBUG|WARNING] [filename.root] [optional arguments]" << endl << endl; + cout << exeName << " <menu.xml> <data.txt> [INFO|DEBUG|WARNING] [INFO|DEBUG|WARNING] [filename.root] [optional arguments]" << endl << endl; cout << "optional arguments:" << endl << " -o|--outfile <filename.root>" << endl << " -n|--nevt <#events>" << endl @@ -99,14 +97,15 @@ int run(int argc, const char* argv[]) { msg.setLevel( msgLvl ); // read the menu - TrigConf::L1Menu l1menu; - TrigConf::JsonFileLoader fileLoader; -fileLoader.loadFile(argv[1], l1menu); + TXC::L1TopoXMLParser XMLParser; + XMLParser.msg().setLevel( msgLvl ); + XMLParser.readConfiguration(argv[1]); + XMLParser.parseConfiguration(); + //XMLParser.menu().print(); - //TFile *f = new TFile(argc>=4 ? argv[3] : "L1TopoSimulation.root","RECREATE"); - /* Change once the final number of bits per module is fixed + //TFile *f = new TFile(argc>=4 ? argv[3] : "L1TopoSimulation.root","RECREATE"); TH1* h[3]; h[0] = new TH1F("Decision/DecisionModule1", "L1 Topo Decision (Module 1)", 64, 0, 64); h[1] = new TH1F("Decision/DecisionModule2", "L1 Topo Decision (Module 2)", 64, 0, 64); @@ -118,21 +117,21 @@ fileLoader.loadFile(argv[1], l1menu); } for(uint i=0; i<3; ++i) h[i]->SetLabelSize(0.025); - */ + // instantiate steering TCS::TopoSteering steering; steering.setUseBitwise(false); - steering.setupFromConfiguration(l1menu); + steering.setupFromConfiguration(XMLParser.takeMenu()); steering.setMsgLevel( msgLvl ); steering.setAlgMsgLevel( algMsgLvl ); std::shared_ptr<IL1TopoHistSvc> topoHistSvc = std::shared_ptr<IL1TopoHistSvc>( new StandaloneL1TopoHistSvc() ); - // topoHistSvc->setBaseDir("L1TopoSimulation.root:"); - // for(int i = 0; i < 3; i++ ) - // topoHistSvc->registerHist(h[i]); + topoHistSvc->setBaseDir("L1TopoSimulation.root:"); + for(int i = 0; i < 3; i++ ) + topoHistSvc->registerHist(h[i]); steering.setHistSvc(topoHistSvc); @@ -165,15 +164,14 @@ fileLoader.loadFile(argv[1], l1menu); steering.executeEvent(); - // const TCS::GlobalDecision & globalDec = - steering.simulationResult().globalDecision(); - /* + const TCS::GlobalDecision & globalDec = steering.simulationResult().globalDecision(); + for(unsigned int module=0; module<3; ++module) for(unsigned int trigger=0; trigger<64; ++trigger) if( globalDec.passed(module, trigger) ) h[module]->Fill(trigger); - */ + steering.reset(); - + } msg << TrigConf::MSGTC::INFO << "=======================================================" << TrigConf::endmsgtc; diff --git a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoTestSteeringConfig.cxx b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoTestSteeringConfig.cxx index 4f6a5ef5008..7717d75645e 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoTestSteeringConfig.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoCoreSim/src/test/TopoTestSteeringConfig.cxx @@ -8,37 +8,36 @@ #include "L1TopoCoreSim/TopoSteering.h" #include "L1TopoConfig/L1TopoXMLParser.h" -#include "TrigConfIO/JsonFileLoader.h" -#include "TrigConfData/L1Menu.h" - using namespace std; int run(int argc, const char * argv[]) { if(argc<2) { - cout << "Please specify topo menu input JSON file:\n" << argv[0] << " -v <menu.json>" << endl; + cout << "Please specify topo menu input XML file:\n" << argv[0] << " -v <menu.xml>" << endl; return 1; } bool verbose = (string(argv[1])=="-v"); - TrigConf::L1Menu l1menu; - TrigConf::JsonFileLoader fileLoader; + TXC::L1TopoXMLParser parser; + parser.readConfiguration(argv[argc-1]); try { - fileLoader.loadFile( argv[0], l1menu); + parser.parseConfiguration(); } catch(std::exception & e) { - cout << "TopoTestSteeringConfig: Caught exception from the topo menu loader, no topo menu will be available! Exception message: " << e.what() << endl; + cout << "TopoTestSteeringConfig: Caught exception from the topo menu parser, no topo menu will be available! Exception message: " << e.what() << endl; return 1; } + TXC::L1TopoMenu menu = parser.takeMenu(); // since parser goes out of scope, we take the menu + if (verbose) - l1menu.printMenu(true); + menu.print(); TCS::TopoSteering steering; try { - steering.setupFromConfiguration(l1menu); + steering.setupFromConfiguration( menu ); } catch(exception & e) { cerr << "TopoTestSteeringConfig: Caught exception when configuring topo steering from menu: " << endl << e.what() << endl; return 1; diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/CMakeLists.txt b/Trigger/TrigT1/L1Topo/L1TopoSimulation/CMakeLists.txt index f6b3339bd02..44e9340ac2e 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/CMakeLists.txt +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/CMakeLists.txt @@ -24,7 +24,7 @@ atlas_add_component( L1TopoSimulation atlas_add_component( L1TopoSimulationTest src/test/*.h src/test/*.cxx src/test/components/*.cxx src/AthenaL1TopoHistSvc.h src/AthenaL1TopoHistSvc.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaMonitoringLib GaudiKernel L1TopoConfig L1TopoCoreSim L1TopoEvent L1TopoInterfaces StoreGateLib TrigConfBase TrigConfInterfaces TrigConfData TrigConfIO) + LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthenaMonitoringLib GaudiKernel L1TopoConfig L1TopoCoreSim L1TopoEvent L1TopoInterfaces StoreGateLib TrigConfBase TrigConfInterfaces ) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/python/L1TopoSimulationConfig.py b/Trigger/TrigT1/L1Topo/L1TopoSimulation/python/L1TopoSimulationConfig.py index 2ac3701a60a..8339ca2dacb 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/python/L1TopoSimulationConfig.py +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/python/L1TopoSimulationConfig.py @@ -9,12 +9,7 @@ class L1TopoSimulation ( LVL1__L1TopoSimulation ): from L1TopoSimulation.L1TopoSimulationMonitoring import L1TopoSimulationMonitoring self.AthenaMonTools += [ L1TopoSimulationMonitoring() ] - enableDebugOutput = False - if enableDebugOutput: - from AthenaCommon.Constants import DEBUG - self.OutputLevel = DEBUG - self.TopoOutputLevel = DEBUG - self.TopoSteeringOutputLevel = DEBUG + class RoiB2TopoInputDataCnv ( LVL1__RoiB2TopoInputDataCnv ): diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/share/L1TopoSimulationTest.py b/Trigger/TrigT1/L1Topo/L1TopoSimulation/share/L1TopoSimulationTest.py index ada857a1351..b9a4f1ddca2 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/share/L1TopoSimulationTest.py +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/share/L1TopoSimulationTest.py @@ -8,10 +8,8 @@ from AthenaCommon.Logging import logging log = logging.getLogger('L1TopoSimulationTest.py') fmenu ,fTOBs = 'L1Topoconfig_MC_pp_v8_NewNaming.xml','eventdump_new.txt' -fjson = 'L1Menu_LS2_v1_22.0.17.json' print ('File for menu :',fmenu) -print ('File for menu (json):', fjson) print ('File for TOBs :',fTOBs) from AthenaCommon.AppMgr import ServiceMgr as svcMgr, theApp @@ -63,8 +61,6 @@ from L1TopoSimulation.L1TopoSimulationTestConfig import L1TopoSimulationTest topSequence += L1TopoSimulationTest() topSequence.L1TopoSimulationTest.InputASCIIFile = fTOBs topSequence.L1TopoSimulationTest.InputXMLFile = fmenu -topSequence.L1TopoSimulationTest.InputJSONFile = fjson - from GaudiSvc.GaudiSvcConf import THistSvc svcMgr += THistSvc() @@ -75,16 +71,15 @@ svcMgr.THistSvc.Output += ["EXPERT DATAFILE='expert-monitoring.root' OPT='RECREA # set algCardinality = 1 to disable cloning for all Algs algCardinality = nThreads - # Cloning can be disable for any alg -if (algCardinality > 1): +if (algCardinality > 1): for alg in topSequence: name = alg.name() - if name in ["SGInputLoader"] : + if name in ["L1TopoSimulation"] : # suppress INFO message about Alg unclonability # set alg.Cardinality = 1 to disable cloning for specific Alg - alg.Cardinality = nThreads + alg.Cardinality = 1 else: alg.Cardinality = algCardinality diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.cxx index bd46c92c83a..c3578f93e54 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.cxx @@ -3,11 +3,22 @@ */ #include "./L1TopoSimulation.h" +#include "./AthenaL1TopoHistSvc.h" + +#include "TH1F.h" +#include "AthenaMonitoring/IMonitorToolBase.h" + +#include "L1TopoCoreSim/TopoSteering.h" #include "L1TopoConfig/L1TopoMenu.h" #include "L1TopoEvent/TopoInputEvent.h" +#include "L1TopoSimulation/IInputTOBConverter.h" +#include "TrigConfInterfaces/IL1TopoConfigSvc.h" +#include "GaudiKernel/ITHistSvc.h" + #include "L1TopoInterfaces/IL1TopoHistSvc.h" +#include "TrigT1Interfaces/TrigT1StoreGateKeys.h" #include "TrigT1Interfaces/TrigT1CaloDefs.h" #include "TrigT1CaloEvent/EmTauROI_ClassDEF.h" @@ -17,61 +28,93 @@ #include "L1TopoRDO/L1TopoTOB.h" #include "L1TopoRDO/L1TopoRDOCollection.h" -#include "./AthenaL1TopoHistSvc.h" +#include "./PeriodicScaler.h" + -// using namespace std; +using namespace std; using namespace LVL1; + namespace { // needed for monitoring class TopoResultBit : public IMonitoredAlgo::IGetter { public: //! constructor - TopoResultBit(const TCS::GlobalDecision & decision, std::string connName) : + TopoResultBit(const TCS::GlobalDecision & decision, unsigned int module) : m_decision(decision), - m_connName(connName) + m_module(module) {} //! return size of data - virtual unsigned int size() const { return 64; } // Change this when implementing multiplicity algorithms (size could change for Topo1) + virtual unsigned int size() const { return 64; } //! indexed access to data - virtual double get(unsigned pos) const { return m_decision.passed(m_connName, pos) ? pos : -1.; } + virtual double get(unsigned pos) const { return m_decision.passed(m_module, pos) ? pos : -1.; } private: const TCS::GlobalDecision & m_decision; - std::string m_connName; + unsigned int m_module; }; } + L1TopoSimulation::L1TopoSimulation(const std::string &name, ISvcLocator *pSvcLocator) : AthAlgorithm(name, pSvcLocator), - m_topoSteering( std::make_unique<TCS::TopoSteering>() ), - m_scaler( std::make_unique<LVL1::PeriodicScaler>() ) + m_l1topoConfigSvc("TrigConf::TrigConfigSvc/TrigConfigSvc", name), + m_histSvc( "THistSvc/THistSvc", name), + m_monitors(this), + m_emtauInputProvider("LVL1::EMTauInputProvider/EMTauInputProvider", this), + m_jetInputProvider("LVL1::JetInputProvider/JetInputProvider", this), + m_energyInputProvider("LVL1::EnergyInputProvider/EnergyInputProvider", this), + m_muonInputProvider("LVL1::MuonInputProvider/MuonInputProvider", this), + m_topoSteering( unique_ptr<TCS::TopoSteering>(new TCS::TopoSteering()) ) { - // const TCS::GlobalDecision & dec = m_topoSteering->simulationResult().globalDecision(); - // declareMonitoredCustomVariable("DecisionModule1", new TopoResultBit(dec, 0)); - // declareMonitoredCustomVariable("DecisionModule2", new TopoResultBit(dec, 1)); - // declareMonitoredCustomVariable("DecisionModule3", new TopoResultBit(dec, 2)); + declareProperty( "TrigConfigSvc", m_l1topoConfigSvc, "Service to provide the L1Topo menu"); + declareProperty( "HistSvc", m_histSvc, "Histogramming service for L1Topo algorithms"); + declareProperty( "EMTAUInputProvider", m_emtauInputProvider, "Tool to fill the EMTAU TOBs of the topo input event"); + declareProperty( "JetInputProvider", m_jetInputProvider, "Tool to fill the Jet TOBs of the topo input event"); + declareProperty( "EnergyInputProvider", m_energyInputProvider, "Tool to fill the energy and MET TOBs of the topo input event"); + declareProperty( "MuonInputProvider", m_muonInputProvider, "Tool to fill the muon TOBs of the topo input event"); + declareProperty( "AthenaMonTools", m_monitors, "List of monitoring tools to be run with this instance, if incorrect then tool is silently skipped."); + declareProperty( "MonHistBaseDir", m_histBaseDir = "L1TopoAlgorithms", "Base directory for monitoring histograms will be /EXPERT/<MonHistBaseDir>" ); + declareProperty( "EnableInputDump", m_enableInputDump, "Boolean to enable writing of input data for standalone running"); + declareProperty( "UseBitwise", m_enableBitwise, "Boolean to enable the bitwise version of software algorithms"); + declareProperty("FillHistoBasedOnHardware", m_fillHistogramsBasedOnHardwareDecision=true, + "Boolean to fill accept/reject histograms based on hdw; default based on sim"); + declareProperty( "InputDumpFile", m_inputDumpFile, "File name for dumping input data"); + declareProperty( "TopoCTPLocation", m_topoCTPLocation = LVL1::DEFAULT_L1TopoCTPLocation, "StoreGate key of topo decision output for CTP" ); + declareProperty( "TopoOverflowCTPLocation", m_topoOverflowCTPLocation = LVL1::DEFAULT_L1TopoOverflowCTPLocation, "StoreGate key of topo overflow output for CTP" ); + declareProperty( "TopoOutputLevel", m_topoOutputLevel, "OutputLevel for L1Topo algorithms" ); + declareProperty( "TopoSteeringOutputLevel", m_topoSteeringOutputLevel, "OutputLevel for L1Topo steering" ); + declareProperty("Prescale", m_prescale = 1, "Internal prescale factor for this algorithm, implemented with a periodic scaler: so 1 means run every time, N means run every 1 in N times it is called; the other times it will exit without doing anything"); + declareProperty("PrescaleDAQROBAccess", m_prescaleForDAQROBAccess = 4, "Prescale factor for requests for DAQ ROBs: can be used to avoid overloading ROS. Zero means disabled, 1 means always, N means sample only 1 in N events"); + + + const TCS::GlobalDecision & dec = m_topoSteering->simulationResult().globalDecision(); + declareMonitoredCustomVariable("DecisionModule1", new TopoResultBit(dec, 0)); + declareMonitoredCustomVariable("DecisionModule2", new TopoResultBit(dec, 1)); + declareMonitoredCustomVariable("DecisionModule3", new TopoResultBit(dec, 2)); + m_scaler = new LVL1::PeriodicScaler(); + } -L1TopoSimulation::~L1TopoSimulation() +LVL1::L1TopoSimulation::~L1TopoSimulation() {} bool -L1TopoSimulation::isClonable() const +LVL1::L1TopoSimulation::isClonable() const { return true; } StatusCode -L1TopoSimulation::initialize() { +LVL1::L1TopoSimulation::initialize() { ATH_MSG_INFO("initialize"); - m_topoSteering->setMsgLevel( TrigConf::MSGTC::Level((int)m_topoSteeringOutputLevel) ); + m_topoSteering->setMsgLevel( TrigConf::MSGTC::Level(m_topoSteeringOutputLevel) ); ATH_MSG_DEBUG("retrieving " << m_monitors); CHECK( m_monitors.retrieve() ); @@ -111,22 +154,26 @@ L1TopoSimulation::initialize() { ATH_MSG_DEBUG("Output trigger key property " << m_topoCTPLocation); ATH_MSG_DEBUG("Output overflow key property " << m_topoOverflowCTPLocation); - const TrigConf::L1Menu * l1menu = nullptr; - ATH_CHECK( detStore()->retrieve(l1menu) ); - ATH_MSG_INFO( "initialize(): retrieving new-style L1 trigger menu from Detector Store" ); + const TXC::L1TopoMenu* menu = m_l1topoConfigSvc->menu(); + if(menu == nullptr) { + ATH_MSG_FATAL("No L1 Topo menu from " << m_l1topoConfigSvc->name()); + return StatusCode::FAILURE; + } m_topoSteering->setUseBitwise(m_enableBitwise); + std::cout << "Calling m_topoSteering->setupFromConfiguration(*menu)" << endl; try { - m_topoSteering->setupFromConfiguration(*l1menu); + m_topoSteering->setupFromConfiguration(*menu); } - catch(std::exception & e) { + catch(exception & e) { ATH_MSG_FATAL("Caught exception when configuring topo steering from menu: " << e.what() ); return StatusCode::FAILURE; } - m_topoSteering->setAlgMsgLevel( TrigConf::MSGTC::Level((int)m_topoOutputLevel) ); + m_topoSteering->setAlgMsgLevel( TrigConf::MSGTC::Level(m_topoOutputLevel) ); m_topoSteering->setOutputAlgosFillBasedOnHardware(m_fillHistogramsBasedOnHardwareDecision); + std::shared_ptr<IL1TopoHistSvc> topoHistSvc = std::shared_ptr<IL1TopoHistSvc>( new AthenaL1TopoHistSvc(m_histSvc) ); topoHistSvc->setBaseDir("/EXPERT/" + m_histBaseDir.value()); @@ -137,33 +184,34 @@ L1TopoSimulation::initialize() { // Exectued once per offline job and for every new run online StatusCode -L1TopoSimulation::stop() { +LVL1::L1TopoSimulation::stop() { ATH_MSG_DEBUG("stop"); // monitoring for (auto mt : m_monitors ) mt->finalHists().ignore(); + return StatusCode::SUCCESS; } // Exectued once per offline job and for every new run online StatusCode -L1TopoSimulation::start() { +LVL1::L1TopoSimulation::start() { ATH_MSG_DEBUG("start"); m_scaler->reset(); - // TODO monitoring : book histogram - // for (auto mt : m_monitors ) - // CHECK( mt->bookHists() ); + // monitoring : book histogram + for (auto mt : m_monitors ) + CHECK( mt->bookHists() ); try { m_topoSteering->initializeAlgorithms(); } - catch(std::exception & e) { + catch(exception & e) { ATH_MSG_FATAL("Caught exception when initializing topo algorithms" << e.what() ); return StatusCode::FAILURE; } @@ -179,7 +227,7 @@ L1TopoSimulation::start() { StatusCode -L1TopoSimulation::execute() { +LVL1::L1TopoSimulation::execute() { const EventContext& ctx = Gaudi::Hive::currentContext(); if (m_prescale>1 && not m_scaler->decision(m_prescale)){ @@ -234,7 +282,7 @@ L1TopoSimulation::execute() { // execute the toposteering m_topoSteering->executeEvent(); - ATH_MSG_DEBUG("Global Decision:\n" << m_topoSteering->simulationResult().globalDecision()); + ATH_MSG_DEBUG("" << m_topoSteering->simulationResult().globalDecision()); /** @@ -246,60 +294,49 @@ L1TopoSimulation::execute() { * */ - // Format for CTP still undecided - const TCS::GlobalDecision & dec = m_topoSteering->simulationResult().globalDecision(); auto topoDecision2CTP = std::make_unique< LVL1::FrontPanelCTP >(); auto topoOverflow2CTP = std::make_unique< LVL1::FrontPanelCTP >(); - - const TrigConf::L1Menu * l1menu = nullptr; - ATH_CHECK( detStore()->retrieve(l1menu) ); - - if( m_isLegacyTopo ) { - // to be implemented - } else { - // set electrical connectors - std::string conn1 = l1menu->board("Topo2").connectorNames()[0]; - std::string conn2 = l1menu->board("Topo3").connectorNames()[0]; - for(unsigned int clock=0; clock<2; ++clock) { - topoDecision2CTP->setCableWord0( clock, 0 ); // ALFA - ATH_MSG_DEBUG("Word 1 " << conn1 << " clock " << clock << " " << dec.decision_field( conn1, clock) ); - topoDecision2CTP->setCableWord1( clock, dec.decision_field( conn1, clock) ); // TOPO 0 - ATH_MSG_DEBUG("Word 2 " << conn2 << " clock " << clock << " " << dec.decision_field( conn2, clock) ); - topoDecision2CTP->setCableWord2( clock, dec.decision_field( conn2, clock) ); // TOPO 1 - // topoOverflow2CTP->setCableWord0( clock, 0 ); // ALFA - // topoOverflow2CTP->setCableWord1( clock, dec.overflow( 0, clock) ); // TOPO 0 - // topoOverflow2CTP->setCableWord2( clock, dec.overflow( 1, clock) ); // TOPO 1 - } - } - + for(unsigned int clock=0; clock<2; ++clock) { + topoDecision2CTP->setCableWord0( clock, 0 ); // ALFA + topoDecision2CTP->setCableWord1( clock, dec.decision( 0, clock) ); // TOPO 0 + topoDecision2CTP->setCableWord2( clock, dec.decision( 1, clock) ); // TOPO 1 + topoOverflow2CTP->setCableWord0( clock, 0 ); // ALFA + topoOverflow2CTP->setCableWord1( clock, dec.overflow( 0, clock) ); // TOPO 0 + topoOverflow2CTP->setCableWord2( clock, dec.overflow( 1, clock) ); // TOPO 1 + } CHECK(SG::makeHandle(m_topoCTPLocation) .record(std::move(topoDecision2CTP))); CHECK(SG::makeHandle(m_topoOverflowCTPLocation).record(std::move(topoOverflow2CTP))); - + // TODO: get the output combination data and put into SG // fill histograms // Commenting out temporarily to avoid crash - // when L1TopoSimulation run without menu confifuration. - // for (auto mt : m_monitors ) - // if ( ! mt->preSelector() ) - // mt->fillHists().ignore(); + //when L1TopoSimulation run without menu confifuration. + //for (auto mt : m_monitors ) + // if ( ! mt->preSelector() ) + // mt->fillHists().ignore(); return StatusCode::SUCCESS; } + + StatusCode -L1TopoSimulation::finalize() { +LVL1::L1TopoSimulation::finalize() { m_topoSteering->inputEvent().dumpFinish(); + + delete m_scaler; + m_scaler=0; + return StatusCode::SUCCESS; } - StatusCode -L1TopoSimulation::retrieveHardwareDecision() +LVL1::L1TopoSimulation::retrieveHardwareDecision() { // some duplication with L1TopoRDO::Helpers // getDecisionAndOverflowBits() ? diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.h b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.h index 909c66cf4c2..c49166093cb 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.h +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/L1TopoSimulation.h @@ -5,32 +5,41 @@ #ifndef L1Topo_L1TopoSimulation #define L1Topo_L1TopoSimulation -#include "L1TopoCoreSim/TopoSteering.h" - -#include "L1TopoSimulation/IInputTOBConverter.h" - -#include "PeriodicScaler.h" #include "TrigConfBase/MsgStream.h" -#include "TrigInterfaces/IMonitoredAlgo.h" -#include "TrigConfInterfaces/IL1TopoConfigSvc.h" -#include "TrigT1Interfaces/TrigT1StoreGateKeys.h" -#include "TrigConfData/L1Menu.h" -#include "TrigT1Interfaces/FrontPanelCTP.h" -#include "StoreGate/ReadHandleKey.h" #include "AthenaBaseComps/AthAlgorithm.h" -#include "AthenaMonitoring/IMonitorToolBase.h" +#include "TrigInterfaces/IMonitoredAlgo.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ITHistSvc.h" -#include "TH1F.h" #include <memory> +#include "TrigT1Interfaces/FrontPanelCTP.h" + +#include "StoreGate/ReadHandleKey.h" + +class TH1; +class IMonitorToolBase; +class ITHistSvc; + +namespace LVL1 { + class PeriodicScaler; +} + +namespace TCS { + class TopoSteering; +} + +namespace TrigConf { + class IL1TopoConfigSvc; +} + namespace LVL1 { + class IInputTOBConverter; + class L1TopoSimulation : public AthAlgorithm, public IMonitoredAlgo { public: L1TopoSimulation(const std::string &name, ISvcLocator *pSvcLocator); @@ -59,37 +68,41 @@ namespace LVL1 { private: - std::unique_ptr<TCS::TopoSteering> m_topoSteering; //!< the topo steering - std::unique_ptr<LVL1::PeriodicScaler> m_scaler {nullptr}; //! prescale decision tool - - - // Services and input tools - ServiceHandle<TrigConf::IL1TopoConfigSvc> m_l1topoConfigSvc { this, "TrigConfigSvc", "TrigConf::TrigConfigSvc/TrigConfigSvc", "Service to provide the L1Topo menu" }; - ServiceHandle<ITHistSvc> m_histSvc { this, "HistSvc", "THistSvc/THistSvc", "Histogramming service for L1Topo algorithms" }; - - ToolHandleArray < IMonitorToolBase > m_monitors { this, "AthenaMonTools", {}, "Monitoring tools"}; - ToolHandle<IInputTOBConverter> m_emtauInputProvider { this, "EMTAUInputProvider", "LVL1::EMTauInputProvider/EMTauInputProvider", "Tool to fill the EMTAU TOBs of the topo input event" }; - ToolHandle<IInputTOBConverter> m_jetInputProvider { this, "JetInputProvider", "LVL1::JetInputProvider/JetInputProvider", "Tool to fill the Jet TOBs of the topo input event" }; - ToolHandle<IInputTOBConverter> m_energyInputProvider { this, "EnergyInputProvider", "LVL1::EnergyInputProvider/EnergyInputProvider", "Tool to fill the energy and MET TOBs of the topo input event"}; - ToolHandle<IInputTOBConverter> m_muonInputProvider { this, "MuonInputProvider", "LVL1::MuonInputProvider/MuonInputProvider", "Tool to fill the muon TOBs of the topo input event" }; - - // outputs - SG::WriteHandleKey<LVL1::FrontPanelCTP> m_topoCTPLocation { this, "TopoCTPLocation", LVL1::DEFAULT_L1TopoCTPLocation, "StoreGate key of topo decision output for CTP"}; ///< SG key of decision bits for CTP - SG::WriteHandleKey<LVL1::FrontPanelCTP> m_topoOverflowCTPLocation { this, "TopoOverflowCTPLocation", LVL1::DEFAULT_L1TopoOverflowCTPLocation, "StoreGate key of topo overflow output for CTP"}; ///< SG key of overflow bits for CTP - - Gaudi::Property<bool> m_isLegacyTopo { this, "IsLegacyTopo", false, "Simulation of Legacy L1Topo boards" }; - Gaudi::Property<bool> m_enableInputDump { this, "EnableInputDump", false, "Enable writing of input data for standalone running" }; - Gaudi::Property<bool> m_enableBitwise { this, "UseBitwise", false, "Boolean to enable the bitwise version of software algorithms"}; - Gaudi::Property<std::string> m_inputDumpFile { this, "InputDumpFile", "inputdump.txt", "File name for dumping input data" }; - Gaudi::Property<int> m_topoOutputLevel { this, "TopoOutputLevel", TrigConf::MSGTC::WARNING, "OutputLevel for L1Topo algorithms"}; - Gaudi::Property<int> m_topoSteeringOutputLevel { this, "TopoSteeringOutputLevel", TrigConf::MSGTC::WARNING, "OutputLevel for L1Topo steering"}; - - // Properties for hardware monitoring - Gaudi::Property<bool> m_fillHistogramsBasedOnHardwareDecision { this, "FillHistoBasedOnHardware", true, "Fill accept/reject histograms based on hdw; default based on sim" }; - Gaudi::Property<unsigned int> m_prescaleForDAQROBAccess { this, "PrescaleDAQROBAccess", 4, "Prescale factor for requests for DAQ ROBs: can be used to avoid overloading ROS. Zero means disabled, 1 means always, N means sample only 1 in N events"}; - Gaudi::Property<unsigned int> m_prescale { this, "Prescale", 1, "Internal prescale factor for this algorithm, implemented with a periodic scaler: so 1 means run every time, N means run every 1 in N times it is called; the other times it will exit without doing anything"}; - Gaudi::Property<std::string> m_histBaseDir { this, "MonHistBaseDir", "L1/L1TopoAlgorithms", "Base directory for monitoring histograms will be /EXPERT/<MonHistBaseDir>"}; - }; + //! \brief Alg handles to tools and services + //! @{ + ServiceHandle<TrigConf::IL1TopoConfigSvc> m_l1topoConfigSvc; + + ServiceHandle<ITHistSvc> m_histSvc; + + ToolHandleArray < IMonitorToolBase > m_monitors; + + ToolHandle<IInputTOBConverter> m_emtauInputProvider; + + ToolHandle<IInputTOBConverter> m_jetInputProvider; + + ToolHandle<IInputTOBConverter> m_energyInputProvider; + + ToolHandle<IInputTOBConverter> m_muonInputProvider; + + //! @} + + BooleanProperty m_enableInputDump { false }; // for enabling input dumping + BooleanProperty m_enableBitwise { false }; // for enabling bitwise algorithms + StringProperty m_inputDumpFile { "inputdump.txt" }; // input dump file + SG::WriteHandleKey<LVL1::FrontPanelCTP> m_topoCTPLocation { "" }; ///< SG key of decision bits for CTP + SG::WriteHandleKey<LVL1::FrontPanelCTP> m_topoOverflowCTPLocation { "" }; ///< SG key of overflow bits for CTP + int m_topoOutputLevel{TrigConf::MSGTC::WARNING}; // property to set the outputlevel of the topo algorithms + int m_topoSteeringOutputLevel{TrigConf::MSGTC::WARNING}; // property to set the outputlevel of the topo steering + + std::unique_ptr<TCS::TopoSteering> m_topoSteering; //!< the topo steering + + BooleanProperty m_fillHistogramsBasedOnHardwareDecision { false }; // default: fill based on simulation + UnsignedIntegerProperty m_prescaleForDAQROBAccess {4}; ///< read hdw bits every N events (used only when m_fillHistogramsBasedOnHardwareDecision is true) + UnsignedIntegerProperty m_prescale; //! property for prescale factor + LVL1::PeriodicScaler* m_scaler; //! prescale decision tool + + StringProperty m_histBaseDir; //! sets base dir for monitoring histograms + }; } #endif diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.cxx index b3aa08ef47f..e801348c30e 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.cxx +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.cxx @@ -13,11 +13,6 @@ #include "GaudiKernel/ITHistSvc.h" -// Dependencies for new menu format -#include "TrigConfIO/JsonFileLoader.h" -#include "TrigConfData/L1Menu.h" -#include "TrigConfData/L1Threshold.h" -#include "TrigConfData/L1Connector.h" using namespace std; @@ -28,7 +23,6 @@ LVL1::L1TopoSimulationTest::L1TopoSimulationTest(const std::string &name, ISvcLo m_OfftopoSteering( unique_ptr<TCS::TopoSteering>(new TCS::TopoSteering()) ) { declareProperty( "InputXMLFile", m_OffinputXMLFile, "File name for menu XML"); - declareProperty( "InputJSONFile", m_OffinputJSONFile, "File name for menu JSON"); declareProperty( "InputASCIIFile", m_OffinputASCIIFile, "File name for ASCII TOB vector"); declareProperty( "HistSvc", m_OffhistSvc, "Histogramming service for L1Topo algorithms"); declareProperty( "MonHistBaseDir", m_OffhistBaseDir = "L1TopoAlgorithms", "Base directory for monitoring histograms will be /EXPERT/<MonHistBaseDir>" ); @@ -49,27 +43,22 @@ LVL1::L1TopoSimulationTest::isClonable() const StatusCode LVL1::L1TopoSimulationTest::initialize() { + m_OfftopoSteering->setMsgLevel( TrigConf::MSGTC::Level(m_OfftopoSteeringOutputLevel) ); - m_OfftopoSteering->setMsgLevel( TrigConf::MSGTC::Level(m_OfftopoSteeringOutputLevel) ); - - ATH_MSG_INFO("initialize"); - - if (m_OffinputXMLFile.empty() || m_OffinputJSONFile.empty()){ - ATH_MSG_FATAL("No L1 Topo menu from JSON " << m_OffinputJSONFile); - return StatusCode::FAILURE; - } - - TrigConf::L1Menu l1menu; - TrigConf::JsonFileLoader fileLoader; - fileLoader.loadFile( m_OffinputJSONFile, l1menu); - m_OfftopoSteering->setupFromConfiguration(l1menu); - + if (m_OffinputXMLFile.empty()){ + ATH_MSG_FATAL("No L1 Topo menu from XML " << m_OffinputXMLFile); + return StatusCode::FAILURE; + } + TXC::L1TopoXMLParser XMLParser; + XMLParser.msg().setLevel( TrigConf::MSGTC::Level(m_OfftopoOutputLevel) ); + XMLParser.readConfiguration(m_OffinputXMLFile); + XMLParser.parseConfiguration(); - // ---------------------------------------------------- - m_OfftopoSteering->setAlgMsgLevel( TrigConf::MSGTC::Level(m_OfftopoOutputLevel) ); + m_OfftopoSteering->setupFromConfiguration(XMLParser.takeMenu()); + m_OfftopoSteering->setAlgMsgLevel( TrigConf::MSGTC::Level(m_OfftopoOutputLevel) ); - std::shared_ptr<IL1TopoHistSvc> topoHistSvc = std::shared_ptr<IL1TopoHistSvc>( new AthenaL1TopoHistSvc(m_OffhistSvc) ); + std::shared_ptr<IL1TopoHistSvc> topoHistSvc = std::shared_ptr<IL1TopoHistSvc>( new AthenaL1TopoHistSvc(m_OffhistSvc) ); topoHistSvc->setBaseDir("/EXPERT/" + m_OffhistBaseDir.value()); @@ -99,25 +88,15 @@ LVL1::L1TopoSimulationTest::initialize() { StatusCode LVL1::L1TopoSimulationTest::execute() { - cout << "Reseting TopoSteering" << endl; - // reset input and internal state m_OfftopoSteering->reset(); - cout << "Getting next event from dump txt" << endl; - // Obtain next events in the dump txt m_Offreader.getNextEvent(); - cout << "Executing even in TopoSteering" << endl; - // execute the toposteering m_OfftopoSteering->executeEvent(); - // Printout the decision bits - cout << "Printing out decisions" << endl; - cout << m_OfftopoSteering->simulationResult().globalDecision(); - return StatusCode::SUCCESS; } diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.h b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.h index cb84a5bfaaf..21360f1df2f 100644 --- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.h +++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/test/L1TopoSimulationTest.h @@ -43,7 +43,6 @@ namespace LVL1 { // make algorithm is clonable virtual bool isClonable() const override; - private: TCS::TopoASCIIReader m_Offreader; @@ -56,7 +55,6 @@ namespace LVL1 { StringProperty m_OffhistBaseDir; //! sets base dir for monitoring histograms StringProperty m_OffinputASCIIFile { "" }; // input dump file StringProperty m_OffinputXMLFile { "" }; // XML file can be register in case of enabling the ASCII file read for validation purposes - StringProperty m_OffinputJSONFile { "" }; // JSON file for menu std::unique_ptr<TCS::TopoSteering> m_OfftopoSteering; //!< the topo steering diff --git a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx index 23c408107df..355395511b1 100644 --- a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx +++ b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx @@ -47,7 +47,7 @@ const std::function< CLHEP::HepRandomEngine*(void) > CTPSimRanluxFactory = [](vo LVL1CTP::CTPSimulation::CTPSimulation( const std::string& name, ISvcLocator* pSvcLocator ) : - AthReentrantAlgorithm ( name, pSvcLocator ), + AthReentrantAlgorithm ( name, pSvcLocator ), m_RNGEngines( CTPSimRanluxFactory, SG::getNSlots() ), m_decoder( new LVL1::CPRoIDecoder() ), m_jetDecoder( new LVL1::JEPRoIDecoder() ) @@ -103,14 +103,14 @@ LVL1CTP::CTPSimulation::start() { const TrigConf::L1Menu * l1menu = nullptr; if( m_useNewConfig ) { - ATH_CHECK( detStore()->retrieve(l1menu) ); - ATH_MSG_INFO( "start(): use new-style L1 menu (json)" ); + ATH_CHECK( m_detStore->retrieve(l1menu) ); + ATH_MSG_INFO( "start(): use L1 trigger menu from detector store" ); if(l1menu == nullptr) { // if no L1 configuration is available yet delayConfig = true; } } else { - ATH_MSG_INFO( "start(): use old-style L1 menu (xml))" ); - if( (m_configSvc->ctpConfig()==nullptr) || + ATH_MSG_INFO( "start(): use L1 trigger menu from L1ConfigSvc" ); + if( (m_configSvc->ctpConfig()==nullptr) || (m_configSvc->ctpConfig()->menu().itemVector().size() == 0) ) { // if no L1 configuration is available yet delayConfig = true; } @@ -120,7 +120,7 @@ LVL1CTP::CTPSimulation::start() { if( ! delayConfig ) { // configure the CTP ResultBuilder // currently both types of configuration can be given (transition period towards Run 3) - std::call_once(m_onceflag, [this, l1menu]{ + std::call_once(m_onceflag, [this, l1menu]{ m_resultBuilder->setConfiguration( m_configSvc->ctpConfig(), l1menu ).ignore(); setHistLabels().ignore(); }); @@ -137,7 +137,7 @@ LVL1CTP::CTPSimulation::execute( const EventContext& context ) const { std::call_once(m_onceflag, [this]{ const TrigConf::L1Menu * l1menu = nullptr; if( m_useNewConfig ) { - detStore()->retrieve(l1menu).ignore(); + m_detStore->retrieve(l1menu).ignore(); } m_resultBuilder->setConfiguration( m_configSvc->ctpConfig(), l1menu ).ignore(); setHistLabels().ignore(); @@ -154,6 +154,8 @@ LVL1CTP::CTPSimulation::execute( const EventContext& context ) const { return StatusCode::SUCCESS; } + + StatusCode LVL1CTP::CTPSimulation::createMultiplicityHist(const std::string & type, unsigned int maxMult ) const { @@ -184,6 +186,7 @@ LVL1CTP::CTPSimulation::createMultiplicityHist(const std::string & type, unsigne return sc; } + StatusCode LVL1CTP::CTPSimulation::setMultiplicityHistLabels(const ConfigSource & cfgSrc, const std::string & type, TrigConf::L1DataDef::TriggerType tt ) const { StatusCode sc; @@ -302,7 +305,7 @@ LVL1CTP::CTPSimulation::setHistLabels() const { const TrigConf::L1Menu * l1menu = nullptr; if( m_useNewConfig ) { - ATH_CHECK( detStore()->retrieve(l1menu) ); + ATH_CHECK( m_detStore->retrieve(l1menu) ); ATH_MSG_DEBUG("setHistLabels(). L1 menu " << l1menu->size() << " items" ); } else { ATH_MSG_DEBUG("setHistLabels(). ConfigSvc with " << m_configSvc->ctpConfig()->menu().itemVector().size() << " items"); @@ -318,21 +321,24 @@ LVL1CTP::CTPSimulation::setHistLabels() const { ATH_CHECK ( setMultiplicityHistLabels( cfgSrc, "tau", L1DataDef::TAU ) ); // Topo + auto hTopo0 = *get1DHist("/input/topo/l1topo0"); + auto hTopo1 = *get1DHist("/input/topo/l1topo1"); if ( l1menu ) { - std::vector<std::string> connNames = l1menu->connectorNames(); - for( const std::string connName : {"LegacyTopo0", "LegacyTopo1", "Topo1El", "Topo2El", "Topo3El"}) { - if( find(connNames.begin(), connNames.end(), connName) == connNames.end() ) { + // to be implemented + } else { + for(const TIP * tip : m_configSvc->ctpConfig()->menu().tipVector() ) { + if ( tip->tipNumber() < 384 ) continue; - } - auto hTopo = *get1DHist("/input/topo/" + connName); - for(uint fpga : {0,1}) { - for(uint clock : {0,1}) { - for(auto & tl : l1menu->connector(connName).triggerLines(fpga,clock)) { - //uint flatIndex = 32*tl.fpga() + 2*tl.startbit() + tl.clock(); // activate later - uint flatIndex = 32*tl.fpga() + tl.startbit() + 16*tl.clock(); - hTopo->GetXaxis()->SetBinLabel(flatIndex+1,tl.name().c_str()); - } - } + unsigned int tipNumber = (unsigned int) ( tip->tipNumber() - 384 ); + switch(tipNumber / 64) { + case 0: + hTopo0->GetXaxis()->SetBinLabel(1+ tipNumber % 64, tip->thresholdName().c_str() ); + break; + case 1: + hTopo1->GetXaxis()->SetBinLabel(1+ tipNumber % 64, tip->thresholdName().c_str() ); + break; + default: + break; } } } @@ -379,6 +385,7 @@ LVL1CTP::CTPSimulation::setHistLabels() const { return StatusCode::SUCCESS; } + StatusCode LVL1CTP::CTPSimulation::bookHists() const { @@ -419,10 +426,10 @@ LVL1CTP::CTPSimulation::bookHists() const { ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("jJets","Number of jets (jJ)", 40, 0, 40) )); ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("jLJets","Number of jets (jLJ)", 40, 0, 40) )); ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("gJets","Number of jets (gJ)", 40, 0, 40) )); - ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("muons","Number of muons", 10, 0, 10) )); + ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("muons","Number of muons", 10, 0, 10) )); ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("emcluster","Number of EM clusters", 20, 0, 20) )); ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("taus","Number of TAU candidates", 20, 0, 20) )); - + // threshold multiplicities ATH_CHECK ( createMultiplicityHist( "muon" ) ); ATH_CHECK ( createMultiplicityHist( "jet" ) ); @@ -436,12 +443,8 @@ LVL1CTP::CTPSimulation::bookHists() const { ATH_CHECK ( hbook( "/multi/all", (std::unique_ptr<TH2>)std::make_unique<TH2I>("R3Mult", "New thresholds multiplicity", 1, 0, 1, 10, 0, 10) )); // Topo - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("LegacyTopo0","L1Topo Decision (Legacy 0)", 64, 0, 64) )); - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("LegacyTopo1","L1Topo Decision (Legacy 1)", 64, 0, 64) )); - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1El","L1Topo Decision (Topo 1 electrical)", 64, 0, 64) )); - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo2El","L1Topo Decision (Topo 2 electrical)", 64, 0, 64) )); - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo3El","L1Topo Decision (Topo 3 electrical)", 64, 0, 64) )); - ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1Opt0","L1Topo Decision (Topo 1 optical 0)", 90, 0, 90) )); + ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("l1topo0","L1Topo Decision Cable 0", 64, 0, 64) )); + ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("l1topo1","L1Topo Decision Cable 1", 64, 0, 64) )); // item decision ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tbpById", "Items decision (tbp)", 512, 0, 512) )); @@ -458,6 +461,7 @@ LVL1CTP::CTPSimulation::bookHists() const { return StatusCode::SUCCESS; } + StatusCode LVL1CTP::CTPSimulation::fillInputHistograms(const EventContext& context) const { @@ -577,43 +581,24 @@ LVL1CTP::CTPSimulation::fillInputHistograms(const EventContext& context) const { } // topo - auto legacyTopoInput = SG::makeHandle( m_iKeyLegacyTopo, context ); - if(legacyTopoInput.isValid()) { - ATH_MSG_DEBUG("Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo); - ATH_MSG_DEBUG("L1TopoLegacy0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord1(0)); - ATH_MSG_DEBUG("L1TopoLegacy0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord1(1)); - ATH_MSG_DEBUG("L1TopoLegacy1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord2(0)); - ATH_MSG_DEBUG("L1TopoLegacy1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord2(1)); - auto h0 = *get1DHist("/input/topo/LegacyTopo0"); - auto h1 = *get1DHist("/input/topo/LegacyTopo1"); - for(unsigned int i=0; i<32; ++i) { - uint32_t mask = 0x1; mask <<= i; - if( (legacyTopoInput->cableWord1(0) & mask) != 0 ) h0->Fill(i); // cable 0, clock 0 - if( (legacyTopoInput->cableWord1(1) & mask) != 0 ) h0->Fill(32 + i); // cable 0, clock 1 - if( (legacyTopoInput->cableWord2(0) & mask) != 0 ) h1->Fill(i); // cable 1, clock 0 - if( (legacyTopoInput->cableWord2(1) & mask) != 0 ) h1->Fill(32 + i); // cable 1, clock 1 - } - } - auto topoInput = SG::makeHandle( m_iKeyTopo, context ); if(topoInput.isValid()) { ATH_MSG_DEBUG("Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo); - ATH_MSG_DEBUG("L1Topo 2 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(0)); - ATH_MSG_DEBUG("L1Topo 2 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(1)); - ATH_MSG_DEBUG("L1Topo 3 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(0)); - ATH_MSG_DEBUG("L1Topo 3 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(1)); - auto h0 = *get1DHist("/input/topo/Topo1El"); - auto h1 = *get1DHist("/input/topo/Topo2El"); - auto h2 = *get1DHist("/input/topo/Topo3El"); + ATH_MSG_DEBUG("L1Topo0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(0)); + ATH_MSG_DEBUG("L1Topo0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(1)); + ATH_MSG_DEBUG("L1Topo1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(0)); + ATH_MSG_DEBUG("L1Topo1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(1)); + auto h0 = *get1DHist("/input/topo/l1topo0"); + auto h1 = *get1DHist("/input/topo/l1topo1"); for(unsigned int i=0; i<32; ++i) { uint32_t mask = 0x1; mask <<= i; - if( (topoInput->cableWord0(0) & mask) != 0 ) h0->Fill(i); // cable 0, clock 0 - if( (topoInput->cableWord0(1) & mask) != 0 ) h0->Fill(32 + i); // cable 0, clock 1 - if( (topoInput->cableWord1(0) & mask) != 0 ) h1->Fill(i); // cable 0, clock 0 - if( (topoInput->cableWord1(1) & mask) != 0 ) h1->Fill(32 + i); // cable 0, clock 1 - if( (topoInput->cableWord2(0) & mask) != 0 ) h2->Fill(i); // cable 1, clock 0 - if( (topoInput->cableWord2(1) & mask) != 0 ) h2->Fill(32 + i); // cable 1, clock 1 + if( (topoInput->cableWord1(0) & mask) != 0 ) h0->Fill(i); // cable 0, clock 0 + if( (topoInput->cableWord1(1) & mask) != 0 ) h0->Fill(32 + i); // cable 0, clock 1 + if( (topoInput->cableWord2(0) & mask) != 0 ) h1->Fill(i); // cable 1, clock 0 + if( (topoInput->cableWord2(1) & mask) != 0 ) h1->Fill(32 + i); // cable 1, clock 1 } + } else { + ATH_MSG_DEBUG("No collection " << m_iKeyTopo); } // bcid @@ -634,66 +619,13 @@ LVL1CTP::CTPSimulation::extractMultiplicities(std::map<std::string, unsigned int const TrigConf::L1Menu * l1menu = nullptr; if( m_useNewConfig ) { - ATH_CHECK( detStore()->retrieve(l1menu) ); + ATH_CHECK( m_detStore->retrieve(l1menu) ); } thrMultiMap.clear(); if( l1menu ) { - std::vector<std::string> connNames = l1menu->connectorNames(); - for( const std::string connName : {"LegacyTopo0", "LegacyTopo1", "Topo1El", "Topo2El", "Topo3El"}) { - if( find(connNames.begin(), connNames.end(), connName) == connNames.end() ) { - continue; - } - uint64_t cable {0}; - if (connName.find("Legacy")==0) { // legacy topo - auto topoInput = SG::makeHandle( m_iKeyLegacyTopo, context ); - if (not topoInput.isValid()) { - continue; - } - if(connName == "LegacyTopo0") { - cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 ); - } else if (connName == "LegacyTopo1") { - cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 ); - } - } else { // new topo - auto topoInput = SG::makeHandle( m_iKeyTopo, context ); - if (not topoInput.isValid()) { - continue; - } - if(connName == "Topo1El") { - cable = ( (uint64_t)topoInput->cableWord0( 1 ) << 32) + topoInput->cableWord0( 0 ); - } else if(connName == "Topo2El") { - cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 ); - } else if (connName == "Topo3El") { - cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 ); - } - } - auto & conn = l1menu->connector(connName); - for(uint fpga : {0,1}) { - for(uint clock : {0,1}) { - for(auto & tl : conn.triggerLines(fpga,clock)) { - //uint flatIndex = 32*tl.fpga() + 2*tl.startbit() + tl.clock(); // activate later - uint flatIndex = 32*tl.fpga() + tl.startbit() + 16*tl.clock(); - uint pass = (cable & (uint64_t(0x1) << flatIndex)) == 0 ? 0 : 1; - if(size_t pos = tl.name().find('['); pos == std::string::npos) { - thrMultiMap[tl.name()] = pass; - ATH_MSG_DEBUG(tl.name() << " MULT calculated mult for topo " << pass); - } else { - auto thrName = tl.name().substr(0,pos); - int bit = std::stoi(tl.name().substr(pos+1)); - thrMultiMap.try_emplace(thrName, 0); - thrMultiMap[thrName] += (pass << bit); - ATH_MSG_DEBUG(thrName << " MULT updated mult for topo " << pass); - } - } - } - } - } for ( auto & thr : l1menu->thresholds() ) { - if(thr->type() == "TOPO" or thr->type()== "R2TOPO" or thr->type() == "MULTTOPO" or thr->type() == "MUTOPO") { - continue; - } // get the multiplicity for each threshold unsigned int multiplicity = calculateMultiplicity( *thr, l1menu, context ); // and record in threshold--> multiplicity map (to be used for item decision) @@ -740,6 +672,7 @@ LVL1CTP::CTPSimulation::extractMultiplicities(std::map<std::string, unsigned int } + unsigned int LVL1CTP::CTPSimulation::calculateJetMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const { unsigned int multiplicity = 0; @@ -807,6 +740,7 @@ LVL1CTP::CTPSimulation::calculateJetMultiplicity( const TrigConf::L1Threshold & } + unsigned int LVL1CTP::CTPSimulation::calculateJetMultiplicity( const TrigConf::TriggerThreshold * confThr, const EventContext& context ) const { unsigned int multiplicity = 0; @@ -818,7 +752,7 @@ LVL1CTP::CTPSimulation::calculateJetMultiplicity( const TrigConf::TriggerThresho } else if ( confThr->cableName() == "JEP2" || confThr->cableName() == "JET2" ) { multiplicity = CTPUtil::getMult( ctpinJet->cableWord1(), confThr->cableStart(), confThr->cableEnd() ); } - } + } } else { // Run-3 threshold const SG::ReadHandleKey< xAOD::JetRoIContainer > * rhk { nullptr }; @@ -897,10 +831,11 @@ LVL1CTP::CTPSimulation::calculateEMMultiplicity( const TrigConf::L1Threshold & c } + unsigned int LVL1CTP::CTPSimulation::calculateEMMultiplicity( const TrigConf::TriggerThreshold * confThr, const EventContext& context ) const { unsigned int multiplicity (0); - if ( confThr->name()[0]=='e' ) { + if ( confThr->name()[0]=='e' ) { // new EM threshold from eFEX auto eFexCluster = SG::makeHandle( m_iKeyEFexCluster, context ); for ( const auto & cl : *eFexCluster ) { @@ -969,7 +904,7 @@ LVL1CTP::CTPSimulation::calculateTauMultiplicity( const TrigConf::L1Threshold & unsigned int LVL1CTP::CTPSimulation::calculateTauMultiplicity( const TrigConf::TriggerThreshold * confThr, const EventContext& context ) const { unsigned int multiplicity = 0; - if ( confThr->name()[0]=='e' ) { + if ( confThr->name()[0]=='e' ) { // new TAU threshold from eFEX auto eFexTaus = SG::makeHandle( m_iKeyEFexTau, context ); const static SG::AuxElement::ConstAccessor<float> accR3ClET ("R3ClusterET"); @@ -1003,6 +938,7 @@ LVL1CTP::CTPSimulation::calculateTauMultiplicity( const TrigConf::TriggerThresho } + unsigned int LVL1CTP::CTPSimulation::calculateMETMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const { unsigned int multiplicity = 0; @@ -1051,6 +987,7 @@ LVL1CTP::CTPSimulation::calculateMETMultiplicity( const TrigConf::L1Threshold & } + unsigned int LVL1CTP::CTPSimulation::calculateMETMultiplicity( const TrigConf::TriggerThreshold * confThr, const EventContext& context ) const { unsigned int multiplicity = 0; @@ -1065,7 +1002,7 @@ LVL1CTP::CTPSimulation::calculateMETMultiplicity( const TrigConf::TriggerThresho } } } else if ( confThr->name().find("TE")==0 ) { - // old TE + // old TE auto ctpinEnergy = SG::makeHandle( m_iKeyCtpinXE, context ); if ( ctpinEnergy.isValid() ) { if ( confThr->cableName() == "JEP3" || confThr->cableName() == "EN1") { @@ -1191,10 +1128,10 @@ LVL1CTP::CTPSimulation::calculateTopoMultiplicity( const TrigConf::TriggerThresh unsigned int LVL1CTP::CTPSimulation::calculateMultiplicity( const TrigConf::TriggerThreshold * confThr, const EventContext& context ) const { unsigned int multiplicity = 0; - if( confThr->cableName() == "CTPCAL" || - confThr->cableName() == "ALFA" || - confThr->cableName() == "NIM1" || - confThr->cableName() == "NIM2" || + if( confThr->cableName() == "CTPCAL" || + confThr->cableName() == "ALFA" || + confThr->cableName() == "NIM1" || + confThr->cableName() == "NIM2" || confThr->type() == "NIM") { return 0; } @@ -1231,6 +1168,8 @@ LVL1CTP::CTPSimulation::calculateMultiplicity( const TrigConf::L1Threshold & con multiplicity = calculateJetMultiplicity( confThr, l1menu, context ); } else if ( confThr.type() == "MU" ) { multiplicity = calculateMuonMultiplicity( confThr, l1menu, context ); + } else if ( confThr.type() == "TOPO" ) { + multiplicity = calculateTopoMultiplicity( confThr, l1menu, context ); } } catch(std::exception & ex) { @@ -1299,7 +1238,7 @@ LVL1CTP::CTPSimulation::finalize() { const TrigConf::L1Menu * l1menu = nullptr; if( m_useNewConfig ) { - ATH_CHECK( detStore()->retrieve(l1menu) ); + ATH_CHECK( m_detStore->retrieve(l1menu) ); } constexpr unsigned int sizeOfCTPOutput = 512; @@ -1358,7 +1297,7 @@ LVL1CTP::CTPSimulation::finalize() { } else { thrHists = { "em/em", "muon/muon", "tau/tau", "jet/jet", "xe/xe", "te/te", "xs/xs" }; } - auto hist = * get2DHist( "/multi/all/LegacyMult" ); + auto hist = * get2DHist( "/multi/all/LegacyMult" ); for(const std::string & histpath : thrHists) { auto h = * get2DHist( "/multi/" + histpath + "Mult" ); auto xaxis = h->GetXaxis(); @@ -1380,7 +1319,7 @@ LVL1CTP::CTPSimulation::finalize() { { // run 3 thresholds if( l1menu ) { - auto hist = * get2DHist( "/multi/all/R3Mult" ); + auto hist = * get2DHist( "/multi/all/R3Mult" ); std::vector<std::string> thrHists = { "em/eEM", "muon/MU", "tau/eTAU", "jet/jJ", "jet/gJ", "xe/gXE", "xe/jXE" }; for(const std::string & histpath : thrHists) { auto h = * get2DHist( "/multi/" + histpath + "Mult" ); diff --git a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.h b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.h index efb96d92223..d6efae27b3b 100644 --- a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.h +++ b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.h @@ -133,7 +133,7 @@ namespace LVL1CTP { // Needed services and tools ServiceHandle<ITHistSvc> m_histSvc { this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" }; ServiceHandle<TrigConf::ILVL1ConfigSvc> m_configSvc { this, "TrigConfigSvc", "TrigConf::TrigConfigSvc/TrigConfigSvc", "Trigger configuration service" }; - // ServiceHandle<StoreGateSvc> m_detStore { this, "DetectorStore", "StoreGateSvc/DetectorStore", "Detector store to get the menu" }; + ServiceHandle<StoreGateSvc> m_detStore { this, "DetectorStore", "StoreGateSvc/DetectorStore", "Detector store to get the menu" }; ToolHandle<LVL1CTP::ResultBuilder> m_resultBuilder { this, "ResultBuilder", "LVL1CTP__ResultBuilder/ResultBuilder", "Builds the CTP result" }; // random engine for calculating prescales diff --git a/Trigger/TrigT1/TrigT1CTP/src/CTPTriggerItem.cxx b/Trigger/TrigT1/TrigT1CTP/src/CTPTriggerItem.cxx index 253c69230d2..b3456445b6f 100644 --- a/Trigger/TrigT1/TrigT1CTP/src/CTPTriggerItem.cxx +++ b/Trigger/TrigT1/TrigT1CTP/src/CTPTriggerItem.cxx @@ -2,11 +2,12 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#include "./CTPTriggerItem.h" #include "TrigConfData/LogicParser.h" + #include "TrigConfL1Data/TriggerItem.h" -#include <exception> +#include "./CTPTriggerItem.h" + LVL1CTP::CTPTriggerItem::CTPTriggerItem() {} @@ -87,13 +88,8 @@ LVL1CTP::CTPTriggerItem::evaluate( const std::map<std::string, unsigned int> & t if( dec && (! m_bunchGroups.empty()) ) { // apply bunchgroups, if set (if not set, it is part of the logic) for( auto & bgName : m_bunchGroups ) { - try { - if( thrDecMap.at(bgName) == 0 ) { - dec = false; break; - } - } - catch(std::exception &) { - throw std::runtime_error( "Problem accessing decision for bunchgroup " + bgName); + if( thrDecMap.at(bgName) == 0 ) { + dec = false; break; } } } diff --git a/Trigger/TrigT1/TrigT1CTP/src/ResultBuilder.cxx b/Trigger/TrigT1/TrigT1CTP/src/ResultBuilder.cxx index 890651d8809..e277d51d912 100644 --- a/Trigger/TrigT1/TrigT1CTP/src/ResultBuilder.cxx +++ b/Trigger/TrigT1/TrigT1CTP/src/ResultBuilder.cxx @@ -118,6 +118,7 @@ StatusCode LVL1CTP::ResultBuilder::constructTIPVector( const std::map<std::string, unsigned int> & thrMultiMap, std::vector<uint32_t> & tip ) const { + tip.resize( m_ctpDataFormat->getTIPwords(), 0 ); for( auto & entry : thrMultiMap ) { @@ -183,7 +184,7 @@ LVL1CTP::ResultBuilder::buildItemDecision( const std::map<std::string, unsigned itemDecisionMap.clear(); try { - for( const auto & itemName : m_itemConfigMap->itemNames() ) { + for( auto itemName : m_itemConfigMap->itemNames() ) { auto ctpItem = m_itemConfigMap->getItem(itemName); bool pass_beforePrescale = ctpItem->evaluate(thrMultiMap); @@ -245,7 +246,7 @@ LVL1CTP::ResultBuilder::constructResultVectors( const std::map<std::string, unsi ATH_MSG_DEBUG( " --> Trigger item " << itemName << " is " << ( !passBP ? "INACTIVE" : ( passAV ? "ACTIVE" : "ACTIVE (but PRESCALED)" ) ) ); } - ATH_MSG_DEBUG( "REGTEST - " << "TriggerType byte is: 0x" << std::setw( 2 ) << std::setfill( '0' ) << std::hex << int(triggerType) ); + ATH_MSG_DEBUG( "REGTEST - " << "TriggerType byte is: 0x" << std::hex << std::setw( 2 ) << std::setfill( '0' ) << triggerType ); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigT1/TrigT1CTP/src/ThresholdMap.cxx b/Trigger/TrigT1/TrigT1CTP/src/ThresholdMap.cxx index 901103b9f5c..4d40dadc4bc 100644 --- a/Trigger/TrigT1/TrigT1CTP/src/ThresholdMap.cxx +++ b/Trigger/TrigT1/TrigT1CTP/src/ThresholdMap.cxx @@ -98,11 +98,6 @@ LVL1CTP::ThresholdMap::getThresholdNames() const { const LVL1CTP::CTPTriggerThreshold & LVL1CTP::ThresholdMap::getCTPThreshold( const std::string & thrName ) const { - try { - return * m_mapByName.at( thrName ); - } - catch(std::exception&) { - throw std::runtime_error("Threshold " + thrName + " not present in CTPSimulation's internal threshold map"); - } + return * m_mapByName.at( thrName ); } diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py index 82621efbf17..463e2b07dc4 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py @@ -213,7 +213,7 @@ def Lvl1SimulationSequence( flags = None ): ctp.DoLUCID = False ctp.DoBCM = False ctp.DoL1Topo = not flags.Trigger.enableL1Phase1 - ctp.UseNewConfig = True + ctp.UseCondL1Menu = False ctp.TrigConfigSvc = svcMgr.LVL1ConfigSvc ctpSim = seqAND("ctpSim", [ctp]) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Config/ItemDef.py b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Config/ItemDef.py index 404df6fa2ad..8cb186e920f 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Config/ItemDef.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Config/ItemDef.py @@ -1654,8 +1654,12 @@ class ItemDef: MenuItem('L1_LFV-MU6').setLogic( d.TOPO_0DR15_2MU6ab & d.MU6.x(2) & physcond) MenuItem('L1_LFV-MU').setLogic( d.R2TOPO_0DR10_MU10ab_MU6ab & d.MU10 & d.MU6.x(2) & physcond) - MenuItem('L1_LFV-EM8I').setLogic( d.TOPO_0DETA04_EM8abi_MU10ab & d.TOPO_0DPHI03_EM8abi_MU10ab & d.MU10 & physcond) #ATR-14282 - MenuItem('L1_LFV-EM15I').setLogic( d.TOPO_0DETA04_EM15abi_MUab & d.TOPO_0DPHI03_EM15abi_MUab & physcond) #ATR-14282 + if isV8 or isHIV5 or isPhaseII: + MenuItem('L1_LFV-EM8I').setLogic( d.TOPO_0DETA04_EM8abi_MU10ab & d.TOPO_0DPHI03_EM8abi_MU10ab & d.MU10 & physcond) #ATR-14282 + MenuItem('L1_LFV-EM15I').setLogic( d.TOPO_0DETA04_EM15abi_MUab & d.TOPO_0DPHI03_EM15abi_MUab & physcond) #ATR-14282 + else: + MenuItem('L1_LFV-EM8I').setLogic( d.TOPO_0DETA04_0DPHI03_EM8abi_MU10ab & physcond) + MenuItem('L1_LFV-EM15I').setLogic( d.TOPO_0DETA04_0DPHI03_EM15abi_MUab & physcond) MenuItem('L1_DPHI-J20s2XE50').setLogic( d.TOPO_10MINDPHI_J20s2_XE50 & physcond) MenuItem('L1_DPHI-J20XE50').setLogic( d.R2TOPO_10MINDPHI_J20ab_XE50 & physcond) @@ -1704,7 +1708,10 @@ class ItemDef: MenuItem('L1_DR-TAU20ITAU12I').setLogic( d.TOPO_0DR28_TAU20abi_TAU12abi & physcond) MenuItem('L1_BOX-TAU20ITAU12I').setLogic( d.R2TOPO_0DETA20_0DPHI20_TAU20abi_TAU12abi & physcond) - MenuItem('L1_DR-TAU20ITAU12I-J25').setLogic( d.TOPO_2DISAMB_J25ab_0DR28_TAU20abi_TAU12abi & physcond) + if isV8: + MenuItem('L1_DR-TAU20ITAU12I-J25').setLogic( d.TOPO_2DISAMB_J25ab_0DR28_TAU20abi_TAU12abi & physcond) + else: + MenuItem('L1_DR-TAU20ITAU12I-J25').setLogic( d.TOPO_1DISAMB_J25ab_0DR28_TAU20abi_TAU12abi & physcond) MenuItem('L1_DR25-TAU20ITAU12I-J25').setLogic( d.R2TOPO_1DISAMB_J25ab_0DR25_TAU20abi_TAU12abi & physcond) MenuItem('L1_LAR-EM').setLogic( d.R2TOPO_LAR_EM20shi1 & physcond).setTriggerType( TT.lardemo ) # LAr demo (ATR-11897) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Menu/MenuMapping.py b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Menu/MenuMapping.py index 0b641377b92..a2a7168ed47 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Menu/MenuMapping.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/L1/Menu/MenuMapping.py @@ -8,7 +8,6 @@ The resolved name is also being used in the L1/Config/ItemDef.py and L1/Config/T """ menuMap = { - "Physics_pp_v7" : "MC_pp_v8", "LS2_v1" : "MC_pp_v8", "Physics_pp_run3_v1" : "MC_pp_v8", "MC_pp_run3_v1" : "MC_pp_v8", -- GitLab