Skip to content
Snippets Groups Projects
Commit 490647bc authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Improved output of test-genfsr test and fix GenFSR merging

parent 832ec4fc
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!872Improved output of test-genfsr test and fix GenFSR merging
<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'> <?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<!-- <!--
(c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration (c) Copyright 2000-2023 CERN for the benefit of the LHCb Collaboration
This software is distributed under the terms of the GNU General Public This software is distributed under the terms of the GNU General Public
Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".
...@@ -26,26 +26,38 @@ file = ET.parse('GeneratorLogFSR.xml') ...@@ -26,26 +26,38 @@ file = ET.parse('GeneratorLogFSR.xml')
root = file.getroot() root = file.getroot()
expected_file = ET.parse(os.path.expandvars('../refs/GeneratorLogFSR_expected.xml')) expected_file = ET.parse(os.path.expandvars('../refs/GeneratorLogFSR_expected.xml'))
expected_root = expected_file.getroot() expected_root = expected_file.getroot()
flag = True missingCounters = []
wrongCounters = []
for expected_counter in expected_root.findall('counter'): for expected_counter in expected_root.findall('counter'):
expected_name = expected_counter.get('name') expected_name = expected_counter.get('name')
expected_value = int(expected_counter.find('value').text) expected_value = int(expected_counter.find('value').text)
value = None
for counter in root.findall('counter'): for counter in root.findall('counter'):
name = counter.get('name') name = counter.get('name')
if name == expected_name: if name == expected_name:
value = int(counter.find('value').text) value = int(counter.find('value').text)
if value != expected_value: if value is None:
flag = False missingCounters.append(expected_name)
break elif value != expected_value:
wrongCounters.append((expected_name, expected_value, value))
if flag == False: if missingCounters or wrongCounters:
causes.append('Counter value different from what expected') causes.append('Counters different from what expected')
errors = ''
if missingCounters:
errors += 'Missing counters:\n ' + '\n '.join(missingCounters)
if wrongCounters:
if missingCounters:
errors += "\n"
errors += 'Wrong counters:\n ' + '\n '.join(['%s %d -> %d' % (name, expValue, value) for name, expValue, value in wrongCounters])
result['Expected XML'] = ET.tostring(expected_root).decode()
result['Output XML'] = ET.tostring(root).decode()
result['Counters mismatch'] = errors
if os.path.exists('GeneratorLogFSR.xml'): if os.path.exists('GeneratorLogFSR.xml'):
os.remove('GeneratorLogFSR.xml') os.remove('GeneratorLogFSR.xml')
......
...@@ -119,9 +119,9 @@ def apply_filters(options, algs_dict): ...@@ -119,9 +119,9 @@ def apply_filters(options, algs_dict):
return alg_filterd_dict return alg_filterd_dict
def define_fsr_writer(options): def make_fsr_algs(options):
""" """
Define Generator FSR writer. Make FSR related algorithms.
Args: Args:
options (DaVinci.Options): lbexec provided options object options (DaVinci.Options): lbexec provided options object
...@@ -129,21 +129,32 @@ def define_fsr_writer(options): ...@@ -129,21 +129,32 @@ def define_fsr_writer(options):
Returns: Returns:
List of FSR algorithm instances to be configured. List of FSR algorithm instances to be configured.
""" """
from PyConf.Algorithms import GenFSRMerge, RecordStream from PyConf.Algorithms import EventAccounting, GenFSRMerge, RecordStream
algs = [] fsrAlgs = {}
if options.merge_genfsr and options.simulation:
mergeGenfsr = GenFSRMerge(name="GenFSRMerge") if options.simulation:
algs.append(mergeGenfsr) algs = []
if options.merge_genfsr:
outputLevel = options.output_level algs.append(GenFSRMerge(name="GenFSRMerge"))
recStream = RecordStream( if options.write_fsr and options.output_file:
name="FSROutputStreamDstWriter", if not options.merge_genfsr:
OutputLevel=outputLevel, # I have no idea if this is safe to do so raise an exception
Output="SVC='Gaudi::RootCnvSvc'") raise NotImplementedError(
algs.append(recStream) "FSR output requested but no merging of FSRs performed.")
algs.append(
return algs RecordStream(
name="FSROutputStreamDstWriter",
OutputLevel=options.output_level,
Output="SVC='Gaudi::RootCnvSvc'"))
if algs:
fsrAlgs.update({"GenFSR": algs})
if options.lumi:
fsrAlgs.update({"Lumi": [EventAccounting(name='EventAccount')]})
# this should be modified to reflect LumiAlgsConf (configured separately?)
return fsrAlgs
def configured_FunTuple(config): def configured_FunTuple(config):
......
...@@ -18,8 +18,7 @@ from Configurables import ApplicationMgr ...@@ -18,8 +18,7 @@ from Configurables import ApplicationMgr
from PyConf.application import configure, configure_input, configured_ann_svc from PyConf.application import configure, configure_input, configured_ann_svc
from PyConf.application import metainfo_repos from PyConf.application import metainfo_repos
from PyConf.control_flow import CompositeNode, NodeLogic from PyConf.control_flow import CompositeNode, NodeLogic
from PyConf.Algorithms import EventAccounting from DaVinci.algorithms import (make_fsr_algs, apply_filters)
from DaVinci.algorithms import (define_fsr_writer, apply_filters)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -176,15 +175,7 @@ def add_davinci_configurables(options, user_algorithms, public_tools): ...@@ -176,15 +175,7 @@ def add_davinci_configurables(options, user_algorithms, public_tools):
dvMainFlow = apply_filters(options, user_algorithms) dvMainFlow = apply_filters(options, user_algorithms)
fsrAlgs = {} fsrAlgs = make_fsr_algs(options)
if options.write_fsr and options.output_file:
if options.simulation:
fsrAlgs.update({"GenFSR": define_fsr_writer(options)})
if options.lumi:
fsrAlgs.update({"Lumi": [EventAccounting(name='EventAccount')]})
# this should be modified to reflect LumiAlgsConf (configured separately?)
dvMainNode = davinci_control_flow(options, dvMainNode = davinci_control_flow(options,
prepare_davinci_nodes(dvMainFlow), prepare_davinci_nodes(dvMainFlow),
prepare_davinci_nodes(fsrAlgs)) prepare_davinci_nodes(fsrAlgs))
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
from PyConf.Algorithms import Gaudi__Examples__VoidConsumer as VoidConsumer from PyConf.Algorithms import Gaudi__Examples__VoidConsumer as VoidConsumer
from DaVinci import Options from DaVinci import Options
from DaVinci.algorithms import (define_fsr_writer, add_filter, apply_filters, from DaVinci.algorithms import (make_fsr_algs, add_filter, apply_filters,
configured_FunTuple) configured_FunTuple)
from PyConf.reading import get_odin, get_decreports, get_hlt_reports, upfront_decoder from PyConf.reading import get_odin, get_decreports, get_hlt_reports, upfront_decoder
from PyConf.application import default_raw_event from PyConf.application import default_raw_event
...@@ -31,7 +31,7 @@ def test_define_write_fsr(): ...@@ -31,7 +31,7 @@ def test_define_write_fsr():
merge_genfsr=True, merge_genfsr=True,
simulation=True, simulation=True,
) )
test_algs = define_fsr_writer(options) test_algs = make_fsr_algs(options)["GenFSR"]
assert any("GenFSRMerge" == x.name for x in test_algs) assert any("GenFSRMerge" == x.name for x in test_algs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment