From f6627f3ac195f197f234bfb75df8d50c56c8b907 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Wed, 14 Feb 2024 17:29:05 +0100 Subject: [PATCH] Adapted tests to IOAlg --- AllenOnline/tests/options/cpu_decoding.py | 4 +- .../tests/options/test_allen_lumisummaries.py | 123 ++++++++---------- MooreOnlineConf/options/calo.py | 10 +- MooreOnlineConf/options/ft.py | 2 +- MooreOnlineConf/options/muon.py | 2 +- MooreOnlineConf/options/ut.py | 10 +- .../python/MooreOnlineConf/utils.py | 2 +- 7 files changed, 68 insertions(+), 85 deletions(-) diff --git a/AllenOnline/tests/options/cpu_decoding.py b/AllenOnline/tests/options/cpu_decoding.py index 9701bb4aa..c9695e92a 100644 --- a/AllenOnline/tests/options/cpu_decoding.py +++ b/AllenOnline/tests/options/cpu_decoding.py @@ -42,8 +42,8 @@ mgr.ExtSvc += [configured_ann_svc('TCKANNSvc')] def decoding(): - ecal_raw = default_raw_banks("Calo", default_raw_event) - ecal_raw_error = default_raw_banks("CaloError", default_raw_event) + ecal_raw = default_raw_banks("Calo") + ecal_raw_error = default_raw_banks("CaloError") decoders = [ loc.producer for loc in [ diff --git a/AllenOnline/tests/options/test_allen_lumisummaries.py b/AllenOnline/tests/options/test_allen_lumisummaries.py index 9ae708d64..6703ac12b 100755 --- a/AllenOnline/tests/options/test_allen_lumisummaries.py +++ b/AllenOnline/tests/options/test_allen_lumisummaries.py @@ -12,24 +12,17 @@ """ from GaudiConf import IOHelper import GaudiPython as GP -from Configurables import (ApplicationMgr, LHCbApp) -from Configurables import GaudiSequencer -from Configurables import createODIN, IODataManager -from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent -from Configurables import HltLumiWriter, HltLumiSummaryDecoder -from PyConf.Algorithms import VoidFilter, HltDecReportsDecoder -from PyConf.application import configured_ann_svc -from PyConf.application import default_raw_event, default_raw_banks +from PyConf.Algorithms import HltLumiWriter, HltLumiSummaryDecoder, VoidFilter, HltDecReportsDecoder +from PyConf.application import configure_input, configure, configured_ann_svc +from PyConf.application import default_raw_banks +from Moore import options +from PyConf.control_flow import CompositeNode, NodeLogic import Functors as F import argparse import json import warnings -NEW_OUTPUT_RAW_EVENT = "/Event/DAQ/NewHltLumiEvent" -NEW_OUTPUT_VIEW = "/Event/DAQ/NewHltLumi/View" -NEW_LUMI_SUMMARY_LOC = "Hlt/NewLumiSummary" - defaultFile = "mep_lumi.mdf" printFreq = 100 @@ -44,77 +37,62 @@ parser.add_argument( ) args = parser.parse_args() -schemaFile = args.schema_json_file -LHCbApp(DataType="Upgrade", Simulation=True) -IOHelper("MDF").inputFiles([args.input_mdf]) -IODataManager().DisablePFNWarning = True +decKeys = {} +try: + with open(args.schema_json_file) as f: + j = json.load(f) + decKeys = { + int(k, 16): json.dumps(v) + for (k, v) in j["DecodingKeys"].items() + } +except FileNotFoundError: + pass +configured_ann_svc.global_bind(LumiOverrule=decKeys) -seq = GaudiSequencer("Decode", Members=[]) +options.input_files = [args.input_mdf] +options.input_type = "MDF" +options.data_type = "Upgrade" +options.simulation = True +options.dddb_tag = "master" +options.conddb_tag = "master" +options.gaudipython_mode = True + +config = configure_input(options) # Workaround for ROOT-10769 with warnings.catch_warnings(): warnings.simplefilter("ignore") import cppyy -unpack_raw = UnpackRawEvent( - "UnpackODINAndLumi", - RawEventLocation='DAQ/RawEvent', - RawBankLocations=['DAQ/RawBanks/ODIN', 'DAQ/RawBanks/HltLumiSummary'], - BankTypes=['ODIN', 'HltLumiSummary']) -createODIN = createODIN(ODIN="createODIN/ODIN") - -seq.Members = [unpack_raw, createODIN] +algs = [] -with default_raw_event.bind(raw_event_format=0.0): - dec_decoder = HltDecReportsDecoder( - RawBanks=default_raw_banks("HltDecReports"), SourceID='Hlt1') +dec_decoder = HltDecReportsDecoder( + RawBanks=default_raw_banks("HltDecReports"), SourceID='Hlt1') - odinFilter = VoidFilter( +algs.append( + VoidFilter( Cut=F.DECREPORTS_FILTER( Lines=['Hlt1ODINLumiDecision'], - DecReports=dec_decoder.OutputHltDecReportsLocation)) - - # FIXME: move all configuration to PyConf - # Extract configurable from PyConf.Algorithm - config = odinFilter.configuration() - - for k, v in config.items(): - seq.Members.append(k[0](k[1], **v)) - if k[1].startswith('VoidFilter'): - break + DecReports=dec_decoder.OutputHltDecReportsLocation))) #Decode, re-encode and re-decode lumi_decoder = HltLumiSummaryDecoder( - RawBanks=unpack_raw.RawBankLocations[1], SourceID='Hlt1') + RawBanks=default_raw_banks("HltLumiSummary"), SourceID='Hlt1') writer = HltLumiWriter( - InputBank=lumi_decoder.OutputContainerName, - OutputRawEvent=NEW_OUTPUT_RAW_EVENT, - OutputView=NEW_OUTPUT_VIEW, - SourceID='Hlt1') + InputBank=lumi_decoder.OutputContainerName, SourceID='Hlt1') redecoder = HltLumiSummaryDecoder( - name="HltLumiSummaryReDecoder", - RawBanks=writer.OutputView, - OutputContainerName=NEW_LUMI_SUMMARY_LOC) - -seq.Members.append(lumi_decoder) -seq.Members.append(writer) -seq.Members.append(redecoder) + name="HltLumiSummaryReDecoder", RawBanks=writer.OutputView) -app = ApplicationMgr(TopAlg=[seq]) +algs.append(redecoder) -decKeys = {} -try: - with open(schemaFile) as f: - j = json.load(f) - decKeys = { - int(k, 16): json.dumps(v) - for (k, v) in j["DecodingKeys"].items() - } -except FileNotFoundError: - pass -app.ExtSvc += [configured_ann_svc(name='HltANNSvc', LumiOverrule=decKeys)] +cf_node = CompositeNode( + 'Decode', + combine_logic=NodeLogic.NONLAZY_OR, + children=algs, + force_order=True) +config.update(configure(options, cf_node)) from Configurables import EventSelector EventSelector().PrintFreq = 1000 @@ -122,13 +100,18 @@ EventSelector().PrintFreq = 1000 appMgr = GP.AppMgr() TES = appMgr.evtSvc() -error = False -count = 0 -while True: + +def events(): appMgr.run(1) - if not TES["/Event"]: - break + while TES["/Event"]: + yield TES + appMgr.run(1) + +count = 0 +error = False +appMgr.run(1) +for TES in events(): dec_reports = TES[dec_decoder.OutputHltDecReportsLocation.location] lumi_report = dec_reports.decReport("Hlt1ODINLumiDecision") @@ -136,12 +119,12 @@ while True: continue count += 1 - summary = TES["Hlt/LumiSummary"] + summary = TES[redecoder.OutputContainerName.location] if not summary: print("LumiSummary TES location not found") error = True continue - newSummary = TES[NEW_LUMI_SUMMARY_LOC] + newSummary = TES[redecoder.OutputContainerName.location] if not newSummary: print("LumiSummary new TES location not found") error = True diff --git a/MooreOnlineConf/options/calo.py b/MooreOnlineConf/options/calo.py index f6d3eec0c..5ddc5169c 100644 --- a/MooreOnlineConf/options/calo.py +++ b/MooreOnlineConf/options/calo.py @@ -8,7 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################# -from PyConf.application import default_raw_banks, default_raw_event +from PyConf.application import default_raw_banks from Moore import options, run_reconstruction from PyConf.Algorithms import CaloFutureRawToDigits from RecoConf.calorimeter_reconstruction import make_digits, make_clusters, make_digits @@ -29,10 +29,10 @@ def calo_moni(): from MooreOnlineConf.utils import update_and_reset data.append(update_and_reset()) - ecal_raw = default_raw_banks("Calo", default_raw_event) - ecal_raw_error = default_raw_banks("CaloError", default_raw_event) - hcal_raw = default_raw_banks("Calo", default_raw_event) - hcal_raw_error = default_raw_banks("CaloError", default_raw_event) + ecal_raw = default_raw_banks("Calo") + ecal_raw_error = default_raw_banks("CaloError") + hcal_raw = default_raw_banks("Calo") + hcal_raw_error = default_raw_banks("CaloError") digits = make_digits(calo_raw_bank=True) ecalClusters = make_clusters(digits["digitsEcal"]) diff --git a/MooreOnlineConf/options/ft.py b/MooreOnlineConf/options/ft.py index 4e0f4e8a6..a98afdabe 100644 --- a/MooreOnlineConf/options/ft.py +++ b/MooreOnlineConf/options/ft.py @@ -21,7 +21,7 @@ options.conddb_tag = 'upgrade/master' def ft_mon(): - raw_event = default_raw_event(["FTNZS"]) + raw_event = default_raw_event("FTNZS") raw_banks = default_raw_banks("FTGeneric") odin = make_odin() diff --git a/MooreOnlineConf/options/muon.py b/MooreOnlineConf/options/muon.py index 20f2afa98..90650ba77 100755 --- a/MooreOnlineConf/options/muon.py +++ b/MooreOnlineConf/options/muon.py @@ -19,7 +19,7 @@ options.conddb_tag = 'muon_cabling_run3_fix_M2R2' def muon_mon(): - raw = default_raw_event(["Muon"]) + raw = default_raw_event("Muon") odin = make_odin() rawToHits = MuonRawInUpgradeToHits(RawEventLocation=raw) diff --git a/MooreOnlineConf/options/ut.py b/MooreOnlineConf/options/ut.py index 00031db2c..2774ac17a 100755 --- a/MooreOnlineConf/options/ut.py +++ b/MooreOnlineConf/options/ut.py @@ -26,7 +26,7 @@ from Configurables import LHCb__Det__LbDD4hep__DD4hepSvc as DD4hepSvc def ut_mon(): - raw = default_raw_event(["UT"]) + raw = default_raw_event("UT") odin = make_odin() # @@ -39,21 +39,21 @@ def ut_mon(): name="UTOnlineMonitor", InputData=digits, ODINLocation=odin, - RawEventLocation=default_raw_event(["UT"])) + RawEventLocation=default_raw_event("UT")) # decoderNZS = UTRawBankToUTNZSDigitsAlg( name="UTRawToDigitsNZS", Type="NZS", - RawEventLocation=default_raw_event(["UT"])) + RawEventLocation=default_raw_event("UT")) digitsNZS = decoderNZS.OutputDigitData ut_onlinemonitorNZS = UTOnlineMonitor( name="UTOnlineMonitorNZS", InputData=digitsNZS, ODINLocation=odin, - RawEventLocation=default_raw_event(["UT"])) + RawEventLocation=default_raw_event("UT")) # - #decoderERR = UTErrorBankToASICHeaderAlg(OutputLevel=INFO, name='UTErrorToASIC', Type="ErrorUTSpecial", RawEventLocation=default_raw_event(["UT"])) + #decoderERR = UTErrorBankToASICHeaderAlg(OutputLevel=INFO, name='UTErrorToASIC', Type="ErrorUTSpecial", RawEventLocation=default_raw_event("UT")) #digitsERR = decoderERR.OutputDigitData #ut_onlinemonitorERR = UTOnlineError( OutputLevel=INFO, name="UTOnlineERR", InputData=digitsERR ) diff --git a/MooreOnlineConf/python/MooreOnlineConf/utils.py b/MooreOnlineConf/python/MooreOnlineConf/utils.py index b996a7013..3aef46ee3 100644 --- a/MooreOnlineConf/python/MooreOnlineConf/utils.py +++ b/MooreOnlineConf/python/MooreOnlineConf/utils.py @@ -19,7 +19,7 @@ from PyConf.application import default_raw_event def update_and_reset(): from PyConf.Algorithms import Online__UpdateAndReset - odin = default_raw_event(["ODIN"]) + odin = default_raw_event("ODIN") rawdata = odin.producer.inputs["RawData"] # the evt_data_t object return Online__UpdateAndReset(name='UpdateAndReset', RawData=rawdata) -- GitLab