From 89b6a5f2dbc64f03377b27e95de3771037310962 Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Mon, 25 Jun 2018 15:05:48 +0200 Subject: [PATCH 1/6] Update validator of genfsr qmtest (dfazzini-genfsr-updateQMTest) --- .../qmtest/gauss.qms/gauss-create-genfsr.qmt | 81 ++++++++++++++++--- .../qmtest/gauss.qms/gauss-merge-genfsr.qmt | 74 ++++++++++++++--- 2 files changed, 133 insertions(+), 22 deletions(-) diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt index b25f4fab1..efdfe6db1 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt @@ -18,29 +18,84 @@ if os.path.exists('GeneratorLogFSR.xml'): file = ET.parse('GeneratorLogFSR.xml') else: causes.append('No output file found') - root = file.getroot() expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-create-genfsr.xml')) - expected_root = expected_file.getroot() -flag = True -for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) +flag = False +for expected_counter in expected_root.findall('counter'): + expected_name = expected_counter.get('name') + #expected_value = int(expected_counter.find('value').text) + + flag = False - for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') + for counter in root.findall('counter'): + name = counter.get('name') if name == expected_name: - expected_value = int(expected_counter.find('value').text) + #value = int(counter.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of counter %s different from what expected' %(name)) + causes.append('Counter %s is missing' %(name)) + break +""" +flag = False +for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + #expected_value = int(expected_fraction.find('value').text) + + flag = False + print expected_name + for fraction in root.findall('fraction'): + name = fraction.get('name') + print " "+name + if name == expected_name: + #value = int(fraction.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of fraction %s different from what expected' %(name)) + causes.append('Fraction %s is missing' %(name)) + break +""" +flag = False +for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + #expected_value = int(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + if name == expected_name: + #value = int(efficiency.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of efficiency %s different from what expected' %(name)) + causes.append('Efficiency %s is missing' %(name)) + break + +flag = False +for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + #expected_value = int(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + if id == expected_id: + #value = int(crosssection.find('value').text) + flag = True - if value != expected_value: - flag = False + if flag == False: + #causes.append('Value of cross-section %s different from what expected' %(id)) + causes.append('Cross-section %s is missing' %(id)) break -if flag == False: - causes.append('Counter value different from what expected') if os.path.exists('GeneratorLogFSR.xml'): os.remove('GeneratorLogFSR.xml') diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt index ae3ced1ed..bdc957795 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt @@ -16,29 +16,85 @@ if os.path.exists('GeneratorLogFSR.xml'): file = ET.parse('GeneratorLogFSR.xml') else: causes.append('No output file found') - root = file.getroot() expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-merge-genfsr.xml')) - expected_root = expected_file.getroot() -flag = True +flag = False for expected_counter in expected_root.findall('counter'): expected_name = expected_counter.get('name') - expected_value = int(expected_counter.find('value').text) + #expected_value = int(expected_counter.find('value').text) + + flag = False for counter in root.findall('counter'): name = counter.get('name') if name == expected_name: - value = int(counter.find('value').text) + #value = int(counter.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of counter %s different from what expected' %(name)) + causes.append('Counter %s is missing' %(name)) + break + +""" +flag = False +for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + #expected_value = int(expected_fraction.find('value').text) + + flag = False + print expected_name + for fraction in root.findall('fraction'): + name = fraction.get('name') + print " "+name + if name == expected_name: + #value = int(fraction.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of fraction %s different from what expected' %(name)) + causes.append('Fraction %s is missing' %(name)) + break +""" + +flag = False +for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + #expected_value = int(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + if name == expected_name: + #value = int(efficiency.find('value').text) + flag = True - if value != expected_value: - flag = False + if flag == False: + #causes.append('Value of efficiency %s different from what expected' %(name)) + causes.append('Efficiency %s is missing' %(name)) break -if flag == False: - causes.append('Counter value different from what expected') +flag = False +for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + #expected_value = int(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + if id == expected_id: + #value = int(crosssection.find('value').text) + flag = True + + if flag == False: + #causes.append('Value of cross-section %s different from what expected' %(id)) + causes.append('Cross-section %s is missing' %(id)) + break if os.path.exists('GeneratorLogFSR.xml'): os.remove('GeneratorLogFSR.xml') -- GitLab From 3c0b42cbe972850b8c81db8ea77926f640c0fd56 Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Mon, 9 Jul 2018 19:04:37 +0200 Subject: [PATCH 2/6] adding gauss-read-genfsr.qmt (dfazzini-genfsr-updateQMTest) --- .../tests/options/testGauss-read-genfsr.py | 18 ++++ .../qmtest/gauss.qms/gauss-read-genfsr.qmt | 98 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 Sim/Gauss/tests/options/testGauss-read-genfsr.py create mode 100644 Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt diff --git a/Sim/Gauss/tests/options/testGauss-read-genfsr.py b/Sim/Gauss/tests/options/testGauss-read-genfsr.py new file mode 100644 index 000000000..3f117f967 --- /dev/null +++ b/Sim/Gauss/tests/options/testGauss-read-genfsr.py @@ -0,0 +1,18 @@ +from Gauss.Configuration import * +from Configurables import GaudiSequencer + +seqGenFSR = GaudiSequencer("GenFSRSeq") +seqGenFSR.Members += ["GenFSRRead", "GenFSRLog"] + +ApplicationMgr().TopAlg += [seqGenFSR] + +from Configurables import LHCbApp +LHCbApp().EvtMax = -1 +LHCbApp().Simulation = True + +#--Set database tags +LHCbApp().DDDBtag = "dddb-20170721-2" +LHCbApp().CondDBtag = "sim-20160321-2-vc-md100" + +EventSelector().Input += ["DATAFILE='PFN:genFSR_2012_Gauss_created.xgen' TYP='POOL_ROOTTREE' OPT='READ'"] + diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt new file mode 100644 index 000000000..538b48c1b --- /dev/null +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt @@ -0,0 +1,98 @@ +<?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'> +<extension class="GaudiTest.GaudiExeTest" kind="test"> + <argument name="program"><text>gaudirun.py</text></argument> + <argument name="prerequisites"><set> + <tuple><text>gauss.gauss-create-genfsr</text><enumeral>PASS</enumeral></tuple> + </set></argument> + <argument name="args"><set> + <text>$GAUSSROOT/tests/options/testGauss-read-genfsr.py</text> + </set></argument> + <argument name="validator"><text> +import xml.etree.ElementTree as ET +import os + +file = 0 +if os.path.exists('GeneratorLogFSR.xml'): + file = ET.parse('GeneratorLogFSR.xml') +else: + causes.append('No output file found') +root = file.getroot() + +expected_file = ET.parse(os.path.expandvars('GeneratorLogFSR_ref.xml')) +expected_root = expected_file.getroot() + +flag = False +for expected_counter in expected_root.findall('counter'): + expected_name = expected_counter.get('name') + expected_value = int(expected_counter.find('value').text) + + flag = False + + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of counter %s different from what expected' %(name)) + break + +flag = False +for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + expected_value = float(expected_fraction.find('value').text) + + flag = False + + for fraction in root.findall('fraction'): + name = fraction.get('name') + value = float(fraction.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of fraction %s different from what expected' %(name)) + break + +flag = False +for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + expected_value = float(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + value = float(efficiency.find('value').text) + if name == expected_name and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of efficiency %s different from what expected' %(name)) + break + +flag = False +for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + expected_value = float(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + value = float(crosssection.find('value').text) + if id == expected_id and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of cross-section %s different from what expected' %(id)) + break + +if os.path.exists('GeneratorLogFSR.xml'): + os.remove('GeneratorLogFSR.xml') +if os.path.exists('GeneratorLogFSR_ref.xml'): + os.remove('GeneratorLogFSR_ref.xml') + </text></argument> +</extension> + -- GitLab From f36fb0e000e2359ca458a607c4740dbce3a5abb4 Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Tue, 10 Jul 2018 14:24:54 +0200 Subject: [PATCH 3/6] adding test gauss-read-merged-genfsr --- .../tests/options/testGauss-merge-genfsr.py | 8 +- .../options/testGauss-read-merged-genfsr.py | 17 +++ .../qmtest/gauss.qms/gauss-create-genfsr.qmt | 83 +++----------- .../qmtest/gauss.qms/gauss-merge-genfsr.qmt | 85 +++------------ .../qmtest/gauss.qms/gauss-read-genfsr.qmt | 5 +- .../gauss.qms/gauss-read-merged-genfsr.qmt | 101 ++++++++++++++++++ 6 files changed, 154 insertions(+), 145 deletions(-) create mode 100644 Sim/Gauss/tests/options/testGauss-read-merged-genfsr.py create mode 100644 Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt diff --git a/Sim/Gauss/tests/options/testGauss-merge-genfsr.py b/Sim/Gauss/tests/options/testGauss-merge-genfsr.py index 0d896abc6..7ac63302a 100644 --- a/Sim/Gauss/tests/options/testGauss-merge-genfsr.py +++ b/Sim/Gauss/tests/options/testGauss-merge-genfsr.py @@ -2,8 +2,7 @@ from Gauss.Configuration import * from Configurables import GaudiSequencer seqGenFSR = GaudiSequencer("GenFSRSeq") -seqGenFSR.Members += ["GenFSRMerge"] -seqGenFSR.Members += ["GenFSRLog"] +seqGenFSR.Members += ["GenFSRMerge", "GenFSRLog"] ApplicationMgr().TopAlg += [seqGenFSR] @@ -18,4 +17,7 @@ EventSelector().Input += [ LHCbApp().EvtMax = -1 LHCbApp().Simulation = True - + +from GaudiConf import IOHelper +idFile = "genFSR_2012_Gauss_merged.xgen" +IOHelper().outStream(idFile) diff --git a/Sim/Gauss/tests/options/testGauss-read-merged-genfsr.py b/Sim/Gauss/tests/options/testGauss-read-merged-genfsr.py new file mode 100644 index 000000000..3ed061a18 --- /dev/null +++ b/Sim/Gauss/tests/options/testGauss-read-merged-genfsr.py @@ -0,0 +1,17 @@ +from Gauss.Configuration import * +from Configurables import GaudiSequencer + +seqGenFSR = GaudiSequencer("GenFSRSeq") +seqGenFSR.Members += ["GenFSRRead", "GenFSRLog"] + +ApplicationMgr().TopAlg += [seqGenFSR] + +from Configurables import LHCbApp +LHCbApp().EvtMax = -1 +LHCbApp().Simulation = True + +#--Set database tags +LHCbApp().DDDBtag = "dddb-20170721-2" +LHCbApp().CondDBtag = "sim-20160321-2-vc-md100" + +EventSelector().Input += ["DATAFILE='PFN:genFSR_2012_Gauss_merged.xgen' TYP='POOL_ROOTTREE' OPT='READ'"] diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt index efdfe6db1..b09e89e0e 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt @@ -20,85 +20,30 @@ else: causes.append('No output file found') root = file.getroot() -expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-create-genfsr.xml')) -expected_root = expected_file.getroot() - +nCounter = 0 flag = False -for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - #expected_value = int(expected_counter.find('value').text) - - flag = False +refNames = ['generated events', 'generated interactions', 'accepted events'] - for counter in root.findall('counter'): - name = counter.get('name') - if name == expected_name: - #value = int(counter.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of counter %s different from what expected' %(name)) - causes.append('Counter %s is missing' %(name)) - break -""" -flag = False -for expected_fraction in expected_root.findall('fraction'): - expected_name = expected_fraction.get('name') - #expected_value = int(expected_fraction.find('value').text) +for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + nCounter = nCounter+1 flag = False - print expected_name - for fraction in root.findall('fraction'): - name = fraction.get('name') - print " "+name - if name == expected_name: - #value = int(fraction.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of fraction %s different from what expected' %(name)) - causes.append('Fraction %s is missing' %(name)) - break -""" -flag = False -for expected_efficiency in expected_root.findall('efficiency'): - expected_name = expected_efficiency.get('name') - #expected_value = int(expected_efficiency.find('value').text) - flag = False - - for efficiency in root.findall('efficiency'): - name = efficiency.get('name') - if name == expected_name: - #value = int(efficiency.find('value').text) + if name in refNames: + if value < 0 or value == 0: flag = True - if flag == False: - #causes.append('Value of efficiency %s different from what expected' %(name)) - causes.append('Efficiency %s is missing' %(name)) - break - -flag = False -for expected_crosssection in expected_root.findall('crosssection'): - expected_id = expected_crosssection.get('id') - #expected_value = int(expected_crosssection.find('value').text) - - flag = False - - for crosssection in root.findall('crosssection'): - id = crosssection.get('id') - if id == expected_id: - #value = int(crosssection.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of cross-section %s different from what expected' %(id)) - causes.append('Cross-section %s is missing' %(id)) + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) break +if(nCounter == 0): + causes.append('Nocounter printed in GeneratorLogFSR.xml file') if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') + os.rename('GeneratorLogFSR.xml', 'GeneratorLogFSR_ref.xml') + </text></argument> </extension> - diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt index bdc957795..3d7cfd4c0 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt @@ -18,88 +18,33 @@ else: causes.append('No output file found') root = file.getroot() -expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-merge-genfsr.xml')) -expected_root = expected_file.getroot() - +nCounter = 0 flag = False -for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - #expected_value = int(expected_counter.find('value').text) - - flag = False +refNames = ['generated events', 'generated interactions', 'accepted events'] - for counter in root.findall('counter'): - name = counter.get('name') - if name == expected_name: - #value = int(counter.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of counter %s different from what expected' %(name)) - causes.append('Counter %s is missing' %(name)) - break - -""" -flag = False -for expected_fraction in expected_root.findall('fraction'): - expected_name = expected_fraction.get('name') - #expected_value = int(expected_fraction.find('value').text) +for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + nCounter = nCounter+1 flag = False - print expected_name - for fraction in root.findall('fraction'): - name = fraction.get('name') - print " "+name - if name == expected_name: - #value = int(fraction.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of fraction %s different from what expected' %(name)) - causes.append('Fraction %s is missing' %(name)) - break -""" - -flag = False -for expected_efficiency in expected_root.findall('efficiency'): - expected_name = expected_efficiency.get('name') - #expected_value = int(expected_efficiency.find('value').text) - flag = False - - for efficiency in root.findall('efficiency'): - name = efficiency.get('name') - if name == expected_name: - #value = int(efficiency.find('value').text) + if name in refNames: + if value < 0 or value == 0: flag = True - if flag == False: - #causes.append('Value of efficiency %s different from what expected' %(name)) - causes.append('Efficiency %s is missing' %(name)) + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) break -flag = False -for expected_crosssection in expected_root.findall('crosssection'): - expected_id = expected_crosssection.get('id') - #expected_value = int(expected_crosssection.find('value').text) - - flag = False - - for crosssection in root.findall('crosssection'): - id = crosssection.get('id') - if id == expected_id: - #value = int(crosssection.find('value').text) - flag = True - - if flag == False: - #causes.append('Value of cross-section %s different from what expected' %(id)) - causes.append('Cross-section %s is missing' %(id)) - break +if(nCounter == 0): + causes.append('No counter printed in GeneratorLogFSR.xml file') if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') + os.rename('GeneratorLogFSR.xml', 'GeneratorLogFSR_ref.xml') + if os.path.exists('genFSR_2012_Gauss_created.xgen'): os.remove('genFSR_2012_Gauss_created.xgen') + </text></argument> </extension> - diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt index 538b48c1b..2e82b92a0 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt @@ -15,7 +15,7 @@ file = 0 if os.path.exists('GeneratorLogFSR.xml'): file = ET.parse('GeneratorLogFSR.xml') else: - causes.append('No output file found') + causes.append('No GeneratorLogFSR.xml found') root = file.getroot() expected_file = ET.parse(os.path.expandvars('GeneratorLogFSR_ref.xml')) @@ -69,7 +69,7 @@ for expected_efficiency in expected_root.findall('efficiency'): flag = True if flag == False: - causes.append('Value of efficiency %s different from what expected' %(name)) + causes.append('Value of efficiency %s different from what expected'%(name)) break flag = False @@ -95,4 +95,3 @@ if os.path.exists('GeneratorLogFSR_ref.xml'): os.remove('GeneratorLogFSR_ref.xml') </text></argument> </extension> - diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt new file mode 100644 index 000000000..af11122df --- /dev/null +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt @@ -0,0 +1,101 @@ +<?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'> +<extension class="GaudiTest.GaudiExeTest" kind="test"> + <argument name="program"><text>gaudirun.py</text></argument> + <argument name="prerequisites"><set> + <tuple><text>gauss.gauss-merge-genfsr</text><enumeral>PASS</enumeral></tuple> + </set></argument> + <argument name="args"><set> + <text>$GAUSSROOT/tests/options/testGauss-read-merged-genfsr.py</text> + </set></argument> + <argument name="validator"><text> +import xml.etree.ElementTree as ET +import os + +file = 0 +file = 2 +if os.path.exists('GeneratorLogFSR.xml'): + file = ET.parse('GeneratorLogFSR.xml') +else: + causes.append('No GeneratorLogFSR.xml found') +root = file.getroot() + +expected_file = ET.parse(os.path.expandvars('GeneratorLogFSR_ref.xml')) +expected_root = expected_file.getroot() + +flag = False +for expected_counter in expected_root.findall('counter'): + expected_name = expected_counter.get('name') + expected_value = int(expected_counter.find('value').text) + + flag = False + + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of counter %s different from what expected' %(name)) + break + +flag = False +for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + expected_value = float(expected_fraction.find('value').text) + + flag = False + + for fraction in root.findall('fraction'): + name = fraction.get('name') + value = float(fraction.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of fraction %s different from what expected' %(name)) + break + +flag = False +for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + expected_value = float(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + value = float(efficiency.find('value').text) + if name == expected_name and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of efficiency %s different from what expected'%(name)) + break + +flag = False +for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + expected_value = float(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + value = float(crosssection.find('value').text) + if id == expected_id and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of cross-section %s different from what expected' %(id)) + break + +if os.path.exists('GeneratorLogFSR.xml'): + os.remove('GeneratorLogFSR.xml') +if os.path.exists('GeneratorLogFSR_ref.xml'): + os.remove('GeneratorLogFSR_ref.xml') +if os.path.exists('genFSR_2012_Gauss_merged.xgen'): + os.remove('genFSR_2012_Gauss_merged.xgen') + + </text></argument> +</extension> -- GitLab From 168978d69b8f9c0e72afc57ec503550d16d0f0d2 Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Tue, 10 Jul 2018 14:35:54 +0200 Subject: [PATCH 4/6] cleaning qmtest genfsr --- Sim/Gauss/tests/options/testGauss-merge-genfsr.py | 4 ++++ Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sim/Gauss/tests/options/testGauss-merge-genfsr.py b/Sim/Gauss/tests/options/testGauss-merge-genfsr.py index 7ac63302a..bb603bdef 100644 --- a/Sim/Gauss/tests/options/testGauss-merge-genfsr.py +++ b/Sim/Gauss/tests/options/testGauss-merge-genfsr.py @@ -18,6 +18,10 @@ EventSelector().Input += [ LHCbApp().EvtMax = -1 LHCbApp().Simulation = True +#--Set database tags +LHCbApp().DDDBtag = "dddb-20170721-2" +LHCbApp().CondDBtag = "sim-20160321-2-vc-md100" + from GaudiConf import IOHelper idFile = "genFSR_2012_Gauss_merged.xgen" IOHelper().outStream(idFile) diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt index af11122df..3fc6d6a71 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt @@ -12,7 +12,6 @@ import xml.etree.ElementTree as ET import os file = 0 -file = 2 if os.path.exists('GeneratorLogFSR.xml'): file = ET.parse('GeneratorLogFSR.xml') else: -- GitLab From 36d06b80fcc61ecd914c3f68fb450a99f665a6fe Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Thu, 15 Nov 2018 19:47:32 +0100 Subject: [PATCH 5/6] fixing reference file name --- .../qmtest/gauss.qms/gauss-create-genfsr.qmt | 45 +++--- .../qmtest/gauss.qms/gauss-merge-genfsr.qmt | 53 ++++--- .../qmtest/gauss.qms/gauss-read-genfsr.qmt | 142 +++++++++-------- .../gauss.qms/gauss-read-merged-genfsr.qmt | 147 +++++++++--------- 4 files changed, 190 insertions(+), 197 deletions(-) diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt index b09e89e0e..4cd0fbdd7 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-create-genfsr.qmt @@ -14,36 +14,35 @@ import xml.etree.ElementTree as ET import os file = 0 -if os.path.exists('GeneratorLogFSR.xml'): - file = ET.parse('GeneratorLogFSR.xml') -else: +if not os.path.exists('GeneratorLogFSR.xml'): causes.append('No output file found') -root = file.getroot() - -nCounter = 0 -flag = False -refNames = ['generated events', 'generated interactions', 'accepted events'] - -for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() - nCounter = nCounter+1 + nCounter = 0 flag = False + refNames = ['generated events', 'generated interactions', 'accepted events'] + + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) - if name in refNames: - if value < 0 or value == 0: - flag = True + nCounter = nCounter+1 + flag = False - if flag == True: - causes.append('Counter %s is lower or equal to 0' %(name)) - break + if name in refNames: + if value < 0 or value == 0: + flag = True -if(nCounter == 0): - causes.append('Nocounter printed in GeneratorLogFSR.xml file') + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) + break -if os.path.exists('GeneratorLogFSR.xml'): - os.rename('GeneratorLogFSR.xml', 'GeneratorLogFSR_ref.xml') + if(nCounter == 0): + causes.append('Nocounter printed in GeneratorLogFSR.xml file') + if os.path.exists('GeneratorLogFSR.xml'): + os.rename('GeneratorLogFSR.xml', 'GeneratorLog_createFSR_ref.xml') </text></argument> </extension> diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt index 3d7cfd4c0..de6817bb3 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-merge-genfsr.qmt @@ -1,8 +1,8 @@ <?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'> <extension class="GaudiTest.GaudiExeTest" kind="test"> <argument name="program"><text>gaudirun.py</text></argument> - <argument name="prerequisites"><set> - <tuple><text>gauss.gauss-create-genfsr</text><enumeral>PASS</enumeral></tuple> +<argument name="prerequisites"><set> + <tuple><text>gauss.gauss-read-genfsr</text><enumeral>PASS</enumeral></tuple> </set></argument> <argument name="args"><set> <text>$GAUSSROOT/tests/options/testGauss-merge-genfsr.py</text> @@ -12,39 +12,38 @@ import xml.etree.ElementTree as ET import os file = 0 -if os.path.exists('GeneratorLogFSR.xml'): - file = ET.parse('GeneratorLogFSR.xml') -else: +if not os.path.exists('GeneratorLogFSR.xml'): causes.append('No output file found') -root = file.getroot() - -nCounter = 0 -flag = False -refNames = ['generated events', 'generated interactions', 'accepted events'] - -for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() - nCounter = nCounter+1 + nCounter = 0 flag = False + refNames = ['generated events', 'generated interactions', 'accepted events'] + + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) - if name in refNames: - if value < 0 or value == 0: - flag = True + nCounter = nCounter+1 + flag = False - if flag == True: - causes.append('Counter %s is lower or equal to 0' %(name)) - break + if name in refNames: + if value < 0 or value == 0: + flag = True -if(nCounter == 0): - causes.append('No counter printed in GeneratorLogFSR.xml file') + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) + break -if os.path.exists('GeneratorLogFSR.xml'): - os.rename('GeneratorLogFSR.xml', 'GeneratorLogFSR_ref.xml') + if(nCounter == 0): + causes.append('No counter printed in GeneratorLogFSR.xml file') -if os.path.exists('genFSR_2012_Gauss_created.xgen'): - os.remove('genFSR_2012_Gauss_created.xgen') + if os.path.exists('GeneratorLogFSR.xml'): + os.rename('GeneratorLogFSR.xml', 'GeneratorLog_mergeFSR_ref.xml') + if os.path.exists('genFSR_2012_Gauss_created.xgen'): + os.remove('genFSR_2012_Gauss_created.xgen') </text></argument> </extension> diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt index 2e82b92a0..126990a9c 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt @@ -12,86 +12,84 @@ import xml.etree.ElementTree as ET import os file = 0 -if os.path.exists('GeneratorLogFSR.xml'): - file = ET.parse('GeneratorLogFSR.xml') -else: +if not os.path.exists('GeneratorLogFSR.xml'): causes.append('No GeneratorLogFSR.xml found') -root = file.getroot() +elif not os.path.exists('GeneratorLog_createFSR_ref.xml'): + causes.append('No reference file GeneratorLog_createFSR_ref.xml found') +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() -expected_file = ET.parse(os.path.expandvars('GeneratorLogFSR_ref.xml')) -expected_root = expected_file.getroot() + expected_file = ET.parse(os.path.expandvars('GeneratorLog_createFSR_ref.xml')) + expected_root = expected_file.getroot() -flag = False -for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - expected_value = int(expected_counter.find('value').text) + for expected_counter in expected_root.findall('counter'): + expected_name = expected_counter.get('name') + expected_value = int(expected_counter.find('value').text) - flag = False + flag = False - for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) - if name == expected_name: - flag = True + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + if name == expected_name: + flag = True - if flag == False: - causes.append('Value of counter %s different from what expected' %(name)) - break + if flag == False: + causes.append('Value of counter %s different from what expected' %(name)) + break -flag = False -for expected_fraction in expected_root.findall('fraction'): - expected_name = expected_fraction.get('name') - expected_value = float(expected_fraction.find('value').text) + for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + expected_value = float(expected_fraction.find('value').text) - flag = False + flag = False - for fraction in root.findall('fraction'): - name = fraction.get('name') - value = float(fraction.find('value').text) - if name == expected_name: - flag = True - - if flag == False: - causes.append('Value of fraction %s different from what expected' %(name)) - break - -flag = False -for expected_efficiency in expected_root.findall('efficiency'): - expected_name = expected_efficiency.get('name') - expected_value = float(expected_efficiency.find('value').text) - - flag = False - - for efficiency in root.findall('efficiency'): - name = efficiency.get('name') - value = float(efficiency.find('value').text) - if name == expected_name and value == expected_value: - flag = True - - if flag == False: - causes.append('Value of efficiency %s different from what expected'%(name)) - break - -flag = False -for expected_crosssection in expected_root.findall('crosssection'): - expected_id = expected_crosssection.get('id') - expected_value = float(expected_crosssection.find('value').text) - - flag = False - - for crosssection in root.findall('crosssection'): - id = crosssection.get('id') - value = float(crosssection.find('value').text) - if id == expected_id and value == expected_value: - flag = True - - if flag == False: - causes.append('Value of cross-section %s different from what expected' %(id)) - break - -if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') -if os.path.exists('GeneratorLogFSR_ref.xml'): - os.remove('GeneratorLogFSR_ref.xml') + for fraction in root.findall('fraction'): + name = fraction.get('name') + value = float(fraction.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of fraction %s different from what expected' %(name)) + break + + for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + expected_value = float(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + value = float(efficiency.find('value').text) + if name == expected_name and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of efficiency %s different from what expected'%(name)) + break + + for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + expected_value = float(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + value = float(crosssection.find('value').text) + if id == expected_id and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of cross-section %s different from what expected' %(id)) + break + + if os.path.exists('GeneratorLogFSR.xml'): + os.remove('GeneratorLogFSR.xml') + if os.path.exists('GeneratorLog_createFSR_ref.xml'): + os.remove('GeneratorLog_createFSR_ref.xml') </text></argument> </extension> diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt index 3fc6d6a71..067af0e5b 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt @@ -12,89 +12,86 @@ import xml.etree.ElementTree as ET import os file = 0 -if os.path.exists('GeneratorLogFSR.xml'): - file = ET.parse('GeneratorLogFSR.xml') -else: +if not os.path.exists('GeneratorLogFSR.xml'): causes.append('No GeneratorLogFSR.xml found') -root = file.getroot() +elif not os.path.exists('GeneratorLog_mergeFSR_ref.xml'): + causes.append('No reference file GeneratorLog_mergeFSR_ref.xml found') +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() -expected_file = ET.parse(os.path.expandvars('GeneratorLogFSR_ref.xml')) -expected_root = expected_file.getroot() + expected_file = ET.parse(os.path.expandvars('GeneratorLog_mergeFSR_ref.xml')) + expected_root = expected_file.getroot() -flag = False -for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - expected_value = int(expected_counter.find('value').text) + for expected_counter in expected_root.findall('counter'): + expected_name = expected_counter.get('name') + expected_value = int(expected_counter.find('value').text) - flag = False + flag = False - for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) - if name == expected_name: - flag = True + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) + if name == expected_name: + flag = True - if flag == False: - causes.append('Value of counter %s different from what expected' %(name)) - break + if flag == False: + causes.append('Value of counter %s different from what expected' %(name)) + break -flag = False -for expected_fraction in expected_root.findall('fraction'): - expected_name = expected_fraction.get('name') - expected_value = float(expected_fraction.find('value').text) + for expected_fraction in expected_root.findall('fraction'): + expected_name = expected_fraction.get('name') + expected_value = float(expected_fraction.find('value').text) - flag = False + flag = False - for fraction in root.findall('fraction'): - name = fraction.get('name') - value = float(fraction.find('value').text) - if name == expected_name: - flag = True - - if flag == False: - causes.append('Value of fraction %s different from what expected' %(name)) - break - -flag = False -for expected_efficiency in expected_root.findall('efficiency'): - expected_name = expected_efficiency.get('name') - expected_value = float(expected_efficiency.find('value').text) - - flag = False - - for efficiency in root.findall('efficiency'): - name = efficiency.get('name') - value = float(efficiency.find('value').text) - if name == expected_name and value == expected_value: - flag = True - - if flag == False: - causes.append('Value of efficiency %s different from what expected'%(name)) - break - -flag = False -for expected_crosssection in expected_root.findall('crosssection'): - expected_id = expected_crosssection.get('id') - expected_value = float(expected_crosssection.find('value').text) - - flag = False - - for crosssection in root.findall('crosssection'): - id = crosssection.get('id') - value = float(crosssection.find('value').text) - if id == expected_id and value == expected_value: - flag = True - - if flag == False: - causes.append('Value of cross-section %s different from what expected' %(id)) - break - -if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') -if os.path.exists('GeneratorLogFSR_ref.xml'): - os.remove('GeneratorLogFSR_ref.xml') -if os.path.exists('genFSR_2012_Gauss_merged.xgen'): - os.remove('genFSR_2012_Gauss_merged.xgen') - + for fraction in root.findall('fraction'): + name = fraction.get('name') + value = float(fraction.find('value').text) + if name == expected_name: + flag = True + + if flag == False: + causes.append('Value of fraction %s different from what expected' %(name)) + break + + for expected_efficiency in expected_root.findall('efficiency'): + expected_name = expected_efficiency.get('name') + expected_value = float(expected_efficiency.find('value').text) + + flag = False + + for efficiency in root.findall('efficiency'): + name = efficiency.get('name') + value = float(efficiency.find('value').text) + if name == expected_name and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of efficiency %s different from what expected'%(name)) + break + + for expected_crosssection in expected_root.findall('crosssection'): + expected_id = expected_crosssection.get('id') + expected_value = float(expected_crosssection.find('value').text) + + flag = False + + for crosssection in root.findall('crosssection'): + id = crosssection.get('id') + value = float(crosssection.find('value').text) + if id == expected_id and value == expected_value: + flag = True + + if flag == False: + causes.append('Value of cross-section %s different from what expected' %(id)) + break + + if os.path.exists('GeneratorLogFSR.xml'): + os.remove('GeneratorLogFSR.xml') + if os.path.exists('GeneratorLog_mergeFSR_ref.xml'): + os.remove('GeneratorLog_mergeFSR_ref.xml') + if os.path.exists('genFSR_2012_Gauss_merged.xgen'): + os.remove('genFSR_2012_Gauss_merged.xgen') </text></argument> </extension> -- GitLab From b7a1da854788b469fb76584818dab27184b0c310 Mon Sep 17 00:00:00 2001 From: Davide Fazzini <Davide Fazzini davide.fazzini@cern.ch> Date: Thu, 15 Nov 2018 19:50:56 +0100 Subject: [PATCH 6/6] fixing reference file name --- Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt | 1 + Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt index 126990a9c..fbb5304a6 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt @@ -89,6 +89,7 @@ else: if os.path.exists('GeneratorLogFSR.xml'): os.remove('GeneratorLogFSR.xml') + if os.path.exists('GeneratorLog_createFSR_ref.xml'): os.remove('GeneratorLog_createFSR_ref.xml') </text></argument> diff --git a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt index 067af0e5b..728a13569 100644 --- a/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt @@ -89,8 +89,10 @@ else: if os.path.exists('GeneratorLogFSR.xml'): os.remove('GeneratorLogFSR.xml') + if os.path.exists('GeneratorLog_mergeFSR_ref.xml'): os.remove('GeneratorLog_mergeFSR_ref.xml') + if os.path.exists('genFSR_2012_Gauss_merged.xgen'): os.remove('genFSR_2012_Gauss_merged.xgen') </text></argument> -- GitLab