diff --git a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/python/TrigPartialEventBuildingConfig.py b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/python/TrigPartialEventBuildingConfig.py index c09b919ba7edcd7155d39f78df99a267e7e1687d..a47d8e6ae65b6b521ae909fe94efb452c429143f 100644 --- a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/python/TrigPartialEventBuildingConfig.py +++ b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/python/TrigPartialEventBuildingConfig.py @@ -5,6 +5,7 @@ from TrigPartialEventBuilding.TrigPartialEventBuildingConf import StaticPEBInfoWriterTool, RoIPEBInfoWriterTool from TrigEDMConfig.DataScoutingInfo import getFullHLTResultID from libpyeformat_helper import SourceIdentifier, SubDetector +from RegionSelector import RegSelToolConfig class StaticPEBInfoWriterToolCfg(StaticPEBInfoWriterTool): @@ -24,10 +25,32 @@ class StaticPEBInfoWriterToolCfg(StaticPEBInfoWriterTool): class RoIPEBInfoWriterToolCfg(RoIPEBInfoWriterTool): + def addRegSelDets(self, detNames): + ''' + Add RegionSelector tools for given detector look-up tables to build PEB list of ROBs + in these detectors that intersect with the RoI. Special value 'All' can be also given + in the detNames list to include all detectors available in RegionSelector. + ''' + if 'All' in detNames: + detNames = [ + 'Pixel', 'SCT', 'TRT', # ID + 'MDT', 'RPC', 'TGC', 'CSC', 'MM', 'sTGC', # Muon + 'TTEM', 'TTHEC', 'FCALEM', 'FCALHAD', 'TILE'] # Calo + for det in detNames: + funcName = 'makeRegSelTool_' + det + if not hasattr(RegSelToolConfig, funcName): + raise RuntimeError('Cannot add detector "' + det + '", RegSelToolConfig does not have a function ' + funcName) + func = getattr(RegSelToolConfig, funcName) + if not callable(func): + raise RuntimeError('Cannot add detector "' + det + '", RegSelToolConfig.' + funcName + ' is not callable') + self.RegionSelectorTools += [func()] + def addROBs(self, robs): + '''Add extra fixed list of ROBs independent of RoI''' self.ExtraROBs.extend(robs) def addSubDets(self, dets): + '''Add extra fixed list of SubDets independent of RoI''' self.ExtraSubDets.extend(dets) def addHLTResultToROBList(self, moduleId=getFullHLTResultID()): diff --git a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.cxx b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.cxx index 5a5b19a347d7cde6caa00881195a9d472195b155..d07bd48c1469fe7b917ede690daecbe3b868d920 100644 --- a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.cxx +++ b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.cxx @@ -18,60 +18,12 @@ RoIPEBInfoWriterTool::RoIPEBInfoWriterTool(const std::string& type, const std::s StatusCode RoIPEBInfoWriterTool::initialize() { ATH_MSG_DEBUG("Initialising RoIPEBInfoWriterTool/" << name()); - ATH_CHECK(m_regionSelector.retrieve()); + ATH_CHECK(m_regionSelectorTools.retrieve()); m_extraPebInfo.robs.insert(m_extraROBs.begin(), m_extraROBs.end()); m_extraPebInfo.subdets.insert(m_extraSubDets.begin(), m_extraSubDets.end()); ATH_MSG_DEBUG("Extra PEBInfo attached to every passed event: " << m_extraPebInfo); - // Ugly solution - need to translate strings into enums. Wouldn't be needed if DETID enum was accessible from python. - - const std::unordered_map<std::string_view,DETID> detNameDict = { - {"LAR", DETID::LAR}, - {"TTEM", DETID::TTEM}, - {"TTHEC", DETID::TTHEC}, - {"TILE", DETID::TILE}, - {"MDT", DETID::MDT}, - {"RPC", DETID::RPC}, - {"TGC", DETID::TGC}, - {"CSC", DETID::CSC}, - {"FCALEM", DETID::FCALEM}, - {"FCALHAD", DETID::FCALHAD}, - {"FTK", DETID::FTK}, - {"MM", DETID::MM}, - {"STGC", DETID::STGC}, - }; - - const std::unordered_map< std::string_view, ToolHandle<IRegSelTool> > detTools = { - { "PIXEL", m_regionSelector_pix }, - { "SCT", m_regionSelector_sct }, - { "TRT", m_regionSelector_trt } - }; - - for (std::string_view name : m_detNames) { - if (name=="All") { - for (const auto& p : detNameDict) m_dets.insert(p.second); - for (const auto& p : detTools) m_tools.insert(p.second); - break; - } - - const auto itt = detTools.find(name); - if ( itt!=detTools.cend() ) { - ATH_MSG_DEBUG("The detector name " << name << " being inserted from the RegSelTools database"); - m_tools.insert(itt->second); - } - else { - ATH_MSG_DEBUG("The detector name " << name << " not in the RegSelTools database - trying RegSelEnum database"); - const auto it = detNameDict.find(name); - if (it==detNameDict.cend()) { - ATH_MSG_ERROR("The detector name " << name << " cannot be translated into RegSelEnum DETID"); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("Adding " << name << "=" << it->second << " to detector list"); - m_dets.insert(it->second); - } - } - return StatusCode::SUCCESS; } @@ -101,15 +53,9 @@ PEBInfoWriterToolBase::PEBInfo RoIPEBInfoWriterTool::createPEBInfo(const PEBInfo TrigRoiDescriptor roiForPEB(eta, etaMin, etaMax, phi, phiMin, phiMax); - for ( auto tool : m_tools ) { - std::vector<uint32_t> detROBs; - tool->ROBIDList( roiForPEB, detROBs); - pebi.robs.insert(detROBs.begin(),detROBs.end()); - } - - for (const DETID detid : m_dets) { + for (const auto& tool : m_regionSelectorTools) { std::vector<uint32_t> detROBs; - m_regionSelector->DetROBIDListUint(detid, roiForPEB, detROBs); + tool->ROBIDList(roiForPEB, detROBs); pebi.robs.insert(detROBs.begin(),detROBs.end()); } diff --git a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.h b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.h index f1f893825978b832843fea07cc663b44ccd89666..66ed0062b6c5d307a14cbdde3dcde3aa0107df36 100644 --- a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.h +++ b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/RoIPEBInfoWriterTool.h @@ -27,25 +27,11 @@ protected: virtual PEBInfoWriterToolBase::PEBInfo createPEBInfo(const PEBInfoWriterToolBase::Input& input) const override; private: - // ------------------------- Service handles --------------------------------- - ServiceHandle<IRegSelSvc> m_regionSelector { - this, "RegionSelector", "RegSelSvc/RegSelSvc", "Region Selector service" + // ------------------------- Tool handles ------------------------------------ + ToolHandleArray<IRegSelTool> m_regionSelectorTools { + this, "RegionSelectorTools", {}, "Region Selector tools" }; - ToolHandle<IRegSelTool> m_regionSelector_pix { - this, "RegSelTool_Pixel", "RegSelTool/RegSelTool_Pixel", "Region Selector Tool" - }; - - ToolHandle<IRegSelTool> m_regionSelector_sct { - this, "RegSelTool_SCT", "RegSelTool/RegSelTool_SCT", "Region Selector Tool" - }; - - ToolHandle<IRegSelTool> m_regionSelector_trt { - this, "RegSelTool_TRT", "RegSelTool/RegSelTool_TRT", "Region Selector Tool" - }; - - - // ------------------------- Properties -------------------------------------- Gaudi::Property<float> m_etaEdge { this, "EtaEdge", 5.0, "Upper limit of |eta| range" @@ -56,11 +42,6 @@ private: Gaudi::Property<float> m_phiWidth { this, "PhiWidth", 0.1, "Half-width of the RoI in phi (Phi-PhiWidth; Phi+PhiWidth)" }; - Gaudi::Property<std::vector<std::string> > m_detNames { - this, "DetNames", {}, - "List of detectors from which ROBs in RoI will be included. Naming follows RegSelEnums DETID. " - "\"All\" is also a possible value." - }; // No string parsing would be needed if DETID wasn't a global enum and was available in python Gaudi::Property<std::vector<uint32_t> > m_extraROBs { this, "ExtraROBs", {}, "Static list of additional ROBs to add for partial event building in each event where the chain passes" diff --git a/Trigger/TrigValidation/TrigP1Test/share/PEBDSTest.py b/Trigger/TrigValidation/TrigP1Test/share/PEBDSTest.py index 2fcbff183e6c26ed3f06962df6b1fc2daab601b2..c854c7076985dbb3a0fff61daa36a142811268e9 100644 --- a/Trigger/TrigValidation/TrigP1Test/share/PEBDSTest.py +++ b/Trigger/TrigValidation/TrigP1Test/share/PEBDSTest.py @@ -86,13 +86,7 @@ def myPebInfoWriterTool(name, eventBuildType): tool.EtaEdge = 5.0 tool.EtaWidth = 0.1 tool.PhiWidth = 0.1 - tool.DetNames = ['All'] - - from RegionSelector.RegSelToolConfig import makeRegSelTool_Pixel, makeRegSelTool_SCT, makeRegSelTool_TRT - tool.RegSelTool_Pixel = makeRegSelTool_Pixel() - tool.RegSelTool_SCT = makeRegSelTool_SCT() - tool.RegSelTool_TRT = makeRegSelTool_TRT() - + tool.addRegSelDets(['All']) tool.ExtraROBs = [] tool.ExtraSubDets = [] tool.addHLTResultToROBList() # add the main (full) HLT result to the list @@ -102,14 +96,8 @@ def myPebInfoWriterTool(name, eventBuildType): tool = RoIPEBInfoWriterToolCfg(name) tool.EtaWidth = 0.5 tool.PhiWidth = 0.5 - tool.DetNames = ['MDT', 'CSC', 'RPC', 'TGC', 'MM', 'STGC'] # all muon detectors + tool.addRegSelDets(['MDT', 'CSC', 'RPC', 'TGC', 'MM', 'sTGC']) # all muon detectors tool.ExtraROBs = [] - - from RegionSelector.RegSelToolConfig import makeRegSelTool_Pixel, makeRegSelTool_SCT, makeRegSelTool_TRT - tool.RegSelTool_Pixel = makeRegSelTool_Pixel() - tool.RegSelTool_SCT = makeRegSelTool_SCT() - tool.RegSelTool_TRT = makeRegSelTool_TRT() - elif 'ElectronDSTest' in eventBuildType: # ElectronDSTest is an example of pure Data Scouting, # where only the special HLT result is saved and nothing else @@ -121,13 +109,7 @@ def myPebInfoWriterTool(name, eventBuildType): tool = RoIPEBInfoWriterToolCfg(name) tool.EtaWidth = 0.3 tool.PhiWidth = 0.3 - tool.DetNames = ['PIXEL', 'SCT', 'TRT', 'TTEM', 'TTHEC', 'FCALEM', 'FCALHAD'] - - from RegionSelector.RegSelToolConfig import makeRegSelTool_Pixel, makeRegSelTool_SCT, makeRegSelTool_TRT - tool.RegSelTool_Pixel = makeRegSelTool_Pixel() - tool.RegSelTool_SCT = makeRegSelTool_SCT() - tool.RegSelTool_TRT = makeRegSelTool_TRT() - + tool.addRegSelDets(['Pixel', 'SCT', 'TRT', 'TTEM', 'TTHEC', 'FCALEM', 'FCALHAD']) tool.ExtraROBs = [] tool.ExtraSubDets = [] diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py index 62cecf49b001a81011d80be1c72b2ebffb2bad8a..f2b85f1ceb34e3f359fb3bd07f2b698da447306c 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py @@ -60,13 +60,7 @@ def pebInfoWriterTool(name, eventBuildType): ]) elif 'LArPEB' in eventBuildType: tool = RoIPEBInfoWriterToolCfg(name) - tool.DetNames = ['PIXEL', 'SCT', 'TRT', 'TTEM', 'TTHEC', 'FCALEM', 'FCALHAD'] - - from RegionSelector.RegSelToolConfig import makeRegSelTool_Pixel, makeRegSelTool_SCT, makeRegSelTool_TRT - tool.RegSelTool_Pixel = makeRegSelTool_Pixel() - tool.RegSelTool_SCT = makeRegSelTool_SCT() - tool.RegSelTool_TRT = makeRegSelTool_TRT() - + tool.addRegSelDets(['Pixel', 'SCT', 'TRT', 'TTEM', 'TTHEC', 'FCALEM', 'FCALHAD']) tool.MaxRoIs = 5 tool.addHLTResultToROBList() # add the main (full) HLT result to the list tool.addCTPResultToROBList() # add the CTP result to the list