diff --git a/Sim/Gauss/tests/options/testGauss-merge-genfsr.py b/Sim/Gauss/tests/options/testGauss-merge-genfsr.py index 0d896abc60716253f698cc200b1893b5d9dedcb4..bb603bdef34d1a09a5c52ef6d597a450e9498fab 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,11 @@ 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/options/testGauss-read-genfsr.py b/Sim/Gauss/tests/options/testGauss-read-genfsr.py new file mode 100644 index 0000000000000000000000000000000000000000..3f117f967f0e0fb5249275949ea749ebe6887ce8 --- /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/options/testGauss-read-merged-genfsr.py b/Sim/Gauss/tests/options/testGauss-read-merged-genfsr.py new file mode 100644 index 0000000000000000000000000000000000000000..3ed061a18f8d6772bca9755b752fb1f706c0224f --- /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 b25f4fab1c55ddca0edcb785a48ac319c565df85..4cd0fbdd7e93c6a8df841e5ab747919b832d87c4 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') +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() -root = file.getroot() - -expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-create-genfsr.xml')) + nCounter = 0 + flag = False + refNames = ['generated events', 'generated interactions', 'accepted events'] -expected_root = expected_file.getroot() + for counter in root.findall('counter'): + name = counter.get('name') + value = int(counter.find('value').text) -flag = True -for counter in root.findall('counter'): - name = counter.get('name') - value = int(counter.find('value').text) + nCounter = nCounter+1 + flag = False - for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - if name == expected_name: - expected_value = int(expected_counter.find('value').text) + if name in refNames: + if value < 0 or value == 0: + flag = True - if value != expected_value: - flag = False - break + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) + break -if flag == False: - causes.append('Counter value different from what expected') + if(nCounter == 0): + causes.append('Nocounter printed in GeneratorLogFSR.xml file') -if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') + 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 ae3ced1edd2c96a45ef76e0430749097c36b1651..de6817bb3cde9f2074b134fa0d09392748e3f7b6 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,38 +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') +else: + file = ET.parse('GeneratorLogFSR.xml') + root = file.getroot() -root = file.getroot() - -expected_file = ET.parse(os.path.expandvars('$GAUSSROOT/tests/refs/testGauss-merge-genfsr.xml')) - -expected_root = expected_file.getroot() - -flag = True -for expected_counter in expected_root.findall('counter'): - expected_name = expected_counter.get('name') - expected_value = int(expected_counter.find('value').text) + nCounter = 0 + 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) + value = int(counter.find('value').text) - if value != expected_value: + nCounter = nCounter+1 flag = False - break -if flag == False: - causes.append('Counter value different from what expected') + if name in refNames: + if value < 0 or value == 0: + flag = True + + if flag == True: + causes.append('Counter %s is lower or equal to 0' %(name)) + break + + if(nCounter == 0): + causes.append('No counter printed in GeneratorLogFSR.xml file') -if os.path.exists('GeneratorLogFSR.xml'): - os.remove('GeneratorLogFSR.xml') -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 new file mode 100644 index 0000000000000000000000000000000000000000..fbb5304a6f9b53ebf077bd0d22de38320ace1dea --- /dev/null +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-genfsr.qmt @@ -0,0 +1,96 @@ +<?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 not os.path.exists('GeneratorLogFSR.xml'): + causes.append('No GeneratorLogFSR.xml found') +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('GeneratorLog_createFSR_ref.xml')) + expected_root = expected_file.getroot() + + 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 + + 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 + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..728a13569028390863219c1b790a1b43e609199f --- /dev/null +++ b/Sim/Gauss/tests/qmtest/gauss.qms/gauss-read-merged-genfsr.qmt @@ -0,0 +1,99 @@ +<?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 +if not os.path.exists('GeneratorLogFSR.xml'): + causes.append('No GeneratorLogFSR.xml found') +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('GeneratorLog_mergeFSR_ref.xml')) + expected_root = expected_file.getroot() + + 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 + + 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 + + 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>